001: //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/opengis/pt/PT_Envelope.java $
002: /*
003: * OpenGIS� Coordinate Transformation Services Implementation Specification
004: * Copyright (2001) OpenGIS consortium
005: *
006: * THIS COPYRIGHT NOTICE IS A TEMPORARY PATCH. Version 1.00 of official
007: * OpenGIS's interface files doesn't contain a copyright notice yet. This
008: * file is a slightly modified version of official OpenGIS's interface.
009: * Changes have been done in order to fix RMI problems and are documented
010: * on the SEAGIS web site (seagis.sourceforge.net). THIS FILE WILL LIKELY
011: * BE REPLACED BY NEXT VERSION OF OPENGIS SPECIFICATIONS.
012: */
013: package org.opengis.pt;
014:
015: // Various JDK's classes
016: import java.io.Serializable;
017:
018: /**
019: * A box defined by two positions.
020: * The two positions must have the same dimension.
021: * Each of the ordinate values in the minimum point must be less than or equal
022: * to the corresponding ordinate value in the maximum point. Please note that
023: * these two points may be outside the valid domain of their coordinate system.
024: * (Of course the points and envelope do not explicitly reference a coordinate
025: * system, but their implicit coordinate system is defined by their context.)
026: *
027: * @version 1.01
028: * @since 1.00
029: * @author Martin Daly
030: * @author Martin Desruisseaux
031: */
032: public class PT_Envelope implements Cloneable, Serializable {
033: /**
034: * Use <code>serialVersionUID</code> from first
035: * draft for interoperability with CSS 1.00.
036: */
037: private static final long serialVersionUID = -1819256261961411213L;
038:
039: /**
040: * Point containing minimum ordinate values.
041: */
042: public PT_CoordinatePoint minCP;
043:
044: /**
045: * Point containing maximum ordinate values.
046: */
047: public PT_CoordinatePoint maxCP;
048:
049: /**
050: * Construct an empty envelope. Caller must
051: * initialize {@link #minCP} and {@link #maxCP}.
052: */
053: public PT_Envelope() {
054: }
055:
056: /**
057: * Returns a hash value for this envelope.
058: * This value need not remain consistent between
059: * different implementations of the same class.
060: */
061: public int hashCode() {
062: int code = 7896312;
063: if (minCP != null)
064: code = code * 37 + minCP.hashCode();
065: if (maxCP != null)
066: code = code * 37 + maxCP.hashCode();
067: return code;
068: }
069:
070: /**
071: * Compares the specified object with
072: * this envelope for equality.
073: */
074: public boolean equals(final Object object) {
075: if (object != null && getClass().equals(object.getClass())) {
076: final PT_Envelope that = (PT_Envelope) object;
077: return (minCP == that.minCP || (minCP != null && minCP
078: .equals(that.minCP)))
079: && (maxCP == that.maxCP || (maxCP != null && maxCP
080: .equals(that.maxCP)));
081: }
082: return false;
083: }
084:
085: /**
086: * Returns a deep copy of this envelope.
087: */
088: public Object clone() {
089: try {
090: final PT_Envelope copy = (PT_Envelope) super .clone();
091: if (copy.minCP != null)
092: copy.minCP = (PT_CoordinatePoint) copy.minCP.clone();
093: if (copy.maxCP != null)
094: copy.maxCP = (PT_CoordinatePoint) copy.maxCP.clone();
095: return copy;
096: } catch (CloneNotSupportedException exception) {
097: // Should not happen, since we are cloneable.
098: throw new InternalError(exception.getMessage());
099: }
100: }
101:
102: /**
103: * Returns a string representation of this envelope.
104: * The returned string is implementation dependent.
105: * It is usually provided for debugging purposes only.
106: */
107: public String toString() {
108: final StringBuffer buffer = new StringBuffer("PT_Envelope");
109: buffer.append('[');
110: buffer.append(minCP);
111: buffer.append(", ");
112: buffer.append(maxCP);
113: buffer.append(']');
114: return buffer.toString();
115: }
116: }
117: /* ********************************************************************
118: Changes to this class. What the people have been up to:
119: $Log$
120: Revision 1.2 2006/07/13 06:28:31 poth
121: comment footer added
122:
123: ********************************************************************** */
|