Example usage for org.jfree.chart.plot ThermometerPlot ThermometerPlot

List of usage examples for org.jfree.chart.plot ThermometerPlot ThermometerPlot

Introduction

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

Prototype

public ThermometerPlot(ValueDataset dataset) 

Source Link

Document

Creates a new thermometer plot, using default attributes where necessary.

Usage

From source file:org.jfree.chart.demo.ThermometerDemo2.java

/**
 * Creates a new demo./*from   w  w w  .  j av  a  2  s. co  m*/
 *
 * @param title  the frame title.
 */
public ThermometerDemo2(final String title) {

    super(title);

    // create a dataset...
    final DefaultValueDataset dataset = new DefaultValueDataset(new Double(43.0));

    // create the chart...
    final ThermometerPlot plot = new ThermometerPlot(dataset);
    final JFreeChart chart = new JFreeChart("Thermometer Demo 2", // chart title
            JFreeChart.DEFAULT_TITLE_FONT, plot, // plot
            false); // include legend

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    //    plot.setInsets(new Insets(5, 5, 5, 5));
    //plot.setRangeInfo(ThermometerPlot.NORMAL, 0.0, 55.0, 0.0, 100.0);
    //plot.setRangeInfo(ThermometerPlot.WARNING, 55.0, 75.0, 0.0, 100.0);
    //plot.setRangeInfo(ThermometerPlot.CRITICAL, 75.0, 100.0, 0.0, 100.0);

    plot.setThermometerStroke(new BasicStroke(2.0f));
    plot.setThermometerPaint(Color.lightGray);
    // OPTIONAL CUSTOMISATION COMPLETED.

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    setContentPane(chartPanel);

}

From source file:org.cyberoam.iview.charts.Thermometer.java

/**
 * This method generates JFreeChart instance for Thermometer chart with iView customization. 
 * @param reportID//  ww  w.  jav  a2s. c  o m
 * @param rsw
 * @param request
 * @return
 */
public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) {
    ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID);
    JFreeChart chart = null;
    ReportColumnBean reportColumnBean = null;
    GraphBean graphBean = null;
    try {
        DefaultValueDataset dataset = null;
        graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());
        reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(),
                graphBean.getYColumnId());
        String yColumnDBname = reportColumnBean.getDbColumnName();
        rsw.first();
        double used = Double.parseDouble(rsw.getString(yColumnDBname));
        rsw.next();
        double free = Double.parseDouble(rsw.getString(yColumnDBname));
        dataset = new DefaultValueDataset((100 * used) / (used + free));
        ThermometerPlot plot = new ThermometerPlot(dataset);
        chart = new JFreeChart("", // chart title
                JFreeChart.DEFAULT_TITLE_FONT, plot, // plot
                false); // include legend
        chart.setBackgroundPaint(Color.white);
        plot.setThermometerStroke(new BasicStroke(2.0f));
        plot.setThermometerPaint(Color.DARK_GRAY);
        plot.setBulbRadius(30);
        plot.setColumnRadius(15);
        plot.setUnits(ThermometerPlot.UNITS_NONE);
        plot.setMercuryPaint(Color.WHITE);
        plot.setValueFont(new Font("Vandara", Font.CENTER_BASELINE, 12));
        plot.setBackgroundPaint(Color.white);
        plot.setBackgroundAlpha(0.0f);
        plot.setOutlineVisible(false);
        plot.setSubrangeInfo(0, 0, 50);
        plot.setSubrangeInfo(1, 50, 85);
        plot.setSubrangeInfo(2, 85, 100);
        plot.setSubrangePaint(0, new Color(75, 200, 85));
        plot.setSubrangePaint(1, new Color(254, 211, 41));
        plot.setSubrangePaint(2, new Color(255, 85, 85));

    } catch (Exception e) {
        CyberoamLogger.appLog.debug("Thermometer=>getChart.exception : " + e, e);
    }
    return chart;
}

From source file:WeatherFrame.java

