Example usage for org.jfree.data Range getLowerBound

List of usage examples for org.jfree.data Range getLowerBound

Introduction

In this page you can find the example usage for org.jfree.data Range getLowerBound.

Prototype

public double getLowerBound() 

Source Link

Document

Returns the lower bound for the range.

Usage

From source file:org.jfree.data.time.TimeSeriesCollectionTest.java

/**
 * This method provides a check for the bounds calculated using the
 * {@link DatasetUtilities#findDomainBounds(org.jfree.data.xy.XYDataset,
 * java.util.List, boolean)} method.//  www.  j  a v a 2 s.com
 */
@Test
public void testFindDomainBounds() {
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    List visibleSeriesKeys = new java.util.ArrayList();
    Range r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertNull(r);

    TimeSeries s1 = new TimeSeries("S1");
    dataset.addSeries(s1);
    visibleSeriesKeys.add("S1");
    r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertNull(r);

    // store the current time zone
    TimeZone saved = TimeZone.getDefault();
    TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris"));

    s1.add(new Year(2008), 8.0);
    r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertEquals(1199142000000.0, r.getLowerBound(), EPSILON);
    assertEquals(1230764399999.0, r.getUpperBound(), EPSILON);

    TimeSeries s2 = new TimeSeries("S2");
    dataset.addSeries(s2);
    s2.add(new Year(2009), 9.0);
    s2.add(new Year(2010), 10.0);
    r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertEquals(1199142000000.0, r.getLowerBound(), EPSILON);
    assertEquals(1230764399999.0, r.getUpperBound(), EPSILON);

    visibleSeriesKeys.add("S2");
    r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true);
    assertEquals(1199142000000.0, r.getLowerBound(), EPSILON);
    assertEquals(1293836399999.0, r.getUpperBound(), EPSILON);

    // restore the default time zone
    TimeZone.setDefault(saved);
}

From source file:ec.util.chart.swing.JTimeSeriesChart.java

@Nonnull
public double[] getZoom() {
    Range domainRange = roSubPlots.get(0).getDomainAxis().getRange();
    Range rangeRange = roSubPlots.get(0).getRangeAxis().getRange();
    return new double[] { domainRange.getLowerBound(), domainRange.getUpperBound(), rangeRange.getLowerBound(),
            rangeRange.getUpperBound() };
}

From source file:net.sf.jasperreports.chartthemes.spring.AegeanChartTheme.java

