001: /*
002: * GeoTools - OpenSource mapping toolkit
003: * http://geotools.org
004: * (C) 2003-2006, GeoTools Project Managment Committee (PMC)
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation;
009: * version 2.1 of the License.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: */
016: package org.geotools.map;
017:
018: import org.geotools.data.FeatureSource;
019: import org.geotools.data.Query;
020: import org.geotools.data.memory.CollectionSource;
021: import org.geotools.geometry.jts.ReferencedEnvelope;
022: import org.geotools.map.event.MapLayerListener;
023: import org.geotools.styling.Style;
024:
025: /**
026: * A layer to be rendered on a device. A layer is an aggregation of both a
027: * {@link FeatureCollection}, a {@link Style} and, optionally, a {@link Query}
028: *
029: * @author Cameron Shorter
030: * @author Martin Desruisseaux
031: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/render/src/main/java/org/geotools/map/MapLayer.java $
032: * @version $Id: MapLayer.java 26197 2007-07-10 21:38:33Z jgarnett $
033: */
034: public interface MapLayer {
035: /**
036: * Get the feature collection for this layer.
037: *
038: * @return The features for this layer, null if not yet set
039: * or if {@link Source} is used.
040: */
041: FeatureSource getFeatureSource();
042:
043: /**
044: * Get the data source for this layer.
045: *
046: * @return Data source for this layer, null if not yet set
047: * or if {@link FeatureSource} is used
048: */
049:
050: CollectionSource getSource();
051:
052: /**
053: * Get the style for this layer. If style has not been set, then null is
054: * returned.
055: *
056: * @return The style (SLD).
057: */
058: Style getStyle();
059:
060: /**
061: * Sets the style for this layer. If a style has not been defined a default
062: * one is used.
063: *
064: * @param style The new style
065: */
066: void setStyle(Style style);
067:
068: /**
069: * Get the title of this layer. If title has not been defined then an empty
070: * string is returned.
071: *
072: * @return The title of this layer.
073: */
074: String getTitle();
075:
076: /**
077: * Set the title of this layer. A {@link LayerEvent} is fired if the new
078: * title is different from the previous one.
079: *
080: * @param title The title of this layer.
081: */
082: void setTitle(String title);
083:
084: /**
085: * Determine whether this layer is visible on a map pane or whether the
086: * layer is hidden.
087: *
088: * @return <code>true</code> if the layer is visible, or <code>false</code>
089: * if the layer is hidden.
090: */
091: boolean isVisible();
092:
093: /**
094: * Specify whether this layer is visible on a map pane or whether the layer
095: * is hidden. A {@link LayerEvent} is fired if the visibility changed.
096: *
097: * @param visible Show the layer if <code>true</code>, or hide the layer if
098: * <code>false</code>
099: */
100: void setVisible(boolean visible);
101:
102: /**
103: * Returns the definition query (filter) for this layer. If no definition
104: * query has been defined {@link Query.ALL} is returned.
105: *
106: */
107: Query getQuery();
108:
109: /**
110: * Sets a definition query for the layer wich acts as a filter for the
111: * features that the layer will draw.
112: *
113: * <p>
114: * A consumer must ensure that this query is used in combination with the
115: * bounding box filter generated on each map interaction to limit the
116: * number of features returned to those that complains both the definition
117: * query and relies inside the area of interest.
118: * </p>
119: * <p>
120: * IMPORTANT: only include attribute names in the query if you want them to
121: * be ALWAYS returned. It is desirable to not include attributes at all
122: * but let the layer user (a renderer?) to decide wich attributes are actually
123: * needed to perform its requiered operation.
124: * </p>
125: *
126: * @param query
127: */
128: void setQuery(Query query);
129:
130: /**
131: * find out the bounds of the layer
132: * @return - the layer's bounds
133: */
134: ReferencedEnvelope getBounds();
135:
136: /**
137: * Add a listener to notify when a layer property changes. Changes include
138: * layer visibility and the title text.
139: *
140: * @param listener The listener to add to the listener list.
141: */
142: void addMapLayerListener(MapLayerListener listener);
143:
144: /**
145: * Removes a listener from the listener list for this layer.
146: *
147: * @param listener The listener to remove from the listener list.
148: */
149: void removeMapLayerListener(MapLayerListener listener);
150: }
|