List of usage examples for org.jfree.chart.plot CategoryPlot addDomainMarker
public void addDomainMarker(CategoryMarker marker)
From source file:spec.reporter.Utils.java
public static void createBmResultGraph(BenchmarkRecord record) { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); String iterName = ""; double max = 0; double min = Long.MAX_VALUE; for (int i = 0; i < record.iterRecords.size(); i++) { BenchmarkRecord.IterationRecord iterRecord = (BenchmarkRecord.IterationRecord) record.iterRecords .get(i);//from w w w .j ava 2 s . c o m String shortName = iterRecord.iterName.replaceFirst("ation", ""); if (iterRecord.score > max) { max = iterRecord.score; iterName = shortName; } if (iterRecord.score < min) { min = iterRecord.score; } dataset.addValue(iterRecord.score, " ", shortName); } JFreeChart chart = ChartFactory.createLineChart(" ", "iterations", Constants.WORKLOAD_METRIC, dataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(new Color(201, 222, 254)); plot.setRangeGridlinePaint(Color.WHITE); if (record.isValidRun() && min != Long.MAX_VALUE) { plot.getRangeAxis().setRange(min - 10, max + 10); } else { plot.getRangeAxis().setRange(0, max + 10); } ValueMarker vm = new ValueMarker(record.maxScore); vm.setLabel(Utils.df.format(record.maxScore)); vm.setLabelAnchor(RectangleAnchor.TOP_LEFT); vm.setLabelTextAnchor(TextAnchor.HALF_ASCENT_LEFT); plot.addRangeMarker(vm); CategoryMarker marker = new CategoryMarker(iterName); marker.setDrawAsLine(true); marker.setPaint(vm.getPaint()); plot.addDomainMarker(marker); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setFillPaint(Color.WHITE); renderer.setSeriesPaint(0, Color.BLUE.darker()); try { ChartUtilities.saveChartAsJPEG(new File(Utils.getFullImageName(record.name + "_results")), chart, 300, 200); } catch (Exception e) { System.out.println("Problems..."); } }
From source file:nl.strohalm.cyclos.controls.reports.statistics.graphs.ChartPostProcessorImpl.java
@SuppressWarnings("rawtypes") private void setMarkers(final CategoryPlot plot, final Map params) { final Marker[] domainMarkers = (Marker[]) params.get("domainMarkers"); // this method may be extended for range markers in future. if (domainMarkers != null && domainMarkers.length > 0) { for (final Marker marker : domainMarkers) { final CategoryMarker cmarker = (CategoryMarker) marker; cmarker.setDrawAsLine(true); if (cmarker.getLabel() != null) { cmarker.setLabelAnchor(RectangleAnchor.TOP_LEFT); cmarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT); }//from ww w.j a v a2s . co m plot.addDomainMarker(cmarker); } } }