Example usage for org.jfree.data.pie PieDataset getKey

List of usage examples for org.jfree.data.pie PieDataset getKey

Introduction

In this page you can find the example usage for org.jfree.data.pie PieDataset getKey.

Prototype

public Comparable getKey(int index);

Source Link

Document

Returns the key associated with the item at a given position.

Usage

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

/**
 * Tests if this object is equal to another.
 *
 * @param obj  the other object.//from  w ww .j  a  v a 2  s .  c  o m
 *
 * @return A boolean.
 */
public boolean equals(Object obj) {
    if (obj == this) {
        return true;
    }

    if (!(obj instanceof PieDataset)) {
        return false;
    }
    PieDataset that = (PieDataset) obj;
    int count = getItemCount();
    if (that.getItemCount() != count) {
        return false;
    }

    for (int i = 0; i < count; i++) {
        Comparable k1 = getKey(i);
        Comparable k2 = that.getKey(i);
        if (!k1.equals(k2)) {
            return false;
        }

        Number v1 = getValue(i);
        Number v2 = that.getValue(i);
        if (v1 == null) {
            if (v2 != null) {
                return false;
            }
        } else {
            if (!v1.equals(v2)) {
                return false;
            }
        }
    }
    return true;

}