Example usage for org.jfree.data KeyedValues2D getValue

List of usage examples for org.jfree.data KeyedValues2D getValue

Introduction

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

Prototype

public Number getValue(Comparable rowKey, Comparable columnKey);

Source Link

Document

Returns the value associated with the specified keys.

Usage

From source file:org.jfree.data.DefaultKeyedValues2D.java

/**
 * Tests if this object is equal to another.
 *
 * @param o  the other object (<code>null</code> permitted).
 *
 * @return A boolean.//from   ww  w.  j ava  2s. c  o  m
 */
public boolean equals(Object o) {

    if (o == null) {
        return false;
    }
    if (o == this) {
        return true;
    }

    if (!(o instanceof KeyedValues2D)) {
        return false;
    }
    KeyedValues2D kv2D = (KeyedValues2D) o;
    if (!getRowKeys().equals(kv2D.getRowKeys())) {
        return false;
    }
    if (!getColumnKeys().equals(kv2D.getColumnKeys())) {
        return false;
    }
    int rowCount = getRowCount();
    if (rowCount != kv2D.getRowCount()) {
        return false;
    }

    int colCount = getColumnCount();
    if (colCount != kv2D.getColumnCount()) {
        return false;
    }

    for (int r = 0; r < rowCount; r++) {
        for (int c = 0; c < colCount; c++) {
            Number v1 = getValue(r, c);
            Number v2 = kv2D.getValue(r, c);
            if (v1 == null) {
                if (v2 != null) {
                    return false;
                }
            } else {
                if (!v1.equals(v2)) {
                    return false;
                }
            }
        }
    }
    return true;
}

From source file:org.jfree.data.DefaultKeyedValues2D.java

/**
 * Tests if this object is equal to another.
 *
 * @param o  the other object (<code>null</code> permitted).
 *
 * @return A boolean.//from www.  ja  v a  2 s  . co m
 */
@Override
public boolean equals(Object o) {

    if (o == null) {
        return false;
    }
    if (o == this) {
        return true;
    }

    if (!(o instanceof KeyedValues2D)) {
        return false;
    }
    KeyedValues2D kv2D = (KeyedValues2D) o;
    if (!getRowKeys().equals(kv2D.getRowKeys())) {
        return false;
    }
    if (!getColumnKeys().equals(kv2D.getColumnKeys())) {
        return false;
    }
    int rowCount = getRowCount();
    if (rowCount != kv2D.getRowCount()) {
        return false;
    }

    int colCount = getColumnCount();
    if (colCount != kv2D.getColumnCount()) {
        return false;
    }

    for (int r = 0; r < rowCount; r++) {
        for (int c = 0; c < colCount; c++) {
            Number v1 = getValue(r, c);
            Number v2 = kv2D.getValue(r, c);
            if (v1 == null) {
                if (v2 != null) {
                    return false;
                }
            } else {
                if (!v1.equals(v2)) {
                    return false;
                }
            }
        }
    }
    return true;
}