Example usage for org.jfree.data SelectableValue SelectableValue

List of usage examples for org.jfree.data SelectableValue SelectableValue

Introduction

In this page you can find the example usage for org.jfree.data SelectableValue SelectableValue.

Prototype

public SelectableValue(Number value) 

Source Link

Document

Creates a new instance with the specified value and the selection state set to false.

Usage

From source file:org.jfree.data.pie.DefaultPieDataset.java

/**
 * Creates a new dataset by copying data from a {@link KeyedValues}
 * instance./*from  ww  w . jav  a 2s. c o  m*/
 *
 * @param data  the data (<code>null</code> not permitted).
 */
public DefaultPieDataset(KeyedValues data) {
    if (data == null) {
        throw new IllegalArgumentException("Null 'data' argument.");
    }
    this.data = new KeyedObjects();
    for (int i = 0; i < data.getItemCount(); i++) {
        SelectableValue dataItem = new SelectableValue(data.getValue(i));
        this.data.addObject(data.getKey(i), dataItem);
    }
}

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.//  www .j a  v  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);
}