List of usage examples for org.jfree.chart.plot XYPlot XYPlot
public XYPlot(XYDataset dataset, ValueAxis domainAxis, ValueAxis rangeAxis, XYItemRenderer renderer)
From source file:org.optaplanner.benchmark.impl.statistic.movecountperstep.MoveCountPerStepProblemStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { Locale locale = benchmarkReport.getLocale(); NumberAxis xAxis = new NumberAxis("Time spent"); xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale)); NumberAxis yAxis = new NumberAxis("Accepted/selected moves per step"); yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale)); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); DrawingSupplier drawingSupplier = new DefaultDrawingSupplier(); plot.setOrientation(PlotOrientation.VERTICAL); int seriesIndex = 0; for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) { XYSeries acceptedSeries = new XYSeries( singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " accepted"); XYSeries selectedSeries = new XYSeries( singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix() + " selected"); XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); if (singleBenchmarkResult.isSuccess()) { MoveCountPerStepSingleStatistic singleStatistic = (MoveCountPerStepSingleStatistic) singleBenchmarkResult .getSingleStatistic(problemStatisticType); for (MoveCountPerStepStatisticPoint point : singleStatistic.getPointList()) { long timeMillisSpent = point.getTimeMillisSpent(); long acceptedMoveCount = point.getMoveCountPerStepMeasurement().getAcceptedMoveCount(); long selectedMoveCount = point.getMoveCountPerStepMeasurement().getSelectedMoveCount(); acceptedSeries.add(timeMillisSpent, acceptedMoveCount); selectedSeries.add(timeMillisSpent, selectedMoveCount); }/*ww w .ja v a 2 s.c o m*/ } XYSeriesCollection seriesCollection = new XYSeriesCollection(); seriesCollection.addSeries(acceptedSeries); seriesCollection.addSeries(selectedSeries); plot.setDataset(seriesIndex, seriesCollection); if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) { // Make the favorite more obvious renderer.setSeriesStroke(0, new BasicStroke(2.0f)); // Dashed line for selected move count renderer.setSeriesStroke(1, new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); } else { // Dashed line for selected move count renderer.setSeriesStroke(1, new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f)); } // Render both lines in the same color Paint linePaint = drawingSupplier.getNextPaint(); renderer.setSeriesPaint(0, linePaint); renderer.setSeriesPaint(1, linePaint); plot.setRenderer(seriesIndex, renderer); seriesIndex++; } JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " move count per step statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "MoveCountPerStepStatistic"); }
From source file:de.unibayreuth.bayeos.goat.panels.timeseries.JPanelDetailMatrix.java
public boolean loadData() { super.loadData(); OctetMatrixTableModel m = new OctetMatrixTableModel(app.getXmlClient()); if (aggregateEnabled) { m.load(nodes, t, a, withAggrCounts); } else {//from w ww . j a va2 s . c o m m.load(nodes, t, s, withStatusCols); } panelTab.setModel(m); panelTab.setObjektNode(objektNode); // Grafik XYDataset xyDataset = new TableModelXYDataset(m); DateAxis domainAxis = new DateAxis("Time"); XYPlot plot = new XYPlot(xyDataset, domainAxis, new NumberAxis("Values"), new DefaultItemRenderer()); panelChart.setChart(new JFreeChart(plot)); panelChart.setLegend(new StandardLegend()); return true; }
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);/*from w w w. ja v a2 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)); }
From source file:inflor.core.plots.HistogramPlot.java
@Override public JFreeChart createChart(FCSFrame dataFrame, TransformSet transforms) { Optional<FCSDimension> domainDimension = FCSUtilities.findCompatibleDimension(dataFrame, spec.getDomainAxisName());/*from w w w. j a v a 2s . c o m*/ AbstractTransform transform = transforms.get(domainDimension.get().getShortName()); double[] transformedData = transform.transform(domainDimension.get().getData()); Histogram1D hist = new Histogram1D(transformedData, transform.getMinTranformedValue(), transform.getMaxTransformedValue(), ChartingDefaults.BIN_COUNT); DefaultXYDataset dataset = new DefaultXYDataset(); dataset.addSeries(dataFrame.getDisplayName(), hist.getData()); ValueAxis domainAxis = PlotUtils.createAxis(domainDimension.get().getDisplayName(), transform); ValueAxis rangeAxis = new NumberAxis(spec.getRangeAxisName()); FillType fillType = FillType.TO_ZERO; XYItemRenderer renderer = new XYSplineRenderer(1, fillType); renderer.setSeriesShape(0, ShapeUtilities.createDiamond(Float.MIN_VALUE));// Make the points // invisible XYPlot plot = new XYPlot(dataset, domainAxis, rangeAxis, renderer); return new JFreeChart(plot); }
From source file:org.csml.tommo.sugar.heatmap.MeanQualityMatrixChart.java
private static MeanQualityMatrixChart createChart(MeanQualityMatrixDataset dataset, NumberAxis xAxis, NumberAxis yAxis, PaintScale paintScale) { XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setPaintScale(paintScale);//from ww w. j av a 2 s . c om XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); MeanQualityMatrixChart chart = new MeanQualityMatrixChart(plot); chart.setBackgroundPaint(Color.white); chart.removeLegend(); return chart; }
From source file:de.iteratec.visualizationmodel.jfreechart.ChartFactory.java
public JFreeChart createXYStepChart(XYDataset dataset) { XYToolTipGenerator toolTipGenerator = !showTooltips ? null : new StandardXYToolTipGenerator(); XYURLGenerator urlGenerator = !showUrls ? null : new StandardXYURLGenerator(); XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, urlGenerator); XYPlot plot = new XYPlot(dataset, (ValueAxis) xAxis, (ValueAxis) yAxis, null); plot.setRenderer(renderer);/*from w w w. j a v a 2 s. c om*/ plot.setOrientation(orientation); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.getRenderer().setSeriesStroke(0, new BasicStroke(5.0f)); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend); THEME.apply(chart); return chart; }
From source file:org.csml.tommo.sugar.heatmap.MappingQualityMatrixChart.java
private static MappingQualityMatrixChart createChart(MappingQualityMatrixDataset dataset, NumberAxis xAxis, NumberAxis yAxis, PaintScale paintScale) { XYBlockRenderer renderer = new XYBlockRenderer(); renderer.setPaintScale(paintScale);/* w w w . jav a 2 s . c o m*/ XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinePaint(Color.white); MappingQualityMatrixChart chart = new MappingQualityMatrixChart(plot); chart.setBackgroundPaint(Color.white); chart.removeLegend(); return chart; }
From source file:org.spantus.exp.segment.draw.DrawDtw.java
protected JFreeChart createXYZChart() { NumberAxis xAxis = new NumberAxis("Sample"); NumberAxis yAxis = new NumberAxis("target"); List<List<Double>> data = info.getDistanceMatrix(); XYZDataset xyzset = new XYZArrayDataset(data); XYPlot plot = new XYPlot(xyzset, xAxis, yAxis, null); XYBlockRenderer r = new XYBlockRenderer(); PaintScale ps = new GrayPaintScale(min, max); // LookupPaintScale ps = new LookupPaintScale(0.0, 4.0, Color.WHITE); // ps.add(1, Color.red); // ps.add(2, Color.green); // ps.add(3, Color.gray); r.setPaintScale(ps);// w ww . ja v a 2s . c o m r.setBlockHeight(1.0f); r.setBlockWidth(1.0f); plot.setRenderer(r); JFreeChart chart = new JFreeChart("Chart Title", JFreeChart.DEFAULT_TITLE_FONT, plot, false); NumberAxis scaleAxis = new NumberAxis("Scale"); scaleAxis.setUpperBound(100); scaleAxis.setAxisLinePaint(Color.white); scaleAxis.setTickMarkPaint(Color.white); scaleAxis.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12)); // PaintScaleLegend legend = new PaintScaleLegend(ps, scaleAxis); // legend.setAxisLocation(AxisLocation.BOTTOM_OR_LEFT); // legend.setPadding(new RectangleInsets(5, 5, 5, 5)); // legend.setStripWidth(50); // legend.setPosition(RectangleEdge.RIGHT); // legend.setBackgroundPaint(Color.WHITE); // chart.addSubtitle(legend); chart.setBackgroundPaint(Color.white); return chart; }
From source file:org.jfree.chart.demo.CombinedXYPlotDemo1.java
/** * Creates a combined chart./*from www . ja v a2s. c o m*/ * * @return the combined chart. */ private JFreeChart createCombinedChart() { // create subplot 1... final XYDataset data1 = createDataset1(); final XYItemRenderer renderer1 = new StandardXYItemRenderer(); final NumberAxis rangeAxis1 = new NumberAxis("Range 1"); final XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); final XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, 10000.0); annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); annotation.setRotationAngle(Math.PI / 4.0); subplot1.addAnnotation(annotation); // create subplot 2... final XYDataset data2 = createDataset2(); final XYItemRenderer renderer2 = new StandardXYItemRenderer(); final NumberAxis rangeAxis2 = new NumberAxis("Range 2"); rangeAxis2.setAutoRangeIncludesZero(false); final XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); // parent plot... final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis("Domain")); plot.setGap(10.0); // add the subplots... plot.add(subplot1, 1); plot.add(subplot2, 1); plot.setOrientation(PlotOrientation.VERTICAL); // return a new chart containing the overlaid plot... return new JFreeChart("CombinedDomainXYPlot Demo", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.optaplanner.benchmark.impl.statistic.scorecalculationspeed.ScoreCalculationSpeedProblemStatistic.java
@Override public void writeGraphFiles(BenchmarkReport benchmarkReport) { Locale locale = benchmarkReport.getLocale(); NumberAxis xAxis = new NumberAxis("Time spent"); xAxis.setNumberFormatOverride(new MillisecondsSpentNumberFormat(locale)); NumberAxis yAxis = new NumberAxis("Score calculation speed per second"); yAxis.setNumberFormatOverride(NumberFormat.getInstance(locale)); yAxis.setAutoRangeIncludesZero(false); XYPlot plot = new XYPlot(null, xAxis, yAxis, null); plot.setOrientation(PlotOrientation.VERTICAL); int seriesIndex = 0; for (SingleBenchmarkResult singleBenchmarkResult : problemBenchmarkResult.getSingleBenchmarkResultList()) { XYSeries series = new XYSeries( singleBenchmarkResult.getSolverBenchmarkResult().getNameWithFavoriteSuffix()); XYItemRenderer renderer = new XYLineAndShapeRenderer(); if (singleBenchmarkResult.hasAllSuccess()) { ScoreCalculationSpeedSubSingleStatistic subSingleStatistic = (ScoreCalculationSpeedSubSingleStatistic) singleBenchmarkResult .getSubSingleStatistic(problemStatisticType); List<ScoreCalculationSpeedStatisticPoint> points = subSingleStatistic.getPointList(); for (ScoreCalculationSpeedStatisticPoint point : points) { long timeMillisSpent = point.getTimeMillisSpent(); long scoreCalculationSpeed = point.getScoreCalculationSpeed(); series.add(timeMillisSpent, scoreCalculationSpeed); }/*from ww w .j ava 2 s .co m*/ } plot.setDataset(seriesIndex, new XYSeriesCollection(series)); if (singleBenchmarkResult.getSolverBenchmarkResult().isFavorite()) { // Make the favorite more obvious renderer.setSeriesStroke(0, new BasicStroke(2.0f)); } plot.setRenderer(seriesIndex, renderer); seriesIndex++; } JFreeChart chart = new JFreeChart(problemBenchmarkResult.getName() + " score calculation speed statistic", JFreeChart.DEFAULT_TITLE_FONT, plot, true); graphFile = writeChartToImageFile(chart, problemBenchmarkResult.getName() + "ScoreCalculationSpeedStatistic"); }