List of usage examples for org.jfree.chart JFreeChart JFreeChart
public JFreeChart(String title, Plot plot)
From source file:edu.ucla.stat.SOCR.chart.demo.BoxAndWhiskerChartDemo1.java
/** * Creates a sample chart./*from w w w . j a v a 2 s .co m*/ * * @param dataset the dataset. * * @return The chart. */ protected JFreeChart createChart(BoxAndWhiskerCategoryDataset dataset) { CategoryAxis domainAxis = new CategoryAxis(null); NumberAxis rangeAxis = new NumberAxis(rangeLabel); BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); JFreeChart chart = new JFreeChart(chartTitle, plot); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); renderer.setLegendItemLabelGenerator( new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT)); //RowCount -- serie count if (dataset.getColumnCount() * dataset.getRowCount() < 5) { domainAxis.setLowerMargin(0.2); domainAxis.setUpperMargin(0.2); if (dataset.getColumnCount() == 1) renderer.setItemMargin(0.5); // domainAxis.setCategoryMargin(domainAxis.getCategoryMargin()*2); /* System.out.println("1lowerMargin="+domainAxis.getLowerMargin()); System.out.println("ItemMargin="+renderer.getItemMargin()); System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/ } else if (dataset.getColumnCount() * dataset.getRowCount() < 10) { domainAxis.setLowerMargin(domainAxis.getLowerMargin() * 2); domainAxis.setUpperMargin(domainAxis.getUpperMargin() * 2); if (dataset.getColumnCount() == 1) renderer.setItemMargin(renderer.getItemMargin() * 2); else domainAxis.setCategoryMargin(domainAxis.getCategoryMargin() * 2); /*System.out.println("2lowerMargin="+domainAxis.getLowerMargin()); System.out.println("ItemMargin="+renderer.getItemMargin()); System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/ } if (legendPanelOn) chart.removeLegend(); return chart; }
From source file:playground.dgrether.linkanalysis.DgCountPerIterationGraph.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("Iteration"); xAxis.setRange(this.controllerConfig.getFirstIteration(), this.controllerConfig.getLastIteration() + 2); ValueAxis yAxis = this.axisBuilder.createValueAxis("Trips"); // yAxis.setRange(-0.05, 0.3); // xAxis.setVisible(false); // xAxis.setFixedAutoRange(1.0); plot.setDomainAxis(xAxis);//w w w .java 2s . c o m plot.setRangeAxis(yAxis); plot.setDataset(0, this.dataset); DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); for (int i = 0; i < this.dataset.getSeriesCount(); i++) { renderer2.setSeriesItemLabelsVisible(i, true); renderer2.setSeriesOutlineStroke(i, new BasicStroke(3.0f)); renderer2.setSeriesStroke(i, new BasicStroke(2.0f)); renderer2.setSeriesPaint(i, colorScheme.getColor(i + 1, "a")); } // renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator); // renderer2.setSeriesStroke(1, new BasicStroke(2.0f)); // renderer2.setSeriesOutlineStroke(1, new BasicStroke(3.0f)); // renderer2.setSeriesPaint(1, colorScheme.getColor(2, "a")); plot.setRenderer(0, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); // chart.removeLegend(); return chart; }
From source file:playground.benjamin.scenarios.zurich.analysis.charts.BkDeltaUtilsChart.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(this.dataset, new NumberAxis("individual income"), new NumberAxis("delta utils"), null);//from www . j a v a 2 s .c o m XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true); plot.setRenderer(renderer); JFreeChart jchart = new JFreeChart("", plot); return jchart; }
From source file:playground.benjamin.scenarios.zurich.analysis.charts.BkDeltaUtilsQuantilesChart.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(this.dataset, new NumberAxis("population deciles sorted by income"), new NumberAxis("delta utils"), null); XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true); plot.setRenderer(renderer);//from ww w . j ava 2s. com JFreeChart jchart = new JFreeChart("", plot); return jchart; }
From source file:info.debatty.java.datasets.examples.GaussianMixtureBuilder.java
/** * Creates a new fast scatter plot demo. * * @param title the frame title./* w w w . j a v a2 s . c o m*/ */ FastScatterPlot2D(final String title, final float[][] data) { super(title); final NumberAxis x_axis = new NumberAxis("X"); x_axis.setAutoRangeIncludesZero(false); final NumberAxis y_axis = new NumberAxis("Y"); y_axis.setAutoRangeIncludesZero(false); final FastScatterPlot plot = new FastScatterPlot(data, x_axis, y_axis); final JFreeChart chart = new JFreeChart(title, plot); // 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(1024, 768)); setContentPane(panel); }
From source file:org.jfree.chart.demo.StackedXYBarChartDemo2.java
private static JFreeChart createChart(TableXYDataset tablexydataset) { DateAxis dateaxis = new DateAxis("Date"); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateaxis.setLowerMargin(0.01D);//from ww w.ja v a 2s.c om dateaxis.setUpperMargin(0.01D); NumberAxis numberaxis = new NumberAxis("Count"); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setUpperMargin(0.10000000000000001D); StackedXYBarRenderer stackedxybarrenderer = new StackedXYBarRenderer(0.14999999999999999D); stackedxybarrenderer.setDrawBarOutline(false); stackedxybarrenderer.setBaseItemLabelsVisible(true); stackedxybarrenderer.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); stackedxybarrenderer.setBasePositiveItemLabelPosition( new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER)); stackedxybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} : {1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0"))); XYPlot xyplot = new XYPlot(tablexydataset, dateaxis, numberaxis, stackedxybarrenderer); JFreeChart jfreechart = new JFreeChart("Holes-In-One / Double Eagles", xyplot); jfreechart.removeLegend(); jfreechart.addSubtitle(new TextTitle("PGA Tour, 1983 to 2003")); TextTitle texttitle = new TextTitle( "http://www.golfdigest.com/majors/masters/index.ssf?/majors/masters/gw20040402albatross.html", new Font("Dialog", 0, 8)); jfreechart.addSubtitle(texttitle); jfreechart.setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); LegendTitle legendtitle = new LegendTitle(xyplot); legendtitle.setBackgroundPaint(Color.white); legendtitle.setFrame(new BlockBorder()); legendtitle.setPosition(RectangleEdge.BOTTOM); jfreechart.addSubtitle(legendtitle); return jfreechart; }
From source file:org.openmicroscopy.shoola.util.ui.graphutils.BarPlot.java
/** * Creates the chart.//from ww w . j a v a2 s . c om * @see ChartObject#createChar() */ void createChart() { CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, rangeAxis, new CustomBarRenderer(colours)); if (backgroundImage != null) { plot.setRangeGridlinesVisible(false); plot.setDomainGridlinesVisible(false); plot.setBackgroundImage(backgroundImage); } chart = new JFreeChart(title, plot); }
From source file:org.codehaus.mojo.chronos.chart.HistoryChartGenerator.java
public final void createGcChart(HistoricSamples samples, String dataId) throws IOException { XYPlot xyplot1 = newPlot(samples.getGcRatio(dataId), "chronos.label.gc.ratio", true); xyplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); xyplot1.getRenderer().setSeriesPaint(0, Color.GREEN); xyplot1.getRangeAxis().setStandardTickUnits(NumberAxis.createStandardTickUnits()); XYPlot xyplot2 = newPlot(samples.getKbCollectedPrSecond(dataId), "chronos.label.gc.kbpersec", true); xyplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); xyplot2.getRenderer().setSeriesPaint(0, Color.GRAY); xyplot2.getRangeAxis().setStandardTickUnits(NumberAxis.createStandardTickUnits()); String timeLabel = bundle.getString("chronos.label.gc.historytime"); DateAxis timeAxis = ChartUtil.createTimeAxis(timeLabel, new SimpleDateFormat()); XYPlot combinedPlot = ChartUtil.createCombinedPlot(timeAxis, xyplot1, xyplot2); // xyplot1.setDomainAxis( timeAxis ); // XYPlot combinedPlot = xyplot1; JFreeChart chart = new JFreeChart(bundle.getString("chronos.label.gc"), combinedPlot); renderer.renderChart("history-gc-" + dataId, chart); }
From source file:org.tsho.dmc2.managers.ManifoldsManager.java
public ManifoldsManager(final DifferentiableMap model, final ManifoldsControlForm2 form, final ManagerListener2 frame, final DmcChartPanel otherPanel) { super(frame); this.model = model; this.form = form; /* defaults */ setGridlines(true);// w w w .java 2 s . c o m crosshair = false; xAxis = (NumberAxis) ((DmcRenderablePlot) otherPanel.getChart().getPlot()).getDomainAxis(); yAxis = (NumberAxis) ((DmcRenderablePlot) otherPanel.getChart().getPlot()).getRangeAxis(); plot = new DmcRenderablePlot(xAxis, yAxis); plotRenderer = new ManifoldsRenderer(model, plot); plot.setPlotRenderer(plotRenderer); plot.addCoreStatusListener(new CoreStatusListener() { public void sendCoreStatus(final CoreStatusEvent event) { if (event.getType() == CoreStatusEvent.REDRAW) { launchThread(); } else if (event.getType() == CoreStatusEvent.REPAINT) { chartPanel.repaint(); } } }); chart = new JFreeChart(model.getName(), plot); chartPanel = new DmcChartPanel(chart); chartPanel.setMouseZoomable(true, false); // stop everything on resizing chartPanel.addComponentListener(new ComponentAdapter() { public void componentResized(final ComponentEvent e) { ManifoldsManager.this.stopRendering(); } }); setCrosshair(crosshair); }
From source file:org.jfree.chart.demo.CategoryStepChartDemo.java
/** * Creates a chart.//w ww. ja v a 2s . co m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { final CategoryItemRenderer renderer = new CategoryStepRenderer(true); final CategoryAxis domainAxis = new CategoryAxis("Category"); final ValueAxis rangeAxis = new NumberAxis("Value"); final CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer); final JFreeChart chart = new JFreeChart("Category Step Chart", plot); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setAnchor(StandardLegend.SOUTH); chart.setBackgroundPaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.addCategoryLabelToolTip("Type 1", "The first type."); domainAxis.addCategoryLabelToolTip("Type 2", "The second type."); domainAxis.addCategoryLabelToolTip("Type 3", "The third type."); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLabelAngle(0 * Math.PI / 2.0); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }