List of usage examples for org.jfree.chart.renderer.xy XYStepRenderer XYStepRenderer
public XYStepRenderer()
From source file:com.att.aro.ui.view.diagnostictab.CreateBarPlot.java
public XYPlot drawStepChartPlot() { XYStepRenderer renderer = new XYStepRenderer(); renderer.setBaseShapesVisible(true); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f)); renderer.setDefaultEntityRadius(6);//from w ww .j a v a2s .c o m XYPlot plot = new XYPlot(null, null, new NumberAxis(), renderer); plot.setDomainPannable(true); plot.setRangePannable(true); return plot; }
From source file:org.optaplanner.benchmark.impl.statistic.single.constraintmatchtotalstepscore.ConstraintMatchTotalStepScoreSingleStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { List<Map<String, XYSeries>> constraintIdToWeightSeriesMapList = new ArrayList<Map<String, XYSeries>>( BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); for (ConstraintMatchTotalStepScoreStatisticPoint point : getPointList()) { int scoreLevel = point.getScoreLevel(); if (scoreLevel >= BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE) { continue; }//from w ww. java 2s. c om while (scoreLevel >= constraintIdToWeightSeriesMapList.size()) { constraintIdToWeightSeriesMapList.add(new LinkedHashMap<String, XYSeries>()); } Map<String, XYSeries> constraintIdToWeightSeriesMap = constraintIdToWeightSeriesMapList.get(scoreLevel); if (constraintIdToWeightSeriesMap == null) { constraintIdToWeightSeriesMap = new LinkedHashMap<String, XYSeries>(); constraintIdToWeightSeriesMapList.set(scoreLevel, constraintIdToWeightSeriesMap); } String constraintId = point.getConstraintPackage() + ":" + point.getConstraintName(); XYSeries weightSeries = constraintIdToWeightSeriesMap.get(constraintId); if (weightSeries == null) { weightSeries = new XYSeries(point.getConstraintName() + " weight"); constraintIdToWeightSeriesMap.put(constraintId, weightSeries); } long timeMillisSpent = point.getTimeMillisSpent(); weightSeries.add(timeMillisSpent, point.getWeightTotal()); } graphFileList = new ArrayList<File>(constraintIdToWeightSeriesMapList.size()); for (int scoreLevelIndex = 0; scoreLevelIndex < constraintIdToWeightSeriesMapList .size(); scoreLevelIndex++) { XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex); // No direct ascending lines between 2 points, but a stepping line instead XYItemRenderer renderer = new XYStepRenderer(); plot.setRenderer(renderer); XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) { seriesCollection.addSeries(series); } plot.setDataset(seriesCollection); JFreeChart chart = new JFreeChart(singleBenchmarkResult.getName() + " constraint match total step score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "ConstraintMatchTotalStepScoreStatisticLevel" + scoreLevelIndex)); } }
From source file:msi.gama.outputs.layers.charts.ChartJFreeChartOutputScatter.java
@Override protected AbstractRenderer createRenderer(final IScope scope, final String serieid) { final String style = this.getChartdataset().getDataSeries(scope, serieid).getStyle(scope); AbstractRenderer newr = new myXYErrorRenderer(); switch (style) { case IKeyword.SPLINE: { newr = new XYSplineRenderer(); break;/*from w ww . j a v a2s .co m*/ } case IKeyword.STEP: { newr = new XYStepRenderer(); break; } case IKeyword.DOT: { newr = new XYShapeRenderer(); break; } case IKeyword.WHISKER: { newr = new XYBoxAndWhiskerRenderer(); break; } case IKeyword.AREA: { newr = new XYAreaRenderer(); break; } case IKeyword.BAR: { newr = new XYBarRenderer(); break; } case IKeyword.THREE_D: { newr = new XYLine3DRenderer(); break; } case IKeyword.STACK: case IKeyword.RING: case IKeyword.EXPLODED: default: { // newr = new FastXYItemRenderer(); newr = new myXYErrorRenderer(); ((myXYErrorRenderer) newr).setMyid(serieid); ((myXYErrorRenderer) newr).setOutput(this); break; } } return newr; }
From source file:org.optaplanner.benchmark.impl.statistic.subsingle.constraintmatchtotalstepscore.ConstraintMatchTotalStepScoreSubSingleStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { List<Map<String, XYSeries>> constraintIdToWeightSeriesMapList = new ArrayList<Map<String, XYSeries>>( BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); for (ConstraintMatchTotalStepScoreStatisticPoint point : getPointList()) { int scoreLevel = point.getScoreLevel(); if (scoreLevel >= BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE) { continue; }/* w w w. j av a2s . c o m*/ while (scoreLevel >= constraintIdToWeightSeriesMapList.size()) { constraintIdToWeightSeriesMapList.add(new LinkedHashMap<String, XYSeries>()); } Map<String, XYSeries> constraintIdToWeightSeriesMap = constraintIdToWeightSeriesMapList.get(scoreLevel); if (constraintIdToWeightSeriesMap == null) { constraintIdToWeightSeriesMap = new LinkedHashMap<String, XYSeries>(); constraintIdToWeightSeriesMapList.set(scoreLevel, constraintIdToWeightSeriesMap); } String constraintId = point.getConstraintPackage() + ":" + point.getConstraintName(); XYSeries weightSeries = constraintIdToWeightSeriesMap.get(constraintId); if (weightSeries == null) { weightSeries = new XYSeries(point.getConstraintName() + " weight"); constraintIdToWeightSeriesMap.put(constraintId, weightSeries); } long timeMillisSpent = point.getTimeMillisSpent(); weightSeries.add(timeMillisSpent, point.getWeightTotal()); } graphFileList = new ArrayList<File>(constraintIdToWeightSeriesMapList.size()); for (int scoreLevelIndex = 0; scoreLevelIndex < constraintIdToWeightSeriesMapList .size(); scoreLevelIndex++) { XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex); // No direct ascending lines between 2 points, but a stepping line instead XYItemRenderer renderer = new XYStepRenderer(); plot.setRenderer(renderer); XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) { seriesCollection.addSeries(series); } plot.setDataset(seriesCollection); JFreeChart chart = new JFreeChart(subSingleBenchmarkResult.getName() + " constraint match total step score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "ConstraintMatchTotalStepScoreStatisticLevel" + scoreLevelIndex)); } }
From source file:org.drools.planner.benchmark.statistic.BestScoreStatistic.java
private CharSequence writeGraphStatistic(File solverStatisticFilesDirectory, String baseName) { XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (Map.Entry<String, BestScoreStatisticListener> listenerEntry : bestScoreStatisticListenerMap .entrySet()) {//from w w w.j a va 2 s .c o m String configName = listenerEntry.getKey(); XYSeries configSeries = new XYSeries(configName); List<BestScoreStatisticPoint> statisticPointList = listenerEntry.getValue() .getBestScoreStatisticPointList(); for (BestScoreStatisticPoint statisticPoint : statisticPointList) { long timeMillisSpend = statisticPoint.getTimeMillisSpend(); Score score = statisticPoint.getScore(); Double scoreGraphValue = scoreDefinition.translateScoreToGraphValue(score); if (scoreGraphValue != null) { configSeries.add(timeMillisSpend, scoreGraphValue); } } seriesCollection.addSeries(configSeries); } NumberAxis xAxis = new NumberAxis("Time millis spend"); xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat()); NumberAxis yAxis = new NumberAxis("Score"); yAxis.setAutoRangeIncludesZero(false); XYItemRenderer renderer = new XYStepRenderer(); XYPlot plot = new XYPlot(seriesCollection, xAxis, yAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(baseName + " best score statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); BufferedImage chartImage = chart.createBufferedImage(1024, 768); File graphStatisticFile = new File(solverStatisticFilesDirectory, baseName + "Statistic.png"); OutputStream out = null; try { out = new FileOutputStream(graphStatisticFile); ImageIO.write(chartImage, "png", out); } catch (IOException e) { throw new IllegalArgumentException("Problem writing graphStatisticFile: " + graphStatisticFile, e); } finally { IOUtils.closeQuietly(out); } return " <img src=\"" + graphStatisticFile.getName() + "\"/>\n"; }
From source file:org.drools.planner.benchmark.statistic.bestscore.BestScoreStatistic.java
private CharSequence writeGraphStatistic(File solverStatisticFilesDirectory, String baseName) { NumberAxis xAxis = new NumberAxis("Time millis spend"); xAxis.setNumberFormatOverride(new MillisecondsSpendNumberFormat()); NumberAxis yAxis = new NumberAxis("Score"); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); int seriesIndex = 0; for (Map.Entry<String, BestScoreStatisticListener> listenerEntry : bestScoreStatisticListenerMap .entrySet()) {//from w w w. j a v a 2 s .com String configName = listenerEntry.getKey(); XYSeries series = new XYSeries(configName); List<BestScoreStatisticPoint> statisticPointList = listenerEntry.getValue().getStatisticPointList(); for (BestScoreStatisticPoint statisticPoint : statisticPointList) { long timeMillisSpend = statisticPoint.getTimeMillisSpend(); Score score = statisticPoint.getScore(); Double scoreGraphValue = scoreDefinition.translateScoreToGraphValue(score); if (scoreGraphValue != null) { series.add(timeMillisSpend, scoreGraphValue); } } XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(series); plot.setDataset(seriesIndex, seriesCollection); XYItemRenderer renderer; // No direct lines between 2 points renderer = new XYStepRenderer(); if (statisticPointList.size() <= 1) { // Workaround for https://sourceforge.net/tracker/?func=detail&aid=3387330&group_id=15494&atid=115494 renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES); } plot.setRenderer(seriesIndex, renderer); seriesIndex++; } plot.setOrientation(PlotOrientation.VERTICAL); JFreeChart chart = new JFreeChart(baseName + " best score statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); BufferedImage chartImage = chart.createBufferedImage(1024, 768); File graphStatisticFile = new File(solverStatisticFilesDirectory, baseName + "BestScoreStatistic.png"); OutputStream out = null; try { out = new FileOutputStream(graphStatisticFile); ImageIO.write(chartImage, "png", out); } catch (IOException e) { throw new IllegalArgumentException("Problem writing graphStatisticFile: " + graphStatisticFile, e); } finally { IOUtils.closeQuietly(out); } return " <img src=\"" + graphStatisticFile.getName() + "\"/>\n"; }
From source file:org.optaplanner.benchmark.impl.statistic.single.constraintmatchtotalbestscore.ConstraintMatchTotalBestScoreSingleStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { List<Map<String, XYSeries>> constraintIdToWeightSeriesMapList = new ArrayList<Map<String, XYSeries>>( BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); for (ConstraintMatchTotalBestScoreStatisticPoint point : getPointList()) { int scoreLevel = point.getScoreLevel(); if (scoreLevel >= BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE) { continue; }/*from ww w . ja v a 2 s.c om*/ while (scoreLevel >= constraintIdToWeightSeriesMapList.size()) { constraintIdToWeightSeriesMapList.add(new LinkedHashMap<String, XYSeries>()); } Map<String, XYSeries> constraintIdToWeightSeriesMap = constraintIdToWeightSeriesMapList.get(scoreLevel); if (constraintIdToWeightSeriesMap == null) { constraintIdToWeightSeriesMap = new LinkedHashMap<String, XYSeries>(); constraintIdToWeightSeriesMapList.set(scoreLevel, constraintIdToWeightSeriesMap); } String constraintId = point.getConstraintPackage() + ":" + point.getConstraintName(); XYSeries weightSeries = constraintIdToWeightSeriesMap.get(constraintId); if (weightSeries == null) { weightSeries = new XYSeries(point.getConstraintName() + " weight"); constraintIdToWeightSeriesMap.put(constraintId, weightSeries); } long timeMillisSpent = point.getTimeMillisSpent(); weightSeries.add(timeMillisSpent, point.getWeightTotal()); } graphFileList = new ArrayList<File>(constraintIdToWeightSeriesMapList.size()); for (int scoreLevelIndex = 0; scoreLevelIndex < constraintIdToWeightSeriesMapList .size(); scoreLevelIndex++) { XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex); // No direct ascending lines between 2 points, but a stepping line instead XYItemRenderer renderer = new XYStepRenderer(); plot.setRenderer(renderer); XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) { seriesCollection.addSeries(series); } plot.setDataset(seriesCollection); JFreeChart chart = new JFreeChart(singleBenchmarkResult.getName() + " constraint match total best score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "ConstraintMatchTotalBestScoreStatisticLevel" + scoreLevelIndex)); } }
From source file:msi.gama.outputs.layers.ChartDataStatement.java
/** * @throws GamaRuntimeException/*from w w w.j a v a 2 s. c o m*/ * @param scope */ public ChartData createData(final IScope scope) throws GamaRuntimeException { ChartData data = new ChartData(); String style = getLiteral(IKeyword.STYLE); if (style == null) { style = IKeyword.LINE; } GamaColor color = Cast.asColor(scope, getFacetValue(scope, IKeyword.COLOR, Cast.asColor(scope, "black"))); boolean showMarkers = getFacetValue(scope, MARKER, true); boolean showLine = getFacetValue(scope, LINE_VISIBLE, true); boolean fillMarkers = getFacetValue(scope, FILL, true); String shapeMarker = getFacetValue(scope, MARKERSHAPE, null); AbstractRenderer r = null; if (style.equals(IKeyword.LINE)) { r = new XYLineAndShapeRenderer(true, showMarkers); r.setSeriesPaint(0, color); ((XYLineAndShapeRenderer) r).setBaseShapesFilled(fillMarkers); if (shapeMarker != null) { if (shapeMarker.equals(MARKER_SQUARE)) { ((XYLineAndShapeRenderer) r).setSeriesShape(0, defaultmarkers[0]); } else if (shapeMarker.equals(MARKER_CIRCLE)) { ((XYLineAndShapeRenderer) r).setSeriesShape(0, defaultmarkers[1]); } else if (shapeMarker.equals(MARKER_UP_TRIANGLE)) { ((XYLineAndShapeRenderer) r).setSeriesShape(0, defaultmarkers[2]); } else if (shapeMarker.equals(MARKER_DIAMOND)) { ((XYLineAndShapeRenderer) r).setSeriesShape(0, defaultmarkers[3]); } else if (shapeMarker.equals(MARKER_HOR_RECTANGLE)) { ((XYLineAndShapeRenderer) r).setSeriesShape(0, defaultmarkers[4]); } else if (shapeMarker.equals(MARKER_DOWN_TRIANGLE)) { ((XYLineAndShapeRenderer) r).setSeriesShape(0, defaultmarkers[5]); } else if (shapeMarker.equals(MARKER_HOR_ELLIPSE)) { ((XYLineAndShapeRenderer) r).setSeriesShape(0, defaultmarkers[6]); } else if (shapeMarker.equals(MARKER_RIGHT_TRIANGLE)) { ((XYLineAndShapeRenderer) r).setSeriesShape(0, defaultmarkers[7]); } else if (shapeMarker.equals(MARKER_VERT_RECTANGLE)) { ((XYLineAndShapeRenderer) r).setSeriesShape(0, defaultmarkers[8]); } else if (shapeMarker.equals(MARKER_LEFT_TRIANGLE)) { ((XYLineAndShapeRenderer) r).setSeriesShape(0, defaultmarkers[9]); } else if (shapeMarker.equals(MARKER_EMPTY)) { ((XYLineAndShapeRenderer) r).setSeriesShapesVisible(0, false); } } ((XYLineAndShapeRenderer) r).setSeriesLinesVisible(0, showLine); } else if (style.equals(IKeyword.AREA)) { r = new XYAreaRenderer(); r.setSeriesPaint(0, color); } else if (style.equals(IKeyword.WHISKER)) { r = new BoxAndWhiskerRenderer(); r.setSeriesPaint(0, color); } else if (style.equals(IKeyword.BAR)) { r = new BarRenderer(); r.setSeriesPaint(0, color); } else if (style.equals(IKeyword.DOT)) { r = new XYDotRenderer(); r = new XYShapeRenderer(); r.setSeriesPaint(0, color); } else if (style.equals(IKeyword.SPLINE)) { r = new XYSplineRenderer(); r.setSeriesPaint(0, color); ((XYSplineRenderer) r).setBaseShapesFilled(fillMarkers); ((XYSplineRenderer) r).setBaseShapesVisible(showMarkers); } else if (style.equals(IKeyword.STEP)) { r = new XYStepRenderer(); } else if (style.equals(IKeyword.AREA_STACK)) { r = new StackedXYAreaRenderer2(); r.setSeriesPaint(0, color); } else if (style.equals(IKeyword.STACK)) { r = new StackedBarRenderer(); r.setSeriesPaint(0, color); // ((XYStepRenderer) r).setBaseShapesFilled(fillMarkers); // ((XYStepRenderer) r).setBaseShapesVisible(showMarkers); } data.renderer = r; data.name = Cast.asString(scope, getFacetValue(scope, IKeyword.LEGEND, getFacetValue(scope, IKeyword.NAME, "data" + dataNumber++))); data.color = color; // r.setSeriesPaint(0, data.color); // in order to "detach" the expression from the current definition scope data.value = getFacet(IKeyword.VALUE).resolveAgainst(scope); return data; }
From source file:org.optaplanner.benchmark.impl.statistic.subsingle.constraintmatchtotalbestscore.ConstraintMatchTotalBestScoreSubSingleStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { List<Map<String, XYSeries>> constraintIdToWeightSeriesMapList = new ArrayList<Map<String, XYSeries>>( BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE); for (ConstraintMatchTotalBestScoreStatisticPoint point : getPointList()) { int scoreLevel = point.getScoreLevel(); if (scoreLevel >= BenchmarkReport.CHARTED_SCORE_LEVEL_SIZE) { continue; }/*from ww w . j av a2 s .c o m*/ while (scoreLevel >= constraintIdToWeightSeriesMapList.size()) { constraintIdToWeightSeriesMapList.add(new LinkedHashMap<String, XYSeries>()); } Map<String, XYSeries> constraintIdToWeightSeriesMap = constraintIdToWeightSeriesMapList.get(scoreLevel); if (constraintIdToWeightSeriesMap == null) { constraintIdToWeightSeriesMap = new LinkedHashMap<String, XYSeries>(); constraintIdToWeightSeriesMapList.set(scoreLevel, constraintIdToWeightSeriesMap); } String constraintId = point.getConstraintPackage() + ":" + point.getConstraintName(); XYSeries weightSeries = constraintIdToWeightSeriesMap.get(constraintId); if (weightSeries == null) { weightSeries = new XYSeries(point.getConstraintName() + " weight"); constraintIdToWeightSeriesMap.put(constraintId, weightSeries); } long timeMillisSpent = point.getTimeMillisSpent(); weightSeries.add(timeMillisSpent, point.getWeightTotal()); } graphFileList = new ArrayList<File>(constraintIdToWeightSeriesMapList.size()); for (int scoreLevelIndex = 0; scoreLevelIndex < constraintIdToWeightSeriesMapList .size(); scoreLevelIndex++) { XYPlot plot = createPlot(benchmarkReport, scoreLevelIndex); // No direct ascending lines between 2 points, but a stepping line instead XYItemRenderer renderer = new XYStepRenderer(); plot.setRenderer(renderer); XYSeriesCollection seriesCollection = new XYSeriesCollection(); for (XYSeries series : constraintIdToWeightSeriesMapList.get(scoreLevelIndex).values()) { seriesCollection.addSeries(series); } plot.setDataset(seriesCollection); JFreeChart chart = new JFreeChart(subSingleBenchmarkResult.getName() + " constraint match total best score diff level " + scoreLevelIndex + " statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFileList.add( writeChartToImageFile(chart, "ConstraintMatchTotalBestScoreStatisticLevel" + scoreLevelIndex)); } }
From source file:uk.ac.ed.epcc.webapp.charts.jfreechart.JFreeTimeChartData.java
public TimeChartDataSet addLineGraph(TimeChartDataSet plot) throws InvalidArgument { TimeChartDataSet myplot = addTimeSeries(plot); if (use_bar || getItems() < STEP_THRESHOLD || use_step) { XYStepRenderer renderer = new XYStepRenderer(); renderer.setAutoPopulateSeriesFillPaint(true); ((XYPlot) chart.getPlot()).setRenderer(myplot.getDatasetId(), renderer, false); } else {/*from w w w . j av a 2 s . c o m*/ XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setAutoPopulateSeriesFillPaint(true); ((XYPlot) chart.getPlot()).setRenderer(myplot.getDatasetId(), renderer, false); } return myplot; }