Example usage for org.jfree.data Range getUpperBound

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

Introduction

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

Prototype

public double getUpperBound() 

Source Link

Document

Returns the upper bound for the range.

Usage

From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelChart.java

private void recalcScrollBar(Plot plot) {
    if (plot instanceof XYPlot) {
        XYPlot hvp = (XYPlot) plot;//w w  w.jav a  2s  .  com
        ValueAxis axis = hvp.getDomainAxis();

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

        Range rng = axis.getRange();

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

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

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

        scrollBarModel.addChangeListener(this);
    }
}

From source file:apidemo.PanScrollZoomDemo.java

/**
 * Handles a {@link ChartChangeEvent}.//from w w w . j a v a2s . co m
 * 
 * @param event  the event.
 */
public void chartChanged(final ChartChangeEvent event) {
    try {
        if (event.getChart() == null) {
            return;
        }

        final BoundedRangeModel scrollBarModel = this.scrollBar.getModel();
        if (scrollBarModel == null) {
            return;
        }

        boolean chartIsZoomed = false;

        final Plot plot = event.getChart().getPlot();
        if (plot instanceof XYPlot) {
            final XYPlot hvp = (XYPlot) plot;
            final ValueAxis xAxis = hvp.getDomainAxis();
            final Range xAxisRange = xAxis.getRange();

            // avoid recursion
            scrollBarModel.removeChangeListener(this);

            final int low = (int) (xAxisRange.getLowerBound() * this.scrollFactor);
            scrollBarModel.setValue(low);
            final int ext = (int) (xAxisRange.getUpperBound() * this.scrollFactor - low);
            scrollBarModel.setExtent(ext);

            // restore
            scrollBarModel.addChangeListener(this);

            // check if zoomed horizontally
            //Range hdr = hvp.getHorizontalDataRange(xAxis);
            final Range hdr = hvp.getDataRange(xAxis);

            final double len = hdr == null ? 0 : hdr.getLength();
            chartIsZoomed |= xAxisRange.getLength() < len;
        }

        if (!chartIsZoomed && plot instanceof XYPlot) {
            // check if zoomed vertically
            final XYPlot vvp = (XYPlot) plot;
            ValueAxis yAxis = vvp.getRangeAxis();
            if (yAxis != null) {
                chartIsZoomed = yAxis.getLowerBound() > this.primYMinMax[0]
                        || yAxis.getUpperBound() < this.primYMinMax[1];

                // right y-axis
                if (!chartIsZoomed && plot instanceof XYPlot) {
                    final XYPlot xyPlot = (XYPlot) plot;
                    yAxis = xyPlot.getRangeAxis(1);
                    if (yAxis != null) {
                        chartIsZoomed = yAxis.getLowerBound() > this.secondYMinMax[0]
                                || yAxis.getUpperBound() < this.secondYMinMax[1];
                    }
                }
            }
        }

        // enable "zoom-out-buttons" if chart is zoomed
        // otherwise disable them
        this.panButton.setEnabled(chartIsZoomed);
        this.zoomOutButton.setEnabled(chartIsZoomed);
        this.fitButton.setEnabled(chartIsZoomed);
        this.scrollBar.setEnabled(chartIsZoomed);
        if (!chartIsZoomed) {
            setPanMode(false);
            this.zoomButton.setSelected(true);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.gumtree.vis.plot1d.KLogarithmicAxis.java

@Override
protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {
    // TODO Auto-generated method stub
    List ticks = new java.util.ArrayList();
    Range range = getRange();

    //get lower bound value:
    double lowerBoundVal = range.getLowerBound();
    //if small log values and lower bound value too small
    // then set to a small value (don't allow <= 0):
    if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) {
        lowerBoundVal = SMALL_LOG_VALUE;
    }//from   ww w.j  a  v a2  s  . c om

    //get upper bound value
    double upperBoundVal = range.getUpperBound();

    //get log10 version of lower bound and round to integer:
    int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal));
    //get log10 version of upper bound and round to integer:
    int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal));

    //        if (iBegCount == iEndCount && iBegCount >= 0
    if (iBegCount == iEndCount && Math.pow(10, iBegCount) > lowerBoundVal) {
        //only 1 power of 10 value, it's > 0 and its resulting
        // tick value will be larger than lower bound of data
        --iBegCount; //decrement to generate more ticks
    }

    int numberOfGrids = 0;
    int numberOfTicks = 0;
    NumberTick lastTick = null;

    double currentTickValue;
    String tickLabel;
    boolean zeroTickFlag = false;
    for (int i = iBegCount; i <= iEndCount; i++) {
        //for each power of 10 value; create ten ticks
        for (int j = 0; j < 10; ++j) {
            //for each tick to be displayed
            if (this.smallLogFlag) {
                //small log values in use; create numeric value for tick
                currentTickValue = Math.pow(10, i) + (Math.pow(10, i) * j);
                if (this.expTickLabelsFlag || (i < 0 && currentTickValue > 0.0 && currentTickValue < 1.0)) {
                    //showing "1e#"-style ticks or negative exponent
                    // generating tick value between 0 & 1; show fewer
                    if (j == 0 || (i > -4 && (j < 2 || j == 4)) || currentTickValue >= upperBoundVal) {
                        //first tick of series, or not too small a value and
                        // one of first 3 ticks, or last tick to be displayed
                        // set exact number of fractional digits to be shown
                        // (no effect if showing "1e#"-style ticks):
                        this.numberFormatterObj.setMaximumFractionDigits(-i);
                        //create tick label (force use of fmt obj):
                        tickLabel = makeTickLabel(currentTickValue, true);
                    } else { //no tick label to be shown
                        //                            tickLabel = "";
                        if (numberOfTicks == 0) {
                            tickLabel = makeTickLabel(currentTickValue, true);
                        } else
                            tickLabel = "";
                    }
                } else { //tick value not between 0 & 1
                         //show tick label if it's the first or last in
                         // the set, or if it's 1-5; beyond that show
                         // fewer as the values get larger:
                    tickLabel = (j < 1 || (i < 1 && j < 5) || (j < 4 - i) || currentTickValue >= upperBoundVal
                            || numberOfTicks == 0) ? makeTickLabel(currentTickValue) : "";
                }
            } else { //not small log values in use; allow for values <= 0
                if (zeroTickFlag) { //if did zero tick last iter then
                    --j; //decrement to do 1.0 tick now
                } //calculate power-of-ten value for tick:
                currentTickValue = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j)
                        : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j));
                if (!zeroTickFlag) { // did not do zero tick last iteration
                    if (Math.abs(currentTickValue - 1.0) < 0.0001 && lowerBoundVal <= 0.0
                            && upperBoundVal >= 0.0) {
                        //tick value is 1.0 and 0.0 is within data range
                        currentTickValue = 0.0; //set tick value to zero
                        zeroTickFlag = true; //indicate zero tick
                    }
                } else { //did zero tick last iteration
                    zeroTickFlag = false; //clear flag
                } //create tick label string:
                //show tick label if "1e#"-style and it's one
                // of the first two, if it's the first or last
                // in the set, or if it's 1-5; beyond that
                // show fewer as the values get larger:
                tickLabel = ((this.expTickLabelsFlag && j < 2) || j < 1 || (i < 1 && j < 5) || (j < 4 - i)
                        || currentTickValue >= upperBoundVal || numberOfTicks == 0)
                                ? makeTickLabel(currentTickValue)
                                : "";
            }

            if (currentTickValue > upperBoundVal) {
                if (lastTick != null) {
                    String lastTickText = lastTick.getText();
                    if (lastTickText == null || lastTickText.trim().length() == 0) {
                        ticks.remove(lastTick);
                        ticks.add(new NumberTick(lastTick.getValue(),
                                createTickLabel(lastTick.getValue(), i - 1), lastTick.getTextAnchor(),
                                lastTick.getRotationAnchor(), lastTick.getAngle()));
                    }
                }
                if (numberOfTicks < 4) {
                    return getAllTicksHorizontal(g2, dataArea, edge);
                }
                return ticks; // if past highest data value then exit
                              // method
            }

            if (currentTickValue >= lowerBoundVal - SMALL_LOG_VALUE) {
                //tick value not below lowest data value
                TextAnchor anchor = null;
                TextAnchor rotationAnchor = null;
                double angle = 0.0;
                if (isVerticalTickLabels()) {
                    anchor = TextAnchor.CENTER_RIGHT;
                    rotationAnchor = TextAnchor.CENTER_RIGHT;
                    if (edge == RectangleEdge.TOP) {
                        angle = Math.PI / 2.0;
                    } else {
                        angle = -Math.PI / 2.0;
                    }
                } else {
                    if (edge == RectangleEdge.TOP) {
                        anchor = TextAnchor.BOTTOM_CENTER;
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
                    } else {
                        anchor = TextAnchor.TOP_CENTER;
                        rotationAnchor = TextAnchor.TOP_CENTER;
                    }
                }

                lastTick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor,
                        angle);
                ticks.add(lastTick);
                if (tickLabel != null && tickLabel.trim().length() > 0)
                    numberOfTicks++;
                numberOfGrids++;
            }
        }
    }
    if (numberOfTicks < 4) {
        return getAllTicksHorizontal(g2, dataArea, edge);
    }
    return ticks;
}

