Example usage for org.jfree.chart ChartPanel setSize

List of usage examples for org.jfree.chart ChartPanel setSize

Introduction

In this page you can find the example usage for org.jfree.chart ChartPanel setSize.

Prototype

public void setSize(int width, int height) 

Source Link

Document

Resizes this component so that it has width width and height height .

Usage

From source file:Reportes.BarChart.java

public ChartPanel reporteVentasEmpresa(DefaultCategoryDataset data) {
    JFreeChart chart = ChartFactory.createBarChart("Reporte de ventas por sede", "Sede", "Cantidad", data,
            PlotOrientation.VERTICAL, true, true, true);

    CategoryPlot categoryP = chart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) categoryP.getRenderer();
    renderer.setMaximumBarWidth(0.35);/*from ww w. ja v  a2 s  .  c  o m*/
    Color color = new Color(67, 165, 208);
    renderer.setSeriesPaint(0, color);

    ChartPanel panel = new ChartPanel(chart, true, true, true, false, false);
    panel.setSize(ancho, alto);

    return panel;
}

From source file:Reportes.BarChart.java

public ChartPanel reporteVentasSede(DefaultCategoryDataset data) {
    JFreeChart chart = ChartFactory.createBarChart("Reporte de ventas por usuario", "Vendedor", "Cantidad",
            data, PlotOrientation.VERTICAL, true, true, true);

    CategoryPlot categoryP = chart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) categoryP.getRenderer();
    renderer.setMaximumBarWidth(0.35);//from w w w.  j ava2  s  .  co  m
    Color color = new Color(67, 165, 208);
    renderer.setSeriesPaint(0, color);

    ChartPanel panel = new ChartPanel(chart, true, true, true, false, false);
    panel.setSize(ancho, alto);

    return panel;
}

From source file:de.main.sessioncreator.ReportingHelper.java

public void addReport(JPanel jp) {
    jp.removeAll();//from  w  w w .  j ava 2 s  .com
    PieDataset dataset = createDataset();
    // based on the dataset we create the chart
    JFreeChart chart = createChart(dataset, "Sessions by Tester");
    // we put the chart into a panel
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.updateUI();
    chartPanel.setSize(490, 350);

    jp.revalidate();
    jp.setOpaque(true);
    jp.add(chartPanel);
    jp.revalidate();
    jp.setVisible(true);
    jp.setSize(700, 500);
    jp.revalidate();
    jp.repaint();
}

From source file:Reportes.BarChart.java

public ChartPanel reporteEmpleados(DefaultCategoryDataset data) {
    JFreeChart JFchart = ChartFactory.createBarChart("Reporte de empleados", "Sedes", "Cantidad", data,
            PlotOrientation.VERTICAL, true, true, true);
    /*/*w  ww.j a v a  2s.c  om*/
    CategoryPlot plot = new CategoryPlot();
            
    ChartFrame chartFrame = new ChartFrame("Reporte de empleadoos", JFchart, false);
    chartFrame.setSize(300, 300);
    chartFrame.setVisible(true);
    */

    CategoryPlot categoryP = JFchart.getCategoryPlot();
    BarRenderer renderer = (BarRenderer) categoryP.getRenderer();
    renderer.setMaximumBarWidth(0.35);
    Color color = new Color(67, 165, 208);
    renderer.setSeriesPaint(0, color);

    ChartPanel panel = new ChartPanel(JFchart, true, true, true, false, false);

    panel.setSize(ancho, alto);

    return panel;
}

From source file:GUI.ResponseStatistics.java

/** * Creates a sample dataset */

private void InitPieChart(JFreeChart chart) {
    ChartPanel chartPanel = new ChartPanel(chart);
    // default size
    chartPanel.setSize(560, 800);

    Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (int) ((dimension.getWidth() - chartPanel.getWidth()) / 2);
    int y = (int) ((dimension.getHeight() - chartPanel.getHeight()) / 2);

    chartPanel.setLocation(WIDTH, WIDTH);
    // add it to our application
    setContentPane(chartPanel);/*w w  w .ja  v a  2s  .com*/

    chartPanel.addChartMouseListener(new ChartMouseListener() {

        public void chartMouseClicked(ChartMouseEvent e) {

            wait = false;

        }

        public void chartMouseMoved(ChartMouseEvent e) {
        }

    });
}

From source file:Model.OpMenu.java

public JFrame GraficoProduto() {
    te.LeArquivo();/*www. ja  va  2 s .  co m*/
    CategoryDataset cds = te.GeraDataset();

    JFreeChart grafico = ChartFactory.createBarChart3D("Venda por produto", "Legenda:", "Quantidade vendida",
            cds, PlotOrientation.VERTICAL, true, true, true);

    JFrame janela = new JFrame(" ");
    Painel painel = new Painel();
    ChartPanel myChartPanel = new ChartPanel(grafico, true);
    myChartPanel.setSize(painel.getWidth(), painel.getHeight());
    myChartPanel.setVisible(true);
    painel.removeAll();
    painel.add(myChartPanel);
    painel.revalidate();
    painel.repaint();

    janela.add(painel);
    janela.setSize(690, 465);
    janela.setVisible(true);

    return janela;
}

