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:UserInterface.FarmerRole.ThermometerDemo.java

public ThermometerDemo(double value, String type) {
    this.setLayout(new GridLayout());
    DefaultValueDataset dataset = new DefaultValueDataset(value);
    if (type.equals("high")) {
        ThermometerPlot plot = new ThermometerPlot(dataset);
        plot.setSubrangePaint(0, Color.green.darker());
        plot.setSubrangePaint(1, Color.ORANGE);
        plot.setSubrangePaint(2, Color.RED.darker());

        plot.setSubrangeInfo(0, 10, 28, 30, 60);

        JFreeChart chart = new JFreeChart("Cold Storage", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
        this.add(new ChartPanel(chart, W, H, W, H, W, H, false, true, true, true, true, true));
    } else if (type.equals("medium")) {
        ThermometerPlot plot = new ThermometerPlot(dataset);
        plot.setSubrangePaint(0, Color.green.darker());
        plot.setSubrangePaint(1, Color.ORANGE);
        plot.setSubrangePaint(2, Color.RED.darker());

        plot.setSubrangeInfo(0, 12, 14, 30, 60);

        JFreeChart chart = new JFreeChart("Medium Storage", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
        this.add(new ChartPanel(chart, W, H, W, H, W, H, false, true, true, true, true, true));
    } else {/*  w w w.  ja  va 2 s .  com*/
        ThermometerPlot plot = new ThermometerPlot(dataset);
        plot.setSubrangePaint(0, Color.green.darker());
        plot.setSubrangePaint(1, Color.YELLOW);
        plot.setSubrangePaint(2, Color.RED.darker());

        plot.setSubrangeInfo(0, 20, 35, 46, 60);

        JFreeChart chart = new JFreeChart("Warm Storage", JFreeChart.DEFAULT_TITLE_FONT, plot, true);
        this.add(new ChartPanel(chart, W, H, W, H, W, H, false, true, true, true, true, true));
    }
}

From source file:Componentes.TermometroMax.java

@Override
public void pintar(javax.swing.JPanel p, int pos) {
    p.removeAll();/*from   w  w  w  .  j  av a2  s .  com*/
    DefaultValueDataset data = new DefaultValueDataset(new Double(ventana.getGraphdata().getTmax()));

    ThermometerPlot plot = new ThermometerPlot(data);
    chart = new JFreeChart("Temperatura Maxima, \nMES: " + Calculos.get_mes(ventana.getMonthdata().getdata()), // chart title
            JFreeChart.DEFAULT_TITLE_FONT, plot, // plot
            false);

    Color Darkorange = new Color(255, 140, 0);
    Color Crimson = new Color(220, 20, 60);
    Color Aquamarine = new Color(127, 255, 212);
    Color Darkslategray = new Color(47, 79, 79);

    plot.setMercuryPaint(Aquamarine);
    plot.setSubrange(NORMAL, 0, 10);
    plot.setSubrange(WARNING, 10.1, 20);
    plot.setSubrange(CRITICAL, 20.1, 50);
    plot.setSubrangePaint(NORMAL, Aquamarine);
    plot.setSubrangePaint(WARNING, Darkorange);
    plot.setSubrangePaint(CRITICAL, Crimson);

    plot.setThermometerStroke(new BasicStroke(2.0f));
    plot.setThermometerPaint(Darkslategray);

    plot.setDisplayRange(5, Calculos.get_min(datos.getTmax()), Calculos.get_max(datos.getTmax()));
    plot.setRange(Calculos.get_min(datos.getTmax()), Calculos.get_max(datos.getTmax()));

    panel = new ChartPanel(chart);
    panel.setBounds(5, 5, 300, 300);
    panel.repaint();
    p.add(panel);
    // jPanel1.repaint();
    p.updateUI();
    // aoIndex=aoAux;
    ///aoAux = 0;
}

From source file:AppPackage.humidity.java

public humidity() {
    try {//  w ww .  ja  va 2s .co m

        JFrame window = new JFrame();
        window.setSize(1000, 615);
        window.setBackground(Color.blue.darker());
        double value = 45;
        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int) ((dimension.getWidth() - window.getWidth()) / 2);
        int y = (int) ((dimension.getHeight() - window.getHeight()) / 2);
        window.setLocation(x, y);
        DefaultValueDataset dataset = new DefaultValueDataset(value);

        ThermometerPlot thermometerplot = new ThermometerPlot(dataset);

        thermometerplot.setSubrangePaint(0, Color.green.darker());
        thermometerplot.setSubrangePaint(1, Color.orange);
        thermometerplot.setSubrangePaint(2, Color.red);
        JFreeChart jfreechart = new JFreeChart("Humidity readings", JFreeChart.DEFAULT_TITLE_FONT,
                thermometerplot, true);
        thermometerplot.setInsets(new RectangleInsets(5D, 5D, 5D, 5D));
        thermometerplot.setPadding(new RectangleInsets(10D, 10D, 10D, 10D));
        thermometerplot.setThermometerStroke(new BasicStroke(2.0F));
        thermometerplot.setThermometerPaint(Color.BLUE);
        thermometerplot.setUnits(0);
        thermometerplot.setGap(3);

        window.add(new ChartPanel(jfreechart), BorderLayout.CENTER);
        window.setVisible(true);

    } catch (Exception e) {
        System.out.print("Chart exception:" + e);
    }
    initComponents();
}

From source file:AppPackage.Temperature.java

public Temperature() {
    try {/*from   w  ww  .  ja  v  a  2 s .c om*/

        JFrame window = new JFrame();
        window.setSize(1000, 615);
        window.setBackground(Color.blue.darker());
        double value = 55;
        Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (int) ((dimension.getWidth() - window.getWidth()) / 2);
        int y = (int) ((dimension.getHeight() - window.getHeight()) / 2);
        window.setLocation(x, y);
        DefaultValueDataset dataset = new DefaultValueDataset(value);

        ThermometerPlot thermometerplot = new ThermometerPlot(dataset);
        thermometerplot.setSubrangePaint(0, Color.green.darker());
        thermometerplot.setSubrangePaint(1, Color.orange);
        thermometerplot.setSubrangePaint(2, Color.red);
        JFreeChart jfreechart = new JFreeChart("Temperature readings", JFreeChart.DEFAULT_TITLE_FONT,
                thermometerplot, true);
        thermometerplot.setInsets(new RectangleInsets(5D, 5D, 5D, 5D));
        thermometerplot.setPadding(new RectangleInsets(10D, 10D, 10D, 10D));
        thermometerplot.setThermometerStroke(new BasicStroke(2.0F));
        thermometerplot.setThermometerPaint(Color.BLUE);

        thermometerplot.setGap(3);

        window.add(new ChartPanel(jfreechart), BorderLayout.CENTER);
        window.setVisible(true);

    } catch (Exception e) {
        System.out.print("Chart exception:" + e);
    }
    initComponents();
}

From source file:Componentes.TermometroMin.java

@Override
public void pintar(javax.swing.JPanel p, int pos) {
    p.removeAll();//from ww w .  j av a2 s.  c  o  m
    DefaultValueDataset data = new DefaultValueDataset(new Double(ventana.getGraphdata().getTmin()));

    ThermometerPlot plot = new ThermometerPlot(data);
    chart = new JFreeChart("Temperatura Mnima, \nMES: " + Calculos.get_mes(ventana.getMonthdata().getdata()), // chart title
            JFreeChart.DEFAULT_TITLE_FONT, plot, // plot
            false);
    Color Darkorange = new Color(255, 140, 0);
    Color Crimson = new Color(220, 20, 60);
    Color Aquamarine = new Color(127, 255, 212);
    Color Darkslategray = new Color(47, 79, 79);

    plot.setMercuryPaint(Aquamarine);
    plot.setSubrange(NORMAL, 0, 2.5);
    plot.setSubrange(WARNING, 2.6, 7.5);
    plot.setSubrange(CRITICAL, 7.6, 20);
    plot.setSubrangePaint(NORMAL, Aquamarine);
    plot.setSubrangePaint(WARNING, Darkorange);
    plot.setSubrangePaint(CRITICAL, Crimson);

    plot.setThermometerStroke(new BasicStroke(2.0f));
    plot.setThermometerPaint(Darkslategray);

    plot.setDisplayRange(2, Calculos.get_min(datos.getTmin()), Calculos.get_max(datos.getTmin()));
    plot.setRange(Calculos.get_min(datos.getTmin()), Calculos.get_max(datos.getTmin()));

    panel = new ChartPanel(chart);
    panel.setBounds(5, 5, 300, 300);
    panel.repaint();
    p.add(panel);
    // jPanel1.repaint();
    p.updateUI();
    // aoIndex=aoAux;
    ///aoAux = 0;
}

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

@Override
protected JFreeChart createChart() {
    ValueDataset value = getDataset();/*www.ja  v  a  2  s . c  o 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:org.sonar.plugins.ral.GaugeChart.java

@Override
protected Plot getPlot(ChartParameters params) {
    ThermometerPlot plot = new ThermometerPlot(createDataset(params));

    plot.setGap(1);/*from   w  w w. j a  va  2  s. c o m*/

    plot.setRange(0, 1);
    plot.setSubrange(0, 0, 1);

    plot.setSubrangePaint(0, Color.decode("#ffffff"));
    plot.setSubrangePaint(1, Color.decode("#ffffff"));
    plot.setSubrangePaint(2, Color.decode("#ffffff"));

    plot.setMercuryPaint(Color.decode("#dddddd"));
    plot.setThermometerPaint(Color.decode("#aaaaaa"));
    plot.setValuePaint(Color.decode("#333333"));

    plot.setUseSubrangePaint(false);
    plot.setUnits(ThermometerPlot.UNITS_NONE);
    plot.setBulbRadius(15);
    plot.setColumnRadius(6);

    NumberAxis axis = new NumberAxis();
    axis.setNumberFormatOverride(NumberFormat.getPercentInstance());
    plot.setRangeAxis(axis);
    plot.setValueLocation(ThermometerPlot.NONE);

    return plot;
}

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

/**
 * Creates a chart of type thermometer./* w  w w  .j  a v  a 2  s . co m*/
 * 
 * @return A chart thermometer.
 */
public JFreeChart createChart() {
    logger.debug("IN");

    if (dataset == null) {
        logger.debug("The dataset to be represented is null");
        return null;
    }

    ThermometerPlot plot = new ThermometerPlot((ValueDataset) dataset);
    logger.debug("Created the new Thermometer Plot");
    JFreeChart chart = new JFreeChart(name, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    logger.debug("Created the new Chart");
    chart.setBackgroundPaint(color);
    logger.debug("Setted the background color of the chart");

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

    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.setRange(lower, upper);
    plot.setUnits(ThermometerPlot.UNITS_NONE);
    logger.debug("Setted all the properties of the plot");

    // set subranges   
    for (Iterator iterator = intervals.iterator(); iterator.hasNext();) {
        KpiInterval subrange = (KpiInterval) iterator.next();
        int range = 0;
        //For the thermometer the number of intervals is forced to 3 and they have to have as labels the following ones
        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());
        }
        logger.debug("Setted new range of the plot");
    }

    logger.debug("OUT");
    return chart;
}

