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.
    List seriesPaints =
        (List) getDefaultValue(defaultChartPropertiesMap, ChartThemesConstants.SERIES_COLORS);

    Paint paint = jrPlot.getMercuryColor();
    if (paint != null) {
      chartPlot.setUseSubrangePaint(false);
    } else {
      // it has no effect, but is kept for backward compatibility reasons
      paint = (Paint) seriesPaints.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
    // 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;
  }
  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;
  }