/** * Creates the dataset needed for this graph. * @return dataset */ private TimeTableXYDataset createDataset() { TimeTableXYDataset dataset = new TimeTableXYDataset(); KnowledgeBase knowledgeBase = PluginImpl.getInstance().getKnowledgeBase(); Map<TimePeriod, Double> periodQuotas = knowledgeBase.getUnknownFailureCauseQuotaPerTime(intervalSize, filter); for (Entry<TimePeriod, Double> entry : periodQuotas.entrySet()) { dataset.add(entry.getKey(), entry.getValue() * HUNDRED_PERCENT, ""); } return dataset; }
/** * Removes an existing data item from the dataset and, if requested, * sends a {@link DatasetChangeEvent} to all registered listeners. * * @param period the (existing!) time period of the value to remove * (<code>null</code> not permitted). * @param seriesName the (existing!) series name to remove the value * (<code>null</code> not permitted). * @param notify whether dataset listener are notified or not. * * @see #add(TimePeriod, double, String) */ public void remove(TimePeriod period, String seriesName, boolean notify) { this.values.removeValue(period, seriesName); if (notify) { fireDatasetChanged(); } }
/** * Returns the maximum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The maximum value. */ public double getDomainUpperBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getUpperBound(); } return result; }
/** * Adds a new data item to the dataset and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param period the time period. * @param y the value for this period. * @param seriesName the name of the series to add the value. * * @see #remove(TimePeriod, Comparable) */ public void add(TimePeriod period, double y, Comparable seriesName) { add(period, new Double(y), seriesName, true); }
@Override public void setParameters(Map<String, String> parameters) throws MacroExecutionException { String timePeriodTypeString = parameters.get(TIMEPERIOD_TYPE_PARAM); if (timePeriodTypeString != null) { this.timePeriodType = TimePeriodType.forName(timePeriodTypeString); if (this.timePeriodType == null) { throw new MacroExecutionException(String.format("Invalid time period type [%s].", timePeriodTypeString)); } } dataset = new TimeTableXYDataset(localeConfiguration.getTimeZone(), localeConfiguration.getLocale()); }
/** * Returns the number of items in a series. This is the same value * that is returned by {@link #getItemCount()} since all series * share the same x-values (time periods). * * @param series the series (zero-based index, ignored). * * @return The number of items within the series. */ public int getItemCount(int series) { return getItemCount(); }
/** * Returns the ending X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The ending X value for the specified series and item. * * @see #getEndXValue(int, int) */ public Number getEndX(int series, int item) { return new Double(getEndXValue(series, item)); }
/** * Returns the starting X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The starting X value for the specified series and item. * * @see #getStartXValue(int, int) */ public Number getStartX(int series, int item) { return new Double(getStartXValue(series, item)); }
/** * Adds a new data item to the dataset and sends a * {@link DatasetChangeEvent} to all registered listeners. * * @param period the time period. * @param y the value for this period. * @param seriesName the name of the series to add the value. * * @see #remove(TimePeriod, String) */ public void add(TimePeriod period, double y, String seriesName) { add(period, new Double(y), seriesName, true); }
final TimeTableXYDataset dataset = new TimeTableXYDataset(); JFreeChart chart = createAreaChart(dataset);
/** * Returns the number of items in a series. This is the same value * that is returned by {@link #getItemCount()} since all series * share the same x-values (time periods). * * @param series the series (zero-based index, ignored). * * @return The number of items within the series. */ @Override public int getItemCount(int series) { return getItemCount(); }
/** * Returns the ending X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The ending X value for the specified series and item. * * @see #getEndXValue(int, int) */ @Override public Number getEndX(int series, int item) { return new Double(getEndXValue(series, item)); }
/** * Returns the starting X value for the specified series and item. * * @param series the series (zero-based index). * @param item the item within a series (zero-based index). * * @return The starting X value for the specified series and item. * * @see #getStartXValue(int, int) */ @Override public Number getStartX(int series, int item) { return new Double(getStartXValue(series, item)); }
TimeTableXYDataset dataset = new TimeTableXYDataset(); for (int i = 0; i < 10; i++) { TimePeriod period = new Millisecond(); dataset.add(period, i, "Series 1"); dataset.add(period, i + 5, "Series 2"); dataset.add(period, i + 10, "Series 3"); dataset.add(period, i + 15, "Series 4");
private void buildDataSet(Map<TimePeriod,Integer> incoming, TimeTableXYDataset ds, String label) { for (Entry<TimePeriod,Integer> e : incoming.entrySet()) ds.add(e.getKey(),e.getValue(),label,false); }
protected XYDataset buildDataSet(List<Activity> activities) throws IOException { Map<TimePeriod,Integer> created = new TreeMap<TimePeriod,Integer>(); Map<TimePeriod,Integer> resolved = new TreeMap<TimePeriod,Integer>(); for (Activity a : activities) { if(!a.isUpdate()) { inc(a,created); continue; } if(a.getField()!= IssueField.STATUS) continue; IssueStatus o = IssueStatus.valueOf(a.getOldValue()); IssueStatus n = IssueStatus.valueOf(a.getNewValue()); if(o.needsWork && !n.needsWork) inc(a,resolved); if(!o.needsWork && n.needsWork) inc(a,created); } TimeTableXYDataset ds = new TimeTableXYDataset(); // add resolved first so that this becomes the foreground buildDataSet(resolved, ds, "resolved"); buildDataSet(created, ds, "created"); saveDataset(ds); return ds; }
/** * Removes an existing data item from the dataset and, if requested, * sends a {@link DatasetChangeEvent} to all registered listeners. * * @param period the (existing!) time period of the value to remove * ({@code null} not permitted). * @param seriesName the (existing!) series name to remove the value * ({@code null} not permitted). * @param notify whether dataset listener are notified or not. * * @see #add(TimePeriod, double, Comparable) */ public void remove(TimePeriod period, Comparable seriesName, boolean notify) { this.values.removeValue(period, seriesName); if (notify) { fireDatasetChanged(); } }
/** * Returns the minimum x-value in the dataset. * * @param includeInterval a flag that determines whether or not the * x-interval is taken into account. * * @return The minimum value. */ public double getDomainLowerBound(boolean includeInterval) { double result = Double.NaN; Range r = getDomainBounds(includeInterval); if (r != null) { result = r.getLowerBound(); } return result; }
TimeTableXYDataset timetablexydataset = new TimeTableXYDataset(); Day day = new Day(1, 3, 2005); Day day1 = new Day(2, 3, 2005); Day day3 = new Day(4, 3, 2005); Day day4 = new Day(5, 3, 2005); timetablexydataset.add(day, 1.0D, "Series 1"); timetablexydataset.add(day1, 1.7D, "Series 1"); timetablexydataset.add(day3, 3.7000000000000002D, "Series 1"); timetablexydataset.add(day4, 2.6000000000000001D, "Series 1"); timetablexydataset.add(day, 3.2000000000000002D, "Series 2"); timetablexydataset.add(day1, 1.1000000000000001D, "Series 2"); timetablexydataset.add(day2, 1.3999999999999999D, "Series 2"); timetablexydataset.add(day3, 2.8999999999999999D, "Series 2"); timetablexydataset.add(day4, 0.59999999999999998D, "Series 2"); return timetablexydataset;
protected void add(TimeTableXYDataset ds, Calendar start, Calendar end, int value, String seriesName) { ds.add(new SimpleTimePeriod(start.getTime(),end==null?new Date():end.getTime()),value, seriesName, false); } }