From source file:org.gumtree.vis.plot1d.KLogarithmicAxis.java

private List getAllTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) {
    // TODO Auto-generated method stub
    List ticks = new java.util.ArrayList();
    Range range = getRange();

    //get lower bound value:
    double lowerBoundVal = range.getLowerBound();
    //if small log values and lower bound value too small
    // then set to a small value (don't allow <= 0):
    if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) {
        lowerBoundVal = SMALL_LOG_VALUE;
    }/*  ww w.  j a v a 2s.c o m*/

    //get upper bound value
    double upperBoundVal = range.getUpperBound();

    //get log10 version of lower bound and round to integer:
    int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal));
    //get log10 version of upper bound and round to integer:
    int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal));

    //        if (iBegCount == iEndCount && iBegCount >= 0
    if (iBegCount == iEndCount && Math.pow(10, iBegCount) > lowerBoundVal) {
        //only 1 power of 10 value, it's > 0 and its resulting
        // tick value will be larger than lower bound of data
        --iBegCount; //decrement to generate more ticks
    }

    int numberOfGrids = 0;
    int numberOfTicks = 0;
    NumberTick lastTick = null;

    double currentTickValue;
    String tickLabel;
    boolean zeroTickFlag = false;
    for (int i = iBegCount; i <= iEndCount; i++) {
        //for each power of 10 value; create ten ticks
        for (int j = 0; j < 10; ++j) {
            //for each tick to be displayed
            if (this.smallLogFlag) {
                //small log values in use; create numeric value for tick
                currentTickValue = Math.pow(10, i) + (Math.pow(10, i) * j);
                if (this.expTickLabelsFlag || (i < 0 && currentTickValue > 0.0 && currentTickValue < 1.0)) {
                    //showing "1e#"-style ticks or negative exponent
                    // generating tick value between 0 & 1; show fewer
                    //first tick of series, or not too small a value and
                    // one of first 3 ticks, or last tick to be displayed
                    // set exact number of fractional digits to be shown
                    // (no effect if showing "1e#"-style ticks):
                    this.numberFormatterObj.setMaximumFractionDigits(-i);
                    //create tick label (force use of fmt obj):
                    tickLabel = makeTickLabel(currentTickValue, true);
                } else { //tick value not between 0 & 1
                         //show tick label if it's the first or last in
                         // the set, or if it's 1-5; beyond that show
                         // fewer as the values get larger:
                    tickLabel = makeTickLabel(currentTickValue);
                }
            } else { //not small log values in use; allow for values <= 0
                if (zeroTickFlag) { //if did zero tick last iter then
                    --j; //decrement to do 1.0 tick now
                } //calculate power-of-ten value for tick:
                currentTickValue = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j)
                        : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j));
                if (!zeroTickFlag) { // did not do zero tick last iteration
                    if (Math.abs(currentTickValue - 1.0) < 0.0001 && lowerBoundVal <= 0.0
                            && upperBoundVal >= 0.0) {
                        //tick value is 1.0 and 0.0 is within data range
                        currentTickValue = 0.0; //set tick value to zero
                        zeroTickFlag = true; //indicate zero tick
                    }
                } else { //did zero tick last iteration
                    zeroTickFlag = false; //clear flag
                } //create tick label string:
                //show tick label if "1e#"-style and it's one
                // of the first two, if it's the first or last
                // in the set, or if it's 1-5; beyond that
                // show fewer as the values get larger:
                tickLabel = makeTickLabel(currentTickValue);
            }

            if (currentTickValue > upperBoundVal) {
                if (lastTick != null) {
                    String lastTickText = lastTick.getText();
                    if (lastTickText == null || lastTickText.trim().length() == 0) {
                        ticks.remove(lastTick);
                        ticks.add(new NumberTick(lastTick.getValue(),
                                createTickLabel(lastTick.getValue(), i - 1), lastTick.getTextAnchor(),
                                lastTick.getRotationAnchor(), lastTick.getAngle()));
                    }
                }
                if (ticks.size() < 2) {
                    double definition = Math.abs(lowerBoundVal - upperBoundVal);
                    int numberOfDigits = 0;
                    if (definition >= 1)
                        numberOfDigits = 0;
                    else {
                        numberOfDigits = (int) Math.ceil((-Math.log10(definition)));
                    }
                    if (definition < 2 * Math.pow(10, -numberOfDigits)) {
                        numberOfDigits++;
                    }
                    double tickVal;
                    tickVal = lowerBoundVal;
                    if (definition > 1)
                        tickLabel = Long.toString((long) Math.rint(tickVal));
                    else
                        tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString();
                    ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.TOP_CENTER,
                            TextAnchor.TOP_CENTER, 0.0));
                    tickVal = upperBoundVal;
                    if (definition > 1)
                        tickLabel = Long.toString((long) Math.rint(tickVal));
                    else
                        tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString();
                    ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.TOP_CENTER,
                            TextAnchor.TOP_CENTER, 0.0));
                }
                return ticks; // if past highest data value then exit
                              // method
            }

            if (currentTickValue >= lowerBoundVal - SMALL_LOG_VALUE) {
                //tick value not below lowest data value
                TextAnchor anchor = null;
                TextAnchor rotationAnchor = null;
                double angle = 0.0;
                if (isVerticalTickLabels()) {
                    anchor = TextAnchor.CENTER_RIGHT;
                    rotationAnchor = TextAnchor.CENTER_RIGHT;
                    if (edge == RectangleEdge.TOP) {
                        angle = Math.PI / 2.0;
                    } else {
                        angle = -Math.PI / 2.0;
                    }
                } else {
                    if (edge == RectangleEdge.TOP) {
                        anchor = TextAnchor.BOTTOM_CENTER;
                        rotationAnchor = TextAnchor.BOTTOM_CENTER;
                    } else {
                        anchor = TextAnchor.TOP_CENTER;
                        rotationAnchor = TextAnchor.TOP_CENTER;
                    }
                }

                lastTick = new NumberTick(new Double(currentTickValue), tickLabel, anchor, rotationAnchor,
                        angle);
                ticks.add(lastTick);
                if (tickLabel != null && tickLabel.trim().length() > 0)
                    numberOfTicks++;
                numberOfGrids++;
            }
        }
    }
    if (ticks.size() < 2) {
        double definition = Math.abs(lowerBoundVal - upperBoundVal);
        int numberOfDigits = 0;
        if (definition >= 1)
            numberOfDigits = 0;
        else {
            numberOfDigits = (int) Math.ceil((-Math.log10(definition)));
        }
        double tickVal;
        tickVal = lowerBoundVal;
        if (definition > 1)
            tickLabel = Long.toString((long) Math.rint(tickVal));
        else
            tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString();
        ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.TOP_CENTER, TextAnchor.TOP_CENTER,
                0.0));
        tickVal = upperBoundVal;
        if (definition > 1)
            tickLabel = Long.toString((long) Math.rint(tickVal));
        else
            tickLabel = (new Formatter()).format("%." + numberOfDigits + "f", tickVal).toString();
        ticks.add(new NumberTick(new Double(tickVal), tickLabel, TextAnchor.TOP_CENTER, TextAnchor.TOP_CENTER,
                0.0));
    }
    return ticks;
}

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);
        }/*from  www . j  a  va 2 s  . c om*/
        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();//from w  ww.j  a  v a2s .  c om
        maxX = xRange2.getUpperBound();
        minY = yRange2.getLowerBound();
        maxY = yRange2.getUpperBound();
        fireZoomChanged();
    }
}

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

