List of usage examples for org.jfree.chart.plot XYPlot setDomainGridlinePaint
public void setDomainGridlinePaint(Paint paint)
From source file:org.matsim.contrib.socnetsim.usage.analysis.CourtesyHistogramListener.java
static JFreeChart getGraphic(final CourtesyHistogram.DataFrame dataFrame, int iteration, String actType) { final XYSeriesCollection xyData = new XYSeriesCollection(); final XYSeries helloSeries = new XYSeries("hello", false, true); final XYSeries goodbyeSerie = new XYSeries("goodbye", false, true); final XYSeries togetherSerie = new XYSeries("pairs together", false, true); int together = 0; for (int i = 0; i < dataFrame.countsHello.length; i++) { together = together + dataFrame.countsHello[i] - dataFrame.countsGoodbye[i]; double hour = i * dataFrame.binSize / 60.0 / 60.0; helloSeries.add(hour, dataFrame.countsHello[i]); goodbyeSerie.add(hour, dataFrame.countsGoodbye[i]); togetherSerie.add(hour, together); }/*from w w w. ja va 2 s. c om*/ xyData.addSeries(helloSeries); xyData.addSeries(goodbyeSerie); xyData.addSeries(togetherSerie); final JFreeChart chart = ChartFactory.createXYStepChart( "Courtesy Statistics," + "actType " + actType + " it." + iteration, "time", "# persons", xyData, PlotOrientation.VERTICAL, true, // legend false, // tooltips false // urls ); XYPlot plot = chart.getXYPlot(); final CategoryAxis axis1 = new CategoryAxis("hour"); axis1.setTickLabelFont(new Font("SansSerif", Font.PLAIN, 7)); plot.setDomainAxis(new NumberAxis("time")); plot.getRenderer().setSeriesStroke(0, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(1, new BasicStroke(2.0f)); plot.getRenderer().setSeriesStroke(2, new BasicStroke(2.0f)); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.gray); plot.setDomainGridlinePaint(Color.gray); return chart; }
From source file:org.gumtree.vis.awt.PlotFactory.java
public static JFreeChart createXYErrorChart(IXYErrorDataset dataset) { JFreeChart chart;//from w w w . j a v a 2 s . c o m String title = null; String xTitle = null; String yTitle = null; if (dataset != null) { title = ""; if (dataset.getTitle() != null) { title = dataset.getTitle(); } xTitle = ""; if (dataset.getXTitle() != null) { xTitle += dataset.getXTitle(); } if (dataset.getXUnits() != null) { xTitle += " (" + dataset.getXUnits() + ")"; } yTitle = ""; if (dataset.getYTitle() != null) { yTitle += dataset.getYTitle(); } if (dataset.getYUnits() != null) { yTitle += " (" + dataset.getYUnits() + ")"; } } else { dataset = new XYErrorDataset(); } chart = createXYLineChart(title, xTitle, yTitle, dataset, PlotOrientation.VERTICAL, true, false, true); chart.setBackgroundPaint(Color.WHITE); final LegendTitle legend = (LegendTitle) chart.getLegend(); RectangleEdge legendPosition = RectangleEdge.BOTTOM; try { String legendProperty = "RectangleEdge." + System.getProperty("kuranda1D.legendPosition"); if (RectangleEdge.BOTTOM.toString().equals(legendProperty)) legendPosition = RectangleEdge.BOTTOM; else if (RectangleEdge.RIGHT.toString().equals(legendProperty)) legendPosition = RectangleEdge.RIGHT; else if (RectangleEdge.LEFT.toString().equals(legendProperty)) legendPosition = RectangleEdge.LEFT; else if (RectangleEdge.TOP.toString().equals(legendProperty)) legendPosition = RectangleEdge.TOP; } catch (Exception e) { // TODO: handle exception } legend.setPosition(legendPosition); chart.setBorderVisible(true); // ChartUtilities.applyCurrentTheme(chart); // chartTheme.apply(chart); XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); // plot.setRangeZeroBaselineVisible(false); // plot.setDomainZeroBaselineVisible(false); ValueAxis rangeAxis = plot.getRangeAxis(); if (rangeAxis instanceof NumberAxis) { ((NumberAxis) rangeAxis).setAutoRangeStickyZero(false); ((NumberAxis) rangeAxis).setAutoRangeIncludesZero(false); } ValueAxis domainAxis = plot.getDomainAxis(); if (domainAxis instanceof NumberAxis) { ((NumberAxis) domainAxis).setAutoRangeStickyZero(false); ((NumberAxis) domainAxis).setAutoRangeIncludesZero(false); } plot.setDomainPannable(true); plot.setRangePannable(true); plot.setDomainGridlinesVisible(true); // plot.setDomainCrosshairLockedOnData(true); // plot.setDomainCrosshairVisible(true); plot.setRangeGridlinesVisible(true); // plot.setRangeCrosshairLockedOnData(true); // plot.setRangeCrosshairVisible(true); // xAxis = plot.getDomainAxis(); // yAxis = plot.getRangeAxis(); plot.setDataset(dataset); XYItemRenderer renderer = chart.getXYPlot().getRenderer(); if (renderer instanceof XYErrorRenderer) { // ((XYLineAndShapeRenderer) renderer).setBaseShapesVisible(true); ((XYErrorRenderer) renderer).setBaseShapesFilled(true); ((XYErrorRenderer) renderer).setDrawXError(false); ((XYErrorRenderer) renderer).setDrawYError(true); } chart.fireChartChanged(); return chart; }
From source file:org.xapagy.ui.tempdyn.GraphEvolution.java
/** * Creates a chart the style we like./* w w w . jav a 2 s .c om*/ * * @param chart */ public static void setChartProperties(JFreeChart chart, List<SimpleEntry<Color, Stroke>> lineStyles) { // set the background and title font chart.setBackgroundPaint(Color.white); chart.getTitle().setFont(new Font("Tahoma", Font.BOLD, 14)); // set the background and the grid all white XYPlot plot = chart.getXYPlot(); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setBackgroundPaint(Color.white); // now plot.setOutlineStroke(null); XYItemRenderer rend = plot.getRenderer(); Stroke stroke = new BasicStroke(2.0f); rend.setBaseStroke(stroke); // rend.setDrawSeriesLineAsPath(true); // stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, // BasicStroke.JOIN_ROUND, 10, new float[] {10, 10}, 0); // strokes.add(stroke); // stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, // BasicStroke.JOIN_ROUND, 10, new float[] {2, 4}, 0); // strokes.add(stroke); int seriesCount = plot.getSeriesCount(); for (int i = 0; i != seriesCount; i++) { SimpleEntry<Color, Stroke> lineStyle = lineStyles.get(i % lineStyles.size()); rend.setSeriesStroke(i, lineStyle.getValue()); rend.setSeriesPaint(i, lineStyle.getKey()); } }
From source file:ioheater.ui.IOHeaterUI.java
/** * Creates a chart.//from ww w .ja v a2 s . com * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Temperature Trend", // title "Time (m:s)", // x-axis label "Temperature (C)", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("H:mm:ss")); return chart; }
From source file:org.jfree.chart.demo.QuarterDateFormatDemo.java
private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", "Date", "Price Per Unit", xydataset, true, true, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); PeriodAxis periodaxis = new PeriodAxis("Quarter", new Quarter(), new Quarter()); periodaxis.setAutoRangeTimePeriodClass(org.jfree.data.time.Quarter.class); PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[1]; aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Quarter.class, new QuarterDateFormat(TimeZone.getDefault(), QuarterDateFormat.ROMAN_QUARTERS)); periodaxis.setLabelInfo(aperiodaxislabelinfo); xyplot.setDomainAxis(periodaxis);// ww w . j ava 2s . co m xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); } return jfreechart; }
From source file:org.mwc.debrief.sensorfusion.views.DataSupport.java
/** * Creates a chart./*from ww w . ja v a 2s .com*/ * * @param dataset * a dataset. * * @return A chart. */ public static JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("Bearing Management", // title "Time", // x-axis label "Bearing", // y-axis label dataset, // data false, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(0, 0, 0, 0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setOrientation(PlotOrientation.HORIZONTAL); final XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("HH:mm.ss")); return chart; }
From source file:scrum.server.common.BurndownChart.java
private static JFreeChart createSprintBurndownChart(List<BurndownSnapshot> snapshots, Date firstDay, Date lastDay, Date originallyLastDay, WeekdaySelector freeDays, int dateMarkTickUnit, float widthPerDay) { DefaultXYDataset data = createSprintBurndownChartDataset(snapshots, firstDay, lastDay, originallyLastDay, freeDays);//from w ww . java2 s. c o m double tick = 1.0; double max = BurndownChart.getMaximum(data); while (max / tick > 25) { tick *= 2; if (max / tick <= 25) break; tick *= 2.5; if (max / tick <= 25) break; tick *= 2; } double valueLabelTickUnit = tick; double upperBoundary = Math.min(max * 1.1f, max + 3); if (!Sys.isHeadless()) LOG.warn("GraphicsEnvironment is not headless"); JFreeChart chart = ChartFactory.createXYLineChart("", "", "", data, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.WHITE); XYPlot plot = chart.getXYPlot(); // plot.setInsets(new RectangleInsets(0, 0, 0, 0)); plot.setAxisOffset(RectangleInsets.ZERO_INSETS); // plot.setOutlineVisible(false); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.lightGray); plot.setDomainGridlinePaint(Color.lightGray); // plot.setRangeCrosshairPaint(Color.lightGray); // plot.setRangeMinorGridlinePaint(Color.lightGray); // plot.setDomainCrosshairPaint(Color.blue); // plot.setDomainMinorGridlinePaint(Color.green); // plot.setDomainTickBandPaint(Color.green); XYItemRenderer renderer = plot.getRenderer(); renderer.setBaseStroke(new BasicStroke(2f)); renderer.setSeriesPaint(0, COLOR_PAST_LINE); renderer.setSeriesStroke(0, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); renderer.setSeriesPaint(1, COLOR_PROJECTION_LINE); renderer.setSeriesStroke(1, new BasicStroke(1.5f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL, 1.0f, new float[] { 3f }, 0)); renderer.setSeriesPaint(2, COLOR_OPTIMUM_LINE); renderer.setSeriesStroke(2, new BasicStroke(2f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL)); DateAxis domainAxis1 = new DateAxis(); String dateFormat = "d."; widthPerDay -= 5; if (widthPerDay > 40) { dateFormat = "EE " + dateFormat; } if (widthPerDay > 10) { float spaces = widthPerDay / 2.7f; dateFormat = Str.multiply(" ", (int) spaces) + dateFormat; } domainAxis1.setDateFormatOverride(new SimpleDateFormat(dateFormat, Locale.US)); domainAxis1.setTickUnit(new DateTickUnit(DateTickUnit.DAY, dateMarkTickUnit)); domainAxis1.setAxisLineVisible(false); Range range = new Range(firstDay.toMillis(), lastDay.nextDay().toMillis()); domainAxis1.setRange(range); DateAxis domainAxis2 = new DateAxis(); domainAxis2.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 1)); domainAxis2.setTickMarksVisible(false); domainAxis2.setTickLabelsVisible(false); domainAxis2.setRange(range); plot.setDomainAxis(0, domainAxis2); plot.setDomainAxis(1, domainAxis1); plot.setDomainAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setNumberFormatOverride(NumberFormat.getIntegerInstance()); rangeAxis.setTickUnit(new NumberTickUnit(valueLabelTickUnit)); rangeAxis.setLowerBound(0); rangeAxis.setUpperBound(upperBoundary); plot.setRangeAxis(rangeAxis); return chart; }
From source file:net.sf.mzmine.chartbasics.HistogramChartFactory.java
public static JFreeChart createHistogramOld(double[] data, int bin, String yAxisLabel, double min, double max) { if (data != null && data.length > 0) { HistogramDataset dataset = new HistogramDataset(); dataset.addSeries("histo", data, bin, min, max); JFreeChart chart = ChartFactory.createHistogram("", yAxisLabel, "n", dataset, PlotOrientation.VERTICAL, true, false, false);// w w w . ja v a 2 s . com chart.setBackgroundPaint(new Color(230, 230, 230)); chart.getLegend().setVisible(false); XYPlot xyplot = chart.getXYPlot(); xyplot.setForegroundAlpha(0.7F); xyplot.setBackgroundPaint(Color.WHITE); xyplot.setDomainGridlinePaint(new Color(150, 150, 150)); xyplot.setRangeGridlinePaint(new Color(150, 150, 150)); xyplot.getDomainAxis().setVisible(true); xyplot.getRangeAxis().setVisible(yAxisLabel != null); XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer(); xybarrenderer.setShadowVisible(false); xybarrenderer.setBarPainter(new StandardXYBarPainter()); // xybarrenderer.setDrawBarOutline(false); return chart; } else return null; }
From source file:org.hxzon.demo.jfreechart.XYDatasetDemo2.java
private static JFreeChart createHighLowChart(XYDataset dataset) { ValueAxis timeAxis = new DateAxis(xAxisLabel); NumberAxis valueAxis = new NumberAxis(yAxisLabel); HighLowRenderer renderer = new HighLowRenderer(); renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); JFreeChart chart = new JFreeChart("HighLow Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); return chart; }
From source file:org.hxzon.demo.jfreechart.OtherDatasetDemo.java
private static JFreeChart createWindChart(WindDataset dataset) { ValueAxis xAxis = new DateAxis(xAxisLabel); ValueAxis yAxis = new NumberAxis("Direction / Force"); yAxis.setRange(-12.0, 12.0);/* w ww . j a va 2 s. co m*/ WindItemRenderer renderer = new WindItemRenderer(); if (tooltips) { renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); } if (urls) { renderer.setURLGenerator(new StandardXYURLGenerator()); } XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); JFreeChart chart = new JFreeChart("Wind Chart Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, legend); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); return chart; }