List of usage examples for org.jfree.chart ChartPanel setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:chart.XYChart.java
public XYChart(String applicationTitle, String chartTitle, double[] xData, double[] YDataAnalitic, double[] YDataNumerical) { super(applicationTitle); JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "", "", createDataset(xData, YDataAnalitic, YDataNumerical), PlotOrientation.VERTICAL, true, true, false); System.out.println("vvvv"); ChartPanel chartPanel = new ChartPanel(xylineChart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); final XYPlot plot = xylineChart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GREEN); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f)); plot.setRenderer(renderer);// w w w . ja v a 2s. c om setContentPane(chartPanel); // panel.removeAll(); // panel.add(chartPanel); // panel.validate(); }
From source file:Servizi.GraficoJ.java
/** * Costruttore che permette la visualizzazione di un grafico * @param titolo Targhetta che descrive il grafico * @param datiFitness array che contiene la media della fitness di ogni generazione * @param fitnessLinea costante che rappresenta il valore di fitness della linea da ottenere * @throws IOException /*from www. jav a 2 s.c om*/ */ public GraficoJ(final String titolo, Double[] datiFitness, Double fitnessLinea, String name) throws IOException { super(titolo); final XYDataset dataset = createDataset(datiFitness, fitnessLinea); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(700, 470)); setContentPane(chartPanel); ChartUtilities.saveChartAsPNG(new File("/home/gianni/Documenti/output/" + name + ".png"), chart, 1024, 768); }
From source file:GanttChart.Gantt.java
/** * Creates a new demo.// w w w.j a v a 2s. co m * * @param title the frame title. */ public Gantt(String title, String nomeProgetto) { super(title); this.nomeProgetto = nomeProgetto; this.progetto = new Progetto(nomeProgetto); setVisible(true); final IntervalCategoryDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(700, 750)); setContentPane(chartPanel); }
From source file:org.jfree.chart.demo.ItemLabelDemo2.java
/** * Creates a new demo instance.// w ww. j a v a2s . c o m * * @param title * the frame title. */ public ItemLabelDemo2(final String title) { super(title); final CategoryDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartPanel); }
From source file:chart.XYChart.java
public XYChart(String applicationTitle, String chartTitle, double[] xData, double[] YDataAnalitic, double[] YDataNumerical1, double[] YDataNumerical2, double[] YDataNumerical3) { super(applicationTitle); JFreeChart xylineChart = ChartFactory.createXYLineChart(chartTitle, "", "", createDatasetForFour(xData, YDataAnalitic, YDataNumerical1, YDataNumerical2, YDataNumerical3), PlotOrientation.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(xylineChart); chartPanel.setPreferredSize(new java.awt.Dimension(560, 367)); final XYPlot plot = xylineChart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GREEN); renderer.setSeriesPaint(2, Color.YELLOW); renderer.setSeriesStroke(0, new BasicStroke(1.0f)); renderer.setSeriesStroke(1, new BasicStroke(1.0f)); renderer.setSeriesStroke(2, new BasicStroke(1.0f)); plot.setRenderer(renderer);/*from ww w .j a v a 2 s . com*/ setContentPane(chartPanel); // panel.removeAll(); // panel.add(chartPanel); // panel.validate(); }
From source file:Client.Gui.BarChart.java
public BarChart(final String title, statistic statisticQ) { super(title); this.statisticQ = statisticQ; // this.thing=thing; final CategoryDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(700, 400)); setContentPane(chartPanel);//from w w w . j av a 2 s . c om }
From source file:dbseer.gui.frame.DBSeerPredictionFrame.java
private void initializeGUI() throws Exception { this.setLayout(new MigLayout("fill")); this.setPreferredSize(new Dimension(1024, 768)); JFreeChart chart = DBSeerChartFactory.createXYLinePredictionChart(center); JTable errorTable = DBSeerChartFactory.createErrorTable(center); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(1024, 768)); String title = center.getPredictionDescription(); if (center.getTestMode() == DBSeerConstants.TEST_MODE_DATASET) { title += ", Test with Dataset (" + center.getTestDatasetName() + ") "; } else {// www .j ava2s . c om title += ", Test with Mixture & TPS (" + center.getTestMixture() + ") "; } switch (center.getGroupingType()) { case DBSeerConstants.GROUP_NONE: title += "[Group: None] "; break; case DBSeerConstants.GROUP_REL_DIFF: title += "[Group: Rel. diff (" + center.getAllowedRelativeDiff() + ")] "; break; case DBSeerConstants.GROUP_NUM_CLUSTER: title += "[Group: Clustering (" + center.getNumClusters() + ")] "; break; case DBSeerConstants.GROUP_RANGE: title += "[Group: User-specified range] "; break; default: break; } if (center.getGroupingType() != DBSeerConstants.GROUP_NONE) { switch (center.getGroupingTarget()) { case DBSeerConstants.GROUP_TARGET_INDIVIDUAL_TRANS_COUNT: title += "[Target: Individual transactions]"; break; case DBSeerConstants.GROUP_TARGET_TPS: title += "[Target: TPS]"; break; default: break; } } this.setTitle(title); if (errorTable != null) { this.add(chartPanel, "grow, wrap"); this.add(errorTable, "growx"); } else { this.add(chartPanel, "grow"); } }
From source file:org.jfree.chart.demo.DualAxisDemo2.java
/** * A demonstration application showing how to create a time series chart with dual axes. * * @param title the frame title./*from w w w.j a v a2 s.c o m*/ */ public DualAxisDemo2(final String title) { super(title); // create a title... final String chartTitle = "Dual Axis Demo 2"; final XYDataset dataset = createDataset1(); final JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle, "Date", "Price Per Unit", dataset, true, true, false); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); final NumberAxis axis2 = new NumberAxis("Secondary"); axis2.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, axis2); plot.setDataset(1, createDataset2()); plot.mapDatasetToRangeAxis(1, 1); final XYItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setPlotShapes(true); rr.setShapesFilled(true); } final StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, Color.black); renderer2.setPlotShapes(true); renderer.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); plot.setRenderer(1, renderer2); final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:org.jfree.chart.demo.GanttDemo2.java
/** * Creates a new demo.//from ww w. j a v a 2 s . co m * * @param title the frame title. */ public GanttDemo2(final String title) { super(title); final IntervalCategoryDataset dataset = createSampleDataset(); // create the chart... final JFreeChart chart = ChartFactory.createGanttChart("Gantt Chart Demo", // chart title "Task", // domain axis label "Date", // range axis label dataset, // data true, // include legend true, // tooltips false // urls ); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); // plot.getDomainAxis().setMaxCategoryLabelWidthRatio(10.0f); final CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:br.ufba.eleicoestransparentes.view.chart.GraficoBarra.java
public GraficoBarra(GraficoFinal graficoFinal) { super(graficoFinal.getNome()); final CategoryDataset dataset = createDataset(graficoFinal.getPontosGrafico()); final JFreeChart chart = createChart(dataset, graficoFinal.getNome()); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartPanel);//from w w w . ja va 2s .co m }