compareTo method

int compareTo(
  1. Object o
)

Compares two envelopes using lexicographic ordering. The ordering comparison is based on the usual numerical comparison between the sequence of ordinates. Null envelopes are less than all non-null envelopes.

@param o an Envelope object

Implementation

int compareTo(Object o) {
  Envelope env = o as Envelope;
  // compare nulls if present
  if (isNull()) {
    if (env.isNull()) return 0;
    return -1;
  } else {
    if (env.isNull()) return 1;
  }
  // compare based on numerical ordering of ordinates
  if (_minx < env._minx) return -1;
  if (_minx > env._minx) return 1;
  if (_miny < env._miny) return -1;
  if (_miny > env._miny) return 1;
  if (_maxx < env._maxx) return -1;
  if (_maxx > env._maxx) return 1;
  if (_maxy < env._maxy) return -1;
  if (_maxy > env._maxy) return 1;
  return 0;
}