From source file:Model.OpMenu.java

public JFrame GraficoCliente() {
    tv.LeArquivo();/*from w w w .ja  v  a2s.c om*/
    float t = tv.Entrada();

    CategoryDataset cds = vc.GeraDataSet(t);

    JFreeChart grafico = ChartFactory.createBarChart3D("Cinco clientes que mais compraram/gastaram",
            "Legenda: ", "Porcentagem (%)", cds, PlotOrientation.VERTICAL, true, true, true);

    JFrame janela = new JFrame(" ");
    Painel panel = new Painel();
    ChartPanel myChartPanel = new ChartPanel(grafico, true);
    myChartPanel.setSize(panel.getWidth(), panel.getHeight());
    myChartPanel.setVisible(true);
    panel.removeAll();
    panel.add(myChartPanel);
    panel.revalidate();
    panel.repaint();

    janela.add(panel);
    janela.setSize(690, 465);
    janela.setVisible(true);

    return janela;

}

From source file:net.sf.mzmine.chartbasics.ChartLogics.java

/**
 * Calculates the size of a chart for a given fixed plot width and height
 * // ww  w .  ja  va 2 s  .  c om
 * @param chart
 * @param plotWidth
 * @return
 */
public static Dimension calcSizeForPlotSize(ChartPanel myChart, double plotWidth, double plotHeight,
        int iterations) {
    makeChartResizable(myChart);

    // estimate plotwidth / height
    double estimatedChartWidth = plotWidth + 200;
    double estimatedChartHeight = plotHeight + 200;

    double lastW = estimatedChartWidth;
    double lastH = estimatedChartHeight;

    // paint and get closer
    try {
        for (int i = 0; i < iterations; i++) {
            // paint on ghost panel with estimated height (if copy panel==true)
            myChart.setSize((int) estimatedChartWidth, (int) estimatedChartHeight);
            myChart.paintImmediately(myChart.getBounds());

            // rendering info
            ChartRenderingInfo info = myChart.getChartRenderingInfo();
            Rectangle2D dataArea = info.getPlotInfo().getDataArea();
            Rectangle2D chartArea = info.getChartArea();

            // // calc title space: will be added later to the right plot size
            // double titleWidth = chartArea.getWidth()-dataArea.getWidth();
            // double titleHeight = chartArea.getHeight()-dataArea.getHeight();

            // calc width and height
            estimatedChartWidth = estimatedChartWidth - dataArea.getWidth() + plotWidth;
            estimatedChartHeight = estimatedChartHeight - dataArea.getHeight() + plotHeight;

            if ((int) lastW == (int) estimatedChartWidth && (int) lastH == (int) estimatedChartHeight)
                break;
            else {
                lastW = estimatedChartWidth;
                lastH = estimatedChartHeight;
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    return new Dimension((int) estimatedChartWidth, (int) estimatedChartHeight);
}

From source file:GUIpresentacion.GUIInformeAltasBajas.java

private void graficarTorta() {
    panelLinea.removeAll();/* w w  w.jav a  2s  .  c o  m*/

    pieDataset = new DefaultPieDataset();

    pieDataset.setValue("Baja", Integer.parseInt(String.valueOf(tabla.getValueAt(1, 0))));

    pieDataset.setValue("Alta", Integer.parseInt(String.valueOf(tabla.getValueAt(0, 0))));

    if (tabla.getRowCount() > 2)
        pieDataset.setValue("Suspensiones", Integer.parseInt(String.valueOf(tabla.getValueAt(2, 0))));

    chart = ChartFactory.createPieChart("Datos", pieDataset, true, true, true);
    p = (PiePlot) chart.getPlot();
    ChartPanel frame = new ChartPanel(chart);
    frame.setSize(310, 340);
    panelLinea.add(frame);
    panelLinea.updateUI();
}

From source file:GUIpresentacion.GUIInformeAltasBajas.java

private void graficarLinea() {
    jPanel2.removeAll();/* www  .  j  a va  2 s. co  m*/
    fecha = new GregorianCalendar();
    Integer anio = fecha.get(Calendar.YEAR);

    String fch1 = Integer.toString(anio);
    //String fch2 = Integer.toString(anio-2);
    //String fch3 = Integer.toString(anio-3);

    datos = new DefaultCategoryDataset();

    datos.setValue(5, "2013", "2013");
    datos.setValue(5, "2014", "2014");
    datos.setValue(2, "2015", "2015");

    chart = ChartFactory.createBarChart("Activos ", "Aos", "Cantidad Activos", datos,
            PlotOrientation.HORIZONTAL, true, true, true);
    ChartPanel frame = new ChartPanel(chart);
    frame.setSize(300, 340);//ancho,alto
    jPanel2.add(frame);
    jPanel2.updateUI();
}