@Override
protected JFreeChart createMeterChart() throws JRException {
    // Start by creating the plot that will hold the meter
    MeterPlot chartPlot = new MeterPlot((ValueDataset) getDataset());
    JRMeterPlot jrPlot = (JRMeterPlot) getPlot();

    // Set the shape
    MeterShapeEnum shape = jrPlot.getShapeValue() == null ? MeterShapeEnum.DIAL : jrPlot.getShapeValue();

    switch (shape) {
    case CHORD:/*  ww w  .j av  a 2s . c om*/
        chartPlot.setDialShape(DialShape.CHORD);
        break;
    case PIE:
        chartPlot.setDialShape(DialShape.PIE);
        break;
    case CIRCLE:
        chartPlot.setDialShape(DialShape.CIRCLE);
        break;
    case DIAL:
    default:
        return createDialChart();
    }

    chartPlot.setDialOutlinePaint(Color.BLACK);
    int meterAngle = jrPlot.getMeterAngleInteger() == null ? 180 : jrPlot.getMeterAngleInteger();
    // Set the size of the meter
    chartPlot.setMeterAngle(meterAngle);

    // Set the spacing between ticks.  I hate the name "tickSize" since to me it
    // implies I am changing the size of the tick, not the spacing between them.
    double tickInterval = jrPlot.getTickIntervalDouble() == null ? 10.0 : jrPlot.getTickIntervalDouble();
    chartPlot.setTickSize(tickInterval);

    JRFont tickLabelFont = jrPlot.getTickLabelFont();
    Integer defaultBaseFontSize = (Integer) getDefaultValue(defaultChartPropertiesMap,
            ChartThemesConstants.BASEFONT_SIZE);
    Font themeTickLabelFont = getFont(
            (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_TICK_LABEL_FONT),
            tickLabelFont, defaultBaseFontSize);
    chartPlot.setTickLabelFont(themeTickLabelFont);

    // localizing the default format, can be overridden by display.getMask()
    chartPlot.setTickLabelFormat(NumberFormat.getInstance(getLocale()));

    Color tickColor = jrPlot.getTickColor() == null ? Color.BLACK : jrPlot.getTickColor();
    chartPlot.setTickPaint(tickColor);
    int dialUnitScale = 1;
    Range range = convertRange(jrPlot.getDataRange());
    if (range != null) {
        // Set the meter's range
        chartPlot.setRange(range);
        double bound = Math.max(Math.abs(range.getUpperBound()), Math.abs(range.getLowerBound()));
        dialUnitScale = ChartThemesUtilities.getScale(bound);
        if ((range.getLowerBound() == (int) range.getLowerBound()
                && range.getUpperBound() == (int) range.getUpperBound() && tickInterval == (int) tickInterval)
                || dialUnitScale > 1) {
            chartPlot.setTickLabelFormat(
                    new DecimalFormat("#,##0", DecimalFormatSymbols.getInstance(getLocale())));
        } else if (dialUnitScale == 1) {
            chartPlot.setTickLabelFormat(
                    new DecimalFormat("#,##0.0", DecimalFormatSymbols.getInstance(getLocale())));
        } else if (dialUnitScale <= 0) {
            chartPlot.setTickLabelFormat(
                    new DecimalFormat("#,##0.00", DecimalFormatSymbols.getInstance(getLocale())));
        }
    }
    chartPlot.setTickLabelsVisible(true);

    // Set all the colors we support
    Paint backgroundPaint = jrPlot.getOwnBackcolor() == null ? ChartThemesConstants.TRANSPARENT_PAINT
            : jrPlot.getOwnBackcolor();
    chartPlot.setBackgroundPaint(backgroundPaint);

    GradientPaint gp = new GradientPaint(new Point(), Color.LIGHT_GRAY, new Point(), Color.BLACK, false);

    if (jrPlot.getMeterBackgroundColor() != null) {
        chartPlot.setDialBackgroundPaint(jrPlot.getMeterBackgroundColor());
    } else {
        chartPlot.setDialBackgroundPaint(gp);
    }
    //chartPlot.setForegroundAlpha(1f);
    Paint needlePaint = jrPlot.getNeedleColor() == null ? new Color(191, 48, 0) : jrPlot.getNeedleColor();
    chartPlot.setNeedlePaint(needlePaint);

    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null) {
        Color valueColor = display.getColor() == null ? Color.BLACK : display.getColor();
        chartPlot.setValuePaint(valueColor);
        String pattern = display.getMask() != null ? display.getMask() : "#,##0.####";
        if (pattern != null)
            chartPlot.setTickLabelFormat(
                    new DecimalFormat(pattern, DecimalFormatSymbols.getInstance(getLocale())));
        JRFont displayFont = display.getFont();
        Font themeDisplayFont = getFont(
                (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_DISPLAY_FONT),
                displayFont, defaultBaseFontSize);

        if (themeDisplayFont != null) {
            chartPlot.setValueFont(themeDisplayFont);
        }
    }
    String label = getChart().hasProperties()
            ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_LABEL)
            : null;

    if (label != null) {
        if (dialUnitScale < 0)
            label = new MessageFormat(label)
                    .format(new Object[] { String.valueOf(Math.pow(10, dialUnitScale)) });
        else if (dialUnitScale < 3)
            label = new MessageFormat(label).format(new Object[] { "1" });
        else
            label = new MessageFormat(label)
                    .format(new Object[] { String.valueOf((int) Math.pow(10, dialUnitScale - 2)) });

    }

    // Set the units - this is just a string that will be shown next to the
    // value
    String units = jrPlot.getUnits() == null ? label : jrPlot.getUnits();
    if (units != null && units.length() > 0)
        chartPlot.setUnits(units);

    chartPlot.setTickPaint(Color.BLACK);

    // Now define all of the intervals, setting their range and color
    List<JRMeterInterval> intervals = jrPlot.getIntervals();
    if (intervals != null && intervals.size() > 0) {
        int size = Math.min(3, intervals.size());

        int colorStep = 0;
        if (size > 3)
            colorStep = 255 / (size - 3);

        for (int i = 0; i < size; i++) {
            JRMeterInterval interval = intervals.get(i);
            Color color = i < 3 ? (Color) ChartThemesConstants.AEGEAN_INTERVAL_COLORS.get(i)
                    : new Color(255 - colorStep * (i - 3), 0 + colorStep * (i - 3), 0);

            interval.setBackgroundColor(color);
            interval.setAlpha(1.0d);
            chartPlot.addInterval(convertInterval(interval));
        }
    }

    // Actually create the chart around the plot
    JFreeChart jfreeChart = new JFreeChart(evaluateTextExpression(getChart().getTitleExpression()), null,
            chartPlot, getChart().getShowLegend() == null ? false : getChart().getShowLegend());

    // Set all the generic options
    configureChart(jfreeChart, getPlot());

    return jfreeChart;

}