/**
 *
 *///from ww w  .  j  ava2  s  .  c o  m
protected JFreeChart createDialChart() throws JRException {

    JRMeterPlot jrPlot = (JRMeterPlot) getPlot();

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

    GradientPaint gp2 = new GradientPaint(new Point(), Color.GRAY, new Point(), Color.BLACK);

    // get data for diagrams
    DialPlot dialPlot = new DialPlot();
    //dialPlot.setView(0.0, 0.0, 1.0, 1.0);
    if (getDataset() != null) {
        dialPlot.setDataset((ValueDataset) getDataset());
    }
    StandardDialFrame dialFrame = new StandardDialFrame();
    //dialFrame.setRadius(0.60);
    //dialFrame.setBackgroundPaint(gp2);
    dialFrame.setForegroundPaint(gp2);
    dialPlot.setDialFrame(dialFrame);

    DialBackground db = new DialBackground(gp);
    db.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    dialPlot.setBackground(db);
    StandardDialScale scale = null;
    int dialUnitScale = 1;
    Range range = convertRange(jrPlot.getDataRange());
    if (range != null) {
        double bound = Math.max(Math.abs(range.getUpperBound()), Math.abs(range.getLowerBound()));
        dialUnitScale = ChartThemesUtilities.getScale(bound);

        double lowerBound = ChartThemesUtilities.getTruncatedValue(range.getLowerBound(), dialUnitScale);
        double upperBound = ChartThemesUtilities.getTruncatedValue(range.getUpperBound(), dialUnitScale);

        scale = new StandardDialScale(lowerBound, upperBound, 225, -270, (upperBound - lowerBound) / 6, 15);
        if ((lowerBound == (int) lowerBound && upperBound == (int) upperBound
                && scale.getMajorTickIncrement() == (int) scale.getMajorTickIncrement()) || dialUnitScale > 1) {
            scale.setTickLabelFormatter(new DecimalFormat("#,##0"));
        } else if (dialUnitScale == 1) {

            scale.setTickLabelFormatter(new DecimalFormat("#,##0.0"));
        } else if (dialUnitScale <= 0) {
            scale.setTickLabelFormatter(new DecimalFormat("#,##0.00"));
        }

    } else {
        scale = new StandardDialScale();
    }
    scale.setTickRadius(0.9);
    scale.setTickLabelOffset(0.16);
    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);
    scale.setTickLabelFont(themeTickLabelFont);
    scale.setMajorTickStroke(new BasicStroke(1f));
    scale.setMinorTickStroke(new BasicStroke(0.3f));
    scale.setMajorTickPaint(Color.WHITE);
    scale.setMinorTickPaint(Color.WHITE);
    scale.setTickLabelsVisible(true);
    scale.setFirstTickLabelVisible(true);
    dialPlot.addScale(0, scale);

    List 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 = (JRMeterInterval) intervals.get(i);
            Range intervalRange = convertRange(interval.getDataRange());
            double intervalLowerBound = ChartThemesUtilities.getTruncatedValue(intervalRange.getLowerBound(),
                    dialUnitScale);
            double intervalUpperBound = ChartThemesUtilities.getTruncatedValue(intervalRange.getUpperBound(),
                    dialUnitScale);

            Color color = i < 3 ? (Color) ChartThemesConstants.AEGEAN_INTERVAL_COLORS.get(i)
                    : new Color(255 - colorStep * (i - 3), 0 + colorStep * (i - 3), 0);

            ScaledDialRange dialRange = new ScaledDialRange(intervalLowerBound, intervalUpperBound,
                    interval.getBackgroundColor() == null ? color : interval.getBackgroundColor(), 12f);
            dialRange.setInnerRadius(0.41);
            dialRange.setOuterRadius(0.41);
            dialPlot.addLayer(dialRange);
        }
    }

    JRValueDisplay display = jrPlot.getValueDisplay();
    String displayVisibility = display != null && getChart().hasProperties()
            ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_VALUE_DISPLAY_VISIBLE)
            : "false";
    if (Boolean.parseBoolean(displayVisibility)) {
        ScaledDialValueIndicator dvi = new ScaledDialValueIndicator(0, dialUnitScale);
        dvi.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
        //         dvi.setFont(JRFontUtil.getAwtFont(jrFont).deriveFont(10f).deriveFont(Font.BOLD));
        dvi.setOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
        dvi.setPaint(Color.WHITE);

        String pattern = display.getMask() != null ? display.getMask() : "#,##0.####";
        if (pattern != null)
            dvi.setNumberFormat(new DecimalFormat(pattern));
        dvi.setRadius(0.15);
        dvi.setValueAnchor(RectangleAnchor.CENTER);
        dvi.setTextAnchor(TextAnchor.CENTER);
        //dvi.setTemplateValue(Double.valueOf(getDialTickValue(dialPlot.getValue(0),dialUnitScale)));
        dialPlot.addLayer(dvi);
    }
    String label = getChart().hasProperties()
            ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_LABEL)
            : null;

    if (label != null) {
        JRFont displayFont = jrPlot.getValueDisplay().getFont();
        Font themeDisplayFont = getFont(
                (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_DISPLAY_FONT),
                displayFont, defaultBaseFontSize);
        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)) });

        String[] textLines = label.split("\\n");
        for (int i = 0; i < textLines.length; i++) {
            DialTextAnnotation dialAnnotation = new DialTextAnnotation(textLines[i]);
            dialAnnotation.setFont(themeDisplayFont);
            dialAnnotation.setPaint(Color.WHITE);
            dialAnnotation.setRadius(Math.sin(Math.PI / 4.0) + i / 10.0);
            dialAnnotation.setAnchor(TextAnchor.CENTER);
            dialPlot.addLayer(dialAnnotation);
        }
    }

    //DialPointer needle = new DialPointer.Pointer();
    Paint paint = new Color(191, 48, 0);
    DialPointer needle = new ScaledDialPointer(dialUnitScale, paint, paint);

    needle.setVisible(true);
    needle.setRadius(0.91);
    dialPlot.addLayer(needle);

    DialCap cap = new DialCap();
    cap.setRadius(0.05);
    cap.setFillPaint(Color.DARK_GRAY);
    cap.setOutlinePaint(Color.GRAY);
    cap.setOutlineStroke(new BasicStroke(0.5f));
    dialPlot.setCap(cap);

    JFreeChart jfreeChart = new JFreeChart((String) evaluateExpression(getChart().getTitleExpression()), null,
            dialPlot, getChart().getShowLegend() == null ? false : getChart().getShowLegend().booleanValue());

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

    jfreeChart.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    jfreeChart.setBorderVisible(false);

    return jfreeChart;

}

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  ww  w  . j  a va  2 s.  com
            }
        }

        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

