List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setDefaultEntityRadius
public void setDefaultEntityRadius(int radius)
From source file:org.jfree.chart.demo.XYLineAndShapeRendererDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createXYLineChart("XYLineAndShapeRenderer Demo 1", "X", "Y", xydataset, PlotOrientation.VERTICAL, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(); xylineandshaperenderer.setSeriesLinesVisible(0, true); xylineandshaperenderer.setSeriesShapesVisible(0, false); xylineandshaperenderer.setSeriesLinesVisible(1, false); xylineandshaperenderer.setSeriesShapesVisible(1, true); xylineandshaperenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); xylineandshaperenderer.setDefaultEntityRadius(6); xyplot.setRenderer(xylineandshaperenderer); return jfreechart; }
From source file:org.jfree.graphics2d.demo.SVGChartWithAnnotationsDemo1.java
/** * Creates a sample chart.//from w ww . j a va2s . c om * * @param dataset a dataset for the chart. * * @return A sample chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("XYDrawableAnnotationDemo1", null, "$ million", dataset); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(true); DateAxis xAxis = (DateAxis) plot.getDomainAxis(); xAxis.setLowerMargin(0.2); xAxis.setUpperMargin(0.2); xAxis.setStandardTickUnits(createStandardDateTickUnits()); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setLowerMargin(0.2); yAxis.setUpperMargin(0.2); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseLinesVisible(true); renderer.setSeriesShape(0, new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0)); renderer.setSeriesShape(1, new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0)); renderer.setSeriesStroke(0, new BasicStroke(3.0f)); renderer.setSeriesStroke(1, new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 5.0f, new float[] { 10.0f, 5.0f }, 0.0f)); renderer.setSeriesFillPaint(0, Color.white); renderer.setSeriesFillPaint(1, Color.white); renderer.setUseFillPaint(true); renderer.setDefaultToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6); renderer.addAnnotation(new XYDrawableAnnotation(new Month(4, 2005).getFirstMillisecond(), 600, 180, 100, 3.0, createPieChart())); renderer.addAnnotation(new XYDrawableAnnotation(new Month(9, 2007).getFirstMillisecond(), 1250, 120, 100, 2.0, createBarChart())); plot.setRenderer(renderer); return chart; }
From source file:edu.unc.LCCC.caBIG.DWD.javaCode.visualization.SetUpPlotWindow.java
public static JPanel createXYLineAndShapeRendererChart(XYDataset data, String x, String y, int w, int h) { //XYDataset data = new SampleXYDataset2(); JFreeChart chart = ChartFactory.createScatterPlot(null, // the title of the chart x, // the label for the X axis y, // the label for the Y axis data, // the dataset for the chart PlotOrientation.VERTICAL, // the orientation of the chart true, // a flag specifying whether or not a legend is required true, // a flag specifying whether or not tooltips should be generated false); // a flag specifying whether or not the chart should generate URLs XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setSeriesLinesVisible(1, false); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesLinesVisible(2, true); renderer.setSeriesShapesVisible(2, false); renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6); plot.setRenderer(renderer);//from w ww . ja va2s . com ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(w, h)); return chartPanel; }
From source file:org.jfree.chart.demo.XYDrawableAnnotationDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("XYDrawableAnnotationDemo1", null, "$ million", xydataset, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainPannable(true);//from ww w . j a v a 2s.c o m xyplot.setRangePannable(true); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setLowerMargin(0.20000000000000001D); dateaxis.setUpperMargin(0.20000000000000001D); dateaxis.setStandardTickUnits(createStandardDateTickUnits()); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setLowerMargin(0.20000000000000001D); numberaxis.setUpperMargin(0.20000000000000001D); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseLinesVisible(true); xylineandshaperenderer.setSeriesShape(0, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D)); xylineandshaperenderer.setSeriesShape(1, new java.awt.geom.Ellipse2D.Double(-5D, -5D, 10D, 10D)); xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(3F)); xylineandshaperenderer.setSeriesStroke(1, new BasicStroke(3F, 1, 1, 5F, new float[] { 10F, 5F }, 0.0F)); xylineandshaperenderer.setSeriesFillPaint(0, Color.white); xylineandshaperenderer.setSeriesFillPaint(1, Color.white); xylineandshaperenderer.setUseFillPaint(true); xylineandshaperenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); xylineandshaperenderer.setDefaultEntityRadius(6); xylineandshaperenderer.addAnnotation(new XYDrawableAnnotation((new Month(4, 2005)).getFirstMillisecond(), 600D, 180D, 100D, 3D, createPieChart())); xylineandshaperenderer.addAnnotation(new XYDrawableAnnotation((new Month(9, 2007)).getFirstMillisecond(), 1250D, 120D, 100D, 2D, createBarChart())); xyplot.setRenderer(xylineandshaperenderer); return jfreechart; }
From source file:net.sf.maltcms.common.charts.ui.XYChartComponentOpenAction.java
@Override public void actionPerformed(ActionEvent e) { Task t = RequestProcessor.getDefault().create(new Runnable() { @Override//from w ww .ja v a 2 s . c o m public void run() { final Numeric1DDataset<Point2D> dataset = createDataset(); final XYChartBuilder builder = new XYChartBuilder(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setDefaultEntityRadius(50); NumberAxis domain = new NumberAxis("x-axis"); domain.setLowerBound(-100); domain.setUpperBound(1000); domain.setLowerMargin(0.1); domain.setUpperMargin(0.1); domain.setPositiveArrowVisible(true); domain.setNegativeArrowVisible(true); builder.xy(dataset).renderer(renderer).domainAxis(domain).useBuffer(false).minimumDrawSize(400, 300) .preferredDrawSize(800, 600).plot().chart("Sample plot").createLegend(true); invokeLater(new Runnable() { @Override public void run() { TopComponent tc = WindowManager.getDefault().findTopComponent("navigatorTC"); if (tc != null) { tc.open(); } } }); invokeLater(new Runnable() { @Override public void run() { XYChartTopComponent<Point2D> xytc = new XYChartTopComponent<>(Point2D.class, dataset, builder); xytc.open(); xytc.requestActive(); } }); } }); RequestProcessor.getDefault().post(t); }
From source file:gov.nih.nci.caintegrator.ui.graphing.chart.plot.KaplanMeierPlot.java
private void createChart(XYDataset dataset) { //Create the chart, dropping in the data set JFreeChart chart = ChartFactory.createXYLineChart("", "Days in Study", "Probability of Survival", dataset, PlotOrientation.VERTICAL, false, //legend true, //tooltips false//urls );//from www . j a v a 2 s .c om LegendTitle legend = chart.getLegend(); XYPlot plot = (XYPlot) chart.getPlot(); /******************************************************** * IMPORTANT: * Ideally I would create the actual Renderer settings for * the at the time I start to march through the * KaplanMeierPlotPointSeriesSets, adding them to the actual * Data Set that is going to be going into the Chart plotter. * But you have no idea how they are going to be sitting in * the Plot dataset so there is no guarantee that setting the * renderer based on a supposed index will actually work. In fact * it didn't work when I wrote this. * */ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < finalDataCollection.getSeriesCount(); i++) { KaplanMeierPlotPointSeries kmSeries = (KaplanMeierPlotPointSeries) finalDataCollection.getSeries(i); if (kmSeries.getType() == SeriesType.CENSOR) { renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, true); } else if (kmSeries.getType() == SeriesType.PROBABILITY) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); } else { //don't show this set as it is not a known type renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, false); } renderer.setSeriesPaint(i, getKMSetColor(kmSeries.getKey(), kmSeries.getType()), true); } renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6); plot.setRenderer(renderer); //change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. rangeAxis.setAutoRange(true); rangeAxis.setRange(0.0, 1.0); kmChart = chart; }
From source file:gov.nih.nci.caintegrator.plots.kaplanmeier.JFreeChartIKMPlottermpl.java
public JFreeChart createKMPlot(Collection<GroupCoordinates> groupsToBePlotted, String title, String xAxisLabel, String yAxisLabel) {/*from w ww .j a v a2 s . com*/ List<KMPlotPointSeriesSet> kmPlotSets = new ArrayList<KMPlotPointSeriesSet>( convertToKaplanMeierPlotPointSeriesSet(groupsToBePlotted)); XYSeriesCollection finalDataCollection = new XYSeriesCollection(); /* Repackage all the datasets to go into the XYSeriesCollection */ for (KMPlotPointSeriesSet dataSet : kmPlotSets) { finalDataCollection.addSeries(dataSet.getCensorPlotPoints()); finalDataCollection.addSeries(dataSet.getProbabilityPlotPoints()); } JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, finalDataCollection, PlotOrientation.VERTICAL, true, //legend true, //tooltips false//urls ); XYPlot plot = (XYPlot) chart.getPlot(); /* * Ideally the actual Renderer settings should have been created * at the survivalLength of iterating KaplanMeierPlotPointSeriesSets, adding them to the actual * Data Set that is going to be going into the Chart plotter. But you have no idea how * they are going to be sitting in the Plot dataset so there is no guarantee that setting the * renderer based on a supposed index will actually work. In fact */ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); for (int i = 0; i < finalDataCollection.getSeriesCount(); i++) { KMPlotPointSeries kmSeries = (KMPlotPointSeries) finalDataCollection.getSeries(i); if (kmSeries.getType() == KMPlotPointSeries.SeriesType.CENSOR) { renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, true); renderer.setSeriesShape(i, getCensorShape()); } else if (kmSeries.getType() == KMPlotPointSeries.SeriesType.PROBABILITY) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, false); } else { //don't show this set as it is not a known type renderer.setSeriesLinesVisible(i, false); renderer.setSeriesShapesVisible(i, false); } renderer.setSeriesPaint(i, getKMSetColor(kmPlotSets, kmSeries.getKey(), kmSeries.getType()), true); } renderer.setToolTipGenerator(new StandardXYToolTipGenerator()); renderer.setDefaultEntityRadius(6); plot.setRenderer(renderer); /* change the auto tick unit selection to integer units only... */ NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); /* OPTIONAL CUSTOMISATION COMPLETED. */ rangeAxis.setAutoRange(true); rangeAxis.setRange(0.0, 1.0); /* set Title and Legend */ chart.setTitle(title); createLegend(chart, kmPlotSets); return chart; }