001 //$HeadURL: svn+ssh://rbezema@svn.wald.intevation.org/deegree/base/branches/2.2_testing/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 /** 020 * A box defined by two positions. 021 * The two positions must have the same dimension. 022 * Each of the ordinate values in the minimum point must be less than or equal 023 * to the corresponding ordinate value in the maximum point. Please note that 024 * these two points may be outside the valid domain of their coordinate system. 025 * (Of course the points and envelope do not explicitly reference a coordinate 026 * system, but their implicit coordinate system is defined by their context.) 027 * 028 * @version 1.01 029 * @since 1.00 030 * @author Martin Daly 031 * @author Martin Desruisseaux 032 */ 033 public class PT_Envelope implements Cloneable, Serializable 034 { 035 /** 036 * Use <code>serialVersionUID</code> from first 037 * draft for interoperability with CSS 1.00. 038 */ 039 private static final long serialVersionUID = -1819256261961411213L; 040 041 /** 042 * Point containing minimum ordinate values. 043 */ 044 public PT_CoordinatePoint minCP; 045 046 /** 047 * Point containing maximum ordinate values. 048 */ 049 public PT_CoordinatePoint maxCP; 050 051 /** 052 * Construct an empty envelope. Caller must 053 * initialize {@link #minCP} and {@link #maxCP}. 054 */ 055 public PT_Envelope() 056 {} 057 058 /** 059 * Returns a hash value for this envelope. 060 * This value need not remain consistent between 061 * different implementations of the same class. 062 */ 063 public int hashCode() 064 { 065 int code = 7896312; 066 if (minCP!=null) code = code*37 + minCP.hashCode(); 067 if (maxCP!=null) code = code*37 + maxCP.hashCode(); 068 return code; 069 } 070 071 /** 072 * Compares the specified object with 073 * this envelope for equality. 074 */ 075 public boolean equals(final Object object) 076 { 077 if (object!=null && getClass().equals(object.getClass())) 078 { 079 final PT_Envelope that = (PT_Envelope) object; 080 return (minCP==that.minCP || (minCP!=null && minCP.equals(that.minCP))) && 081 (maxCP==that.maxCP || (maxCP!=null && maxCP.equals(that.maxCP))); 082 } 083 return false; 084 } 085 086 /** 087 * Returns a deep copy of this envelope. 088 */ 089 public Object clone() 090 { 091 try 092 { 093 final PT_Envelope copy = (PT_Envelope) super.clone(); 094 if (copy.minCP!=null) copy.minCP = (PT_CoordinatePoint) copy.minCP.clone(); 095 if (copy.maxCP!=null) copy.maxCP = (PT_CoordinatePoint) copy.maxCP.clone(); 096 return copy; 097 } 098 catch (CloneNotSupportedException exception) 099 { 100 // Should not happen, since we are cloneable. 101 throw new InternalError(exception.getMessage()); 102 } 103 } 104 105 /** 106 * Returns a string representation of this envelope. 107 * The returned string is implementation dependent. 108 * It is usually provided for debugging purposes only. 109 */ 110 public String toString() 111 { 112 final StringBuffer buffer=new StringBuffer("PT_Envelope"); 113 buffer.append('['); 114 buffer.append(minCP); 115 buffer.append(", "); 116 buffer.append(maxCP); 117 buffer.append(']'); 118 return buffer.toString(); 119 } 120 } 121 /* ******************************************************************** 122 Changes to this class. What the people have been up to: 123 $Log$ 124 Revision 1.2 2006/07/13 06:28:31 poth 125 comment footer added 126 127 ********************************************************************** */