From source file:org.eurocarbdb.application.glycoworkbench.plugin.PeakListChartPanel.java

public void updateChart() {
    // auto zoom/*from   w w w. j  a  va2 s.  c  o m*/
    if (theDocument.size() > 0) {
        Range mz_range = thePlot.getDomainAxis().getRange();

        // update data
        double mz_toll = screenToDataX(1.);
        double[][] data = theDocument.getData(mz_range.getLowerBound(), mz_range.getUpperBound());

        // update visible data and compute intensity range
        visibleData.clear();
        double min_int = (data[0].length > 0) ? data[1][0] : 0.;
        double max_int = (data[0].length > 0) ? data[1][0] : 0.;
        for (int i = 0; i < data[0].length; i++) {
            min_int = Math.min(min_int, data[1][i]);
            max_int = Math.max(max_int, data[1][i]);
            visibleData.put(data[0][i], data[1][i]);
        }
        //Range new_int_range = new Range(min_int,max_int);
        Range new_int_range = new Range(0., max_int);

        // make space for annotations
        Rectangle2D data_area = theChartPanel.getScreenDataArea();
        if (data_area.getHeight() > 0)
            new_int_range = Range.expand(new_int_range, 0., 12. / data_area.getHeight());

        // resize y axis
        thePlot.getRangeAxis().setRange(new_int_range);

        // reload dataset
        theDataset.removeSeries("intensities");
        theDataset.addSeries("intensities", data);
    } else {
        thePlot.getRangeAxis().setRange(new Range(0., 1.));
        theDataset.removeSeries("intensities");
    }

    // restore annotation shapes
    showSelection();
}

From source file:com.epiq.bitshark.ui.IVQPanel.java

