List of usage examples for org.jfree.chart.plot XYPlot setRenderer
public void setRenderer(int index, XYItemRenderer renderer)
From source file:playground.dgrether.analysis.charts.DgAvgDeltaMoneyGroupChart.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]"); ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Money [Chf]"); plot.setDomainAxis(xAxis);/*from w ww. j a v a 2s. c o m*/ plot.setRangeAxis(yAxis); DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); renderer2.setSeriesItemLabelsVisible(0, true); renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator); plot.setDataset(0, this.dataset); renderer2.setSeriesStroke(0, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(0, new BasicStroke(3.0f)); renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a")); plot.setRenderer(0, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); return chart; }
From source file:org.jfree.eastwood.ChartEngine.java
/** * The 'ewtr' tag is an Eastwood extension that draws a trend line over a * chart, using data that has been added to a secondary dataset using the * 'ewd2' tag.// w ww. j av a2s . com * * @param params the chart parameters; * @param chart the chart under construction (will be updated by this * method if necessary). */ public static void processEWTR(Map params, JFreeChart chart) { // the 'ewtr' arguments are: // - <seriesIndex> : the index of the series in the secondary dataset; // - <colour> : the colour; // - <lineThickness> : the line thickness; String[] ewtrStr = (String[]) params.get("ewtr"); if (ewtrStr != null) { String[] atts = ewtrStr[0].split(","); int series = Integer.parseInt(atts[0]); Color color = parseColor(atts[1]); float lineWidth = Float.parseFloat(atts[2]); Plot plot = chart.getPlot(); if (plot instanceof CategoryPlot) { CategoryPlot cp = (CategoryPlot) plot; if (cp.getDataset(1) != null) { LineAndShapeRenderer r = new LineAndShapeRenderer(true, false); r.setBaseSeriesVisible(false); r.setSeriesVisible(series, Boolean.TRUE); r.setSeriesPaint(series, color); r.setSeriesStroke(series, new BasicStroke(lineWidth)); cp.setRenderer(1, r); cp.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); } } else if (plot instanceof XYPlot) { XYPlot xp = (XYPlot) plot; if (xp.getDataset(1) != null) { XYLineAndShapeRenderer r = new XYLineAndShapeRenderer(true, false); r.setBaseSeriesVisible(false); r.setSeriesVisible(series, Boolean.TRUE); r.setSeriesPaint(series, color); r.setSeriesStroke(series, new BasicStroke(lineWidth)); xp.setRenderer(1, r); xp.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); } } } }
From source file:com.graphhopper.jsprit.analysis.toolbox.Plotter.java
private XYPlot createPlot(final XYSeriesCollection problem, XYSeriesCollection shipments, XYSeriesCollection solution) {/* www.j a v a 2s . c o m*/ XYPlot plot = new XYPlot(); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); XYLineAndShapeRenderer problemRenderer = getProblemRenderer(problem); plot.setDataset(0, problem); plot.setRenderer(0, problemRenderer); XYItemRenderer shipmentsRenderer = getShipmentRenderer(shipments); plot.setDataset(1, shipments); plot.setRenderer(1, shipmentsRenderer); if (solution != null) { XYItemRenderer solutionRenderer = getRouteRenderer(solution); plot.setDataset(2, solution); plot.setRenderer(2, solutionRenderer); } NumberAxis xAxis = new NumberAxis(); NumberAxis yAxis = new NumberAxis(); if (boundingBox == null) { xAxis.setRangeWithMargins(getDomainRange(problem)); yAxis.setRangeWithMargins(getRange(problem)); } else { xAxis.setRangeWithMargins(new Range(boundingBox.minX, boundingBox.maxX)); yAxis.setRangeWithMargins(new Range(boundingBox.minY, boundingBox.maxY)); } plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis); return plot; }
From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java
private void addSeries(Series<?> series) { Unit unit = series.getUnit();/*from w w w . j av a 2s . c om*/ XYPlot plot = chart.getXYPlot(); Integer datasetIndex = datasetMapping.get(unit); TimeSeriesCollection col; if (datasetIndex == null) { col = new TimeSeriesCollection(); int nextIndex = getNextDatasetIndex(plot); datasetMapping.put(unit, nextIndex); plot.setDataset(nextIndex, col); plot.setRenderer(nextIndex, new XYLineAndShapeRenderer(true, false)); NumberAxis axis = new AutoNumberAxis(unit); plot.setRangeAxis(nextIndex, axis); plot.mapDatasetToRangeAxis(nextIndex, nextIndex); seriesMapping.put(unit, new ArrayList<String>()); } else { col = (TimeSeriesCollection) plot.getDataset(datasetIndex); } TimeSeries ts = new SeriesWrapper(series, sampler); seriesMapping.get(unit).add(series.getKey()); col.addSeries(ts); setColor(series.getKey(), palette.allocate()); }
From source file:playground.dgrether.analysis.charts.DgAvgDeltaUtilsGroupChart.java
public JFreeChart createChart() { XYPlot plot = new XYPlot(); ValueAxis xAxis = this.axisBuilder.createValueAxis("Income [Chf / Year]"); ValueAxis yAxis = this.axisBuilder.createValueAxis("Delta Utils [Utils]"); plot.setDomainAxis(xAxis);//from www . ja v a 2 s .c o m plot.setRangeAxis(yAxis); DgColorScheme colorScheme = new DgColorScheme(); XYItemRenderer renderer2; renderer2 = new XYLineAndShapeRenderer(true, true); renderer2.setSeriesItemLabelsVisible(0, true); renderer2.setSeriesItemLabelGenerator(0, this.labelGenerator); plot.setDataset(0, this.dataset); renderer2.setSeriesStroke(0, new BasicStroke(2.0f)); renderer2.setSeriesOutlineStroke(0, new BasicStroke(3.0f)); renderer2.setSeriesPaint(0, colorScheme.getColor(1, "a")); plot.setRenderer(0, renderer2); JFreeChart chart = new JFreeChart("", plot); chart.setBackgroundPaint(ChartColor.WHITE); chart.getLegend().setItemFont(this.axisBuilder.getAxisFont()); chart.setTextAntiAlias(true); return chart; }
From source file:cn.InstFS.wkr.NetworkMining.UIs.TimeSeriesChart1.java
public static JFreeChart createChart2(ArrayList<DataItems> _nor_model, ArrayList<DataItems> _abnor_model, DataItems nor, DataItems abnor, Map<String, ArrayList<LinePos>> mapAB, String chartname, String protocol1, String protocol2) { XYDataset xydataset = createNormalDataset(nor, protocol1); JFreeChart jfreechart = ChartFactory.createXYLineChart(chartname, "", "", xydataset); jfreechart.getLegend().setVisible(false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); NumberAxis numberaxis = (NumberAxis) xyplot.getRangeAxis(); numberaxis.setAutoRangeIncludesZero(false); java.awt.geom.Ellipse2D.Double double1 = new java.awt.geom.Ellipse2D.Double(-4D, -4D, 6D, 6D); XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); // ??/*w ww . j av a2 s. c om*/ xylineandshaperenderer.setSeriesLinesVisible(0, true); xylineandshaperenderer.setBaseShapesVisible(false); xylineandshaperenderer.setSeriesShape(0, double1); xylineandshaperenderer.setSeriesPaint(0, Color.blue); xylineandshaperenderer.setSeriesFillPaint(0, Color.blue); xylineandshaperenderer.setSeriesOutlinePaint(0, Color.blue); xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(0.5F)); // ? // xylineandshaperenderer.setBaseItemLabelGenerator(new // StandardXYItemLabelGenerator()); // xylineandshaperenderer.setBaseItemLabelsVisible(true); int datasetcount0 = xyplot.getDatasetCount(); XYDataset xydataset1 = createNormalDataset(abnor, protocol2); // xydataset1. XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer(); int datasetcount = xyplot.getDatasetCount(); xyplot.setDataset(datasetcount, xydataset1); xyplot.setRenderer(datasetcount, xylineandshaperenderer1); // ??? xylineandshaperenderer1.setBaseShapesVisible(false); // ?? xylineandshaperenderer1.setSeriesLinesVisible(0, true); xylineandshaperenderer1.setSeriesShape(0, double1); // xylineandshaperenderer1.setSeriesPaint(0, Color.green); xylineandshaperenderer1.setSeriesFillPaint(0, Color.green); xylineandshaperenderer1.setSeriesOutlinePaint(0, Color.green); xylineandshaperenderer1.setUseFillPaint(true); xylineandshaperenderer1.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); xylineandshaperenderer1.setSeriesStroke(0, new BasicStroke(0.5F)); // //? /* * for (int i = 0; i < _nor_model.size(); i++) { XYDataset xydataset2 = * createmodeDataset(_nor_model.get(i), "_nor_model" + i); * XYLineAndShapeRenderer xylineandshaperenderer2 = new * XYLineAndShapeRenderer(); xyplot.setDataset(i + 2, xydataset2); * xyplot.setRenderer(2 + i, xylineandshaperenderer2); // ??? * xylineandshaperenderer2.setBaseShapesVisible(false); // ?? * xylineandshaperenderer2.setSeriesLinesVisible(0, true); * xylineandshaperenderer2.setSeriesShape(0, double1); // * xylineandshaperenderer2.setSeriesPaint(0, Color.red); * xylineandshaperenderer2.setSeriesFillPaint(0, Color.red); * xylineandshaperenderer2.setSeriesOutlinePaint(0, Color.red); * xylineandshaperenderer2.setUseFillPaint(true); * xylineandshaperenderer2 .setBaseItemLabelGenerator(new * StandardXYItemLabelGenerator()); * xylineandshaperenderer2.setSeriesStroke(0, new BasicStroke(2.5F)); * * } for (int i = 0; i < _abnor_model.size(); i++) { XYDataset * xydataset3 = createmodeDataset(_abnor_model.get(i), "_abnor_model" + * i); XYLineAndShapeRenderer xylineandshaperenderer3 = new * XYLineAndShapeRenderer(); xyplot.setDataset(i + 2 + * _nor_model.size(), xydataset3); xyplot.setRenderer(i + 2 + * _nor_model.size(), xylineandshaperenderer3); // ??? * xylineandshaperenderer3.setBaseShapesVisible(false); // ?? * xylineandshaperenderer3.setSeriesLinesVisible(0, true); * xylineandshaperenderer3.setSeriesShape(0, double1); // * xylineandshaperenderer3.setSeriesPaint(0, Color.red); * xylineandshaperenderer3.setSeriesFillPaint(0, Color.red); * xylineandshaperenderer3.setSeriesOutlinePaint(0, Color.red); * xylineandshaperenderer3.setUseFillPaint(true); * xylineandshaperenderer3 .setBaseItemLabelGenerator(new * StandardXYItemLabelGenerator()); * xylineandshaperenderer3.setSeriesStroke(0, new BasicStroke(2.5F)); * * } */ // ?? // // ///////////////////////////////// // ? XYDataset xydataset4 = createLineDataset(nor, abnor, mapAB, xyplot); // ??y=1 ValueMarker valuemarker = new ValueMarker(1); // valuemarker.setLabelOffsetType(LengthAdjustmentType.EXPAND); valuemarker.setPaint(Color.black); // ? valuemarker.setStroke(new BasicStroke(1.0F)); // // valuemarker.setLabel(""); //? valuemarker.setLabelFont(new Font("SansSerif", 0, 11)); // ? valuemarker.setLabelPaint(Color.red); valuemarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); valuemarker.setLabelTextAnchor(TextAnchor.BOTTOM_LEFT); xyplot.addRangeMarker(valuemarker); // // //jfreechart.getLegend().setVisible(true); return jfreechart; }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputScatter.java
@Override protected void clearDataSet(final IScope scope) { // TODO Auto-generated method stub super.clearDataSet(scope); final XYPlot plot = (XYPlot) this.chart.getPlot(); for (int i = plot.getDatasetCount() - 1; i >= 1; i--) { plot.setDataset(i, null);/*w ww .j a va 2s .c o m*/ plot.setRenderer(i, null); } ((XYIntervalSeriesCollection) jfreedataset.get(0)).removeAllSeries(); jfreedataset.clear(); jfreedataset.add(0, new XYIntervalSeriesCollection()); plot.setDataset((XYIntervalSeriesCollection) jfreedataset.get(0)); plot.setRenderer(0, null); IdPosition.clear(); }
From source file:ca.nengo.plot.impl.DefaultPlotter.java
/** * @see ca.nengo.plot.Plotter#doPlot(ca.nengo.util.TimeSeries, ca.nengo.util.TimeSeries, java.lang.String) *//*w w w . j a v a 2 s.c o m*/ public void doPlot(TimeSeries ideal, TimeSeries actual, String title) { XYSeriesCollection idealDataset = getDataset(ideal); XYSeriesCollection actualDataset = getDataset(actual); JFreeChart chart = ChartFactory.createXYLineChart(title, "Time (s)", "", idealDataset, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDataset(1, actualDataset); XYLineAndShapeRenderer idealRenderer = new XYLineAndShapeRenderer(true, false); idealRenderer.setDrawSeriesLineAsPath(true); idealRenderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10f, new float[] { 10f, 10f }, 0f)); plot.setRenderer(plot.indexOf(idealDataset), idealRenderer); XYLineAndShapeRenderer actualRenderer = new XYLineAndShapeRenderer(true, false); actualRenderer.setDrawSeriesLineAsPath(true); //idealRenderer.setStroke(new BasicStroke(1f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 10f, new float[]{10f, 10f}, 0f)); plot.setRenderer(plot.indexOf(actualDataset), actualRenderer); showChart(chart, "Time Series Plot"); }
From source file:ucar.unidata.idv.control.chart.ChartHolder.java
/** * add data set/*from w w w. ja va 2 s . c o m*/ * * @param dataset dataset * @param rangeAxis axis * @param renderer renderer * @param side which side */ protected void add(XYDataset dataset, ValueAxis rangeAxis, XYItemRenderer renderer, AxisLocation side) { synchronized (chartManager.getMutex()) { XYPlot xyPlot = (XYPlot) plot; xyPlot.setRangeAxis(paramCount, rangeAxis, false); xyPlot.setDataset(paramCount, dataset); xyPlot.mapDatasetToRangeAxis(paramCount, paramCount); xyPlot.setRenderer(paramCount, renderer); if (side != null) { xyPlot.setRangeAxisLocation(paramCount, side); } paramCount++; } }
From source file:org.optaplanner.benchmark.impl.report.BenchmarkReport.java
private XYPlot createScalabilityPlot(List<XYSeries> seriesList, String xAxisLabel, NumberFormat xAxisNumberFormat, String yAxisLabel, NumberFormat yAxisNumberFormat) { NumberAxis xAxis = new NumberAxis(xAxisLabel); xAxis.setNumberFormatOverride(xAxisNumberFormat); NumberAxis yAxis = new NumberAxis(yAxisLabel); yAxis.setNumberFormatOverride(yAxisNumberFormat); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); int seriesIndex = 0; for (XYSeries series : seriesList) { XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(series); plot.setDataset(seriesIndex, seriesCollection); XYItemRenderer renderer = createScalabilityPlotRenderer(yAxisNumberFormat); plot.setRenderer(seriesIndex, renderer); seriesIndex++;/*from w w w .jav a2 s. c om*/ } plot.setOrientation(PlotOrientation.VERTICAL); return plot; }