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:Negocio.Produccion.Planificacion.GanttManager.java

public static ChartFrame getFrameGantt(String titulo, PlanProduccion plan, JDialog parent) {
    ChartFrame af = new ChartFrame(parent);
    final IntervalCategoryDataset dataset = createDataset(plan);
    final JFreeChart chart = createChart(dataset);

    // add the chart to a panel...
    final ChartPanel chartPanel = new ChartPanel(chart);
    af.setTitle(titulo);/*from w ww .java  2s.  c om*/
    af.setContentPane(chartPanel);
    af.pack();
    RefineryUtilities.centerFrameOnScreen(af);
    return af;

}

From source file:lectorarchivos.VerCSV.java

public static void mostrarGrafica(JTable jTableInfoCSV) {
    //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());
    }//www .j  av a 2s  .com

    //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:dumbara.view.Chart1.java

public static void ViewLineChart(String[] agencyID, String[] sslesDate, ArrayList<String[]> arrayList)
        throws SQLException, ClassNotFoundException {
    XYSeries series1 = new XYSeries("Agency 1");
    XYSeries series2 = new XYSeries("Agency 2");
    XYSeries series3 = new XYSeries("Agency 3");
    XYSeries series4 = new XYSeries("Agency 4");

    for (String[] strings : arrayList) {

        for (int i = 0; i < sslesDate.length; i++) {
            System.out.println(sslesDate[i].split("-")[1] + "");
            series1.add(Double.parseDouble(sslesDate[i].split("-")[1] + ""),
                    Double.parseDouble(arrayList.get(0)[i]));
        }/*from w  w w. j  a v a 2s .c  om*/

        for (int i = 0; i < sslesDate.length; i++) {
            series2.add(Double.parseDouble(sslesDate[i].split("-")[1] + ""),
                    Double.parseDouble(arrayList.get(1)[i]));
        }

        for (int i = 0; i < sslesDate.length; i++) {
            series3.add(Double.parseDouble(sslesDate[i].split("-")[1] + ""),
                    Double.parseDouble(arrayList.get(2)[i]));
        }

        for (int i = 0; i < sslesDate.length; i++) {
            series4.add(Double.parseDouble(sslesDate[i].split("-")[1] + ""),
                    Double.parseDouble(arrayList.get(3)[i]));

        }

    }

    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series1);
    dataset.addSeries(series2);
    dataset.addSeries(series3);
    dataset.addSeries(series4);
    XYDataset dataset1 = dataset;
    JFreeChart chart = ChartFactory.createXYLineChart("", "Test Id", "Average Marks", dataset1,
            PlotOrientation.VERTICAL, true, false, false);
    XYPlot plot = (XYPlot) chart.getPlot();
    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true);
    renderer.setSeriesShapesVisible(0, true);
    renderer.setSeriesLinesVisible(1, true);
    renderer.setSeriesShapesVisible(1, true);
    renderer.setSeriesLinesVisible(2, true);
    renderer.setSeriesShapesVisible(2, true);
    renderer.setSeriesFillPaint(2, Color.MAGENTA);
    plot.setRenderer(renderer);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 300));
    //(chartPanel);
    ChartFrame frame = new ChartFrame("Dumbara Water Management System", chart);
    frame.setLocationRelativeTo(null);
    frame.pack();
    frame.setVisible(true);

}

From source file:org.micromanager.CRISP.CRISPFrame.java

