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:analisisnumerico.Graficador.java
public Graficador(Funcion F, double lower, double upper) { //super("Graficador"); JFrame f = new JFrame("Grafica"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.setLayout(new BorderLayout(0, 5)); XYDataset paresDeDatos = generarDatos(F, lower, upper); JFreeChart diagrama = crearDiagrama(paresDeDatos); ChartPanel chartPanel = new ChartPanel(diagrama); chartPanel.setPreferredSize(new Dimension(500, 400)); //setContentPane(chartPanel); f.add(chartPanel, BorderLayout.CENTER); chartPanel.setMouseWheelEnabled(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalAxisTrace(true); f.pack();//from w w w . j a va2 s .c o m f.setLocationRelativeTo(null); f.setVisible(true); }
From source file:com.mycompany.istudy.principalservices.GraphicalView.java
/** * Overwrites the method of createXYLineChart from ChartFactory interface * and creates a XYLine Chart.//from w w w.j a v a 2 s. com * @param applicationTitle * @param chartTitle * @param investedHoursPerWeek * @param hoursToBeInvested */ public GraphicalView(String applicationTitle, String chartTitle, Map<Double, Double> investedHoursPerWeek, Map<Double, Double> hoursToBeInvested) { super(applicationTitle); xylineChart = ChartFactory.createXYLineChart(chartTitle, "Calender Weeks", "Invested Study-hours", createDataset(investedHoursPerWeek, hoursToBeInvested), 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.BLUE); renderer.setSeriesPaint(1, Color.RED); renderer.setSeriesStroke(0, new BasicStroke(4.0f)); plot.setRenderer(renderer); setContentPane(chartPanel); }
From source file:org.jfree.chart.demo.StackedBarChartDemo1.java
/** * Creates a new demo./*from ww w . jav a 2 s . c o m*/ * * @param title the frame title. */ public StackedBarChartDemo1(final String title) { super(title); final CategoryDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:org.jfree.chart.demo.PieChartDemo5.java
/** * Creates a new demo instance./*w w w . ja va2s. c om*/ * * @param title the frame title. */ public PieChartDemo5(final String title) { super(title); final PieDataset dataset = createDataset(); final JFreeChart chart = createChart(dataset); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:overSession.CreateGraph.java
public CreateGraph(String applicationTitle, String chartTitle, LinkedList<LinkedList<String>> pData, int sensorNum) { super(applicationTitle); this.pressureData = pData; this.sensorNumber = sensorNum; JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, "Session", "Average Pressure Value (per session)", createDataset(), PlotOrientation.VERTICAL, true, true, false);/*from w w w.ja v a 2 s . c om*/ //lineChart.setBackgroundPaint(Color.red); ChartPanel chartPanel = new ChartPanel(lineChart); chartPanel.setPreferredSize(new java.awt.Dimension(1200, 500)); setContentPane(chartPanel); File fileLineChart = new File("LineChart" + this.sensorNumber + ".jpeg"); try { ChartUtilities.saveChartAsJPEG(fileLineChart, lineChart, 1200, 500); } catch (IOException e) { e.printStackTrace(); } }
From source file:vista.montecarlo.GraficoEvolutivo.java
public GraficoEvolutivo(String applicationTitle, String chartTitle, double[][] costos) { super(applicationTitle); costosPromedio = costos;//from w w w. j ava 2 s . c o m JFreeChart lineChart = ChartFactory.createLineChart(chartTitle, TITL_EJE_X, TITL_EJE_Y, createDataset(), PlotOrientation.VERTICAL, true, true, false); ChartPanel chartPanel = new ChartPanel(lineChart); chartPanel.setPreferredSize(new java.awt.Dimension(1300, 733)); setContentPane(chartPanel); setDefaultCloseOperation(DISPOSE_ON_CLOSE); }
From source file:de.tuberlin.dima.flinkhandson.utils.SingleSeriesBarChart.java
public SingleSeriesBarChart(String title, String xLabel, String yLabel, Color barColor, Map<String, Double> result) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (Map.Entry<String, Double> e : result.entrySet()) { dataset.addValue(e.getValue(), "", e.getKey()); }/*from w ww.j ava 2s. c om*/ JFreeChart chart = ChartFactory.createBarChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryAxis xAxis = plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.BLACK); plot.setBackgroundPaint(Color.WHITE); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setSeriesPaint(0, barColor); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(1024, 768)); getContentPane().add(chartPanel); pack(); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:org.jfree.chart.demo.LineChartDemo4.java
/** * Creates a new demo./* w w w . ja va 2 s. c om*/ * * @param title the frame title. */ public LineChartDemo4(final String title) { super(title); // create a dataset... final XYDataset dataset = new SampleXYDataset(); // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo 4", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); final XYPlot plot = chart.getXYPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); // 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:org.jfree.chart.demo.XYSeriesDemo2.java
/** * A demonstration application showing an {@link XYSeries} where all the y-values are the same. * * @param title the frame title./*from w w w. java 2s . c o m*/ */ public XYSeriesDemo2(final String title) { super(title); final XYSeries series = new XYSeries("Flat Data"); series.add(1.0, 100.0); series.add(5.0, 100.0); series.add(4.0, 100.0); series.add(12.5, 100.0); series.add(17.3, 100.0); series.add(21.2, 100.0); series.add(21.9, 100.0); series.add(25.6, 100.0); series.add(30.0, 100.0); final XYSeriesCollection data = new XYSeriesCollection(series); final JFreeChart chart = ChartFactory.createXYLineChart("XY Series Demo 2", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); final XYPlot plot = (XYPlot) chart.getPlot(); final NumberAxis axis = (NumberAxis) plot.getRangeAxis(); axis.setAutoRangeIncludesZero(false); axis.setAutoRangeMinimumSize(1.0); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }
From source file:org.jfree.chart.demo.XYBarChartDemo3.java
/** * Constructs the demo application.//from w ww . j a v a 2s . c o m * * @param title the frame title. */ public XYBarChartDemo3(final String title) { super(title); // create a dataset... final IntervalXYDataset dataset = new SimpleIntervalXYDataset(); // create the chart... final JFreeChart chart = createChart(dataset); // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 300)); setContentPane(chartPanel); }