Example usage for org.jfree.chart ChartFrame pack

List of usage examples for org.jfree.chart ChartFrame pack

Introduction

In this page you can find the example usage for org.jfree.chart ChartFrame pack.

Prototype

@SuppressWarnings("deprecation")
public void pack() 

Source Link

Document

Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.

Usage

From source file:trabajoanalisis.grafico.java

public void graficar(JTable a) {
    XYSeries series = new XYSeries("t/n");

    // Introduccion de datos
    int i = 0;// w w  w  .java2 s  .c  o  m
    while (a.getValueAt(i, 1) != null) {
        System.out.println(a.getValueAt(i, 1).toString());
        System.out.println(i);
        series.add(Integer.parseInt(a.getValueAt(i, 0).toString()),
                Integer.parseInt(a.getValueAt(i, 1).toString()));
        System.out.println("Se ha agregado " + Integer.parseInt(a.getValueAt(i, 0).toString()) + " y "
                + a.getValueAt(i, 1).toString());
        i++;

    }
    //        series.add(1, 1);
    //        series.add(2, 6);
    //        series.add(3, 3);
    //        series.add(4, 10);

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);

    JFreeChart chart = ChartFactory.createXYLineChart("Grafica", // Ttulo
            "n", // Etiqueta Coordenada X
            "tiempo", // Etiqueta Coordenada Y
            dataset, // Datos
            PlotOrientation.VERTICAL, true, // Muestra la leyenda de los productos (Producto A)
            false, false);

    // Mostramos la grafica en pantalla
    ChartFrame frame = new ChartFrame("Grafica", chart);
    frame.pack();
    frame.setVisible(true);

}

From source file:br.unicamp.cst.behavior.bn.support.Grafico.java

public Grafico(String frametitle, String charttitle, String xlabel, String ylabel, XYSeriesCollection dataset) {
    JFreeChart chart = ChartFactory.createXYLineChart(charttitle, xlabel, ylabel, dataset,
            PlotOrientation.VERTICAL, true, true, false);

    XYPlot plot = (XYPlot) chart.getPlot();

    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setShapesVisible(true);/*from  w  w  w. j av a2  s. com*/
    renderer.setShapesFilled(true);

    setXyplot(plot);
    setChart(chart);

    ChartFrame frame = new ChartFrame(frametitle, chart);

    frame.pack();
    frame.setVisible(true);
}

From source file:prc2.Graficos.java

public void PieGraphI(ArrayList<Integer> d, int pos, String s, String y) {
    //System.out.println("Estoy EN PIEGRAPH");
    // Fuente de Datos
    DefaultPieDataset data = new DefaultPieDataset();
    int tmp = 0;// w w w .  j  av a 2s  .  c o m
    for (int i = pos; i <= pos + 11; i++) {
        tmp += 1;
        data.setValue("Mes " + tmp + ": " + d.get(i) + " ", d.get(i));

        //data.setValue(d.get(pos), 45);
        //data.setValue("Python", 15);
    }

    // Creando el Grafico
    JFreeChart chart = ChartFactory.createPieChart("Grfico de " + s + " para el ao " + y, data, true, true,
            false);

    // Mostrar Grafico
    ChartFrame frame = new ChartFrame("JFreeChart", chart);

    frame.pack();
    frame.setVisible(true);
}

From source file:pwr.lab5.Window.java

public void showChart(Window win) {
    final JFreeChart chart = ChartFactory.createXYLineChart("DOM, SAX, StAX parsing time", // chart title
            "number of XML nodes", // x axis label
            "time [ms]", // y axis label
            win.dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            false // urls
    );//from  www .  j  a  v  a  2s. c  o  m
    ChartFrame pane = new ChartFrame("ELO", chart);
    pane.pack();
    pane.setVisible(true);
}

From source file:prc2.Graficos.java

public void PieGraphF(ArrayList<Float> d, int pos, String s, String y) {
    //System.out.println("Estoy EN PIEGRAPH");
    // Fuente de Datos
    DefaultPieDataset data = new DefaultPieDataset();
    int tmp = 0;/*from w ww.ja v  a2  s  . co m*/
    for (int i = pos; i <= pos + 11; i++) {
        tmp += 1;
        data.setValue("Mes " + tmp + ": " + d.get(i) + " ", d.get(i));

        //data.setValue(d.get(pos), 45);
        //data.setValue("Python", 15);
    }

    // Creando el Grafico
    JFreeChart chart = ChartFactory.createPieChart("Grfico de " + s + " para el ao " + y, data, true, true,
            false);

    // Mostrar Grafico
    ChartFrame frame = new ChartFrame("JFreeChart", chart);

    frame.pack();
    frame.setVisible(true);
    /*
    // Fuente de Datos
    DefaultPieDataset data = new DefaultPieDataset();
    data.setValue("C", 40);
    data.setValue("Java", 45);
    data.setValue("Python", 15);
            
    // Creando el Grafico
    JFreeChart chart = ChartFactory.createPieChart(
    "Ejemplo Rapido de Grafico en un ChartFrame", 
    data, 
    true, 
    true, 
    false);
            
    // Mostrar Grafico
    ChartFrame frame = new ChartFrame("JFreeChart", chart);
    frame.pack();
    frame.setVisible(true);*/
}