public IVQPanel() {

    initComponents();// w  w  w . j  a v  a  2  s.  c o m

    initGraph();

    JPanel holderPanel = new JPanel() {

        @Override
        public void paint(Graphics g) {

            Range newDomain = null; // x
            Range newRange = null; // y

            Range currentDomainRange = plot.getDomainAxis().getRange();
            Range currentRangeRange = plot.getRangeAxis().getRange();

            if (plot.getDomainAxis().isAutoRange()) {
                plot.getDomainAxis().setAutoRange(false);
            }

            if (plot.getRangeAxis().isAutoRange()) {
                plot.getRangeAxis().setAutoRange(false);
            }

            Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea();
            double width = dataArea.getWidth();
            double height = dataArea.getHeight();

            double domainScale = 1;
            double rangeScale = 1;

            // scale the domain values up to match the pixels
            if (width > height) {
                domainScale = width / height;
                double extent = currentRangeRange.getUpperBound() - currentRangeRange.getLowerBound();
                newDomain = new Range(-(extent * domainScale) / 2, (extent * domainScale) / 2);

            } else if (height > width) {
                rangeScale = height / width;
                double extent = currentDomainRange.getUpperBound() - currentDomainRange.getLowerBound();
                newRange = new Range(-(extent * rangeScale) / 2, (extent * rangeScale) / 2);
            }

            if (newDomain == null) {
                double extent = currentDomainRange.getUpperBound() - currentDomainRange.getLowerBound();
                newDomain = new Range(-(extent) / 2, (extent) / 2);
            }

            if (newRange == null) {
                double extent = currentRangeRange.getUpperBound() - currentRangeRange.getLowerBound();
                newRange = new Range(-(extent) / 2, (extent) / 2);
            }

            if (newDomain != null) {
                plot.getDomainAxis().setRange(newDomain, true, false);
            }

            if (newRange != null) {
                plot.getRangeAxis().setRange(newRange, true, false);
            }

            Graphics2D g2 = (Graphics2D) g.create();
            super.paint(g2);

            g2.dispose();
        }
    };

    holderPanel.setLayout(new BorderLayout());
    holderPanel.add(chartPanel, BorderLayout.CENTER);
    mainPanel.add(holderPanel, BorderLayout.CENTER);

    headerPanel.setBackgroundPainter(Common.getHeaderPainter());

    chartLabel.setUI(new BasicLabelUI());
}

From source file:apidemo.PanScrollZoomDemo.java

/**
 * Recalculates the scrollbar settings./* www.j  av  a  2 s.com*/
 * 
 * @param plot  the plot.
 */
private void recalcScrollBar(final Plot plot) {
    if (plot instanceof XYPlot) {
        final XYPlot hvp = (XYPlot) plot;
        final ValueAxis axis = hvp.getDomainAxis();

        axis.setLowerMargin(0);
        axis.setUpperMargin(0);

        final Range rng = axis.getRange();

        final BoundedRangeModel scrollBarModel = this.scrollBar.getModel();
        final int len = scrollBarModel.getMaximum() - scrollBarModel.getMinimum();
        if (rng.getLength() > 0) {
            this.scrollFactor = len / rng.getLength();
        }

        final double dblow = rng.getLowerBound();
        final int ilow = (int) (dblow * this.scrollFactor);
        scrollBarModel.setMinimum(ilow);
        final int val = ilow;
        scrollBarModel.setValue(val);

        final double dbup = rng.getUpperBound();
        final int iup = (int) (dbup * this.scrollFactor);
        scrollBarModel.setMaximum(iup);
        final int ext = iup - ilow;
        scrollBarModel.setExtent(ext);

        scrollBarModel.addChangeListener(this);
    }
}

From source file:org.esa.beam.visat.toolviews.stat.ScatterPlotPanel.java

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);
        }// w ww  .  j  av a  2s  . co m
        break;
    case AxisRangeControl.PROPERTY_NAME_MIN:
        valueAxis.setLowerBound(axisRangeControl.getMin());
        break;
    case AxisRangeControl.PROPERTY_NAME_MAX:
        valueAxis.setUpperBound(axisRangeControl.getMax());
        break;
    }
}

From source file:de.bund.bfr.knime.pmm.common.chart.ChartCreator.java

@Override
public void mouseReleased(MouseEvent e) {
    ValueAxis domainAxis = ((XYPlot) getChart().getPlot()).getDomainAxis();
    ValueAxis rangeAxis = ((XYPlot) getChart().getPlot()).getRangeAxis();

    Range xRange1 = domainAxis.getRange();
    Range yRange1 = rangeAxis.getRange();
    super.mouseReleased(e);
    Range xRange2 = domainAxis.getRange();
    Range yRange2 = rangeAxis.getRange();

    if (!xRange1.equals(xRange2) || !yRange1.equals(yRange2)) {
        minX = xRange2.getLowerBound();
        maxX = xRange2.getUpperBound();//from   w w  w .  jav a2  s .  c o  m
        minY = yRange2.getLowerBound();
        maxY = yRange2.getUpperBound();
        fireZoomChanged();
    }
}

