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 java.awt.geom.AffineTransform;
019: import java.io.IOException;
020: import java.util.Collection;
021: import java.util.Iterator;
022:
023: import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader;
024: import org.geotools.data.FeatureSource;
025: import org.geotools.feature.FeatureCollection;
026: import org.geotools.geometry.jts.ReferencedEnvelope;
027: import org.geotools.map.event.MapBoundsEvent;
028: import org.geotools.map.event.MapBoundsListener;
029: import org.geotools.map.event.MapLayerListListener;
030: import org.geotools.styling.Style;
031: import org.opengis.coverage.grid.GridCoverage;
032: import org.opengis.referencing.FactoryException;
033: import org.opengis.referencing.crs.CoordinateReferenceSystem;
034: import org.opengis.referencing.operation.TransformException;
035:
036: import com.vividsolutions.jts.geom.Envelope;
037:
038: /**
039: * Store context information about a map display. This object is based on the
040: * OGC Web Map Context Specification.
041: *
042: * @author Cameron Shorter
043: * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/library/render/src/main/java/org/geotools/map/MapContext.java $
044: * @version $Id: MapContext.java 26197 2007-07-10 21:38:33Z jgarnett $
045: */
046: public interface MapContext {
047: /**
048: * Add a new layer if not already present and trigger a
049: * {@link LayerListEvent}.
050: *
051: * @param layer
052: * the layer to be inserted
053: *
054: * @return true if the layer has been added, false otherwise
055: */
056: boolean addLayer(MapLayer layer);
057:
058: /**
059: * Add a new layer in the specified position and trigger a
060: * {@link LayerListEvent}. Layer won't be added if it's already in the
061: * list.
062: *
063: * @param index
064: * index at which the layer will be inserted
065: * @param layer
066: * the layer to be inserted
067: *
068: * @return true if the layer has been added, false otherwise
069: */
070: boolean addLayer(int index, MapLayer layer);
071:
072: /**
073: * Add a new layer and trigger a {@link LayerListEvent}.
074: *
075: * @param featureSource
076: * a FeatureSource with the new layer that will be added.
077: */
078: void addLayer(FeatureSource featureSource, Style style);
079:
080: /**
081: * Add a new layer and trigger a {@link LayerListEvent}.
082: *
083: * @param collection
084: * a FeatureCollection with the new layer that will be added.
085: */
086: void addLayer(FeatureCollection collection, Style style);
087:
088: /**
089: * Add a new layer and trigger a {@link LayerListEvent}.
090: *
091: * @param collection Collection with the new layer that will be added.
092: */
093: void addLayer(Collection collection, Style style);
094:
095: /**
096: * Add a new layer and trigger a {@link LayerListEvent}
097: *
098: * @param gridCoverage
099: * a GridCoverage with the new layer that will be added.
100: *
101: */
102: void addLayer(GridCoverage gridCoverage, Style style);
103:
104: /**
105: * Add a new layer and trigger a {@link LayerListEvent}
106: *
107: * @param gridCoverage
108: * an AbstractGridCoverage2DReader with the new layer that will be added.
109: *
110: */
111: void addLayer(AbstractGridCoverage2DReader gridCoverage, Style style);
112:
113: /**
114: * Remove a layer, if present, and trigger a {@link LayerListEvent}.
115: *
116: * @param layer
117: * a MapLayer that will be added.
118: *
119: * @return true if the layer has been removed
120: */
121: boolean removeLayer(MapLayer layer);
122:
123: /**
124: * Remove a layer and trigger a {@link LayerListEvent}.
125: *
126: * @param index
127: * The index of the layer that it's going to be removed
128: *
129: * @return the layer removed, if any
130: */
131: MapLayer removeLayer(int index);
132:
133: /**
134: * Add an array of new layers and trigger a {@link LayerListEvent}.
135: *
136: * @param layers
137: * The new layers that are to be added.
138: *
139: * @return the number of layers actually added to the MapContext
140: */
141: int addLayers(MapLayer[] layers);
142:
143: /**
144: * Remove an array of layers and trigger a {@link LayerListEvent}.
145: *
146: * @param layers
147: * The layers that are to be removed.
148: */
149: void removeLayers(MapLayer[] layers);
150:
151: /**
152: * Clears the whole layer list. Will fire a LayerListChangedEvent
153: */
154: void clearLayerList();
155:
156: /**
157: * Return this model's list of layers. If no layers are present, then an
158: * empty array is returned.
159: *
160: * @return This model's list of layers.
161: */
162: MapLayer[] getLayers();
163:
164: /**
165: * Return the requested layer.
166: *
167: * @param index
168: * index of layer to return.
169: *
170: * @return the layer at the specified position
171: *
172: * @throws IndexOutOfBoundsException
173: * if the index is out of range
174: */
175: MapLayer getLayer(int index) throws IndexOutOfBoundsException;
176:
177: /**
178: * Moves a layer from a position to another. Will fire a MapLayerListEvent
179: *
180: * @param sourcePosition
181: * the layer current position
182: * @param destPosition
183: * the layer new position
184: */
185: void moveLayer(int sourcePosition, int destPosition);
186:
187: /**
188: * Returns an iterator over the layers in this context in proper sequence.
189: *
190: * @return an iterator over the layers in this context in proper sequence.
191: */
192: Iterator iterator();
193:
194: /**
195: * Returns the index of the first occurrence of the specified layer, or -1
196: * if this list does not contain this element.
197: *
198: * @param layer
199: * the MapLayer to search for
200: *
201: * @return DOCUMENT ME!
202: */
203: int indexOf(MapLayer layer);
204:
205: /**
206: * Returns the number of layers in this map context
207: *
208: * @return the number of layers in this map context
209: */
210: int getLayerCount();
211:
212: /**
213: * Get the bounding box of all the layers in this MapContext. If all the
214: * layers cannot determine the bounding box in the speed required for each
215: * layer, then null is returned. The bounds will be expressed in the
216: * MapContext coordinate system.
217: *
218: * @return The bounding box of the features or null if unknown and too
219: * expensive for the method to calculate.
220: *
221: * @throws IOException
222: * if an IOException occurs while accessing the FeatureSource
223: * bounds
224: *
225: */
226: ReferencedEnvelope getLayerBounds() throws IOException;
227:
228: /**
229: * Register interest in receiving a {@link LayerListEvent}. A
230: * <code>LayerListEvent</code> is sent if a layer is added or removed, but
231: * not if the data within a layer changes.
232: *
233: * @param listener
234: * The object to notify when Layers have changed.
235: */
236: void addMapLayerListListener(MapLayerListListener listener);
237:
238: /**
239: * Remove interest in receiving {@link LayerListEvent}.
240: *
241: * @param listener
242: * The object to stop sending <code>LayerListEvent</code>s.
243: */
244: void removeMapLayerListListener(MapLayerListListener listener);
245:
246: /**
247: * Set a new area of interest and trigger a {@link BoundingBoxEvent}.
248: *
249: * @param areaOfInterest
250: * The new areaOfInterest.
251: * @param coordinateReferenceSystem
252: * The coordinate system being using by this model.
253: *
254: * @throws IllegalArgumentException
255: * if an argument is <code>null</code>.
256: *
257: */
258: void setAreaOfInterest(Envelope areaOfInterest,
259: CoordinateReferenceSystem coordinateReferenceSystem)
260: throws IllegalArgumentException;
261:
262: /**
263: * Set a new area of interest and trigger an {@link BoundingBoxEvent}.
264: *
265: * @param areaOfInterest
266: * The new area of interest.
267: *
268: * @throws IllegalArgumentException
269: * if an argument is <code>null</code>.
270: * @deprecated Please use {@link #setAreaOfInterest(ReferencedEnvelope)}
271: * or {@link #setAreaOfInterest(Envelope, CoordinateReferenceSystem)}
272: */
273: void setAreaOfInterest(Envelope areaOfInterest)
274: throws IllegalArgumentException;
275:
276: /**
277: * Set a new area of interest and trigger an {@link BoundingBoxEvent}.
278: *
279: * @param areaOfInterest
280: * The new area of interest.
281: *
282: * @throws IllegalArgumentException
283: * if an argument is <code>null</code>.
284: *
285: */
286: void setAreaOfInterest(ReferencedEnvelope areaOfInterest);
287:
288: /**
289: * Gets the current area of interest.
290: *
291: * @return Current area of interest
292: *
293: */
294: ReferencedEnvelope getAreaOfInterest();
295:
296: /**
297: * Get the current coordinate system.
298: *
299: * @return the coordinate system of this box.
300: */
301: CoordinateReferenceSystem getCoordinateReferenceSystem();
302:
303: /**
304: * Transform the coordinates according to the provided transform. Useful for
305: * zooming and panning processes.
306: *
307: * @param transform
308: * The transform to change area of interest.
309: */
310: void transform(AffineTransform transform);
311:
312: /**
313: * Register interest in receiving {@link MapBoundsEvent}s.
314: *
315: * @param listener
316: * The object to notify when the area of interest has changed.
317: */
318: void addMapBoundsListener(MapBoundsListener listener);
319:
320: /**
321: * Remove interest in receiving a {@link BoundingBoxEvent}s.
322: *
323: * @param listener
324: * The object to stop sending change events.
325: */
326: void removeMapBoundsListener(MapBoundsListener listener);
327:
328: /**
329: * Get the abstract which describes this interface, returns an empty string
330: * if this has not been set yet.
331: *
332: * @return The Abstract.
333: */
334: String getAbstract();
335:
336: /**
337: * Set an abstract which describes this context.
338: *
339: * @param conAbstract
340: * the Abstract.
341: */
342: void setAbstract(final String conAbstract);
343:
344: /**
345: * Get the contact information associated with this context, returns an
346: * empty string if contactInformation has not been set.
347: *
348: * @return the ContactInformation.
349: */
350: String getContactInformation();
351:
352: /**
353: * Set contact inforation associated with this class.
354: *
355: * @param contactInformation
356: * the ContactInformation.
357: */
358: void setContactInformation(final String contactInformation);
359:
360: /**
361: * Set the <code>CoordinateReferenceSystem</code> for this map context.
362: *
363: * @param crs
364: * @throws FactoryException
365: * @throws TransformException
366: */
367: void setCoordinateReferenceSystem(
368: final CoordinateReferenceSystem crs)
369: throws TransformException, FactoryException;
370:
371: /**
372: * Get an array of keywords associated with this context, returns an empty
373: * array if no keywords have been set. The array returned is a copy, changes
374: * to the returned array won't influence the MapContextState
375: *
376: * @return array of keywords
377: */
378: String[] getKeywords();
379:
380: /**
381: * Set an array of keywords to associate with this context.
382: *
383: * @param keywords
384: * the Keywords.
385: */
386: void setKeywords(final String[] keywords);
387:
388: /**
389: * Get the title, returns an empty string if it has not been set yet.
390: *
391: * @return the title, or an empty string if it has not been set.
392: */
393: String getTitle();
394:
395: /**
396: * Set the title of this context.
397: *
398: * @param title
399: * the title.
400: */
401: void setTitle(final String title);
402:
403: /**
404: * Registers PropertyChangeListener to receive events.
405: *
406: * @param listener
407: * The listener to register.
408: */
409: public void addPropertyChangeListener(
410: java.beans.PropertyChangeListener listener);
411:
412: /**
413: * Removes PropertyChangeListener from the list of listeners.
414: *
415: * @param listener
416: * The listener to remove.
417: */
418: public void removePropertyChangeListener(
419: java.beans.PropertyChangeListener listener);
420: }
|