public WeatherFrame() {
    initComponents();/*from   ww  w  .j  a va2 s .c o m*/

    fc = new JFileChooser();
    fc.setMultiSelectionEnabled(true);

    //only can select a single button a time
    ButtonGroup group = new ButtonGroup();
    group.add(AllRadioButton);
    group.add(YearlyRadioButton);
    group.add(MonthlyRadioButton);
    group.add(WeeklyRadioButton);
    group.add(DailyRadioButton);

    jComboBox1.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Temperature", "Humidity",
            "Barometric Pressure", "Windspeed", "UVindex", "Raindfall" }));

    TempSet = new TimeSeriesCollection();
    JFreeChart chart = ChartFactory.createXYLineChart("Temperature", "", "Degree Fahrenheit", TempSet,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.white);
    ChartPanel.setLayout(new java.awt.BorderLayout());
    ChartPanel CP = new ChartPanel(chart);
    CP.setPreferredSize(new Dimension(ChartPanel.getWidth(), ChartPanel.getHeight()));
    ChartPanel.add(CP, BorderLayout.CENTER);

    DefaultValueDataset dataset = new DefaultValueDataset(20f);
    ThermometerPlot thermometerplot = new ThermometerPlot(dataset);
    JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, thermometerplot, true);
    jfreechart.setBackgroundPaint(new Color(240, 240, 240));
    thermometerplot.setThermometerPaint(Color.lightGray);
    thermometerplot.setThermometerStroke(new BasicStroke(2.0F));
    ChartPanel DP = new ChartPanel(jfreechart);
    DP.setPreferredSize(new Dimension(TempThermoPanel.getWidth(), TempThermoPanel.getHeight()));
    TempThermoPanel.setLayout(new java.awt.BorderLayout());
    TempThermoPanel.add(DP);
    TempThermoPanel.validate();
}

From source file:it.eng.spagobi.engines.chart.bo.charttypes.dialcharts.Thermometer.java

/**
 * Creates a chart of type thermometer.//from w ww .  j ava 2 s. com
 * 
 * @param chartTitle  the chart title.
 * @param dataset  the dataset.
 * 
 * @return A chart thermometer.
 */

public JFreeChart createChart(DatasetMap datasets) {
    logger.debug("IN");
    Dataset dataset = (Dataset) datasets.getDatasets().get("1");

    ThermometerPlot plot = new ThermometerPlot((ValueDataset) dataset);
    JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chart.setBackgroundPaint(color);

    TextTitle title = setStyleTitle(name, styleTitle);
    chart.setTitle(title);
    if (subName != null && !subName.equals("")) {
        TextTitle subTitle = setStyleTitle(subName, styleSubTitle);
        chart.addSubtitle(subTitle);
    }

    plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setPadding(new RectangleInsets(10.0, 10.0, 10.0, 10.0));
    plot.setThermometerStroke(new BasicStroke(2.0f));
    plot.setThermometerPaint(Color.lightGray);
    plot.setGap(3);
    plot.setValueLocation(3);
    plot.setValuePaint(labelsValueStyle.getColor());
    plot.setValueFont(new Font(labelsValueStyle.getFontName(), Font.PLAIN, labelsValueStyle.getSize()));

    plot.setRange(lower, upper);

    if (units.equalsIgnoreCase(FAHRENHEIT))
        plot.setUnits(ThermometerPlot.UNITS_FAHRENHEIT);
    else if (units.equalsIgnoreCase(CELCIUS))
        plot.setUnits(ThermometerPlot.UNITS_CELCIUS);
    else if (units.equalsIgnoreCase(KELVIN))
        plot.setUnits(ThermometerPlot.UNITS_KELVIN);
    else
        plot.setUnits(ThermometerPlot.UNITS_NONE);

    // set subranges   
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval subrange = (KpiInterval) iterator.next();
        int range = 0;
        if (subrange.getLabel().equalsIgnoreCase(NORMAL))
            range = (ThermometerPlot.NORMAL);
        else if (subrange.getLabel().equalsIgnoreCase(WARNING))
            range = (ThermometerPlot.WARNING);
        else if (subrange.getLabel().equalsIgnoreCase(CRITICAL))
            range = (ThermometerPlot.CRITICAL);

        plot.setSubrange(range, subrange.getMin(), subrange.getMax());
        if (subrange.getColor() != null) {
            plot.setSubrangePaint(range, subrange.getColor());
        }
        //plot.setDisplayRange(subrange.getRange(), subrange.getLower(), subrange.getUpper());   
    }
    //plot.setFollowDataInSubranges(true);
    logger.debug("OUT");

    return chart;
}

From source file:com.xilinx.kintex7.ThermoPlot.java