From source file:userinterface.graph.AxisSettings.java

private void updateAxis() {
    /** -- First check whether we still have the right axis object */

    /* If we do not have a logarithmic scale, but the axis settings want one, then change the axis. */
    if (axis instanceof NumberAxis && isLogarithmic()) {
        /** Update xAxis such that other settings can be checked for consistency. */
        PrismLogarithmicAxis newAxis = new PrismLogarithmicAxis(getHeading());

        /** We need to discard all negative and zero values should there be any. */
        /* TODO: Do this in a more elegant way. */
        synchronized (graph.getSeriesLock()) {
            for (Graph.SeriesKey key : graph.getAllSeriesKeys()) {
                XYSeries series = graph.getXYSeries(key);

                if (series instanceof PrismXYSeries) {
                    PrismXYSeries prismSeries = (PrismXYSeries) series;

                    if (isDomain)
                        prismSeries.setLogarithmicDomainAxis(true);
                    else
                        prismSeries.setLogarithmicRangeAxis(true);
                }/*from  w w  w.j a v a 2s  . c o  m*/
            }
        }

        if (isDomain) {
            this.plot.setDomainAxis(newAxis);
            axis = this.plot.getDomainAxis();
        } else {
            this.plot.setRangeAxis(newAxis);
            axis = this.plot.getRangeAxis();
        }
    }

    /* If we have a logarithmic scale, but the axis settings want a normal scale, then change the axis. */
    if (axis instanceof PrismLogarithmicAxis && !isLogarithmic()) {
        /** Update xAxis such that other settings can be checked for consistency. */
        if (isDomain) {
            this.plot.setDomainAxis(new NumberAxis(getHeading()));
            axis = this.plot.getDomainAxis();
        } else {
            this.plot.setRangeAxis(new NumberAxis(getHeading()));
            axis = this.plot.getRangeAxis();
        }

        /** It could be we discarded some negative and zero values, lets bring them back. */
        synchronized (graph.getSeriesLock()) {
            for (Graph.SeriesKey key : graph.getAllSeriesKeys()) {
                XYSeries series = graph.getXYSeries(key);

                if (series instanceof PrismXYSeries) {
                    PrismXYSeries prismSeries = (PrismXYSeries) series;

                    if (isDomain)
                        prismSeries.setLogarithmicDomainAxis(false);
                    else
                        prismSeries.setLogarithmicRangeAxis(false);
                }
            }
        }
    }

    /** -- Check done, now look for smaller changes. */

    /* If the heading of the axis does not match the heading set in the settings... */
    if (!(axis.getLabel().equals(getHeading()))) {
        axis.setLabel(getHeading());
    }

    /* Update axis heading font if appropriate */
    if (!(axis.getLabelFont().equals(getHeadingFont().f))) {
        axis.setLabelFont(getHeadingFont().f);
    }

    /* Update axis heading colour if appropriate */
    if (!(axis.getLabelPaint().equals(getHeadingFont().c))) {
        axis.setLabelPaint(getHeadingFont().c);
    }

    /* Update axis numbering font if appropriate */
    if (!(axis.getTickLabelFont().equals(getNumberFont().f))) {
        axis.setTickLabelFont(getNumberFont().f);
    }

    /* Update axis numbering colour if appropriate */
    if (!(axis.getTickLabelPaint().equals(getNumberFont().c))) {
        axis.setTickLabelPaint(getNumberFont().c);
    }

    /* Update gridlines if appropriate. */
    if (isDomain && (plot.isDomainGridlinesVisible() != showGrid.getBooleanValue())) {
        plot.setDomainGridlinesVisible(showGrid.getBooleanValue());
    }

    if (!isDomain && (plot.isRangeGridlinesVisible() != showGrid.getBooleanValue())) {
        plot.setRangeGridlinesVisible(showGrid.getBooleanValue());
    }

    /* Update gridline colour if appropriate. */
    if (isDomain && (!plot.getDomainGridlinePaint().equals(gridColour.getColorValue()))) {
        plot.setDomainGridlinePaint(gridColour.getColorValue());
    }

    if (!isDomain && (!plot.getRangeGridlinePaint().equals(gridColour.getColorValue()))) {
        plot.setRangeGridlinePaint(gridColour.getColorValue());
    }

    /** Check properties specific to logarithmic axis. */
    if (axis instanceof PrismLogarithmicAxis) {
        PrismLogarithmicAxis logAxis = (PrismLogarithmicAxis) axis;

        if ((logStyle.getCurrentIndex() == BASE_AND_EXPONENT) != logAxis.isBaseAndExponentFormatOverride()) {
            logAxis.setBaseAndExponentFormatOverride(logStyle.getCurrentIndex() == BASE_AND_EXPONENT);
        }

        if ((logStyle.getCurrentIndex() == VALUES)
                && logAxis.getNumberFormatOverride() != this.valuesFormatter) {
            logAxis.setNumberFormatOverride(this.valuesFormatter);
        }

        /* Switched from auto to manual? */
        if (logAxis.isAutoRange() && !autoScale.getBooleanValue()) {
            Range range = logAxis.getRange();
            logAxis.setAutoRange(false);

            try {
                this.minimumPower.setValue(logAxis.calculateLog(range.getLowerBound()));
                this.maximumPower.setValue(logAxis.calculateLog(range.getUpperBound()));
            } catch (SettingException e) {
                // best effort.
            }
        }

        /* Switched from manual to auto? */
        if (!axis.isAutoRange() && autoScale.getBooleanValue()) {
            axis.setAutoRange(true);
        }

        /* If the log base is wrong. */
        if (logBase.getDoubleValue() != logAxis.getBase()) {
            Range range = axis.getRange();

            logAxis.setBase(logBase.getDoubleValue());

            try {
                this.minimumPower.setValue(logAxis.calculateLog(range.getLowerBound()));
                this.maximumPower.setValue(logAxis.calculateLog(range.getUpperBound()));
            } catch (SettingException e) {
                // best effort
            }

            if (Math.round(logBase.getDoubleValue()) == logBase.getDoubleValue())
                logAxis.setMinorTickCount((int) logBase.getDoubleValue());
            else
                logAxis.setMinorTickCount(1);
        }

        /* If manual, logarithmic, and range does not match our settings, then update */
        if (!axis.isAutoRange()) {
            Range range = logAxis.getRange();

            if (range.getLowerBound() != logAxis.calculateValue(minimumPower.getDoubleValue())
                    || range.getUpperBound() != logAxis.calculateValue(maximumPower.getDoubleValue())) {
                axis.setRange(logAxis.calculateValue(minimumPower.getDoubleValue()),
                        logAxis.calculateValue(maximumPower.getDoubleValue()));
            }
        }
    }

    /** Check properties specific to numeric axis. */
    if (axis instanceof NumberAxis) {
        NumberAxis numAxis = (NumberAxis) axis;

        /* Switched from auto to manual? */
        if (axis.isAutoRange() && !autoScale.getBooleanValue()) {
            Range range = axis.getRange();
            axis.setAutoRange(false);
            axis.setAutoTickUnitSelection(false);

            try {
                this.minValue.setValue(range.getLowerBound());
                this.maxValue.setValue(range.getUpperBound());
                this.gridInterval.setValue(numAxis.getTickUnit().getSize());
            } catch (SettingException e) {
                // best effort.
            }
        }

        /* Switched from manual to auto? */
        if (!axis.isAutoRange() && autoScale.getBooleanValue()) {
            axis.setAutoRange(true);
            axis.setAutoTickUnitSelection(true);
        }

        /* If manual, numeric, and range does not match our settings, then update */
        if (!axis.isAutoRange()) {
            Range range = axis.getRange();

            if (range.getLowerBound() != minValue.getDoubleValue()
                    || range.getUpperBound() != maxValue.getDoubleValue()) {
                axis.setRange(minValue.getDoubleValue(), maxValue.getDoubleValue());
            }

            if (gridInterval.getDoubleValue() != numAxis.getTickUnit().getSize()) {
                // FIXME: With i.e. interval 0.01 it rounds "0.10" to "0.1"
                numAxis.setTickUnit(new NumberTickUnit(gridInterval.getDoubleValue()));
                // Some experimental code to make axis display only odd numbers:
                /*if (axisShouldOnlyShowOdd) numAxis.setNumberFormatOverride(new DecimalFormat()
                { public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
                      return ((int)number % 2 == 0) ? new StringBuffer("") : super.format(number, toAppendTo, pos);
                } });*/
            }
        }
    }
}

