Example usage for org.jfree.data.general DefaultValueDataset DefaultValueDataset

List of usage examples for org.jfree.data.general DefaultValueDataset DefaultValueDataset

Introduction

In this page you can find the example usage for org.jfree.data.general DefaultValueDataset DefaultValueDataset.

Prototype

public DefaultValueDataset(Number value) 

Source Link

Document

Creates a new dataset with the specified value.

Usage

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

public static void main(String args[]) {
    DefaultValueDataset defaultvaluedataset = new DefaultValueDataset(75D);
    MeterPlot meterplot = new MeterPlot(defaultvaluedataset);
    JFreeChart jfreechart = new JFreeChart("Scaled Image Test", meterplot);
    try {/*w w w .  ja va 2s .  c  o  m*/
        File file = new File("meterchart100.png");
        BufferedOutputStream bufferedoutputstream = new BufferedOutputStream(new FileOutputStream(file));
        java.awt.image.BufferedImage bufferedimage = jfreechart.createBufferedImage(200, 200, 400D, 400D, null);
        ChartUtilities.writeBufferedImageAsPNG(bufferedoutputstream, bufferedimage);
    } catch (IOException ioexception) {
        System.out.println(ioexception.toString());
    }
}

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

/**
 * Starting point for the demo.// ww w  .  ja  v  a 2s  . co m
 *
 * @param args  ignored.
 */
public static void main(final String[] args) {

    final ValueDataset dataset = new DefaultValueDataset(75.0);
    final MeterPlot plot = new MeterPlot(dataset);
    final JFreeChart chart = new JFreeChart("Scaled Image Test", plot);

    // ****************************************************************************
    // * JFREECHART DEVELOPER GUIDE                                               *
    // * The JFreeChart Developer Guide, written by David Gilbert, is available   *
    // * to purchase from Object Refinery Limited:                                *
    // *                                                                          *
    // * http://www.object-refinery.com/jfreechart/guide.html                     *
    // *                                                                          *
    // * Sales are used to provide funding for the JFreeChart project - please    * 
    // * support us so that we can continue developing free software.             *
    // ****************************************************************************

    // save it to an image
    try {
        final File file1 = new File("meterchart100.png");
        final OutputStream out = new BufferedOutputStream(new FileOutputStream(file1));
        final BufferedImage image = chart.createBufferedImage(200, 200, 400, 400, null);
        ChartUtilities.writeBufferedImageAsPNG(out, image);
    } catch (IOException e) {
        System.out.println(e.toString());
    }

}

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

public static JPanel createDemoPanel() {
    JFreeChart jfreechart = createChart(new DefaultValueDataset(new Double(45D)));
    return new ChartPanel(jfreechart);
}

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

public CompassDemo1(String s) {
    super(s);/*from w w w . ja  v  a  2 s .co m*/
    DefaultValueDataset defaultvaluedataset = new DefaultValueDataset(new Double(45D));
    JFreeChart jfreechart = createChart(defaultvaluedataset);
    ChartPanel chartpanel = new ChartPanel(jfreechart);
    chartpanel.setPreferredSize(new Dimension(500, 270));
    chartpanel.setEnforceFileExtensions(false);
    setContentPane(chartpanel);
}

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 {/*from w ww .j a  v  a  2s .co  m*/
        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:UserInterface.FarmerRole.HumidityGraph.java

public HumidityGraph(double value, String type) {

    data = new DefaultValueDataset(value);
    final JFrame frame = new JFrame();
    meterPlot = new MeterPlot(data);
    frame.getContentPane().setLayout(new BorderLayout(5, 5));
    frame.setDefaultCloseOperation(3);/*w  w  w . j a v a 2  s .  c  om*/
    frame.setTitle("Inventory Humidity");
    meterChart = new JFreeChart("Humidity Chart", JFreeChart.DEFAULT_TITLE_FONT, this.meterPlot, false);
    panelMeter = new ChartPanel(this.meterChart);
    frame.getContentPane().add(panelMeter, BorderLayout.CENTER);
    frame.setSize(700, 400);
    final Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2);
    frame.setVisible(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  a  2s. c o  m
    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 {/*  ww w  .  ja  v a  2s  .  c  o 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   www .  ja va2 s . co  m

        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   www.  java  2  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;
}