Example usage for org.jfree.chart.plot MeterPlot setRange

List of usage examples for org.jfree.chart.plot MeterPlot setRange

Introduction

In this page you can find the example usage for org.jfree.chart.plot MeterPlot setRange.

Prototype

public void setRange(Range range) 

Source Link

Document

Sets the range for the dial and sends a PlotChangeEvent to all registered listeners.

Usage

From source file:net.sf.jasperreports.engine.fill.DefaultChartTheme.java

/**
 *
 *//*from  w w  w.j a  v  a2 s .c om*/
protected JFreeChart createMeterChart() throws JRException {
    JRMeterPlot jrPlot = (JRMeterPlot) getPlot();

    // Start by creating the plot that will hold the meter
    MeterPlot chartPlot = new MeterPlot((ValueDataset) getDataset());

    // Set the shape
    MeterShapeEnum shape = jrPlot.getShapeValue() == null ? MeterShapeEnum.PIE : jrPlot.getShapeValue();
    switch (shape) {
    case CHORD:
        chartPlot.setDialShape(DialShape.CHORD);
        break;
    case CIRCLE:
        chartPlot.setDialShape(DialShape.CIRCLE);
        break;
    case PIE:
    default:
        chartPlot.setDialShape(DialShape.PIE);
    }

    // Set the meter's range
    chartPlot.setRange(convertRange(jrPlot.getDataRange()));

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

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

    // Set the font used for tick labels
    if (jrPlot.getTickLabelFont() != null) {
        chartPlot.setTickLabelFont(fontUtil.getAwtFont(jrPlot.getTickLabelFont(), getLocale()));
    }

    // 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);

    // Set all the colors we support
    Color color = jrPlot.getMeterBackgroundColor();
    if (color != null) {
        chartPlot.setDialBackgroundPaint(color);
    }

    color = jrPlot.getNeedleColor();
    if (color != null) {
        chartPlot.setNeedlePaint(color);
    }

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

    // Set how the value is displayed.
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null) {
        if (display.getColor() != null) {
            chartPlot.setValuePaint(display.getColor());
        }

        if (display.getMask() != null) {
            chartPlot.setTickLabelFormat(
                    new DecimalFormat(display.getMask(), DecimalFormatSymbols.getInstance(getLocale())));
        }

        if (display.getFont() != null) {
            chartPlot.setValueFont(fontUtil.getAwtFont(display.getFont(), getLocale()));
        }

    }

    color = jrPlot.getTickColor();
    if (color != null) {
        chartPlot.setTickPaint(color);
    }

    // Now define all of the intervals, setting their range and color
    List<JRMeterInterval> intervals = jrPlot.getIntervals();
    if (intervals != null) {
        Iterator<JRMeterInterval> iter = intervals.iterator();
        while (iter.hasNext()) {
            JRMeterInterval interval = iter.next();
            chartPlot.addInterval(convertInterval(interval));
        }
    }

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

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

    return jfreeChart;
}

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

/**
 *
 *//*from w ww  .j  av  a  2 s .  c  o  m*/
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:
        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().intValue();
    // 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().doubleValue();
    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);

    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"));
        } else if (dialUnitScale == 1) {
            chartPlot.setTickLabelFormat(new DecimalFormat("#,##0.0"));
        } else if (dialUnitScale <= 0) {
            chartPlot.setTickLabelFormat(new DecimalFormat("#,##0.00"));
        }
    }
    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));
        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 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);
            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(new Double(1.0));
            chartPlot.addInterval(convertInterval(interval));
        }
    }

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

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

    return jfreeChart;

}

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:// w w  w  .  ja va  2  s.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:net.sf.fspdfs.chartthemes.simple.SimpleChartTheme.java

/**
 * Build and configure a meter chart./*from   w w w.  jav a 2  s. c om*/
 *
 * @param evaluation current expression evaluation phase
 * @throws JRException
