List of usage examples for org.jfree.data.pie PieDatasetChangeInfo PieDatasetChangeInfo
public PieDatasetChangeInfo(PieDatasetChangeType t, int index1, int index2)
From source file:org.jfree.data.pie.DefaultPieDataset.java
/** * Sets the data value for a key and sends a {@link DatasetChangeEvent} to * all registered listeners./*w w w. j av a 2 s . c om*/ * * @param key the key (<code>null</code> not permitted). * @param value the value. * * @throws IllegalArgumentException if <code>key</code> is * <code>null</code>. */ public void setValue(Comparable key, Number value) { int index = this.data.getIndex(key); PieDatasetChangeType ct = PieDatasetChangeType.ADD; if (index >= 0) { ct = PieDatasetChangeType.UPDATE; } this.data.setObject(key, new SelectableValue(value)); PieDatasetChangeInfo info = new PieDatasetChangeInfo(ct, index, index); fireDatasetChanged(info); }
From source file:org.jfree.data.pie.DefaultPieDataset.java
/** * Inserts a new value at the specified position in the dataset or, if * there is an existing item with the specified key, updates the value * for that item and moves it to the specified position. After the change * is made, this method sends a {@link DatasetChangeEvent} to all * registered listeners./*from w w w. j a v a 2 s .co m*/ * * @param position the position (in the range 0 to getItemCount()). * @param key the key (<code>null</code> not permitted). * @param value the value (<code>null</code> permitted). * * @since 1.0.6 */ public void insertValue(int position, Comparable key, Number value) { this.data.insertValue(position, key, value); PieDatasetChangeType ct = PieDatasetChangeType.ADD; // TODO: unit tests for inserts where key already exists. fireDatasetChanged(new PieDatasetChangeInfo(ct, position, position)); }
From source file:org.jfree.data.pie.DefaultPieDataset.java
/** * Removes an item from the dataset and sends a {@link DatasetChangeEvent} * to all registered listeners./*from ww w . ja v a2 s.co m*/ * * @param key the key (<code>null</code> not permitted). * * @throws IllegalArgumentException if <code>key</code> is * <code>null</code>. */ public void remove(Comparable key) { int i = getIndex(key); this.data.removeValue(key); PieDatasetChangeType ct = PieDatasetChangeType.REMOVE; fireDatasetChanged(new PieDatasetChangeInfo(ct, i, i)); }
From source file:org.jfree.data.pie.DefaultPieDataset.java
/** * Clears all data from this dataset and sends a {@link DatasetChangeEvent} * to all registered listeners (unless the dataset was already empty). * * @since 1.0.2//ww w . j ava 2 s . c o m */ public void clear() { if (getItemCount() > 0) { this.data.clear(); PieDatasetChangeType ct = PieDatasetChangeType.CLEAR; fireDatasetChanged(new PieDatasetChangeInfo(ct, -1, -1)); } }
From source file:org.jfree.data.pie.DefaultPieDataset.java
/** * Sorts the dataset's items by key and sends a {@link DatasetChangeEvent} * to all registered listeners./*from w ww . j ava2 s. com*/ * * @param order the sort order (<code>null</code> not permitted). * * @since 1.0.3 */ public void sortByKeys(SortOrder order) { this.data.sortByKeys(order); PieDatasetChangeType ct = PieDatasetChangeType.UPDATE; fireDatasetChanged(new PieDatasetChangeInfo(ct, 0, getItemCount() - 1)); }
From source file:org.jfree.data.pie.DefaultPieDataset.java
/** * Sorts the dataset's items by value and sends a {@link DatasetChangeEvent} * to all registered listeners.//from w w w. jav a 2 s .c om * * @param order the sort order (<code>null</code> not permitted). * * @since 1.0.3 */ public void sortByValues(SortOrder order) { this.data.sortByObjects(order); PieDatasetChangeType ct = PieDatasetChangeType.UPDATE; fireDatasetChanged(new PieDatasetChangeInfo(ct, 0, getItemCount() - 1)); }