List of usage examples for org.jfree.chart.plot XYPlot setBackgroundPaint
public void setBackgroundPaint(Paint paint)
From source file:presentationGui.GraphFrame.java
/** * Creates a chart./*from w ww . ja v a2 s . c om*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Comportamento Asintotico del throughput", // chart title "numero job", // x axis label "throughput", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... /*final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits());*/ // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.jfree.chart.demo.TimeSeriesDemo13.java
/** * Creates a chart./*from w ww. j a v a 2s . co m*/ * * @param dataset a dataset. * * @return A chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Weekly Data", "Date", "Value", dataset, true, true, false); chart.setBackgroundPaint(Color.white); // final StandardLegend sl = (StandardLegend) chart.getLegend(); // sl.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer renderer = plot.getRenderer(); if (renderer instanceof StandardXYItemRenderer) { final StandardXYItemRenderer rr = (StandardXYItemRenderer) renderer; rr.setPlotShapes(true); rr.setShapesFilled(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); final TickUnits standardUnits = new TickUnits(); standardUnits.add(new DateTickUnit(DateTickUnit.DAY, 1, new SimpleDateFormat("MMM dd ''yy"))); standardUnits.add(new DateTickUnit(DateTickUnit.DAY, 7, new SimpleDateFormat("MMM dd ''yy"))); standardUnits.add(new DateTickUnit(DateTickUnit.MONTH, 1, new SimpleDateFormat("MMM ''yy"))); axis.setStandardTickUnits(standardUnits); return chart; }
From source file:br.prof.salesfilho.oci.image.GraphicBuilder.java
public void createChart() { chart = ChartFactory.createXYLineChart(this.title, this.xLabel, this.yLabel, this.collectionDataset, PlotOrientation.VERTICAL, true, true, false); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); List<XYSeries> listSeries = collectionDataset.getSeries(); for (int i = 0; i < listSeries.size(); i++) { renderer.setSeriesLinesVisible(i, true); renderer.setSeriesShapesVisible(i, true); renderer.setSeriesShapesFilled(i, false); }//from ww w .ja v a 2s. c om plot.setRenderer(renderer); plot.setRangePannable(true); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chartPanel.setChart(chart); }
From source file:com.hello2morrow.sonargraph.jenkinsplugin.model.AbstractPlot.java
private void applyStandardPlotColors(XYPlot plot) { plot.setBackgroundPaint(BACK_GROUND_COLOR); plot.setRangeGridlinePaint(GRID_LINE_COLOR); }
From source file:LineChartDemo6.java
/** * Creates a chart./*from w w w.ja va 2 s .co m*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Line Chart Demo 6", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); //renderer.setSeriesLinesVisible(0, false); //renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:org.jfree.chart.demo.CrosshairDemo1.java
/** * Creates a chart./*from ww w . j a va2 s . c o m*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createXYLineChart("Crosshair Demo 1", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(true); plot.setDomainCrosshairLockedOnData(true); plot.setRangeCrosshairVisible(true); plot.setRangeCrosshairLockedOnData(true); final StandardXYItemRenderer renderer = (StandardXYItemRenderer) plot.getRenderer(); renderer.setPlotShapes(true); renderer.setShapesFilled(true); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:net.sf.profiler4j.console.AllocDiffPanel.java
public AllocDiffPanel(int maxAgeMillis) { super(new BorderLayout()); totalSeries = new TimeSeries("Allocs/Sec", Millisecond.class); totalSeries.setMaximumItemAge(maxAgeMillis); TimeSeriesCollection seriesCollection = new TimeSeriesCollection(); seriesCollection.addSeries(totalSeries); NumberAxis numberAxis = new NumberAxis("Allocs/Sec"); numberAxis.setLabelFont(new Font("SansSerif", 0, 14)); numberAxis.setTickLabelFont(new Font("SansSerif", 0, 12)); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); DateAxis dateAxis = new DateAxis("Time"); dateAxis.setTickLabelFont(new Font("SansSerif", 0, 12)); dateAxis.setLabelFont(new Font("SansSerif", 0, 14)); dateAxis.setAutoRange(true);//www. jav a2 s .c om dateAxis.setLowerMargin(0); dateAxis.setUpperMargin(0); dateAxis.setTickLabelsVisible(true); dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); lineRenderer.setSeriesPaint(0, Color.RED); lineRenderer.setSeriesPaint(1, Color.GREEN.darker()); lineRenderer.setStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY); xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart chart = new JFreeChart("Object Allocactions in Remote JVM", new Font("SansSerif", Font.PLAIN, 18), xyplot, true); chart.setBackgroundPaint(Color.white); ChartPanel panel = new ChartPanel(chart); panel.setBorder(createCompoundBorder(createEmptyBorder(8, 8, 8, 8), createLineBorder(Color.LIGHT_GRAY))); add(panel); setBorder(createEmptyBorder(8, 8, 8, 8)); }
From source file:edu.ucla.stat.SOCR.chart.demo.CrosshairDemo4.java
/** * Creates a chart./*from ww w . j a va 2 s . co m*/ * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title domainLabel, // x axis label rangeLabel, // y axis label dataset, // data PlotOrientation.VERTICAL, !legendPanelOn, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); setXSummary(dataset); return chart; }
From source file:eu.choreos.chart.XYChart.java
private JFreeChart createChart(XYDataset dataset, String chartTitle) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title "Execution size", // domain axis label "Range", // range axis label dataset, // initial series PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );// w w w . jav a 2s .c om // set chart background chart.setBackgroundPaint(Color.white); // set a few custom plot features XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // set the plot's axes to display integers TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setStandardTickUnits(ticks); domain.resizeRange(1.1); domain.setLowerBound(0.5); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setStandardTickUnits(ticks); range.setUpperBound(range.getUpperBound() * 1.1); // render shapes and lines XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true); plot.setRenderer(renderer); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // set the renderer's stroke Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); renderer.setBaseOutlineStroke(stroke); // label the points NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(2); XYItemLabelGenerator generator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); return chart; }
From source file:net.sf.profiler4j.console.MemoryPlotPanel.java
public MemoryPlotPanel(int maxAge, String title) { super(new BorderLayout()); totalSeries = new TimeSeries("Committed Memory", Millisecond.class); totalSeries.setMaximumItemAge(maxAge); usedSeries = new TimeSeries("Used Memory", Millisecond.class); usedSeries.setMaximumItemAge(maxAge); TimeSeriesCollection seriesCollection = new TimeSeriesCollection(); seriesCollection.addSeries(totalSeries); seriesCollection.addSeries(usedSeries); NumberAxis numberAxis = new NumberAxis("Memory (KB)"); numberAxis.setLabelFont(new Font("SansSerif", 0, 14)); numberAxis.setTickLabelFont(new Font("SansSerif", 0, 12)); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); DateAxis dateAxis = new DateAxis("Time"); dateAxis.setTickLabelFont(new Font("SansSerif", 0, 12)); dateAxis.setLabelFont(new Font("SansSerif", 0, 14)); dateAxis.setAutoRange(true);/* w w w . j a v a 2 s. c o m*/ dateAxis.setLowerMargin(0); dateAxis.setUpperMargin(0); dateAxis.setTickLabelsVisible(true); dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss")); XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false); lineRenderer.setSeriesPaint(0, Color.RED); lineRenderer.setSeriesPaint(1, Color.GREEN.darker()); lineRenderer.setStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY); xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); JFreeChart chart = new JFreeChart(title, new Font("SansSerif", Font.PLAIN, 14), xyplot, true); chart.setBackgroundPaint(Color.white); ChartPanel panel = new ChartPanel(chart); panel.setBorder(createCompoundBorder(createEmptyBorder(8, 8, 8, 8), createLineBorder(Color.LIGHT_GRAY))); add(panel); setBorder(createEmptyBorder(8, 8, 8, 8)); }