*/
protected JFreeChart createMeterChart() throws JRException {
    JRMeterPlot jrPlot = (JRMeterPlot) getPlot();

    // Start by creating the plot that will hold the meter
    MeterPlot chartPlot = new MeterPlot((ValueDataset) getDataset());

    // Set the shape
    MeterShapeEnum shape = jrPlot.getShapeValue() == null ? MeterShapeEnum.PIE : jrPlot.getShapeValue();
    if (shape == MeterShapeEnum.CHORD)
        chartPlot.setDialShape(DialShape.CHORD);
    else if (shape == MeterShapeEnum.CIRCLE)
        chartPlot.setDialShape(DialShape.CIRCLE);
    else if (shape == MeterShapeEnum.DIAL)
        return createDialChart();
    else
        chartPlot.setDialShape(DialShape.PIE);

    // Set the meter's range
    chartPlot.setRange(convertRange(jrPlot.getDataRange()));

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

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

    // 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().doubleValue();
    chartPlot.setTickSize(tickInterval);

    // Set all the colors we support
    Color color = jrPlot.getMeterBackgroundColor();
    if (color != null)
        chartPlot.setDialBackgroundPaint(color);

    color = jrPlot.getNeedleColor();
    if (color != null)
        chartPlot.setNeedlePaint(color);

    JRBaseFont font = new JRBaseFont();
    JRFontUtil.copyNonNullOwnProperties(getPlotSettings().getTickLabelFont(), font);
    JRFontUtil.copyNonNullOwnProperties(jrPlot.getTickLabelFont(), font);
    font = new JRBaseFont(getChart(), font);
    chartPlot.setTickLabelFont(JRFontUtil.getAwtFont(font, getLocale()));

    // Set how the value is displayed.
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null) {
        if (display.getColor() != null) {
            chartPlot.setValuePaint(display.getColor());
        }

        if (display.getMask() != null) {
            chartPlot.setTickLabelFormat(new DecimalFormat(display.getMask()));
        }

        font = new JRBaseFont();
        JRFontUtil.copyNonNullOwnProperties(getPlotSettings().getDisplayFont(), font);
        JRFontUtil.copyNonNullOwnProperties(jrPlot.getValueDisplay().getFont(), font);
        font = new JRBaseFont(getChart(), font);
        chartPlot.setValueFont(JRFontUtil.getAwtFont(font, getLocale()));

    }

    color = jrPlot.getTickColor();
    if (color != null)
        chartPlot.setTickPaint(color);

    // Now define all of the intervals, setting their range and color
    List intervals = jrPlot.getIntervals();
    if (intervals != null) {
        Iterator iter = intervals.iterator();
        while (iter.hasNext()) {
            JRMeterInterval interval = (JRMeterInterval) iter.next();
            if (interval != null)
                chartPlot.addInterval(convertInterval(interval));
        }
    }

    // Actually create the chart around the plot
    JFreeChart jfreeChart = new JFreeChart((String) evaluateExpression(getChart().getTitleExpression()), null,
            chartPlot, isShowLegend());

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

    return jfreeChart;
}

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

/**
 * Build and configure a meter chart.//from w  w  w.j  a va 2 s. com
 *
 * @param evaluation current expression evaluation phase
 * @throws JRException
*/
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.PIE : jrPlot.getShapeValue();

    switch (shape) {
    case CHORD:
        chartPlot.setDialShape(DialShape.CHORD);
        break;
    case CIRCLE:
        chartPlot.setDialShape(DialShape.CIRCLE);
        break;
    case DIAL:
        return createDialChart();
    case PIE:
    default:
        chartPlot.setDialShape(DialShape.PIE);
    }

    // Set the meter's range
    chartPlot.setRange(convertRange(jrPlot.getDataRange()));

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

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

    // 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().doubleValue();
    chartPlot.setTickSize(tickInterval);

    // Set all the colors we support
    Color color = jrPlot.getMeterBackgroundColor();
    if (color != null)
        chartPlot.setDialBackgroundPaint(color);

    color = jrPlot.getNeedleColor();
    if (color != null)
        chartPlot.setNeedlePaint(color);

    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);

    JRValueDisplay display = jrPlot.getValueDisplay();
    JRFont displayFont = display.getFont();
    Font themeDisplayFont = getFont(
            (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_DISPLAY_FONT),
            displayFont, defaultBaseFontSize);
    // Set how the value is displayed.
    if (display != null) {
        if (display.getColor() != null) {
            chartPlot.setValuePaint(display.getColor());
        }

        if (display.getMask() != null) {
            chartPlot.setTickLabelFormat(new DecimalFormat(display.getMask()));
        }
        if (display.getFont() != null) {
            chartPlot.setValueFont(themeDisplayFont);
        }

    }

    color = jrPlot.getTickColor();
    if (color != null)
        chartPlot.setTickPaint(color);

    // Now define all of the intervals, setting their range and color
    List intervals = jrPlot.getIntervals();
    if (intervals != null) {
        Iterator iter = intervals.iterator();
        while (iter.hasNext()) {
            JRMeterInterval interval = (JRMeterInterval) iter.next();
            if (interval != null)
                chartPlot.addInterval(convertInterval(interval));
        }
    }

    // Actually create the chart around the plot
    JFreeChart jfreeChart = new JFreeChart((String) evaluateExpression(getChart().getTitleExpression()), null,
            chartPlot, isShowLegend());

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

    return jfreeChart;
}

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

