List of usage examples for org.jfree.chart.renderer.xy XYLineAndShapeRenderer setBaseLinesVisible
public void setBaseLinesVisible(boolean flag)
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);// w w w .ja v a 2 s.com 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:org.jfree.graphics2d.demo.SVGChartWithAnnotationsDemo1.java
/** * Creates a sample chart./*from w w w. j a va2 s. co m*/ * * @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:com.javafxpert.neuralnetviz.scenario.PlotUtil.java
private static JFreeChart createChart(XYZDataset dataset, double[] mins, double[] maxs, int nPoints, XYDataset xyData) {/* w ww . j a v a 2 s. c om*/ NumberAxis xAxis = new NumberAxis("X"); xAxis.setRange(mins[0], maxs[0]); NumberAxis yAxis = new NumberAxis("Y"); yAxis.setRange(mins[1], maxs[1]); XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setBlockWidth((maxs[0] - mins[0]) / (nPoints - 1)); renderer.setBlockHeight((maxs[1] - mins[1]) / (nPoints - 1)); PaintScale scale = new GrayPaintScale(0, 1.0); renderer.setPaintScale(scale); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); JFreeChart chart = new JFreeChart("", plot); chart.getXYPlot().getRenderer().setSeriesVisibleInLegend(0, false); NumberAxis scaleAxis = new NumberAxis("Probability (class 0)"); scaleAxis.setAxisLinePaint(Color.white); scaleAxis.setTickMarkPaint(Color.white); scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 7)); PaintScaleLegend legend = new PaintScaleLegend(new GrayPaintScale(), scaleAxis); legend.setStripOutlineVisible(false); legend.setSubdivisionCount(20); legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); legend.setAxisOffset(5.0); legend.setMargin(new RectangleInsets(5, 5, 5, 5)); legend.setFrame(new BlockBorder(Color.red)); legend.setPadding(new RectangleInsets(10, 10, 10, 10)); legend.setStripWidth(10); legend.setPosition(RectangleEdge.LEFT); chart.addSubtitle(legend); ChartUtilities.applyCurrentTheme(chart); plot.setDataset(1, xyData); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(); renderer2.setBaseLinesVisible(false); plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return chart; }
From source file:org.lmn.fc.frameworks.starbase.plugins.observatory.ui.tabs.charts.ChartUIHelper.java
/*********************************************************************************************** * Customise the Plot data renderer to improve legend visibility. * * @param plot/*w ww .ja va 2 s.com*/ * @param rendererindex */ public static void customisePlotRenderer(final XYPlot plot, final int rendererindex) { if (plot != null) { final XYItemRenderer renderer; renderer = plot.getRenderer(rendererindex); if ((renderer != null) && (renderer instanceof XYLineAndShapeRenderer)) { final XYLineAndShapeRenderer xyItemRenderer; xyItemRenderer = (XYLineAndShapeRenderer) renderer; xyItemRenderer.setBaseLinesVisible(true); xyItemRenderer.setBaseShapesVisible(false); xyItemRenderer.setBaseShapesFilled(true); xyItemRenderer.setItemLabelsVisible(true); // Set the shape for the Chart legend items setLegendShape(xyItemRenderer); } } }
From source file:org.jfree.chart.demo.XYBoxAnnotationDemo1.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Breakdowns", "Production Date", "Hours of Operation", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); xylineandshaperenderer.setSeriesShape(0, new Rectangle(2, 2)); xylineandshaperenderer.setSeriesShape(1, new Rectangle(2, 2)); xylineandshaperenderer.setBaseLinesVisible(false); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseToolTipGenerator(null); xylineandshaperenderer.setSeriesPaint(0, Color.blue); xylineandshaperenderer.setSeriesPaint(1, Color.red); xyplot.setDomainGridlineStroke(new BasicStroke(1.0F)); xyplot.setRangeGridlineStroke(new BasicStroke(1.0F)); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setTickUnit(new NumberTickUnit(50000D)); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1)); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM.yy")); dateaxis.setVerticalTickLabels(true); Color color = new Color(255, 0, 0, 60); Color color1 = new Color(0, 255, 0, 60); XYBoxAnnotation xyboxannotation = new XYBoxAnnotation((new Day(1, 1, 2004)).getMiddleMillisecond(), 0.0D, (new Day(31, 1, 2004)).getMiddleMillisecond(), 50000D, new BasicStroke(0.0F), color, color); xyboxannotation.setToolTipText("Value: 2.9"); xylineandshaperenderer.addAnnotation(xyboxannotation); xyboxannotation = new XYBoxAnnotation((new Day(1, 2, 2004)).getMiddleMillisecond(), 0.0D, (new Day(29, 2, 2004)).getMiddleMillisecond(), 50000D, new BasicStroke(0.0F), color, color); xyboxannotation.setToolTipText("Value: 2.5"); xylineandshaperenderer.addAnnotation(xyboxannotation); xyboxannotation = new XYBoxAnnotation((new Day(1, 5, 2004)).getMiddleMillisecond(), 50000D, (new Day(31, 5, 2004)).getMiddleMillisecond(), 100000D, new BasicStroke(0.0F), color, color); xyboxannotation.setToolTipText("Value: 1.8"); xylineandshaperenderer.addAnnotation(xyboxannotation); xyboxannotation = new XYBoxAnnotation((new Day(1, 6, 2005)).getMiddleMillisecond(), 0.0D, (new Day(30, 6, 2005)).getMiddleMillisecond(), 50000D, new BasicStroke(0.0F), color1, color1); xyboxannotation.setToolTipText("Value: 3.7"); xylineandshaperenderer.addAnnotation(xyboxannotation); return jfreechart; }
From source file:figs.Chart.java
public void createChart() { final XYPlot plot = chart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseLinesVisible(false); renderer.setBaseShapesVisible(true); plot.setRenderer(renderer);//from w ww .ja va2 s. com chart.setBackgroundPaint(Color.white); plot.setOutlinePaint(Color.black); }
From source file:jamel.gui.charts.InstantScatterChart.java
/** * Creates a new instant chart.// ww w.j a v a 2 s .com * * @param title the title. * @param xLabel the label of the x series. * @param yLabel the label of the y series. */ public InstantScatterChart(String title, String xLabel, String yLabel) { super(title, null, xLabel, yLabel); this.xLabel = xLabel; this.yLabel = yLabel; final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseLinesVisible(false); renderer.setSeriesPaint(0, new Color(0.3f, 0.3f, 0.3f, 0.5f)); renderer.setSeriesFillPaint(0, new Color(0.3f, 0.3f, 1f, 0.5f)); renderer.setUseFillPaint(true); ((XYPlot) getPlot()).setRenderer(renderer); }
From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo6.java
protected JFreeChart createLegend(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // url );//from www.j a va 2 s .c om // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseLinesVisible(false); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); plot.setRenderer(renderer); return chart; }
From source file:guineu.modules.filter.Alignment.RANSAC.AlignmentRansacPlot.java
public AlignmentRansacPlot() { super(null, true); dataset = new XYSeriesCollection(); chart = ChartFactory.createXYLineChart("", null, null, dataset, PlotOrientation.VERTICAL, true, true, false);/*from w w w . j a va2 s.c o m*/ chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); // legend constructed by ChartFactory legend = chart.getLegend(); legend.setItemFont(legendFont); // legend.setFrame(BlockBorder.NONE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // set default renderer properties XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseLinesVisible(false); renderer.setBaseShapesVisible(true); renderer.setSeriesShape(0, dataPointsShape); renderer.setSeriesShape(1, dataPointsShape); renderer.setSeriesLinesVisible(2, true); renderer.setSeriesShapesVisible(2, false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GRAY); renderer.setSeriesPaint(2, Color.BLUE); renderer.setBaseItemLabelPaint(labelsColor); plot.setRenderer(renderer); }
From source file:net.sf.mzmine.modules.peaklistmethods.alignment.ransac.AlignmentRansacPlot.java
public AlignmentRansacPlot() { super(null, true); dataset = new XYSeriesCollection(); chart = ChartFactory.createXYLineChart("", null, null, dataset, PlotOrientation.VERTICAL, true, true, false);/*from w w w.j ava2 s .c o m*/ chart.setBackgroundPaint(Color.white); setChart(chart); // title chartTitle = chart.getTitle(); chartTitle.setMargin(5, 0, 0, 0); chartTitle.setFont(titleFont); // legend constructed by ChartFactory legend = chart.getLegend(); legend.setItemFont(legendFont); legend.setFrame(BlockBorder.NONE); // set the plot properties plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // set grid properties plot.setDomainGridlinePaint(gridColor); plot.setRangeGridlinePaint(gridColor); // set crosshair (selection) properties plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(crossHairColor); plot.setRangeCrosshairPaint(crossHairColor); plot.setDomainCrosshairStroke(crossHairStroke); plot.setRangeCrosshairStroke(crossHairStroke); // set default renderer properties XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setBaseLinesVisible(false); renderer.setBaseShapesVisible(true); renderer.setSeriesShape(0, dataPointsShape); renderer.setSeriesShape(1, dataPointsShape); renderer.setSeriesLinesVisible(2, true); renderer.setSeriesShapesVisible(2, false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, Color.GRAY); renderer.setSeriesPaint(2, Color.BLUE); renderer.setBaseItemLabelPaint(labelsColor); plot.setRenderer(renderer); }