/** * Some checks for a simple dataset. */ public void testStandard() { TimeTableXYDataset d = new TimeTableXYDataset(); d.add(new Year(1999), 1.0, "Series 1"); assertEquals(d.getItemCount(), 1); assertEquals(d.getSeriesCount(), 1); d.add(new Year(2000), 2.0, "Series 2"); assertEquals(d.getItemCount(), 2); assertEquals(d.getSeriesCount(), 2); assertEquals(d.getYValue(0, 0), 1.0, DELTA); assertTrue(Double.isNaN(d.getYValue(0, 1))); assertTrue(Double.isNaN(d.getYValue(1, 0))); assertEquals(d.getYValue(1, 1), 2.0, DELTA); }
/** * Some checks for the getTimePeriod() method. */ public void testGetTimePeriod() { TimeTableXYDataset d = new TimeTableXYDataset(); d.add(new Year(1999), 1.0, "Series 1"); d.add(new Year(1998), 2.0, "Series 1"); d.add(new Year(1996), 3.0, "Series 1"); assertEquals(d.getTimePeriod(0), new Year(1996)); assertEquals(d.getTimePeriod(1), new Year(1998)); assertEquals(d.getTimePeriod(2), new Year(1999)); }
public void processNode(Object name, Map map, Object value) throws Exception { if(value != null && value instanceof TimeTableXYDataset) { this.xyDataset = (TimeTableXYDataset)value; }else { // TODO } }
private ChartPanel buildSmallMidLargeCapChart(TimeSeriesModel timeSeriesModel) { TimeTableXYDataset xyDataset = buildTimeTableXYDataset(timeSeriesModel, smallMidLargeAreaTimeSeriesTypes); LegendItemCollection legendItems = new LegendItemCollection(); legendItems.add(new LegendItem(resourceManager.getString("smallcap"), Color.blue)); legendItems.add(new LegendItem(resourceManager.getString("midcap"), Color.magenta)); legendItems.add(new LegendItem(resourceManager.getString("largecap"), Color.green)); XYItemRenderer xyItemRenderer = buildXYAreaRenderer(Color.blue, Color.magenta, Color.green); XYPlot xyPlot = new XYPlot(xyDataset, buildDateAxis(), buildNumberAxis(), xyItemRenderer); xyPlot.setRangeAxis(1, buildNumberAxis()); xyPlot.mapDatasetToRangeAxes(0, buildRangeAxes()); xyPlot.setFixedLegendItems(legendItems); applyXYPlotLookAndFeel(xyPlot, false); xyPlots.add(xyPlot); return buildChartPanel(buildChart(smallMidLargeCap, xyPlot)); }
private ChartPanel buildValueCoreGrowthChart(TimeSeriesModel timeSeriesModel) { TimeTableXYDataset xyDataset = buildTimeTableXYDataset(timeSeriesModel, valueCoreGrowthAreaTimeSeriesTypes); LegendItemCollection legendItems = new LegendItemCollection(); legendItems.add(new LegendItem(resourceManager.getString("value"), Color.cyan)); legendItems.add(new LegendItem(resourceManager.getString("core"), Color.yellow)); legendItems.add(new LegendItem(resourceManager.getString("growth"), Color.black)); XYItemRenderer xyItemRenderer = buildXYAreaRenderer(Color.cyan, Color.yellow, Color.black); XYPlot xyPlot = new XYPlot(xyDataset, buildDateAxis(), buildNumberAxis(), xyItemRenderer); xyPlot.setRangeAxis(1, buildNumberAxis()); xyPlot.mapDatasetToRangeAxes(0, buildRangeAxes()); xyPlot.setFixedLegendItems(legendItems); applyXYPlotLookAndFeel(xyPlot, false); xyPlots.add(xyPlot); return buildChartPanel(buildChart(valueCoreGrowth, xyPlot)); }
@SuppressWarnings("unchecked") public Dataset getDataset() { Map<String, TimePeriodCollater> seriesToPeriodMap = new HashMap<String, TimePeriodCollater>(); TimeTableXYDataset dataset = new TimeTableXYDataset(); for (ResultsSummary summary : getResultsList()) { String[] seriesKeys = getSeriesKeys(summary); if (seriesKeys != null) { for (int i = 0; (i < seriesKeys.length); i++) { String key = seriesKeys[i]; Date buildDate = summary.getBuildDate(); TimePeriodCollater collaterForSeries = (TimePeriodCollater) seriesToPeriodMap.get(key); if (collaterForSeries == null) { collaterForSeries = createCollater(getPeriod(buildDate, getPeriodRange()), key); collaterForSeries.addResult(summary); seriesToPeriodMap.put(key, collaterForSeries); } else if (isInPeriod(collaterForSeries.getPeriod(), buildDate)) { collaterForSeries.addResult(summary); } else { writeCollaterToDataSet(dataset, collaterForSeries); RegularTimePeriod nextPeriod = collaterForSeries.getPeriod().next(); while (!isInPeriod(nextPeriod, buildDate)) { nextPeriod = nextPeriod.next(); } collaterForSeries = createCollater(nextPeriod, key); collaterForSeries.addResult(summary); seriesToPeriodMap.put(key, collaterForSeries); } } } } Collection<TimePeriodCollater> finalPeriods = seriesToPeriodMap.values(); TimePeriodCollater timePeriodCollater; for (Iterator<TimePeriodCollater> iterator = finalPeriods.iterator(); iterator.hasNext(); writeCollaterToDataSet(dataset, timePeriodCollater)) { timePeriodCollater = iterator.next(); } return dataset; }
/******************************************************************************************************** * run(). * * @return */ private String run() { if ((resultsList != null) && !resultsList.isEmpty()) { ModuleDescriptor descriptor = pluginManager.getPluginModule(getReportKey()); if (descriptor != null) { ReportCollector collector = (ReportCollector) descriptor.getModule(); collector.setResultsList(getResultsList()); collector.setParams(Collections.EMPTY_MAP); dataset = (TimeTableXYDataset) collector.getDataset(); } } return SUCCESS; }
/** * Test clearing data. */ public void testClear() { TimeTableXYDataset d = new TimeTableXYDataset(); d.add(new Year(1999), 1.0, "Series 1"); assertEquals(d.getItemCount(), 1); assertEquals(d.getSeriesCount(), 1); d.add(new Year(2000), 2.0, "Series 2"); d.clear(); // Make sure there's nothing left assertEquals(0, d.getItemCount()); assertEquals(0, d.getSeriesCount()); }
/** Create the dataset used for the plot. */ private TimeTableXYDataset createDataset() { TimeTableXYDataset dataset = new TimeTableXYDataset(); for (SeriesDescriptor seriesDesriptor : seriesList) { String seriesTitle = seriesDesriptor.seriesTitle; TimeSeries timeSeries = createTimeSeries(seriesTitle, seriesDesriptor.series); for (int i = 0; i < timeSeries.getItemCount(); ++i) { TimeSeriesDataItem di = timeSeries.getDataItem(i); dataset.add(di.getPeriod(), di.getValue().doubleValue(), seriesTitle); } } return dataset; }
/******************************************************************************************************** * generateToolTip(). * * @param xyDataset * @param series * @param item * @return */ public String generateToolTip(XYDataset xyDataset, int series, int item) { TimeTableXYDataset dataset = (TimeTableXYDataset) xyDataset; double checkstyleDelta = dataset.getYValue(series, item); String authorName = (String) dataset.getSeriesKey(series); TimePeriod timePeriod = dataset.getTimePeriod(item); return NumberUtils.round(checkstyleDelta, 1) + " CheckStyle violation delta on " + timePeriod + " for " + authorName; }
/******************************************************************************************************** * generateToolTip(). * * @param xyDataset * @param series * @param item * @return */ public String generateToolTip(XYDataset xyDataset, int series, int item) { TimeTableXYDataset dataset = (TimeTableXYDataset) xyDataset; double violations = dataset.getYValue(series, item); String buildKey = (String) dataset.getSeriesKey(series); TimePeriod timePeriod = dataset.getTimePeriod(item); return "Build in " + timePeriod + " contained " + NumberUtils.round(violations, 1) + " style violations in build " + buildKey; }
/** * Getter for property xyDataset. * @return Value of property xyDataset. */ public TimeTableXYDataset getXyDataset() { return this.xyDataset; }
/** * Setter for property xyDataset. * @param xyDataset New value of property xyDataset. */ public void setXyDataset(TimeTableXYDataset xyDataset) { this.xyDataset = xyDataset; }