/**
 *
 */// ww w. j a  v  a2s .  com
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:
        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().intValue();
    // 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().doubleValue();
    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);

    Color tickColor = jrPlot.getTickColor() == null ? Color.BLACK : jrPlot.getTickColor();
    chartPlot.setTickPaint(tickColor);
    int dialUnitScale = 1;

    Range range = convertRange(jrPlot.getDataRange());
    // Set the meter's range
    if (range != null) {
        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"));
        } else if (dialUnitScale == 1) {
            chartPlot.setTickLabelFormat(new DecimalFormat("#,##0.0"));
        } else if (dialUnitScale <= 0) {
            chartPlot.setTickLabelFormat(new DecimalFormat("#,##0.00"));
        }
    }
    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));
        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 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);
            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(new Double(1.0));
            chartPlot.addInterval(convertInterval(interval));
        }
    }

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

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

    return jfreeChart;

}

From source file:net.sf.jasperreports.chartthemes.simple.SimpleChartTheme.java

/**
 * Build and configure a meter chart./* ww  w  . j  a  v  a2 s. c om*/
 */
protected JFreeChart createMeterChart() throws JRException {
    JRMeterPlot jrPlot = (JRMeterPlot) getPlot();

    // Start by creating the plot that will hold the meter
    MeterPlot chartPlot = new MeterPlot((ValueDataset) getDataset());

    // Set the shape
    MeterShapeEnum shape = jrPlot.getShapeValue() == null ? MeterShapeEnum.PIE : jrPlot.getShapeValue();
    if (shape == MeterShapeEnum.CHORD)
        chartPlot.setDialShape(DialShape.CHORD);
    else if (shape == MeterShapeEnum.CIRCLE)
        chartPlot.setDialShape(DialShape.CIRCLE);
    else if (shape == MeterShapeEnum.DIAL)
        return createDialChart();
    else
        chartPlot.setDialShape(DialShape.PIE);

    // Set the meter's range
    chartPlot.setRange(convertRange(jrPlot.getDataRange()));

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

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

    // 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);

    // Set all the colors we support
    Color color = jrPlot.getMeterBackgroundColor();
    if (color != null)
        chartPlot.setDialBackgroundPaint(color);

    color = jrPlot.getNeedleColor();
    if (color != null)
        chartPlot.setNeedlePaint(color);

    JRBaseFont font = new JRBaseFont();
    FontUtil.copyNonNullOwnProperties(getPlotSettings().getTickLabelFont(), font);
    FontUtil.copyNonNullOwnProperties(jrPlot.getTickLabelFont(), font);
    font = new JRBaseFont(getChart(), font);
    chartPlot.setTickLabelFont(getFontUtil().getAwtFont(font, getLocale()));

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

    // Set how the value is displayed.
    JRValueDisplay display = jrPlot.getValueDisplay();
    if (display != null) {
        if (display.getColor() != null) {
            chartPlot.setValuePaint(display.getColor());
        }

        if (display.getMask() != null) {
            chartPlot.setTickLabelFormat(
                    new DecimalFormat(display.getMask(), DecimalFormatSymbols.getInstance(getLocale())));
        }

        font = new JRBaseFont();
        FontUtil.copyNonNullOwnProperties(getPlotSettings().getDisplayFont(), font);
        FontUtil.copyNonNullOwnProperties(jrPlot.getValueDisplay().getFont(), font);
        font = new JRBaseFont(getChart(), font);
        chartPlot.setValueFont(getFontUtil().getAwtFont(font, getLocale()));

    }

    color = jrPlot.getTickColor();
    if (color != null)
        chartPlot.setTickPaint(color);

    // Now define all of the intervals, setting their range and color
    List<JRMeterInterval> intervals = jrPlot.getIntervals();
    if (intervals != null) {
        Iterator<JRMeterInterval> iter = intervals.iterator();
        while (iter.hasNext()) {
            JRMeterInterval interval = iter.next();
            if (interval != null)
                chartPlot.addInterval(convertInterval(interval));
        }
    }

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

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

    return jfreeChart;
}

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

