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

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

Introduction

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

Prototype

int UNITS_KELVIN

To view the source code for org.jfree.chart.plot ThermometerPlot UNITS_KELVIN.

Click Source Link

Document

A constant for unit type 'Kelvin'.

Usage

From source file:biz.ixnay.pivot.charts.skin.jfree.ThermometerViewSkin.java

@Override
protected JFreeChart createChart() {
    ValueDataset value = getDataset();//from  w  w  w . j a va2s  . co m
    ThermometerPlot plot = new ThermometerPlot(value);
    // TODO: set style values before creating the chart object
    SingleValueChartView chartView = (SingleValueChartView) getComponent();
    SingleValueChartView.ValueRange bounds = chartView.getValueBounds();
    plot.setRange(bounds.getLower(), bounds.getUpper());
    for (SingleValueChartView.Range range : SingleValueChartView.Range.values()) {
        SingleValueChartView.ValueRange rangeBounds = chartView.getValueRange(range);
        if (rangeBounds != null) {
            double lower = rangeBounds.getLower();
            double upper = rangeBounds.getUpper();
            switch (range) {
            case NORMAL:
                plot.setSubrange(ThermometerPlot.NORMAL, lower, upper);
                break;
            case WARNING:
                plot.setSubrange(ThermometerPlot.WARNING, lower, upper);
                break;
            case CRITICAL:
                plot.setSubrange(ThermometerPlot.CRITICAL, lower, upper);
                break;
            }
        }
    }
    if (units != null) {
        switch (units) {
        case NONE:
            plot.setUnits(ThermometerPlot.UNITS_NONE);
            break;
        case CELSIUS:
            plot.setUnits(ThermometerPlot.UNITS_CELCIUS);
            break;
        case FAHRENHEIT:
            plot.setUnits(ThermometerPlot.UNITS_FAHRENHEIT);
            break;
        case KELVIN:
            plot.setUnits(ThermometerPlot.UNITS_KELVIN);
            break;
        }
    }
    if (bulbRadius > 0) {
        plot.setBulbRadius(bulbRadius);
    }
    return createChart(plot);
}

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

/**
 * Creates a chart of type thermometer./*  ww  w .  ja  v a2s . co  m*/
 * 
 * @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.bdb.weather.display.current.Thermometer.java

private void setUnits(Temperature.Unit unit) {
    System.out.println("Setting temperature units");
    thermometerPlot.setRange(minValue.get(unit), maxValue.get(unit));
    thermometerPlot.setValueFormat(unit.getFormatter());
    switch (unit) {
    case FAHRENHEIT:
        thermometerPlot.setUnits(ThermometerPlot.UNITS_FAHRENHEIT);
        break;//www  .j  a  v a 2s  .c o m

    case CELSIUS:
        thermometerPlot.setUnits(ThermometerPlot.UNITS_CELCIUS);
        break;

    case KELVIN:
        thermometerPlot.setUnits(ThermometerPlot.UNITS_KELVIN);
        break;
    }
}