From source file:net.sf.fspdfs.chartthemes.spring.EyeCandySixtiesChartTheme.java

/**
 *
 *///from   w  ww.  j  a va  2 s  .  c  o  m
protected JFreeChart createThermometerChart() throws JRException {
    JRThermometerPlot jrPlot = (JRThermometerPlot) getPlot();

    // Create the plot that will hold the thermometer.
    ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset) getDataset());
    // Build a chart around this plot
    JFreeChart jfreeChart = new JFreeChart(chartPlot);

    // Set the generic options
    configureChart(jfreeChart, getPlot());
    jfreeChart.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    jfreeChart.setBorderVisible(false);

    Range range = convertRange(jrPlot.getDataRange());

    if (range != null) {
        // Set the boundary of the thermomoter
        chartPlot.setLowerBound(range.getLowerBound());
        chartPlot.setUpperBound(range.getUpperBound());
    }
    chartPlot.setGap(0);

    // Units can only be Fahrenheit, Celsius or none, so turn off for now.
    chartPlot.setUnits(ThermometerPlot.UNITS_NONE);

    // Set the color of the mercury.  Only used when the value is outside of
    // any defined ranges.
    Paint paint = (jrPlot.getMercuryColor() != null ? (Paint) jrPlot.getMercuryColor()
            : (Paint) ChartThemesConstants.EYE_CANDY_SIXTIES_GRADIENT_PAINTS.get(0));
    chartPlot.setMercuryPaint(paint);

    chartPlot.setThermometerPaint(THERMOMETER_COLOR);
    chartPlot.setThermometerStroke(new BasicStroke(2f));
    chartPlot.setOutlineVisible(false);
    chartPlot.setValueFont(chartPlot.getValueFont().deriveFont(Font.BOLD));

    // Set the formatting of the value display
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null) {
        if (display.getColor() != null) {
            chartPlot.setValuePaint(display.getColor());
        }
        if (display.getMask() != null) {
            chartPlot.setValueFormat(new DecimalFormat(display.getMask()));
        }
        if (display.getFont() != null) {
            //            chartPlot.setValueFont(JRFontUtil.getAwtFont(display.getFont()).deriveFont(Font.BOLD));
        }
    }

    // Set the location of where the value is displayed
    ValueLocationEnum valueLocation = jrPlot.getValueLocationValue();
    switch (valueLocation) {
    case NONE:
        chartPlot.setValueLocation(ThermometerPlot.NONE);
        break;
    case LEFT:
        chartPlot.setValueLocation(ThermometerPlot.LEFT);
        break;
    case RIGHT:
        chartPlot.setValueLocation(ThermometerPlot.RIGHT);
        break;
    case BULB:
    default:
        chartPlot.setValueLocation(ThermometerPlot.BULB);
        break;
    }

    // Define the three ranges
    range = convertRange(jrPlot.getLowRange());
    if (range != null) {
        chartPlot.setSubrangeInfo(2, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getMediumRange());
    if (range != null) {
        chartPlot.setSubrangeInfo(1, range.getLowerBound(), range.getUpperBound());
    }

    range = convertRange(jrPlot.getHighRange());
    if (range != null) {
        chartPlot.setSubrangeInfo(0, range.getLowerBound(), range.getUpperBound());
    }

    return jfreeChart;

}