/** * Returns a key for the specified section. If there is no such section * in the dataset, we generate a key. This is to provide some backward * compatibility for the (now deprecated) methods that get/set attributes * based on section indices. The preferred way of doing this now is to * link the attributes directly to the section key (there are new methods * for this, starting from version 1.0.3). * * @param section the section index. * * @return The key. * * @since 1.0.3 */ protected Comparable getSectionKey(int section) { Comparable key = null; if (this.dataset != null) { if (section >= 0 && section < this.dataset.getItemCount()) { key = this.dataset.getKey(section); } } if (key == null) { key = new Integer(section); } return key; }
/** * Returns a key for the specified section. If there is no such section * in the dataset, we generate a key. This is to provide some backward * compatibility for the (now deprecated) methods that get/set attributes * based on section indices. The preferred way of doing this now is to * link the attributes directly to the section key (there are new methods * for this, starting from version 1.0.3). * * @param section the section index. * * @return The key. * * @since 1.0.3 */ protected Comparable getSectionKey(int section) { Comparable key = null; if (this.dataset != null) { if (section >= 0 && section < this.dataset.getItemCount()) { key = this.dataset.getKey(section); } } if (key == null) { key = new Integer(section); } return key; }
/** * Returns {@code true} if the dataset is empty (or {@code null}), * and {@code false} otherwise. * * @param dataset the dataset ({@code null} permitted). * * @return A boolean. */ public static boolean isEmptyOrNull(PieDataset dataset) { if (dataset == null) { return true; } int itemCount = dataset.getItemCount(); if (itemCount == 0) { return true; } for (int item = 0; item < itemCount; item++) { Number y = dataset.getValue(item); if (y != null) { double yy = y.doubleValue(); if (yy > 0.0) { return false; } } } return true; }
/** * Returns <code>true</code> if the dataset is empty (or <code>null</code>), * and <code>false</code> otherwise. * * @param dataset the dataset (<code>null</code> permitted). * * @return A boolean. */ public static boolean isEmptyOrNull(PieDataset dataset) { if (dataset == null) { return true; } int itemCount = dataset.getItemCount(); if (itemCount == 0) { return true; } for (int item = 0; item < itemCount; item++) { Number y = dataset.getValue(item); if (y != null) { double yy = y.doubleValue(); if (yy > 0.0) { return false; } } } return true; }
/** * Sort a pie dataset by it's values (highest to lowest) * @param source the source dataset (<code>null</code> not permitted). * @return The pie dataset with sorted items. */ public static PieDataset createSortedPieDataset(PieDataset source) { List items = new ArrayList(source.getItemCount()); for (Iterator iterator = source.getKeys().iterator(); iterator.hasNext();) { Comparable key = (Comparable) iterator.next(); Number dataValue = source.getValue(key); items.add(new SortableItem(key, dataValue)); } Collections.sort(items); Collections.reverse(items); DefaultPieDataset sortedDataset = new DefaultPieDataset(); for (Iterator iterator = items.iterator(); iterator.hasNext();) { SortableItem sortableItem = (SortableItem) iterator.next(); sortedDataset.setValue(sortableItem.key, sortableItem.value); } return sortedDataset; }
int sectionCount = dataset.getItemCount(); if (colors.length < sectionCount) { // we need to interpolate some
if (that.getItemCount() != count) { return false;
if (that.getItemCount() != count) { return false;
if (that.getItemCount() != count) { return false;
if (that.getItemCount() != count) { return false;
/** * Handle color customization requested. * - get customization parameters from parameter Map and modify plot accordingly * @param parameters macro parameters * @param plot chart plot * @throws MacroExecutionException */ void handleColorCustomization(Map parameters, Plot plot) throws MacroExecutionException { String colors = (String) parameters.get("colors"); if (colors != null) { String[] color = colors.split(","); for (int i = 0; i < color.length; i++) { if (plot instanceof CategoryPlot) { ((CategoryPlot) plot).getRenderer().setSeriesPaint(i, stringToColor(color[i])); } else if (plot instanceof XYPlot) { ((XYPlot) plot).getRenderer().setSeriesPaint(i, stringToColor(color[i])); } else if (plot instanceof PiePlot) { PiePlot piePlot = (PiePlot)plot; PieDataset pieDataset = piePlot.getDataset(); if (i < pieDataset.getItemCount()) piePlot.setSectionPaint(pieDataset.getKey(i), stringToColor(color[i])); } } } }
for (int i = 0; i < piedataset.getItemCount(); i++) { Comparable key = piedataset.getKey(i); Paint p;
for (int i = 0; i < piedataset.getItemCount(); i++) { Comparable key = piedataset.getKey(i); Paint p;
PiePlot plot = (PiePlot) chart.getPlot(); PieDataset dataset = plot.getDataset(); for (int i = 0; i < dataset.getItemCount(); i++) { String key = (String) dataset.getKey(i); plot.setSectionPaint(key, seriesColorsByName.get(key));
for(int i = 0; i < piedataset.getItemCount(); i++)
for (int j = 0; j < dataset.getItemCount(); j++)
for (int j = 0; j < dataset.getItemCount(); j++)