01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2003-2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.map.event;
17:
18: // J2SE dependencies
19: import java.util.EventObject;
20:
21: /**
22: * Event fired when some {@linkplain Layer layer} property changes.
23: *
24: * @author Andrea Aime
25: * @author Ian Turton
26: * @author Martin Desruisseaux
27: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/render/src/main/java/org/geotools/map/event/MapLayerEvent.java $
28: * @version $Id: MapLayerEvent.java 25075 2007-04-09 19:20:46Z desruisseaux $
29: *
30: * @see Layer
31: * @see LayerListener
32: */
33: public class MapLayerEvent extends EventObject {
34: /**
35: * Flag set when the layer visibility changed.
36: *
37: * @see #getReason
38: */
39: public static final int VISIBILITY_CHANGED = 1;
40:
41: /**
42: * Flag set when the some metadata (like the title) changes
43: *
44: * @see #getReason
45: */
46: public static final int METADATA_CHANGED = 2;
47:
48: /**
49: * Flag set when the data attached to this layer changed.
50: *
51: * @see #getReason
52: */
53: public static final int DATA_CHANGED = 3;
54:
55: /**
56: * Flag set when the style attached to this layer changed.
57: *
58: * @see #getReason
59: */
60: public static final int STYLE_CHANGED = 4;
61:
62: /**
63: * Flag set when the definition query attached to this layer changed.
64: *
65: * @see #getReason
66: */
67: public static final int FILTER_CHANGED = 5;
68:
69: /** The reason for the change. */
70: private final int reason;
71:
72: /**
73: * Creates a new instance of <code>LayerEvent</code> with the specified reason.
74: *
75: * @param source The source of the event change.
76: * @param reason Why the event was fired.
77: *
78: * @throws IllegalArgumentException If the <code>reason</code> is not a valid enum.
79: */
80: public MapLayerEvent(final Object source, final int reason)
81: throws IllegalArgumentException {
82: super (source);
83: this .reason = reason;
84:
85: if ((reason <= 0) || (reason > FILTER_CHANGED)) {
86: throw new IllegalArgumentException();
87: }
88: }
89:
90: /**
91: * Returns the reason why this event is fired. It is one of {@link #VISIBILITY_CHANGED} or
92: * {@link #TITLE_CHANGED} constants.
93: *
94: * @return DOCUMENT ME!
95: */
96: public int getReason() {
97: return reason;
98: }
99: }
|