public void createPlot() {
    dset = new DefaultValueDataset(50);
    plot = new ThermometerPlot(dset);
    plot.setRange(0, 125);//  w  w  w  . ja v  a  2  s  . c om
    //plot.setFollowDataInSubranges(true);
    //plot.setUseSubrangePaint(false);
    plot.setThermometerStroke(new BasicStroke(2.0f));
    plot.setSubrange(ThermometerPlot.NORMAL, 0, 60);
    plot.setSubrange(ThermometerPlot.WARNING, 60, 85);
    plot.setSubrange(ThermometerPlot.CRITICAL, 86, 125);

    plot.setThermometerPaint(Color.BLACK);
    plot.setOutlineVisible(false);
    plot.setBackgroundAlpha(0);
    plot.setMercuryPaint(Color.ORANGE);
    plot.setUnits(ThermometerPlot.UNITS_NONE);
    chart = new JFreeChart("", plot);
    TextTitle ttitle = new TextTitle("Temperature (\u2103)", new Font("Temperature (\u2103)", Font.BOLD, 15));
    ttitle.setPaint(Color.WHITE);
    chart.setTitle(ttitle);
    chart.setBackgroundPaint(new Color(133, 133, 133));
    //chart.setTitle("");
}

From source file:org.pentaho.plugin.jfreereport.reportcharts.ThermometerChartExpression.java

protected JFreeChart computeChart(final Dataset dataset) {
    ValueDataset thermometerDataset = null;
    if (dataset instanceof ValueDataset) {
        thermometerDataset = (ValueDataset) dataset;
    }//from   www .jav  a2  s .  c o m

    final ThermometerPlot plot = new ThermometerPlot(thermometerDataset);
    return new JFreeChart(computeTitle(), JFreeChart.DEFAULT_TITLE_FONT, plot, true);
}

From source file:org.pentaho.reporting.engine.classic.extensions.legacy.charts.LegacyChartType.java

