@Override
    public boolean equals(Object obj) {
        if (obj == this) {
            return true;
        }
        if (obj instanceof Rectangle2D) {
            Rectangle2D r = (Rectangle2D)obj;
            return
                getX() == r.getX() &&
                getY() == r.getY() &&
                getWidth() == r.getWidth() &&
                getHeight() == r.getHeight();
        }
        return false;
    }