/**
 * Build and configure a meter chart./*from  ww w .  ja  va  2  s. c  o  m*/
 */
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.PIE : jrPlot.getShapeValue();

    switch (shape) {
    case CHORD:
        chartPlot.setDialShape(DialShape.CHORD);
        break;
    case CIRCLE:
        chartPlot.setDialShape(DialShape.CIRCLE);
        break;
    case DIAL:
        return createDialChart();
    case PIE:
    default:
        chartPlot.setDialShape(DialShape.PIE);
    }

    // Set the meter's range
    chartPlot.setRange(convertRange(jrPlot.getDataRange()));

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

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

    // 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);

    // Set all the colors we support
    Color color = jrPlot.getMeterBackgroundColor();
    if (color != null)
        chartPlot.setDialBackgroundPaint(color);

    color = jrPlot.getNeedleColor();
    if (color != null)
        chartPlot.setNeedlePaint(color);

    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()));

    JRValueDisplay display = jrPlot.getValueDisplay();
    JRFont displayFont = display.getFont();
    Font themeDisplayFont = getFont(
            (JRFont) getDefaultValue(defaultPlotPropertiesMap, ChartThemesConstants.PLOT_DISPLAY_FONT),
            displayFont, defaultBaseFontSize);
    // Set how the value is displayed.
    if (display != null) {
        if (display.getColor() != null) {
            chartPlot.setValuePaint(display.getColor());
        }

        if (display.getMask() != null) {
            chartPlot.setTickLabelFormat(
                    new DecimalFormat(display.getMask(), DecimalFormatSymbols.getInstance(getLocale())));
        }
        if (display.getFont() != null) {
            chartPlot.setValueFont(themeDisplayFont);
        }

    }

    color = jrPlot.getTickColor();
    if (color != null)
        chartPlot.setTickPaint(color);

    // Now define all of the intervals, setting their range and color
    List<JRMeterInterval> intervals = jrPlot.getIntervals();
    if (intervals != null) {
        Iterator<JRMeterInterval> iter = intervals.iterator();
        while (iter.hasNext()) {
            JRMeterInterval interval = iter.next();
            if (interval != null)
                chartPlot.addInterval(convertInterval(interval));
        }
    }

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

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

    return jfreeChart;
}

From source file:net.sf.jasperreports.chartthemes.spring.EyeCandySixtiesChartTheme.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:/*from   w ww .  jav  a  2 s  .c o  m*/
        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());
    // Set the meter's range
    if (range != null) {
        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:ucar.unidata.idv.flythrough.Flythrough.java

/**
 * _more_/*from   w  ww.  j  av  a2  s  .c  o  m*/
 *
 * @param pt1 _more_
 *
 * @throws Exception _more_
 */
protected void processReadout(FlythroughPoint pt1) throws Exception {

    Font font = new Font("Dialog", Font.BOLD, 22);
    dials = new ArrayList<JComponent>();
    if ((readoutLabel == null) || (pt1 == null)) {
        return;
    }

    List<ReadoutInfo> samples = new ArrayList<ReadoutInfo>();
    readoutLabel.setText(readout.getReadout(pt1.getEarthLocation(), showReadout, true, samples));

    if (!showReadout) {
        return;
    }

    List comps = new ArrayList();
    for (FlythroughDecorator decorator : decorators) {
        decorator.handleReadout(pt1, samples);
    }

    for (ReadoutInfo info : samples) {
        Real r = info.getReal();
        if (r == null) {
            continue;
        }

        Unit unit = info.getUnit();
        if (unit == null) {
            unit = r.getUnit();
        }
        String name = ucar.visad.Util.cleanTypeName(r.getType());

        String unitSuffix = "";
        if (unit != null) {
            unitSuffix = " [" + unit + "]";
        }

        double v = r.getValue(unit);
        if (v == v) {
            v = Misc.parseNumber(Misc.format(v));
        }

        JLabel label = new JLabel(name.replace("_", " "));

        label.setFont(font);
        DefaultValueDataset dataset = new DefaultValueDataset(new Double(v));
        MeterPlot plot = new MeterPlot(dataset);
        if (info.getRange() != null) {
            Range range = info.getRange();
            plot.setRange(new org.jfree.data.Range(range.getMin(), range.getMax()));
        }
        if (unit != null) {
            plot.setUnits(unit.toString());
        } else {
            plot.setUnits("");
        }
        plot.setDialBackgroundPaint(Color.white);
        plot.setTickLabelsVisible(true);
        plot.setValueFont(font);
        plot.setTickLabelFont(font);
        plot.setTickLabelPaint(Color.darkGray);
        plot.setTickPaint(Color.black);
        plot.setValuePaint(Color.black);

        JFreeChart chart = new JFreeChart("", plot);
        TextTitle title = new TextTitle(" " + label.getText() + " ", font);
        title.setBackgroundPaint(Color.gray);
        title.setPaint(Color.white);
        chart.setTitle(title);
        ChartPanel chartPanel = new ChartPanel(chart);
        chartPanel.setPreferredSize(dialDimension);
        chartPanel.setSize(new Dimension(150, 150));
        plot.setBackgroundPaint(new Color(255, 255, 255, 0));
        plot.setBackgroundImageAlpha(0.0f);
        chart.setBackgroundPaint(new Color(255, 255, 255, 0));
        chartPanel.setBackground(new Color(255, 255, 255, 0));
        comps.add(chartPanel);
        dials.add(chartPanel);
    }

    readoutDisplay.removeAll();
    updateDashboard();

}