From source file:org.jls.toolbox.math.chart.Thermometer.java

/**
 * Permet de crer et de paramtrer le thermomtre.
 *//* w  w w  . j ava  2 s  .  c  o  m*/
private void createChart() {
    this.plot = new ThermometerPlot(this.dataset);
    this.chart = new JFreeChart(this.plot);

    this.plot.setInsets(new RectangleInsets(0, 0, 0, 0));
    this.plot.setPadding(new RectangleInsets(0, 0, 0, 0));
    this.plot.setThermometerStroke(new BasicStroke(1.0f));
    this.plot.setThermometerPaint(Color.black);
    this.plot.setFollowDataInSubranges(true);
    this.plot.setRange(0, 100);
    this.plot.setForegroundAlpha(100);

    // this.chart.setBackgroundPaint(new JPanel().getBackground());
    this.chart.setAntiAlias(true);
    this.chart.setPadding(new RectangleInsets(0, 0, 0, 0));
    this.chart.setTitle(this.title);

    this.panel = new ChartPanel(this.chart);
    double coeff = 0.3;
    int width = (int) (this.panel.getPreferredSize().getWidth() * coeff);
    int height = (int) (this.panel.getPreferredSize().getHeight() * coeff);
    this.panel.setPreferredSize(new Dimension(width, height));
}

From source file:cn.edu.thss.iise.bpmdemo.charts.ThermometerDemo2.java

/**
 * Creates a new demo./*  www.  ja  v  a 2  s  . c  om*/
 *
 * @param title
 *            the frame title.
 */
public ThermometerDemo2(final String title) {

    super(title);
    plot = new ThermometerPlot(dataset);
    chart = new JFreeChart("Thermometer Demo 2", // chart title
            JFreeChart.DEFAULT_TITLE_FONT, plot, // plot
            false);

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

}