/**
* Create a frame with a plot of the data given in XYSeries
*///  w w  w  .j a va2  s . c o m
public static void plotData(String title, XYSeries data, String xTitle, String yTitle, int xLocation,
        int yLocation) {
    // JFreeChart code
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(data);
    JFreeChart chart = ChartFactory.createScatterPlot(title, // Title
            xTitle, // x-axis Label
            yTitle, // y-axis Label
            dataset, // Dataset
            PlotOrientation.VERTICAL, // Plot Orientation
            false, // Show Legend
            true, // Use tooltips
            false // Configure chart to generate URLs?
    );
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.white);
    plot.setRangeGridlinePaint(Color.lightGray);
    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setSeriesPaint(0, Color.black);
    renderer.setSeriesFillPaint(0, Color.white);
    renderer.setSeriesLinesVisible(0, true);
    Shape circle = new Ellipse2D.Float(-2.0f, -2.0f, 4.0f, 4.0f);
    renderer.setSeriesShape(0, circle, false);
    renderer.setUseFillPaint(true);

    ChartFrame graphFrame = new ChartFrame(title, chart);
    graphFrame.getChartPanel().setMouseWheelEnabled(true);
    graphFrame.pack();
    graphFrame.setLocation(xLocation, yLocation);
    graphFrame.setVisible(true);
}

From source file:DATA.Grafica.java

public void mostrarGrafica() {

    this.grafica = ChartFactory.createHistogram(titulo, "Nivel Gris", "Frecuencia", coleccion,
            PlotOrientation.VERTICAL, false, false, false);
    ChartFrame frame = new ChartFrame(titulo, grafica);
    frame.pack();
    frame.setVisible(true);/*from w ww . j  ava  2s  . co m*/
}

From source file:br.com.utfpr.pb.view.GraficoProdutosMaisVendidosView.java

public GraficoProdutosMaisVendidosView() {
    try {//from   w w  w. j av a2 s. c  om
        // cria o grfico
        JFreeChart grafico = ChartFactory.createBarChart("Produtos mais Vendidos vs Comprados", "Produto",
                "Total venda", graficoDao.produtosMaisVendidos(), PlotOrientation.VERTICAL, true, true, false);

        //exibe o grfico
        ChartFrame frame = new ChartFrame("Grfico", grafico);
        frame.pack();
        frame.setVisible(true);
        frame.setLocationRelativeTo(null);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:br.com.utfpr.pb.view.GraficoTotalVendasView.java

public GraficoTotalVendasView() {
    try {//from  ww w. j  a v  a  2  s .c  o m
        // cria o grfico
        JFreeChart grafico = ChartFactory.createBarChart("Total de Vendas vs Compras por Data", "Data",
                "Valor Total", graficoDao.totalVendasPorData(), PlotOrientation.VERTICAL, true, true, false);

        //exibe o grfico
        ChartFrame frame = new ChartFrame("Grfico", grafico);
        frame.pack();
        frame.setVisible(true);
        frame.setLocationRelativeTo(null);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:br.com.utfpr.pb.view.GraficoQuantidadeVendasView.java

public GraficoQuantidadeVendasView() {
    try {//from   w w w . j  a  v a  2 s .co  m
        // cria o grfico
        JFreeChart grafico = ChartFactory.createBarChart("Nmero de Vendas vs Compras por Data", "Data",
                "Quantidade", graficoDao.quantidadeVendasPorData(), PlotOrientation.VERTICAL, true, true,
                false);

        //exibe o grfico
        ChartFrame frame = new ChartFrame("Grfico", grafico);
        frame.pack();
        frame.setVisible(true);
        frame.setLocationRelativeTo(null);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:geneticonreinas.data.Grafica.java

public void mostrarGrafica() {
    // Crear la serie con los datos

    grafica = ChartFactory.createXYLineChart(this.tituloGrafica, this.axisXlabel, this.axisYlabel, coleccion,
            PlotOrientation.VERTICAL, true, false, false);

    ChartFrame panel = new ChartFrame(null, grafica);
    panel.pack();
    panel.setVisible(true);/*from w  ww  .  ja v a 2 s.co m*/
}

From source file:algoritmosdeordenamiento.Grafica.java

public void creaYmuestraGrafica() {

    this.grafica = ChartFactory.createXYLineChart(nombre, tituloEjeX, tituloEjeY, series);

    // utilizar un panel especial dentro de jfreechart
    ChartFrame panel = new ChartFrame("grafica", grafica);
    panel.pack();
    panel.setVisible(true);//  ww w .j  a  va2  s. com

}