List of usage examples for org.jfree.chart ChartPanel ChartPanel
public ChartPanel(JFreeChart chart, boolean useBuffer)
From source file:lospolloshermanos.BarChart.java
public BarChart(String title, int no_of_items, ResultSet result) { // super(title); this.Title = title; this.result = result; this.no_of_items = no_of_items; if (title.equals("Categories")) { CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(900, 300)); this.Title = "Categories 2"; CategoryDataset dataset2 = createDataset(); JFreeChart chart2 = createChart(dataset2); ChartPanel chartPanel2 = new ChartPanel(chart2, false); chartPanel2.setPreferredSize(new Dimension(900, 300)); this.setLayout(new GridLayout(2, 1)); this.add(chartPanel); this.add(chartPanel2); } else if (title.equals("Items")) { CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(900, 300)); this.Title = "Items 2"; CategoryDataset dataset2 = createDataset(); JFreeChart chart2 = createChart(dataset2); ChartPanel chartPanel2 = new ChartPanel(chart2, false); chartPanel2.setPreferredSize(new Dimension(900, 300)); this.setLayout(new GridLayout(2, 1)); this.add(chartPanel); this.add(chartPanel2); } else if (title.equals("Ratings")) { CategoryDataset dataset = createDataset(); JFreeChart chart = createChart(dataset); ChartPanel chartPanel = new ChartPanel(chart, false); chartPanel.setPreferredSize(new Dimension(900, 300)); this.setLayout(new GridLayout(1, 1)); this.add(chartPanel); }/* w w w. j a v a 2s. c o m*/ // setContentPane(chartPanel); // this.setDefaultCloseOperation(javax.swing.WindowConstants.HIDE_ON_CLOSE); }
From source file:scatterplot1k.JFreeScatter.java
/** * Creates a new fast scatter plot demo. * * @param title the frame title./*w ww. jav a 2s .c om*/ * @param sampleSize */ public JFreeScatter(final String title, int sampleSize) { super(title); this.sampleCount = sampleSize; data = new float[2][sampleSize]; populateData(); final NumberAxis domainAxis = new NumberAxis("X"); domainAxis.setAutoRangeIncludesZero(false); final NumberAxis rangeAxis = new NumberAxis("Y"); rangeAxis.setAutoRangeIncludesZero(false); final FastScatterPlot plot = new FastScatterPlot(this.data, domainAxis, rangeAxis); final JFreeChart chart = new JFreeChart("Fast Scatter Plot", plot); // chart.setLegend(null); // force aliasing of the rendered content.. chart.getRenderingHints().put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); final ChartPanel panel = new ChartPanel(chart, true); panel.setPreferredSize(new java.awt.Dimension(800, 600)); // panel.setHorizontalZoom(true); // panel.setVerticalZoom(true); panel.setMinimumDrawHeight(10); panel.setMaximumDrawHeight(2000); panel.setMinimumDrawWidth(20); panel.setMaximumDrawWidth(2000); setContentPane(panel); }
From source file:de.fub.maps.project.detector.model.statistics.HistogramPanel.java
/** * Creates new form histogramPanel//w w w. j a v a 2s .c om */ public HistogramPanel() { initComponents(); histogramChart = ChartFactory.createHistogram(null, null, null, dataSet, PlotOrientation.VERTICAL, false, true, true); plot = histogramChart.getXYPlot(); chartPanel = new ChartPanel(histogramChart, true); add(chartPanel, BorderLayout.CENTER); XYBarRenderer barRenderer = new XYBarRenderer(.05); barRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); barRenderer.setBarPainter(new StandardXYBarPainter()); barRenderer.setBarAlignmentFactor(.1); barRenderer.setBasePaint(Color.blue); // barRenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); barRenderer.setBaseItemLabelGenerator( new StandardXYItemLabelGenerator(StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, new CustomNumberFormat(), new CustomNumberFormat())); barRenderer.setBaseItemLabelsVisible(true); plot.setRenderer(barRenderer); plot.setBackgroundPaint(Color.white); histogramChart.setBackgroundPaint(Color.white); plot.setRangeGridlinesVisible(true); chartPanel.setVerticalAxisTrace(false); chartPanel.setDisplayToolTips(true); chartPanel.setBackground(Color.white); }
From source file:de.fub.maps.project.plugins.tasks.eval.heading.HeadingHistogramm.java
/** * Creates new form HeadingHistogramm/*from www .j a v a 2s. c o m*/ */ public HeadingHistogramm() { initComponents(); barChart = ChartFactory.createXYBarChart(null, "Degree", false, null, dataset, PlotOrientation.VERTICAL, true, true, true); barChart.setBackgroundPaint(Color.WHITE); barChart.getPlot().setBackgroundPaint(Color.WHITE); XYBarRenderer barRenderer = new XYBarRenderer(.05); barRenderer.setShadowVisible(false); barRenderer.setBarPainter(new StandardXYBarPainter()); barRenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); barChart.getXYPlot().setRenderer(barRenderer); chartpanel = new ChartPanel(barChart, false); add(chartpanel, BorderLayout.CENTER); }
From source file:simphy.XYChart.java
public XYChart(Pendulum p) { this.p = p;//from w w w . j a v a 2s. co m type = "pendulum"; // Create a simple XY chart series = new XYSeries("Omega-Time Plot"); series1 = new XYSeries("Theta-Time Plot"); dataset = new XYSeriesCollection(); dataset.addSeries(series); dataset.addSeries(series1); // Generate the graph chart = ChartFactory.createXYLineChart("Velocity/Angle Graph", // Title "time", // x-axis Label "Angular Velocity(rad/s)/Angle(rad)", // y-axis Label dataset, // Dataset PlotOrientation.VERTICAL, // Plot Orientation true, // Show Legend true, // Use tooltips false // Configure chart to generate URLs? ); this.setTitle(p.toString()); this.setBounds(950, 0, 400, 700); panel = new ChartPanel(chart, false); this.add(panel, BorderLayout.CENTER); this.setAlwaysOnTop(true); this.addWindowListener(this); this.pack(); SwingUtilities.invokeLater(new Runnable() { @Override public void run() { XYChart.this.setVisible(true); } }); }
From source file:jesse.GA_ANN.DataVis.java
JFreeChart createChart()//Here Input MillSecond { total = new XYSeries[10]; XYSeriescollection = new XYSeriesCollection(); for (int i = 0; i < 10; i++) { total[i] = new XYSeries(i); XYSeriescollection.addSeries(total[i]); }/*from www .ja va2 s.co m*/ dateaxis = new NumberAxis("Time"); NumberAxis Conaxis = new NumberAxis("z??"); dateaxis.setAutoRange(true); dateaxis.setLowerMargin(0.0D); dateaxis.setUpperMargin(0.0D); dateaxis.setTickLabelsVisible(true); xylineandshaperenderer = new XYLineAndShapeRenderer(true, false); xylineandshaperenderer.setSeriesPaint(0, Color.green); xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(1F, 0, 2)); xylineandshaperenderer.setFillPaint(new Color(30, 30, 220), true); Conaxis.setRange(-1, 1); Conaxis.setAutoRange(true); Conaxis.setAutoRangeIncludesZero(false); XYPlot xyplot = new XYPlot(XYSeriescollection, dateaxis, Conaxis, xylineandshaperenderer); JFreeChart jfreechart = new JFreeChart("time-z", new Font("Arial", 1, 24), xyplot, true); ChartUtilities.applyCurrentTheme(jfreechart); ChartPanel chartpanel = new ChartPanel(jfreechart, true); chartpanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4), BorderFactory.createLineBorder(Color.black))); return jfreechart; }
From source file:TelasBanzos.TelaRelatorioDiadaSemana.java
/** * Creates new form TelaNovoOrcamento/* w w w .j a va2 s . c o m*/ */ public TelaRelatorioDiadaSemana() { initComponents(); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.setValue(2, "3", "Domingo"); dataset.setValue(5, "3", "Segunda"); dataset.setValue(4, "3", "Tera"); dataset.setValue(7, "3", "Quarta"); dataset.setValue(6, "3", "Quinta"); dataset.setValue(2, "3", "Sexta"); dataset.setValue(4, "3", "Sbado"); JFreeChart chart = ChartFactory.createBarChart("Alunos matriculados por dia da semana", "Dia da semana", "Quantidade Alunos", dataset, PlotOrientation.VERTICAL, false, true, false); ChartPanel myChartPanel = new ChartPanel(chart, true); pnGraf.add(myChartPanel); //colocar cor nas barras CategoryPlot plot = chart.getCategoryPlot(); BarRenderer render = (BarRenderer) plot.getRenderer(); render.setSeriesPaint(0, Color.ORANGE); setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("BanzosIcon.png")));//para setar um icone na janela }
From source file:de.fub.maps.gpx.analysis.ui.charts.LineChart.java
/** * Creates new form LineChart/*w ww. j av a2s. c om*/ */ public LineChart() { initComponents(); chart = ChartFactory.createXYLineChart(null, NbBundle.getMessage(LineChart.class, "LineChart.Domain.Name"), NbBundle.getMessage(LineChart.class, "LineCHart.Value.Name"), dataset, PlotOrientation.VERTICAL, false, true, true); plot = chart.getXYPlot(); plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); plot.setBackgroundPaint(Color.white); plot.getRenderer(0).setSeriesPaint(0, Color.BLUE); plot.getRenderer(0).setSeriesShape(0, new Ellipse2D.Double(0, 0, 2, 2)); plot.getRenderer(0).setBaseShape(new Ellipse2D.Double(0, 0, 2, 2)); chartPanel = new ChartPanel(chart, false); add(chartPanel, BorderLayout.CENTER); }
From source file:edu.ucla.stat.SOCR.chart.demo.RingChartDemo1.java
public void doTest() { JFreeChart chart;//from w ww . j a v a2s .com ChartGenerator_JTable chartMaker = new ChartGenerator_JTable(); resetChart(); showMessageDialog(chartTitle + " doTest get called!"); int[][] pairs = new int[1][2]; pairs[0][0] = 1; // value pairs[0][1] = 0; // name chart = chartMaker.getPieChart(chartTitle, dataTable, pairs, "ring"); chartPanel = new ChartPanel(chart, false); setChart(); }
From source file:edu.ucla.stat.SOCR.chart.demo.PieChartDemo3.java
/** * sample code showing how to use ChartGenerator_JTable to create chart *//*from w w w. j a v a 2 s . c om*/ public void doTest() { JFreeChart chart; ChartGenerator_JTable chartMaker = new ChartGenerator_JTable(); resetChart(); showMessageDialog(chartTitle + " doTest get called!"); int[][] pairs = new int[1][2]; pairs[0][0] = 1; // value pairs[0][1] = 0; // name chart = chartMaker.getPieChart(chartTitle, dataTable, pairs, ""); chartPanel = new ChartPanel(chart, false); setChart(); }