if (that.getItemCount() != count) { return false; Comparable k2 = that.getKey(i); if (!k1.equals(k2)) { return false; Number v2 = that.getValue(i); if (v1 == null) { if (v2 != null) {
/** * Returns the section label as supplied in the constructor. * * @param dataset the dataset. * @param key the section key. * * @return The section label. */ public String generateSectionLabel(PieDataset dataset, Comparable key) { int index = dataset.getIndex(key); if (index < this.labels.size()) { return this.labels.get(index).toString(); } else { return null; } }
/** * 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; }
public String generateToolTip(PieDataset dataset, Comparable key) { Number number = dataset.getValue(key); return key + ": " + number.intValue() + " (" + (100 * number.intValue() / totalCopy) + "%)"; } });
/** * 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; }
return result; List keys = this.dataset.getKeys(); int section = 0; Shape shape = getLegendItemShape(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); Number n = this.dataset.getValue(key); boolean include; if (n == null) { new Line2D.Float(), new BasicStroke(), Color.BLACK); item.setDataset(getDataset()); item.setSeriesIndex(this.dataset.getIndex(key)); item.setSeriesKey(key); result.add(item);
private static Collection getAllStatisticKeys(PieDataset pieDataset) { final List statisticKeys = newArrayList(); final List segmentKeys = pieDataset.getKeys(); for (final Object segmentKey : segmentKeys) { if (segmentKey instanceof PieSegment) { statisticKeys.add(((PieSegment) segmentKey).getKey()); } } return statisticKeys; }
private static void setSectionColor(PieDataset dataset, PiePlot plot, int section, Color outline, Color paint ) { try { Comparable key = dataset.getKey(section); plot.setSectionOutlinePaint(key, outline); plot.setSectionPaint(key, paint); } catch (IndexOutOfBoundsException ie) { // This item hasn't been created, in the dataset so we skip it and don't set its colours // No further action is currently required in this case. } } }
/** * Sets the dataset and sends a {@link DatasetChangeEvent} to 'this'. * * @param dataset the dataset ({@code null} permitted). * * @see #getDataset() */ public void setDataset(PieDataset dataset) { // if there is an existing dataset, remove the plot from the list of // change listeners... PieDataset existing = this.dataset; if (existing != null) { existing.removeChangeListener(this); } // set the new dataset, and register the chart as a change listener... this.dataset = dataset; if (dataset != null) { setDatasetGroup(dataset.getGroup()); dataset.addChangeListener(this); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); }
PiePlot clone = (PiePlot) super.clone(); if (clone.dataset != null) { clone.dataset.addChangeListener(clone);
/** * 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; }
public String generateToolTip(final PieDataset dataset, final Comparable key) { final Number number = dataset.getValue(key); return key + ": " + number + " " + i18nBean.getText(ISSUES_MESSAGE_CODE) + " (" + (100 * number.intValue() / numIssues) + "%)"; } };
return result; List keys = this.dataset.getKeys(); int section = 0; Shape shape = getLegendItemShape(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); Number n = this.dataset.getValue(key); boolean include = true; if (n == null) { new Line2D.Float(), new BasicStroke(), Color.black); item.setDataset(getDataset()); item.setSeriesIndex(this.dataset.getIndex(key)); item.setSeriesKey(key); result.add(item);
/** * 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; }
/** * Returns the maximum explode percent. * * @return The percent. */ public double getMaximumExplodePercent() { if (this.dataset == null) { return 0.0; } double result = 0.0; Iterator iterator = this.dataset.getKeys().iterator(); while (iterator.hasNext()) { Comparable key = (Comparable) iterator.next(); Number explode = (Number) this.explodePercentages.get(key); if (explode != null) { result = Math.max(result, explode.doubleValue()); } } return result; }
/** * Sets the dataset and sends a {@link DatasetChangeEvent} to 'this'. * * @param dataset the dataset (<code>null</code> permitted). * * @see #getDataset() */ public void setDataset(PieDataset dataset) { // if there is an existing dataset, remove the plot from the list of // change listeners... PieDataset existing = this.dataset; if (existing != null) { existing.removeChangeListener(this); } // set the new dataset, and register the chart as a change listener... this.dataset = dataset; if (dataset != null) { setDatasetGroup(dataset.getGroup()); dataset.addChangeListener(this); } // send a dataset change event to self... DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); datasetChanged(event); }
this.dataset = dataset; if (dataset != null) { dataset.addChangeListener(this);