/**
 *
 */// w w  w . j  av  a  2s  .  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;

}

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

@Override
protected JFreeChart createDialChart() throws JRException {

    JRMeterPlot jrPlot = (JRMeterPlot) getPlot();

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

    GradientPaint gp2 = new GradientPaint(new Point(), Color.GRAY, new Point(), Color.BLACK);

    // get data for diagrams
    DialPlot dialPlot = new DialPlot();
    //dialPlot.setView(0.0, 0.0, 1.0, 1.0);
    if (getDataset() != null) {
        dialPlot.setDataset((ValueDataset) getDataset());
    }//from   w w w  .  ja v  a2  s.c om
    StandardDialFrame dialFrame = new StandardDialFrame();
    //dialFrame.setRadius(0.60);
    //dialFrame.setBackgroundPaint(gp2);
    dialFrame.setForegroundPaint(gp2);
    dialPlot.setDialFrame(dialFrame);

    DialBackground db = new DialBackground(gp);
    db.setGradientPaintTransformer(new StandardGradientPaintTransformer(GradientPaintTransformType.VERTICAL));
    dialPlot.setBackground(db);
    StandardDialScale scale = null;
    int dialUnitScale = 1;
    Range range = convertRange(jrPlot.getDataRange());
    if (range != null) {
        double bound = Math.max(Math.abs(range.getUpperBound()), Math.abs(range.getLowerBound()));
        dialUnitScale = ChartThemesUtilities.getScale(bound);

        double lowerBound = ChartThemesUtilities.getTruncatedValue(range.getLowerBound(), dialUnitScale);
        double upperBound = ChartThemesUtilities.getTruncatedValue(range.getUpperBound(), dialUnitScale);
        int tickCount = jrPlot.getTickCount() != null && jrPlot.getTickCount() > 1 ? jrPlot.getTickCount() : 7;
        scale = new StandardDialScale(lowerBound, upperBound, 225, -270,
                (upperBound - lowerBound) / (tickCount - 1), 15);
        if ((lowerBound == (int) lowerBound && upperBound == (int) upperBound
                && scale.getMajorTickIncrement() == (int) scale.getMajorTickIncrement()) || dialUnitScale > 1) {
            scale.setTickLabelFormatter(
                    new DecimalFormat("#,##0", DecimalFormatSymbols.getInstance(getLocale())));
        } else if (dialUnitScale == 1) {

            scale.setTickLabelFormatter(
                    new DecimalFormat("#,##0.0", DecimalFormatSymbols.getInstance(getLocale())));
        } else if (dialUnitScale <= 0) {
            scale.setTickLabelFormatter(
                    new DecimalFormat("#,##0.00", DecimalFormatSymbols.getInstance(getLocale())));
        } else {
            // localizing the default tick label formatter
            scale.setTickLabelFormatter(
                    new DecimalFormat("0.0", DecimalFormatSymbols.getInstance(getLocale())));
        }

    } else {
        scale = new StandardDialScale();

        // localizing the default tick label formatter
        scale.setTickLabelFormatter(new DecimalFormat("0.0", DecimalFormatSymbols.getInstance(getLocale())));
    }
    scale.setTickRadius(0.9);
    scale.setTickLabelOffset(0.16);
    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);
    scale.setTickLabelFont(themeTickLabelFont);
    scale.setMajorTickStroke(new BasicStroke(1f));
    scale.setMinorTickStroke(new BasicStroke(0.3f));
    scale.setMajorTickPaint(Color.WHITE);
    scale.setMinorTickPaint(Color.WHITE);
    scale.setTickLabelsVisible(true);
    scale.setFirstTickLabelVisible(true);

    dialPlot.addScale(0, scale);

    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);
            Range intervalRange = convertRange(interval.getDataRange());
            double intervalLowerBound = ChartThemesUtilities.getTruncatedValue(intervalRange.getLowerBound(),
                    dialUnitScale);
            double intervalUpperBound = ChartThemesUtilities.getTruncatedValue(intervalRange.getUpperBound(),
                    dialUnitScale);

            Color color = i < 3 ? (Color) ChartThemesConstants.AEGEAN_INTERVAL_COLORS.get(i)
                    : new Color(255 - colorStep * (i - 3), 0 + colorStep * (i - 3), 0);

            ScaledDialRange dialRange = new ScaledDialRange(intervalLowerBound, intervalUpperBound,
                    interval.getBackgroundColor() == null ? color : interval.getBackgroundColor(), 12f);
            dialRange.setInnerRadius(0.41);
            dialRange.setOuterRadius(0.41);
            dialPlot.addLayer(dialRange);
        }
    }

    JRValueDisplay display = jrPlot.getValueDisplay();
    String displayVisibility = display != null && getChart().hasProperties()
            ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_VALUE_DISPLAY_VISIBLE)
            : "false";
    if (Boolean.parseBoolean(displayVisibility)) {
        ScaledDialValueIndicator dvi = new ScaledDialValueIndicator(0, dialUnitScale);
        dvi.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
        //         dvi.setFont(JRFontUtil.getAwtFont(jrFont).deriveFont(10f).deriveFont(Font.BOLD));
        dvi.setOutlinePaint(ChartThemesConstants.TRANSPARENT_PAINT);
        dvi.setPaint(Color.WHITE);

        String pattern = display.getMask() != null ? display.getMask() : "#,##0.####";
        if (pattern != null)
            dvi.setNumberFormat(new DecimalFormat(pattern, DecimalFormatSymbols.getInstance(getLocale())));
        dvi.setRadius(0.15);
        dvi.setValueAnchor(RectangleAnchor.CENTER);
        dvi.setTextAnchor(TextAnchor.CENTER);
        //dvi.setTemplateValue(Double.valueOf(getDialTickValue(dialPlot.getValue(0),dialUnitScale)));
        dialPlot.addLayer(dvi);
    }
    String label = getChart().hasProperties()
            ? getChart().getPropertiesMap().getProperty(DefaultChartTheme.PROPERTY_DIAL_LABEL)
            : null;

    if (label != null) {
        JRFont displayFont = jrPlot.getValueDisplay().getFont();
        Font themeDisplayFont = getFont(
                (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_DISPLAY_FONT),
                displayFont, defaultBaseFontSize);
        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)) });

        String[] textLines = label.split("\\n");
        for (int i = 0; i < textLines.length; i++) {
            DialTextAnnotation dialAnnotation = new DialTextAnnotation(textLines[i]);
            dialAnnotation.setFont(themeDisplayFont);
            dialAnnotation.setPaint(Color.WHITE);
            dialAnnotation.setRadius(Math.sin(Math.PI / 4.0) + i / 10.0);
            dialAnnotation.setAnchor(TextAnchor.CENTER);
            dialPlot.addLayer(dialAnnotation);
        }
    }

    //DialPointer needle = new DialPointer.Pointer();
    Paint paint = new Color(191, 48, 0);
    DialPointer needle = new ScaledDialPointer(dialUnitScale, paint, paint);

    needle.setVisible(true);
    needle.setRadius(0.91);
    dialPlot.addLayer(needle);

    DialCap cap = new DialCap();
    cap.setRadius(0.05);
    cap.setFillPaint(Color.DARK_GRAY);
    cap.setOutlinePaint(Color.GRAY);
    cap.setOutlineStroke(new BasicStroke(0.5f));
    dialPlot.setCap(cap);

    JFreeChart jfreeChart = new JFreeChart(evaluateTextExpression(getChart().getTitleExpression()), null,
            dialPlot, getChart().getShowLegend() == null ? false : getChart().getShowLegend());

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

    jfreeChart.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    jfreeChart.setBorderVisible(false);

    return jfreeChart;

}