List of usage examples for org.jfree.chart ChartPanel ChartPanel
public ChartPanel(JFreeChart chart)
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 /*w w w .jav a 2 s .com*/ */ 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:uom.research.thalassemia.util.BarChartCreator.java
/** * Creates a panel for the demo (used by SuperDemo.java). * * @param pCategoryDataset dataset//from w w w. j a va 2 s .c o m * @param pTitle main title * @param psubTitle sub title * @param pxTitle x Axis Title * @param pyTitle y axis title * @return A panel. */ public JPanel createPanel(final CategoryDataset pCategoryDataset, final String pTitle, final String psubTitle, final String pxTitle, final String pyTitle) { mainTitle = pTitle; subTitle = psubTitle; xTitle = pxTitle; yTitle = pyTitle; categoryDataset = pCategoryDataset; JFreeChart chart = createChart(categoryDataset); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseWheelEnabled(true); return chartPanel; }
From source file:window.view.VueCourbe.java
public VueCourbe(MainSphere ms, int width, int height) { this._ms = ms; this._listeDiff = new ArrayList<>(); this._listeIterations = new ArrayList<>(); // This will create the dataset DefaultXYDataset dataset = getData(); // based on the dataset we create the chart JFreeChart chart = createChart(dataset, "Courbe d'volution des rsultats"); // we put the chart into a panel this._chartPanel = new ChartPanel(chart); // default size this._chartPanel.setPreferredSize(new java.awt.Dimension(width * 2, height)); // add it to our application this.add(this._chartPanel); pack();/*from w ww . j a va 2s . c o m*/ setResizable(false); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:cz.cuni.mff.ksi.jinfer.attrstats.JFCWrapper.java
/** * Creates a {@link JPanel} containing a pie chart with provided title, * visualizing the domain of the provided {@link Attribute#content}. * * @param title Graph title.//from w ww .ja v a2s .c o m * @param content Content of the {@link Attribute} to be visualized. Each * value of this content is represented with weight according to the number of * times it is found there. * @return JPanel containing a constructed JFreeChart pie chart. */ private static JPanel createGraphPanel(final String title, final List<String> content) { final ChartPanel ret = new ChartPanel(createChart(title, createDataset(content))); ret.setPreferredSize(new Dimension(320, 240)); return ret; }
From source file:org.jfree.chart.demo.BarChart3DDemo4.java
public BarChart3DDemo4(String s) { super(s);/*w w w .j a v a 2 s . c o m*/ CategoryDataset categorydataset = createDataset(); JFreeChart jfreechart = createChart(categorydataset); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartpanel); }
From source file:com.sjsu.uidesign.ExecStatus.java
public ExecStatus() { super();// w w w. j ava 2s. c o m super.setTitle("Task Execution Status"); super.setSize(500, 500); super.setResizable(true); super.setLocationRelativeTo(null); JLabel usageImage = new JLabel(); //usageImage.setIcon(new ImageIcon("Pie_3.png")); //usageImage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/sjsu/uidesign/Bar_4.png"))); // NOI18N //add(usageImage); DefaultCategoryDataset barChartData = new DefaultCategoryDataset(); barChartData.setValue(6, "Cache Cleanup", "Cache Cleanup"); barChartData.setValue(8, "Antivirus Scan", "Antivirus Scan"); barChartData.setValue(7, "Empty Recycle Bin", "Empty Recycle Bin"); JFreeChart barChart = ChartFactory.createBarChart("Task Execution Status", "Task Name", "Status", createDataset(), PlotOrientation.VERTICAL, true, true, false); CategoryPlot barChar = barChart.getCategoryPlot(); barChar.setRangeGridlinePaint(Color.ORANGE); ChartPanel barPanel = new ChartPanel(barChart); JPanel panelChart = new JPanel(); panelChart.removeAll(); panelChart.add(barPanel, BorderLayout.CENTER); panelChart.validate(); add(panelChart); }
From source file:GUI.meilleurePrestataire.java
public meilleurePrestataire() throws SQLException { dataset = new DefaultPieDataset(); Connection connexion = MyConnection.getInstance(); String requete = "select * from evaluationprestataire"; Statement statement = connexion.createStatement(); ResultSet resultat = statement.executeQuery(requete); while (resultat.next()) { dataset.setValue(/*from w w w . j a v a 2s.c om*/ userDAO.retrieveUtilisateurById(resultat.getInt(2)).getNom() + " : " + resultat.getInt(3), resultat.getInt(3)); } graphe = ChartFactory.createPieChart3D("Les notes des prestataires", dataset, true, true, false); cp = new ChartPanel(graphe); this.add(cp); }
From source file:AppPackage.Temperature.java
public Temperature() { try {/* ww w .j a v a2 s . c o 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:eu.choreos.vv.chart.XYChart.java
public static ChartPanel createChart(String chartTitle, List<PlotData> reports, String xLabel, String yLabel) { XYSeriesCollection dataset = new XYSeriesCollection(); for (PlotData report : reports) { createDataset(dataset, (LineData) report); }/*from w w w .j av a2s. c om*/ JFreeChart chart = createChart(dataset, chartTitle, xLabel, yLabel); ChartPanel panel = new ChartPanel(chart); return panel; }
From source file:dbseer.gui.frame.DBSeerPlotCustomFrame.java
private void initializeGUI() { this.setLayout(new MigLayout("fill")); JFreeChart chart = null;//w ww .j av a 2 s . c o m try { chart = DBSeerChartFactory.createCustomXYLineChart(xAxisName, yAxisName); } catch (Exception e) { e.printStackTrace(); } chartPanel = new ChartPanel(chart); this.add(chartPanel, "grow"); ArrayList<DBSeerChart> charts = new ArrayList<DBSeerChart>(); DBSeerChart newChart = new DBSeerChart("Custom", chart); newChart.setXAxisName(xAxisName); newChart.setYAxisName(yAxisName); charts.add(newChart); // if live/current dataset, launch the chart refresher. if (dataset.isCurrent()) { final DBSeerChartRefreshWorker refresher = new DBSeerChartRefreshWorker(charts, dataset); this.addWindowListener(new WindowAdapter() { @Override public void windowClosed(WindowEvent windowEvent) { refresher.stop(); refresher.cancel(false); super.windowClosed(windowEvent); } }); refresher.execute(); } }