/** * Confirm that the equals method can distinguish all the required fields. */ public void testEquals() { XIntervalSeriesCollection c1 = new XIntervalSeriesCollection(); XIntervalSeriesCollection c2 = new XIntervalSeriesCollection(); assertEquals(c1, c2); // add a series XIntervalSeries s1 = new XIntervalSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3); c1.addSeries(s1); assertFalse(c1.equals(c2)); XIntervalSeries s2 = new XIntervalSeries("Series"); s2.add(1.0, 1.1, 1.2, 1.3); c2.addSeries(s2); assertTrue(c1.equals(c2)); // add an empty series c1.addSeries(new XIntervalSeries("Empty Series")); assertFalse(c1.equals(c2)); c2.addSeries(new XIntervalSeries("Empty Series")); assertTrue(c1.equals(c2)); }
private void setStx(Stx stx) { if (stx != null) { HistogramPanelModel.HistogramConfig config = createHistogramConfig(); if (config == null) { return; } if (!model.hasStx(config)) { model.setStx(config, stx); } dataset = new XIntervalSeriesCollection(); final int[] binCounts = stx.getHistogramBins(); final RasterDataNode raster = getRaster(); final XIntervalSeries series = new XIntervalSeries(raster.getName()); final Histogram histogram = stx.getHistogram(); for (int i = 0; i < binCounts.length; i++) { final double xMin = histogram.getBinLowValue(0, i); final double xMax = i < binCounts.length - 1 ? histogram.getBinLowValue(0, i + 1) : histogram.getHighValue(0); series.add(xMin, xMin, xMax, binCounts[i]); } dataset.addSeries(series); } handleStxChange(); }
public ChartValue getHistogramValue(SoftwareProject softwareProject, Metric metric, int numberOfSets, double doubleHistogram[], int x, int y, ServletContext sc) { System.out.println("getHistogramValue"); List<RevisionMetricValueDto> dataValues = getDataValues(softwareProject, metric); boolean isDelta = false; XIntervalSeriesCollection dataset = createHistogramDataSet(dataValues, numberOfSets, doubleHistogram, isDelta); System.out.println("criando histograma"); String metricName = metric.getName(); String chartPath = DEFAULT_CHART_PATH + "DynamicHistogram" + System.currentTimeMillis() + ".png"; ChartRenderingInfo info = this.createHistogram(x, y, dataset, metricName, chartPath, sc); String tag = this.createHistogramImageMap(info); System.out.println("terminado histograma"); ChartValue chartValue = new ChartValue(); chartValue.setTag(tag); chartValue.setChartPath(chartPath); return chartValue; }
private static ChartPanel getHistogramPlotPanel(XIntervalSeriesCollection dataset, String xAxisLabel, String yAxisLabel, Color color) { JFreeChart chart = ChartFactory.createHistogram( null, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, false, // Legend? true, // tooltips false // url ); final XYPlot xyPlot = chart.getXYPlot(); //xyPlot.setForegroundAlpha(0.85f); xyPlot.setNoDataMessage("No data"); xyPlot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); renderer.setSeriesPaint(0, color); StandardXYBarPainter painter = new StandardXYBarPainter(); renderer.setBarPainter(painter); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(300, 200)); // chartPanel.getPopupMenu().add(createCopyDataToClipboardMenuItem()); return chartPanel; }
private void createUI() { dataset = new XIntervalSeriesCollection(); chart = ChartFactory.createHistogram( CHART_TITLE, "Values", "Frequency in #pixels", dataset, PlotOrientation.VERTICAL, false, // Legend? true, // tooltips false // url ); final XYPlot xyPlot = chart.getXYPlot(); xyPlot.setDomainZeroBaselineStroke(new BasicStroke(0.2f)); final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); renderer.setShadowYOffset(-4.0); renderer.setBaseToolTipGenerator(new XYPlotToolTipGenerator()); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setSeriesPaint(0, new Color(0, 0, 200)); createUI(createChartPanel(chart), createOptionsPanel(), bindingContext); isInitialized = true; final Binding minBinding = xAxisRangeControl.getBindingContext().getBinding("min"); final double min = (Double) minBinding.getPropertyValue(); final Binding maxBinding = xAxisRangeControl.getBindingContext().getBinding("max"); final double max = (Double) maxBinding.getPropertyValue(); if (!histogramComputing && min > max) { minBinding.setPropertyValue(max); maxBinding.setPropertyValue(min); } updateXAxis(); }
private XIntervalSeriesCollection createHistogramDataSet(List<RevisionMetricValueDto> dataValues, int numberOfSets, double doubleHistogram[], boolean isDelta) { XIntervalSeriesCollection dataset = new XIntervalSeriesCollection(); XIntervalSeries series = new XIntervalSeries("Metric Values"); int y[] = new int[numberOfSets + 1]; int i; for (i = 0; i < (numberOfSets + 1); i++) { y[i] = 0; } double auxValue; for (RevisionMetricValueDto dataValue : dataValues) { if (isDelta) { auxValue = dataValue.getDeltaMetricValue(); } else { auxValue = dataValue.getAbsoluteMetricValue(); } if (!Double.isNaN(auxValue)) { i = this.getIndexOfHistogram(auxValue, numberOfSets, doubleHistogram); if (i >= 0) { y[i] = y[i] + 1; } } } for (i = 0; i < (numberOfSets); i++) { series.add((doubleHistogram[i] + doubleHistogram[i + 1]) / 2, doubleHistogram[i], doubleHistogram[i + 1], y[i]); } dataset.addSeries(series); return dataset; }
private ChartRenderingInfo createHistogram(int x, int y, XIntervalSeriesCollection dataset, String metricName, String chartPath, ServletContext sc) { try { JFreeChart chart = ChartFactory.createXYBarChart(metricName + " Histogram", "Value", false, "Number", dataset, PlotOrientation.VERTICAL, false, true, false); File chartFile = new File(sc.getRealPath(chartPath)); ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); ChartUtilities.saveChartAsPNG(chartFile, chart, x, y, info); return info; } catch (Exception e) { return null; } }
/** * Verify that this class implements {@link PublicCloneable}. */ public void testPublicCloneable() { XIntervalSeriesCollection c1 = new XIntervalSeriesCollection(); assertTrue(c1 instanceof PublicCloneable); }
private static ChartPanel createChartPanel(XIntervalSeries percentileSeries, String xAxisLabel, String yAxisLabel, Color color) { XIntervalSeriesCollection percentileDataset = new XIntervalSeriesCollection(); percentileDataset.addSeries(percentileSeries); return getHistogramPlotPanel(percentileDataset, xAxisLabel, yAxisLabel, color); }