001: /*
002: * uDig - User Friendly Desktop Internet GIS client
003: * http://udig.refractions.net
004: * (C) 2004, Refractions Research Inc.
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: */
017: package net.refractions.udig.project.render;
018:
019: import java.awt.Point;
020: import java.awt.Rectangle;
021: import java.awt.image.BufferedImage;
022:
023: import net.refractions.udig.catalog.IGeoResource;
024: import net.refractions.udig.project.IAbstractContext;
025: import net.refractions.udig.project.ILayer;
026:
027: import org.geotools.data.Query;
028:
029: /**
030: * Simplifies access of resource data and output image for renderers.
031: * A RenderContext has three main Jobs:
032: * <ul>
033: * <li> Maps between a Renderer and the Layer and GeoResource it must use </li>
034: * <li> Provides access to the BufferedImage that the renderer should draw to </li>
035: * <li> Acts as a facade to the rest of the model </li>
036: * </ul>
037: *
038: * @author Jesse
039: * @since 1.0.0
040: */
041: public interface IRenderContext extends IAbstractContext {
042:
043: /**
044: * Test if content is rendered at the provided point.
045: * <p>
046: * Used to optimize getInfo and selection tools.
047: * </p>
048: *
049: * @param screenLocation
050: * @return true if non transparent pixel is rendered at screenLocation
051: */
052: public boolean hasContent(Point screenLocation);
053:
054: /**
055: * Grab a specific rectangle from the raster to provide instant feedback for geoInfo and
056: * selection tools.
057: * <p>
058: * Often this feedback takes place on the display under direction of the tool.
059: * </p>
060: *
061: * @param rectangle Rectangle indicating area of interest
062: * @return Buffered image copied from the raster, or null if unavailable
063: * @see BufferedImage
064: */
065: public BufferedImage copyImage(Rectangle rectangle);
066:
067: /**
068: * Returns a bufferedImage that a renderer can render to.
069: * <p>
070: * The method does not guarantee an image that is the same size as the request, only that the
071: * returned image will be at least the size requested
072: * </p>
073: * <p>
074: * The user of the image is required to clear the image. The image maybe cached and as a result
075: * may be dirty.
076: * </p>
077: *
078: * @return The bufferedImage that the renderer renders to.
079: * @see BufferedImage
080: */
081: public BufferedImage getImage(int width, int height);
082:
083: /**
084: * Returns a bufferedImage that a renderer can renders to.
085: * <p>
086: * The returned image will be the same size as the display or bigger
087: * </p>
088: *
089: * @return The bufferedImage that the renderer renders to.
090: * @see BufferedImage
091: */
092: public BufferedImage getImage();
093:
094: /**
095: * Returns the layer in the renderer is responsible for.
096: * <p>
097: * Should normally be used when only one layer is being rendered.
098: * </p>
099: *
100: * @return ILayer
101: * @see ILayer
102: */
103: ILayer getLayer();
104:
105: /**
106: * Returns service associated with the first layer in the map.
107: * <p>
108: * Should normally be used when only one layer is being rendered.
109: * </p>
110: *
111: * @return IGeoResource the georesource that will be used to render the layer.
112: */
113: IGeoResource getGeoResource();
114:
115: /**
116: * Determines the zorder of the renderer. Convenience method for getLayer.getZorder()
117: *
118: * @return the zorder of the layer contained in the context.
119: * @see ILayer#getZorder()
120: */
121: public int getZorder();
122:
123: /**
124: * Returns true if the renderer has visible data.
125: * <p>
126: * If not layer is not a CompositeRenderer then this is just a call to ILayer.isVisible().
127: * Otherwise if one of the layers is visible then it should return true
128: * </p>
129: *
130: * @return true if the renderer has visible data.
131: * @see ILayer#isVisible()
132: */
133: public boolean isVisible();
134:
135: /**
136: * Clears the entire image so it is all transparent.
137: * <p>
138: * Convenience for clearImage(getImage().getWidth(), getImage.getHeight());
139: * <p>
140: *
141: * @see clearImage(Rectangle)
142: */
143: public void clearImage();
144:
145: /**
146: * @return The filter that will return all the features that need to be rendered
147: */
148: public Query getFeatureQuery();
149:
150: /**
151: * Clears the area of the image indicated by the rectangle.
152: *
153: * @param paintArea
154: * @see clearImage()
155: */
156: public void clearImage(Rectangle paintArea);
157:
158: /**
159: * Sets the status of the layer contained by the context.
160: *
161: * @see ILayer#DONE
162: * @see ILayer#ERROR
163: * @see ILayer#MISSING
164: * @see ILayer#WAIT
165: * @see ILayer#WARNING
166: * @see ILayer#WORKING
167: * @see ILayer#UNCONFIGURED
168: * @param status the new status to set on the layer.
169: * @uml.property name="status"
170: */
171: public void setStatus(int status);
172:
173: /**
174: * Gets the status of the layer contained by the context.
175: *
176: * @see ILayer#DONE
177: * @see ILayer#ERROR
178: * @see ILayer#MISSING
179: * @see ILayer#WAIT
180: * @see ILayer#WARNING
181: * @see ILayer#WORKING
182: * @see ILayer#UNCONFIGURED
183: * @uml.property name="status"
184: */
185: public int getStatus();
186:
187: /**
188: * A message to provide the user with additional feed back about the current rendering status.
189: * <p>
190: * This is used to provide feedback for a Layer's rendering status.
191: * </p>
192: *
193: * @see ILayer#getStatusMessage()
194: * @see #setStatus(int)
195: * @see #getStatus()
196: * @see #getStatusMessage()
197: * @return message to provide the user with additional feed back about the current rendering
198: * status.
199: * @uml.property name="statusMessage"
200: */
201: public String getStatusMessage();
202:
203: /**
204: * Sets the current rendering status message
205: *
206: * @param message the status message
207: * @see ILayer#getStatusMessage()
208: * @see ILayer#getStatus()
209: * @see #getStatusMessage()
210: * @see #getStatus()
211: * @uml.property name="statusMessage"
212: */
213: public void setStatusMessage(String message);
214:
215: public IRenderContext copy();
216:
217: /**
218: * Returns the labeller for the next rendering.
219: *
220: * @return the labeller that draws the labels on the top of the map.
221: */
222: public ILabelPainter getLabelPainter();
223: }
|