private JFreeChart createChart(final Expression aExpression) {
    if (aExpression instanceof BarLineChartExpression) {
        final CategoryAxis catAxis = new CategoryAxis("Category");// NON-NLS
        final NumberAxis barsAxis = new NumberAxis("Value");// NON-NLS
        final NumberAxis linesAxis = new NumberAxis("Value2");// NON-NLS

        final CategoryPlot plot = new CategoryPlot(createDataset(), catAxis, barsAxis, new BarRenderer());
        plot.setRenderer(1, new LineAndShapeRenderer());

        // add lines dataset and axis to plot
        plot.setDataset(1, createDataset());
        plot.setRangeAxis(1, linesAxis);

        // map lines to second axis
        plot.mapDatasetToRangeAxis(1, 1);

        // set rendering order
        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

        // set location of second axis
        plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

        return new JFreeChart("Bar Line Chart", plot);
    }//from  w w  w.  j  a  v a 2s  . c o m

    if (aExpression instanceof RingChartExpression) {
        return ChartFactory.createRingChart("Ring Chart", createPieDataset(), true, false, false);// NON-NLS
    }
    if (aExpression instanceof AreaChartExpression) {
        return ChartFactory.createAreaChart("Area Chart", "Category", "Value", createDataset(),
                PlotOrientation.VERTICAL, true, false, false);// NON-NLS
    }
    if (aExpression instanceof BarChartExpression) {
        return ChartFactory.createBarChart("Bar Chart", "Category", "Value", createDataset(),
                PlotOrientation.VERTICAL, true, false, false);// NON-NLS

    }
    if (aExpression instanceof LineChartExpression) {
        return ChartFactory.createLineChart("Line Chart", "Category", "Value", createDataset(),
                PlotOrientation.VERTICAL, true, false, false);// NON-NLS
    }
    if (aExpression instanceof MultiPieChartExpression) {
        return ChartFactory.createMultiplePieChart("Multi Pie Chart", createDataset(), TableOrder.BY_COLUMN,
                true, false, false);// NON-NLS
    }
    if (aExpression instanceof PieChartExpression) {
        return ChartFactory.createPieChart("Pie Chart", createPieDataset(), true, false, false);// NON-NLS
    }
    if (aExpression instanceof WaterfallChartExpressions) {
        return ChartFactory.createWaterfallChart("Bar Chart", "Category", "Value", createDataset(),
                PlotOrientation.HORIZONTAL, true, false, false);// NON-NLS
    }
    if (aExpression instanceof BubbleChartExpression) {
        return ChartFactory.createBubbleChart("Bubble Chart", "X", "Y", createXYZDataset(),
                PlotOrientation.VERTICAL, true, false, false);// NON-NLS
    }
    if (aExpression instanceof ExtendedXYLineChartExpression) {
        return ChartFactory.createXYLineChart("XY Line Chart", "X", "Y", createXYZDataset(),
                PlotOrientation.VERTICAL, true, false, false);// NON-NLS
    }
    if (aExpression instanceof ScatterPlotChartExpression) {
        return ChartFactory.createScatterPlot("Scatter Chart", "X", "Y", createXYZDataset(),
                PlotOrientation.VERTICAL, true, false, false);// NON-NLS
    }
    if (aExpression instanceof XYAreaLineChartExpression) {
        final NumberAxis catAxis = new NumberAxis("Range");// NON-NLS
        final NumberAxis barsAxis = new NumberAxis("Value");// NON-NLS
        final NumberAxis linesAxis = new NumberAxis("Value2");// NON-NLS

        final XYPlot plot = new XYPlot(createXYZDataset(), catAxis, barsAxis, new XYAreaRenderer());
        plot.setRenderer(1, new XYLineAndShapeRenderer());

        // add lines dataset and axis to plot
        plot.setDataset(1, createXYZDataset());
        plot.setRangeAxis(1, linesAxis);

        // map lines to second axis
        plot.mapDatasetToRangeAxis(1, 1);

        // set rendering order
        plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);

        // set location of second axis
        plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);

        return new JFreeChart("XY Area Line Chart", plot);// NON-NLS
    }
    if (aExpression instanceof XYAreaChartExpression) {
        return ChartFactory.createXYAreaChart("XY Area Chart", "X", "Y", createXYZDataset(),
                PlotOrientation.VERTICAL, true, false, false);// NON-NLS
    }
    if (aExpression instanceof XYBarChartExpression) {
        return XYBarChartExpression.createXYBarChart("XY Bar Chart", "X", false, "Y", createIntervalXYDataset(),
                PlotOrientation.VERTICAL, true, false, false);// NON-NLS
    }
    if (aExpression instanceof XYLineChartExpression) {
        return ChartFactory.createXYLineChart("XY Line Chart", "X", "Y", createXYZDataset(),
                PlotOrientation.VERTICAL, true, false, false);// NON-NLS
    }
    if (aExpression instanceof RadarChartExpression) {
        final SpiderWebPlot plot = new SpiderWebPlot(createDataset());
        return new JFreeChart("Radar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    }
    if (aExpression instanceof ThermometerChartExpression) {
        final DefaultValueDataset dataset = new DefaultValueDataset(new Double(65.0));
        final ThermometerPlot plot = new ThermometerPlot(dataset);

        return new JFreeChart("Thermometer Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    }
    return null;
}

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

/**
 *
 *///from  w  w w  . ja  v a  2 s .  c om
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() != null ? (Paint) jrPlot.getMercuryColor()
            : (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;
}

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

@Override
protected JFreeChart createThermometerChart() throws JRException {
    JRThermometerPlot jrPlot = (JRThermometerPlot) getPlot();

    // Create the plot that will hold the thermometer.
    ThermometerPlot chartPlot = new ThermometerPlot((ValueDataset) getDataset());

    ChartUtil chartUtil = ChartUtil.getInstance(getChartContext().getJasperReportsContext());
    // setting localized range axis formatters
    chartPlot.getRangeAxis().setStandardTickUnits(chartUtil.createIntegerTickUnits(getLocale()));

    // Build a chart around this plot
    JFreeChart jfreeChart = new JFreeChart(evaluateTextExpression(getChart().getTitleExpression()), null,
            chartPlot, getChart().getShowLegend() == null ? false : getChart().getShowLegend());

    // Set the generic options
    configureChart(jfreeChart, getPlot());
    jfreeChart.setBackgroundPaint(ChartThemesConstants.TRANSPARENT_PAINT);
    jfreeChart.setBorderVisible(false);/*from   w  w w  .j  a v  a2 s  . c  o  m*/

    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.
    @SuppressWarnings("unchecked")
    List<Paint> seriesPaints = (List<Paint>) 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 = 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));

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

    // 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(), DecimalFormatSymbols.getInstance(getLocale())));
        }
        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;
}

From source file:org.jfree.chart.demo.JFreeChartDemoBase.java

/**
 * Creates and returns a sample thermometer chart.
 *
 * @return a sample thermometer chart.//from  w ww  .java 2s.c  om
 */
public JFreeChart createThermometerChart() {

    // create a default chart based on some sample data...
    final String title = this.resources.getString("meter.thermo.title");
    final String subtitleStr = this.resources.getString("meter.thermo.subtitle");
    final String units = this.resources.getString("meter.thermo.units");

    final DefaultValueDataset data = new DefaultValueDataset(new Double(34.0));
    final ThermometerPlot plot = new ThermometerPlot(data);
    plot.setUnits(units);
    final JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);

    // then customise it a little...
    final TextTitle subtitle = new TextTitle(subtitleStr, new Font("SansSerif", Font.BOLD, 12));
    chart.addSubtitle(subtitle);
    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.blue));
    return chart;

}