List of usage examples for org.jfree.chart StandardLegend setDisplaySeriesShapes
public void setDisplaySeriesShapes(boolean flag)
From source file:org.jfree.chart.demo.ScatterPlotDemo.java
/** * A demonstration application showing a scatter plot. * /* w w w.j av a2 s.c o m*/ * @param title * the frame title. */ public ScatterPlotDemo(final String title) { super(title); final XYDataset data = new SampleXYDataset2(); final JFreeChart chart = ChartFactory.createScatterPlot("Scatter Plot Demo", "X", "Y", data, PlotOrientation.VERTICAL, true, true, false); final Legend legend = chart.getLegend(); if (legend instanceof StandardLegend) { final StandardLegend sl = (StandardLegend) legend; sl.setDisplaySeriesShapes(true); } XYPlot plot = (XYPlot) chart.getPlot(); plot.setNoDataMessage("NO DATA"); final NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); chartPanel.setVerticalAxisTrace(true); chartPanel.setHorizontalAxisTrace(true); chartPanel.setVerticalZoom(true); chartPanel.setHorizontalZoom(true); setContentPane(chartPanel); }
From source file:hr.restart.util.chart.ChartXYZ.java
/** * Creates a LINE CHART.//from w w w . j av a2 s .c o m * * @param dataset The org.jfree.data.CategoryDataset * @param title The title * @return org.jfree.chart.JFreeChart */ final private JFreeChart createLineChart(final CategoryDataset dataset, String title) { // create the chart... final JFreeChart chart = ChartFactory.createLineChart(title, // chart title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); //print the subtitles java.util.List subs = getSubtitles(); if (subs != null) for (int i = 0; i < subs.size(); i++) { chart.addSubtitle(new TextTitle(subs.get(i).toString())); } // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... final StandardLegend legend = (StandardLegend) chart.getLegend(); legend.setDisplaySeriesShapes(true); legend.setShapeScaleX(1.5); legend.setShapeScaleY(1.5); legend.setDisplaySeriesLines(true); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); //plot.setBackgroundPaint(Color.lightGray); //plot.setRangeGridlinePaint(Color.white); // customise the range axis... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setDrawShapes(true); adjustLineRenderer(renderer); // renderer.setSeriesStroke( // 0, new BasicStroke( // 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, // 1.0f, new float[] {10.0f, 6.0f}, 0.0f // ) // ); // renderer.setSeriesStroke( // 1, new BasicStroke( // 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, // 1.0f, new float[] {6.0f, 6.0f}, 0.0f // ) // ); // renderer.setSeriesStroke( // 2, new BasicStroke( // 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, // 1.0f, new float[] {2.0f, 6.0f}, 0.0f // ) // ); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }