Java Code Examples for org.jfree.chart.axis.ValueAxis#setUpperBound()

The following examples show how to use org.jfree.chart.axis.ValueAxis#setUpperBound() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PolarPlot.java    From openstock with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Zooms the axis ranges by the specified percentage about the anchor point.
 *
 * @param percent  the amount of the zoom.
 */
@Override
public void zoom(double percent) {
    for (int axisIdx = 0; axisIdx < getAxisCount(); axisIdx++) {
        final ValueAxis axis = getAxis(axisIdx);
        if (axis != null) {
            if (percent > 0.0) {
                double radius = axis.getUpperBound();
                double scaledRadius = radius * percent;
                axis.setUpperBound(scaledRadius);
                axis.setAutoRange(false);
            }
            else {
                axis.setAutoRange(true);
            }
        }
    }
}
 
Example 2
Source File: PolarPlot.java    From ccu-historian with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Zooms the axis ranges by the specified percentage about the anchor point.
 *
 * @param percent  the amount of the zoom.
 */
@Override
public void zoom(double percent) {
    for (int axisIdx = 0; axisIdx < getAxisCount(); axisIdx++) {
        final ValueAxis axis = getAxis(axisIdx);
        if (axis != null) {
            if (percent > 0.0) {
                double radius = axis.getUpperBound();
                double scaledRadius = radius * percent;
                axis.setUpperBound(scaledRadius);
                axis.setAutoRange(false);
            }
            else {
                axis.setAutoRange(true);
            }
        }
    }
}
 
Example 3
Source File: PolarPlot.java    From SIMVA-SoS with Apache License 2.0 6 votes vote down vote up
/**
 * Zooms the axis ranges by the specified percentage about the anchor point.
 *
 * @param percent  the amount of the zoom.
 */
@Override
public void zoom(double percent) {
    for (int axisIdx = 0; axisIdx < getAxisCount(); axisIdx++) {
        final ValueAxis axis = getAxis(axisIdx);
        if (axis != null) {
            if (percent > 0.0) {
                double radius = axis.getUpperBound();
                double scaledRadius = radius * percent;
                axis.setUpperBound(scaledRadius);
                axis.setAutoRange(false);
            }
            else {
                axis.setAutoRange(true);
            }
        }
    }
}
 
Example 4
Source File: PolarPlot.java    From ECG-Viewer with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Zooms the axis ranges by the specified percentage about the anchor point.
 *
 * @param percent  the amount of the zoom.
 */
@Override
public void zoom(double percent) {
    for (int axisIdx = 0; axisIdx < getAxisCount(); axisIdx++) {
        final ValueAxis axis = getAxis(axisIdx);
        if (axis != null) {
            if (percent > 0.0) {
                double radius = axis.getUpperBound();
                double scaledRadius = radius * percent;
                axis.setUpperBound(scaledRadius);
                axis.setAutoRange(false);
            }
            else {
                axis.setAutoRange(true);
            }
        }
    }
}
 
Example 5
Source File: ScatterPlotPanel.java    From snap-desktop with GNU General Public License v3.0 6 votes vote down vote up
private void handleAxisRangeControlChanges(PropertyChangeEvent evt, AxisRangeControl axisRangeControl,
                                           ValueAxis valueAxis, Range computedAutoRange) {
    final String propertyName = evt.getPropertyName();
    switch (propertyName) {
        case AxisRangeControl.PROPERTY_NAME_AUTO_MIN_MAX:
            if (axisRangeControl.isAutoMinMax()) {
                final double min = computedAutoRange.getLowerBound();
                final double max = computedAutoRange.getUpperBound();
                axisRangeControl.adjustComponents(min, max, 3);
            }
            break;
        case AxisRangeControl.PROPERTY_NAME_MIN:
            valueAxis.setLowerBound(axisRangeControl.getMin());
            break;
        case AxisRangeControl.PROPERTY_NAME_MAX:
            valueAxis.setUpperBound(axisRangeControl.getMax());
            break;
    }
}
 
Example 6
Source File: PolarPlot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Zooms the axis ranges by the specified percentage about the anchor point.
 *
 * @param percent  the amount of the zoom.
 */
@Override
public void zoom(double percent) {
    for (int axisIdx = 0; axisIdx < getAxisCount(); axisIdx++) {
        final ValueAxis axis = getAxis(axisIdx);
        if (axis != null) {
            if (percent > 0.0) {
                double radius = axis.getUpperBound();
                double scaledRadius = radius * percent;
                axis.setUpperBound(scaledRadius);
                axis.setAutoRange(false);
            }
            else {
                axis.setAutoRange(true);
            }
        }
    }
}
 
Example 7
Source File: PolarPlot.java    From buffer_bci with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Zooms the axis ranges by the specified percentage about the anchor point.
 *
 * @param percent  the amount of the zoom.
 */
@Override
public void zoom(double percent) {
    for (int axisIdx = 0; axisIdx < getAxisCount(); axisIdx++) {
        final ValueAxis axis = getAxis(axisIdx);
        if (axis != null) {
            if (percent > 0.0) {
                double radius = axis.getUpperBound();
                double scaledRadius = radius * percent;
                axis.setUpperBound(scaledRadius);
                axis.setAutoRange(false);
            }
            else {
                axis.setAutoRange(true);
            }
        }
    }
}
 
Example 8
Source File: BaseChartBuilder.java    From qpid-broker-j with Apache License 2.0 5 votes vote down vote up
private void configureYAxisBounds(final ChartingDefinition chartingDefinition, final JFreeChart chart)
{
    if (chart.getPlot() != null && chart.getPlot() instanceof XYPlot)
    {
        ValueAxis rangeAxis = chart.getXYPlot().getRangeAxis();
        if (chartingDefinition.getYAxisLowerBound() != null)
        {
            rangeAxis.setLowerBound(chartingDefinition.getYAxisLowerBound());
        }
        if (chartingDefinition.getYAxisUpperBound() != null)
        {
            rangeAxis.setUpperBound(chartingDefinition.getYAxisUpperBound());
        }
    }
}
 
Example 9
Source File: AggregationExecutionChartBuilder.java    From livingdoc-confluence with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private void customizeChart(JFreeChart chart) throws IOException {
    chart.setBackgroundPaint(Color.white);
    chart.setBorderVisible(settings.isBorder());

    TextTitle chartTitle = chart.getTitle();
    customizeTitle(chartTitle, DEFAULT_TITLE_FONT);

    addSubTitle(chart, settings.getSubTitle(), DEFAULT_SUBTITLE_FONT);
    addSubTitle(chart, settings.getSubTitle2(), DEFAULT_SUBTITLE2_FONT);

    CategoryPlot plot = ( CategoryPlot ) chart.getPlot();
    plot.setNoDataMessage(ldUtil.getText("livingdoc.historic.nodata"));

    StackedBarRenderer renderer = new StackedBarRenderer(true);
    plot.setRenderer(renderer);

    int index = 0;
    renderer.setSeriesPaint(index ++ , GREEN_COLOR);
    if (settings.isShowIgnored()) {
        renderer.setSeriesPaint(index ++ , Color.yellow);
    }
    renderer.setSeriesPaint(index, Color.red);

    renderer.setToolTipGenerator(new DefaultTooltipGenerator());
    renderer.setItemURLGenerator(new CategoryURLGenerator() {

        @Override
        public String generateURL(CategoryDataset data, int series, int category) {
            Comparable< ? > valueKey = data.getColumnKey(category);
            ChartLongValue value = ( ChartLongValue ) valueKey;
            return "javascript:" + settings.getExecutionUID() + "_showHistoricChart('" + value.getId() + "');";
        }
    });

    CategoryAxis domainAxis = plot.getDomainAxis();
    customizeAxis(domainAxis);
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90);
    domainAxis.setCategoryMargin(0.01);

    ValueAxis rangeAxis = plot.getRangeAxis();
    customizeAxis(rangeAxis);
    rangeAxis.setLowerBound(0);
    rangeAxis.setUpperBound(1.0);

    if (rangeAxis instanceof NumberAxis) {
        NumberAxis numberAxis = ( NumberAxis ) rangeAxis;
        numberAxis.setTickUnit(new NumberTickUnit(.10));
        numberAxis.setNumberFormatOverride(PERCENT_FORMATTER);
    }

    plot.setForegroundAlpha(0.8f);
}
 
Example 10
Source File: XYBarChartExpression.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
protected void configureChart( final JFreeChart chart ) {
  super.configureChart( chart );

  final XYPlot xypl = chart.getXYPlot();
  final XYItemRenderer renderer = xypl.getRenderer();
  final XYBarRenderer br = (XYBarRenderer) renderer;
  br.setDrawBarOutline( isChartSectionOutline() );
  if ( margin != null ) {
    br.setMargin( margin.doubleValue() );
  }

  br.setShadowVisible( shadowVisible );
  br.setShadowXOffset( shadowXOffset );
  br.setShadowYOffset( shadowYOffset );

  if ( ( isStacked() ) && renderPercentages && ( br instanceof StackedXYBarRenderer ) ) {
    final StackedXYBarRenderer sbr = (StackedXYBarRenderer) br;
    sbr.setRenderAsPercentages( true );

    final ValueAxis rangeAxis = xypl.getRangeAxis();
    final int level = getRuntime().getProcessingContext().getCompatibilityLevel();
    if ( ClassicEngineBoot.isEnforceCompatibilityFor( level, 3, 8 ) ) {
      if ( getRangeMinimum() != 0 ) {
        rangeAxis.setLowerBound( getRangeMinimum() );
      }
      if ( getRangeMaximum() != 1 ) {
        rangeAxis.setUpperBound( getRangeMaximum() );
      }
      if ( getRangeMinimum() == 0 && getRangeMaximum() == 0 ) {
        rangeAxis.setLowerBound( 0 );
        rangeAxis.setUpperBound( 1 );
        rangeAxis.setAutoRange( true );
      }
    } else {
      rangeAxis.setLowerBound( getRangeMinimum() );
      rangeAxis.setUpperBound( getRangeMaximum() );
      rangeAxis.setAutoRange( isRangeAxisAutoRange() );
    }
  }

}