001: /*
002: * The Unified Mapping Platform (JUMP) is an extensible, interactive GUI
003: * for visualizing and manipulating spatial features with geometry and attributes.
004: *
005: * Copyright (C) 2003 Vivid Solutions
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program 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
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: *
021: * For more information, contact:
022: *
023: * Vivid Solutions
024: * Suite #1A
025: * 2328 Government Street
026: * Victoria BC V8T 5G5
027: * Canada
028: *
029: * (250)385-6040
030: * www.vividsolutions.com
031: */
032: package com.vividsolutions.jump.workbench.model;
033:
034: import java.util.Collection;
035: import java.util.Collections;
036: import com.vividsolutions.jts.util.Assert;
037:
038: /**
039: * An addition, removal, or modification of a Feature.
040: *
041: * @see com.vividsolutions.jump.feature.Feature Feature
042: * @see FeatureEventType
043: */
044: public class FeatureEvent {
045: private Layer layer;
046: private FeatureEventType type;
047: private Collection features;
048: private Collection oldFeatureClones;
049:
050: //[UT] 25.08.2005 added
051: private Collection oldFeatureAttClones;
052:
053: /**
054: * @param oldFeatureClones for GEOMETRY_MODIFIED events, clones of the Features before
055: * they were modified; null for other events
056: */
057: public FeatureEvent(Collection features, FeatureEventType type,
058: Layer layer, Collection oldFeatureClones) {
059: Assert.isTrue(layer != null);
060: Assert.isTrue(type != null);
061:
062: Assert
063: .isTrue((type == FeatureEventType.GEOMETRY_MODIFIED && oldFeatureClones != null)
064: || (type != FeatureEventType.GEOMETRY_MODIFIED && oldFeatureClones == null)
065: || (type == FeatureEventType.ATTRIBUTES_MODIFIED && oldFeatureAttClones == null));
066:
067: this .layer = layer;
068: this .type = type;
069: this .features = features;
070:
071: // [UT] 25.08.2005 uncommented and...
072: // this.oldFeatureClones = oldFeatureClones;
073: //[UT] 25.08.2005 did like this
074: if (this .type == FeatureEventType.GEOMETRY_MODIFIED) {
075: this .oldFeatureClones = oldFeatureClones;
076: } else if (this .type == FeatureEventType.ATTRIBUTES_MODIFIED) {
077: this .oldFeatureAttClones = oldFeatureClones;
078: }
079: }
080:
081: public Layer getLayer() {
082: return layer;
083: }
084:
085: public FeatureEventType getType() {
086: return type;
087: }
088:
089: public Collection getFeatures() {
090: return Collections.unmodifiableCollection(features);
091: }
092:
093: public Collection getOldFeatureClones() {
094: return Collections.unmodifiableCollection(oldFeatureClones);
095: }
096:
097: //[UT] 25.08.2005 added
098: public Collection getOldFeatureAttClones() {
099: return Collections.unmodifiableCollection(oldFeatureAttClones);
100: }
101: }
|