From source file:lectorarchivos.MostrarGraficaCSV.java

/**
 * Creates new form MostrarGraficaCSV/* w  w  w.  j  a  va 2  s  .  c om*/
 */
public MostrarGraficaCSV(JTable jTableInfoCSV) {
    initComponents();
    this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    panel = new JPanel();
    getContentPane().add(panel);

    //Fuente de datos
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    //Recorremos la columna del consumo de la tabla
    for (int i = jTableInfoCSV.getRowCount() - 1; i >= 0; i--) {
        if (Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()) > 0)
            dataset.setValue(Double.parseDouble(jTableInfoCSV.getValueAt(i, 4).toString()), "Consumo",
                    jTableInfoCSV.getValueAt(i, 0).toString());
    }

    //Creando el grfico
    JFreeChart chart = ChartFactory.createBarChart3D("Consumo", "Fecha", "Consumo", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    chart.setBackgroundPaint(Color.cyan);
    chart.getTitle().setPaint(Color.black);
    chart.setBackgroundPaint(Color.white);
    chart.removeLegend();

    //Cambiar color de barras
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    BarRenderer barRenderer = (BarRenderer) plot.getRenderer();
    barRenderer.setSeriesPaint(0, Color.decode("#5882FA"));

    // Mostrar Grafico
    ChartFrame frame = new ChartFrame("CONSUMO", chart);
    frame.pack();
    frame.getChartPanel().setMouseZoomable(false);
    frame.setVisible(true);

    panel.add(frame);

}

From source file:mes2.Chart.java

public void createwykres() {
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection(dataSet);
    // Dodanie kolejnych serii do kolekcji:
    xySeriesCollection.addSeries(dataSet2);

    // tworzenie XYDataSet 
    XYDataset xyDataset = xySeriesCollection;
    // tworzenie wykresu 
    JFreeChart lineGraph = ChartFactory.createXYLineChart("Wykres nagrzewania wsadu", // Title 
            "Czas", // X-Axis label 
            "Temperatura", // Y-Axis label 
            xyDataset, // Dataset 
            PlotOrientation.VERTICAL, //Plot orientation 
            true, //show legend 
            true, // Show tooltips 
            false //url show 
    );/*  w  w  w  . j av a2s .  com*/
    ChartFrame frame1 = new ChartFrame("Szybkie wyswietlanie wykresu - klasa ChartFrame", lineGraph);
    frame1.pack();
    frame1.setVisible(true);
    frame1.setLocationRelativeTo(null);
    //frame1.setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    ChartPanel chartPanel = new ChartPanel(lineGraph);
    //frame.getContentPane().add(chartPanel);
    // frame.getContentPane().add(new JLabel("<<< wykres dodany jako ChartPanel"));

}

From source file:edu.uara.wrappers.customcharts.CustomJFreeChart.java

/**
 * draw chart on a frame/*from ww w  .j  a  va 2  s  .c o  m*/
 * @param frameTitle
 * @return
 */
public ChartFrame drawChart(String frameTitle) {
    try {
        ChartFrame frame = new ChartFrame(frameTitle, chart);
        frame.pack();
        //frame.setVisible(true);
        return frame;
    } catch (Exception ex) {
        System.out.println(ex.getMessage());
        return null;
    }

}

From source file:br.unicamp.cst.motivational.MotivationalMonitor.java

@Override
public synchronized void run() {

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    final JFreeChart chart = ChartFactory.createBarChart(getTitle(), getEntity(), "Value", dataset,
            PlotOrientation.VERTICAL, true, true, false);

    final CategoryPlot plot = chart.getCategoryPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    chart.setBackgroundPaint(Color.lightGray);

    ChartFrame frame = new ChartFrame(getTitle(), chart);
    frame.pack();
    frame.setVisible(true);/*from   w  ww .j a v  a  2s . co m*/

    while (true) {
        ArrayList<Codelet> tempCodeletsList = new ArrayList<Codelet>();
        tempCodeletsList.addAll(this.getListOfMotivationalEntities());

        synchronized (tempCodeletsList) {

            for (Codelet co : tempCodeletsList) {
                dataset.addValue(co.getActivation(), co.getName(), "activation");
            }
            try {
                Thread.currentThread().sleep(getRefreshPeriod());
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }
}

From source file:org.audiveris.omr.util.ChartPlotter.java

/**
 * Wrap chart into a frame with specific title and display the frame at provided
 * location.//from  w w w. jav a  2 s .  com
 *
 * @param title    frame title
 * @param location frame location
 */
public void display(String title, Point location) {
    ChartFrame frame = new ChartFrame(title, chart, true);
    frame.pack();
    frame.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    frame.setLocation(location);
    frame.setVisible(true);
}