@Override public JFreeChart getChart() throws IOException { if (chart == null) { final YIntervalSeriesCollection series_collection = getDataset(); chart = ChartFactory.createXYLineChart("Change of state over time", "Time through experiment (s)", "Number of instances", series_collection, PlotOrientation.VERTICAL, true, false, false); final XYErrorRenderer error_renderer = new XYErrorRenderer(); error_renderer.setBaseShapesVisible(false); error_renderer.setBaseLinesVisible(true); error_renderer.setDrawYError(false); final XYPlot plot = chart.getXYPlot(); plot.getRangeAxis().setLowerBound(0); plot.setRenderer(error_renderer); PlainChartTheme.applyTheme(chart); } return chart; }
@Override public JFreeChart getChart() throws IOException { if (chart == null) { final YIntervalSeriesCollection series_collection = getDataset(); chart = ChartFactory.createXYLineChart(chart_title, "Time through experiment (s)", y_axis_label, series_collection, PlotOrientation.VERTICAL, getDataset().getSeriesCount() > 1, false, false); final XYErrorRenderer error_renderer = new XYErrorRenderer(); error_renderer.setBaseShapesVisible(false); error_renderer.setBaseLinesVisible(true); error_renderer.setDrawYError(false); final XYPlot plot = chart.getXYPlot(); plot.getRangeAxis().setLowerBound(0); plot.setRenderer(error_renderer); PlainChartTheme.applyTheme(chart); } return chart; }
private synchronized XYItemRenderer getXYItemRenderer() { if (show_error_bars) { final XYErrorRenderer error_renderer = new XYErrorRenderer(); error_renderer.setBaseLinesVisible(true); error_renderer.setBaseShapesVisible(false); error_renderer.setDrawYError(true); return error_renderer; } else { return null; } }
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYErrorRenderer r1 = new XYErrorRenderer(); XYErrorRenderer r2 = new XYErrorRenderer(); assertEquals(r1, r2); // drawXError r1.setDrawXError(false); assertFalse(r1.equals(r2)); r2.setDrawXError(false); assertTrue(r1.equals(r2)); // drawYError r1.setDrawYError(false); assertFalse(r1.equals(r2)); r2.setDrawYError(false); assertTrue(r1.equals(r2)); // capLength r1.setCapLength(9.0); assertFalse(r1.equals(r2)); r2.setCapLength(9.0); assertTrue(r1.equals(r2)); // errorPaint r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); assertFalse(r1.equals(r2)); r2.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); assertTrue(r1.equals(r2)); }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { XYErrorRenderer r1 = new XYErrorRenderer(); XYErrorRenderer r2 = new XYErrorRenderer(); assertTrue(r1.equals(r2)); int h1 = r1.hashCode(); int h2 = r2.hashCode(); assertEquals(h1, h2); }
/** * Check that the equals() method distinguishes all fields. */ public void testEquals() { XYErrorRenderer r1 = new XYErrorRenderer(); XYErrorRenderer r2 = new XYErrorRenderer(); assertEquals(r1, r2); // drawXError r1.setDrawXError(false); assertFalse(r1.equals(r2)); r2.setDrawXError(false); assertTrue(r1.equals(r2)); // drawYError r1.setDrawYError(false); assertFalse(r1.equals(r2)); r2.setDrawYError(false); assertTrue(r1.equals(r2)); // capLength r1.setCapLength(9.0); assertFalse(r1.equals(r2)); r2.setCapLength(9.0); assertTrue(r1.equals(r2)); // errorPaint r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); assertFalse(r1.equals(r2)); r2.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.green)); assertTrue(r1.equals(r2)); // errorStroke r1.setErrorStroke(new BasicStroke(1.5f)); assertFalse(r1.equals(r2)); r2.setErrorStroke(new BasicStroke(1.5f)); assertTrue(r1.equals(r2)); }
private JFreeChart createChart(final XYDataset dataset) { final JFreeChart result = ChartFactory.createTimeSeriesChart( graphTitle, "Time", "Price", dataset, true, true, false ); plot = result.getXYPlot(); plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.lightGray); ValueAxis xaxis = plot.getDomainAxis(); xaxis.setAutoRange(true); xaxis.setVisible(false); xaxis.setFixedAutoRange(16000.0); // 60 seconds xaxis.setVerticalTickLabels(true); ValueAxis yaxis = plot.getRangeAxis(); yaxis.setRange(0, 100.0); xaxis2 = new NumberAxis("Volume"); plot.setDataset(1, dataset2); plot.setRangeAxis(1, xaxis2); plot.mapDatasetToRangeAxis(1, 1); XYBarRenderer renderer2 = new XYBarRenderer(0.20); renderer2.setToolTipGenerator( new StandardXYToolTipGenerator( StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.00") ) ); renderer2.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance()); plot.setRenderer(1, renderer2); plot.setDataset(2, dataset3); plot.mapDatasetToRangeAxis(2, 0); XYErrorRenderer renderer3 = new XYErrorRenderer(); plot.setRenderer(2, renderer3); plot.setDataset(3, dataset4); plot.mapDatasetToRangeAxis(3, 1); XYBarRenderer renderer4 = new XYBarRenderer(0.20); plot.setRenderer(3, renderer4); return result; }
protected AbstractRenderer createRenderer(final IScope scope, final String serieid) { // TODO Auto-generated method stub return new XYErrorRenderer(); }
/** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XYErrorRenderer r1 = new XYErrorRenderer(); assertTrue(r1 instanceof PublicCloneable); }
private void createUI() { final XYPlot plot = getPlot(); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); plot.setNoDataMessage(NO_DATA_MESSAGE); int confidenceDSIndex = 0; int regressionDSIndex = 1; int scatterpointsDSIndex = 2; plot.setDataset(confidenceDSIndex, acceptableDeviationDataset); plot.setDataset(regressionDSIndex, regressionDataset); plot.setDataset(scatterpointsDSIndex, scatterpointsDataset); plot.addAnnotation(r2Annotation); final DeviationRenderer identityRenderer = new DeviationRenderer(true, false); identityRenderer.setSeriesPaint(0, StatisticChartStyling.SAMPLE_DATA_PAINT); identityRenderer.setSeriesFillPaint(0, StatisticChartStyling.SAMPLE_DATA_FILL_PAINT); plot.setRenderer(confidenceDSIndex, identityRenderer); final DeviationRenderer regressionRenderer = new DeviationRenderer(true, false); regressionRenderer.setSeriesPaint(0, StatisticChartStyling.REGRESSION_DATA_PAINT); regressionRenderer.setSeriesFillPaint(0, StatisticChartStyling.REGRESSION_DATA_FILL_PAINT); plot.setRenderer(regressionDSIndex, regressionRenderer); final XYErrorRenderer scatterPointsRenderer = new XYErrorRenderer(); scatterPointsRenderer.setDrawXError(true); scatterPointsRenderer.setErrorStroke(new BasicStroke(1)); scatterPointsRenderer.setErrorPaint(StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT); scatterPointsRenderer.setSeriesShape(0, StatisticChartStyling.CORRELATIVE_POINT_SHAPE); scatterPointsRenderer.setSeriesOutlinePaint(0, StatisticChartStyling.CORRELATIVE_POINT_OUTLINE_PAINT); scatterPointsRenderer.setSeriesFillPaint(0, StatisticChartStyling.CORRELATIVE_POINT_FILL_PAINT); scatterPointsRenderer.setSeriesLinesVisible(0, false); scatterPointsRenderer.setSeriesShapesVisible(0, true); scatterPointsRenderer.setSeriesOutlineStroke(0, new BasicStroke(1.0f)); scatterPointsRenderer.setSeriesToolTipGenerator(0, (dataset, series, item) -> { final XYIntervalSeriesCollection collection = (XYIntervalSeriesCollection) dataset; final Comparable key = collection.getSeriesKey(series); final double xValue = collection.getXValue(series, item); final double endYValue = collection.getEndYValue(series, item); final double yValue = collection.getYValue(series, item); return String.format("%s: mean = %6.2f, sigma = %6.2f | %s: value = %6.2f", getRasterName(), yValue, endYValue - yValue, key, xValue); }); plot.setRenderer(scatterpointsDSIndex, scatterPointsRenderer); final boolean autoRangeIncludesZero = false; final boolean xLog = scatterPlotModel.xAxisLogScaled; final boolean yLog = scatterPlotModel.yAxisLogScaled; plot.setDomainAxis( StatisticChartStyling.updateScalingOfAxis(xLog, plot.getDomainAxis(), autoRangeIncludesZero)); plot.setRangeAxis(StatisticChartStyling.updateScalingOfAxis(yLog, plot.getRangeAxis(), autoRangeIncludesZero)); createUI(createChartPanel(chart), createInputParameterPanel(), bindingContext); plot.getDomainAxis().addChangeListener(domainAxisChangeListener); scatterPlotDisplay.setMouseWheelEnabled(true); scatterPlotDisplay.setMouseZoomable(true); }
public BufferedImage generateChart(Map<String, List<Double>> data, Map<Integer, String> runToCommit, String yCaption, int width, int height) { // create dataset YIntervalSeriesCollection dataset = new YIntervalSeriesCollection(); YIntervalSeries s1 = new YIntervalSeries(yCaption); int i = 0; for (Integer run : runToCommit.keySet()) { String commit = runToCommit.get(run); DescriptiveStatistics stats = getStats(data.get(commit)); double mean = stats.getMean(); double std = stats.getStandardDeviation(); s1.add(i++, mean, mean - 1.96 * std, mean + 1.96 * std); } dataset.addSeries(s1); // create chart //NumberAxis xAxis = new NumberAxis("Revision number"); Set<String> strings = data.keySet(); final String[] stringsArray = new String[strings.size()]; int k = 0; for (String str : strings) { stringsArray[k++] = StringUtils.abbreviate(str, 10); } ValueAxis xAxis = new SymbolAxis("Commits", stringsArray); NumberAxis yAxis = new NumberAxis("Cluster processing time (ms)"); yAxis.setAutoRangeStickyZero(false); XYErrorRenderer renderer = new XYErrorRenderer(); renderer.setBaseLinesVisible(true); renderer.setSeriesStroke(0, new BasicStroke(3.0f)); renderer.setBaseShapesVisible(false); renderer.setErrorPaint(Color.blue); renderer.setErrorStroke(new BasicStroke(1.0f)); XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); JFreeChart chart = new JFreeChart("Average time to process queued work", plot); chart.setBackgroundPaint(Color.white); // create output image BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); Graphics2D graphics = image.createGraphics(); graphics.setBackground(Color.white); graphics.clearRect(0, 0, width, height); // render chart.draw(graphics, new Rectangle2D.Double(0, 0, width, height)); return image; }