001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2003-2006, GeoTools Project Managment Committee (PMC)
005: * (C) 2002, Centre for Computational Geography
006: *
007: * This library is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU Lesser General Public
009: * License as published by the Free Software Foundation;
010: * version 2.1 of the License.
011: *
012: * This library is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: */
017: package org.geotools.index.rtree;
018:
019: import com.vividsolutions.jts.geom.Envelope;
020: import org.geotools.index.Data;
021:
022: /**
023: * DOCUMENT ME!
024: *
025: * @author Tommaso Nolli
026: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/plugin/shapefile/src/main/java/org/geotools/index/rtree/Entry.java $
027: */
028: public class Entry implements Cloneable {
029: private Envelope bounds;
030: private Object data;
031: private EntryBoundsChangeListener listener;
032:
033: public Entry(Envelope e, Object data) {
034: this .bounds = e;
035: this .data = data;
036: }
037:
038: /**
039: * DOCUMENT ME!
040: *
041: */
042: public Envelope getBounds() {
043: return bounds;
044: }
045:
046: /**
047: * DOCUMENT ME!
048: *
049: */
050: public Object getData() {
051: return data;
052: }
053:
054: public void setData(Data data) {
055: this .data = data;
056: }
057:
058: /**
059: * @see java.lang.Object#equals(java.lang.Object)
060: */
061: public boolean equals(Object obj) {
062: Entry e = (Entry) obj;
063:
064: return this .bounds.equals(e.getBounds())
065: && this .data.equals(e.getData());
066: }
067:
068: /**
069: * DOCUMENT ME!
070: *
071: * @param envelope
072: */
073: void setBounds(Envelope envelope) {
074: bounds = envelope;
075:
076: if (this .listener != null) {
077: this .listener.boundsChanged(this );
078: }
079: }
080:
081: /**
082: * @see java.lang.Object#clone()
083: */
084: protected Object clone() {
085: Entry ret = new Entry(new Envelope(this .bounds), this .data);
086: ret.setListener(this .listener);
087:
088: return ret;
089: }
090:
091: /**
092: * @see java.lang.Object#toString()
093: */
094: public String toString() {
095: return "Entry --> " + this .bounds + " - key: " + this .data;
096: }
097:
098: /**
099: * DOCUMENT ME!
100: *
101: * @param listener
102: */
103: public void setListener(EntryBoundsChangeListener listener) {
104: this.listener = listener;
105: }
106: }
|