001: /*
002: * uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004,
003: * Refractions Research Inc. This library is free software; you can redistribute it and/or modify it
004: * under the terms of the GNU Lesser General Public License as published by the Free Software
005: * Foundation; version 2.1 of the License. This library is distributed in the hope that it will be
006: * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
007: * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
008: */
009: package net.refractions.udig.project.internal.render;
010:
011: import java.awt.Point;
012: import java.awt.geom.AffineTransform;
013:
014: import net.refractions.udig.project.internal.Map;
015: import net.refractions.udig.project.internal.render.impl.ViewportModelImpl;
016: import net.refractions.udig.project.render.IViewportModel;
017: import net.refractions.udig.project.render.displayAdapter.IMapDisplayListener;
018:
019: import org.eclipse.emf.ecore.EObject;
020: import org.opengis.referencing.crs.CoordinateReferenceSystem;
021:
022: import com.vividsolutions.jts.geom.Coordinate;
023: import com.vividsolutions.jts.geom.Envelope;
024:
025: /**
026: * TODO Purpose of net.refractions.udig.project.internal.render
027: * <p>
028: * </p>
029: *
030: * @author Jesse
031: * @since 1.0.0
032: * @model
033: */
034: public interface ViewportModel extends EObject, IMapDisplayListener,
035: IViewportModel {
036:
037: /**
038: * <!-- begin-user-doc --> <!-- end-user-doc -->
039: *
040: * @generated
041: */
042: String copyright = "uDig - User Friendly Desktop Internet GIS client http://udig.refractions.net (C) 2004, Refractions Research Inc. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; version 2.1 of the License. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details."; //$NON-NLS-1$
043:
044: /**
045: * A Default setting to use for the viewport screen size.
046: *
047: * @model
048: */
049: public static final Envelope NIL_BBOX = new Envelope(0, 0, 0, 0);
050:
051: /**
052: * A Default setting to use for the viewport CRS.
053: *
054: * @model
055: */
056: public static final CoordinateReferenceSystem DEFAULT_CRS = ViewportModelImpl
057: .getDefaultCRS();
058:
059: /**
060: * Returns the local coordinate system. The local coordinate system is the CRS that all the
061: * layer data will be transformed into. Once the layer data is transformed into the local CRS
062: * then it is transformed for display onto the screen
063: *
064: * @return the local coordinate system
065: * @uml.property name="cRS"
066: * @model unsettable='true'
067: */
068: public CoordinateReferenceSystem getCRS();
069:
070: /**
071: * Sets the value of the '{@link net.refractions.udig.project.internal.render.ViewportModel#getCRS <em>CRS</em>}'
072: * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
073: *
074: * @param value the new value of the '<em>CRS</em>' attribute.
075: * @see #isSetCRS()
076: * @see #unsetCRS()
077: * @see #getCRS()
078: * @generated
079: */
080: void setCRS(CoordinateReferenceSystem value);
081:
082: /**
083: * Unsets the value of the '{@link net.refractions.udig.project.internal.render.ViewportModel#getCRS <em>CRS</em>}'
084: * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
085: *
086: * @see #isSetCRS()
087: * @see #getCRS()
088: * @see #setCRS(CoordinateReferenceSystem)
089: * @generated
090: */
091: void unsetCRS();
092:
093: /**
094: * Returns whether the value of the '{@link net.refractions.udig.project.internal.render.ViewportModel#getCRS <em>CRS</em>}'
095: * attribute is set. <!-- begin-user-doc --> <!-- end-user-doc -->
096: *
097: * @return whether the value of the '<em>CRS</em>' attribute is set.
098: * @see #unsetCRS()
099: * @see #getCRS()
100: * @see #setCRS(CoordinateReferenceSystem)
101: * @generated
102: */
103: boolean isSetCRS();
104:
105: /**
106: * Returns the bounding box of the Viewport in world coordinates.
107: * <p>
108: * Note: Since Envelope is not a UDIG element changes to the bounds envelope object will not
109: * raise events. Therefore the bounds should only be modified via the ViewportModel interface
110: * </p>
111: *
112: * @return the bounding box of the Viewport in world coordinates.
113: * @uml.property name="bounds"
114: * @model default=""
115: */
116: public Envelope getBounds();
117:
118: /**
119: * Sets the value of the '{@link net.refractions.udig.project.internal.render.ViewportModel#getBounds <em>Bounds</em>}'
120: * attribute. <!-- begin-user-doc -->
121: * <p>
122: * The bbox must have a positive width and height and must have a aspect ratio within 0.0000001
123: * units of the value returned by {@linkplain #getAspectRatio()} .
124: * </p>
125: * <p>
126: * It is recommended that setHeight() or setWidth() methods are used since they preserve the
127: * aspect ratio of the Viewport
128: * <p>
129: * <!-- end-user-doc -->
130: *
131: * @param value the new value of the '<em>Bounds</em>' attribute.
132: * @see #getBounds()
133: * @generated
134: */
135: void setBounds(Envelope value);
136:
137: /**
138: * Sets the viewport's bounding box. The bounding box will be fit to the window based on the MapDisplay so
139: * the bounds provided here may not be the final bounds.
140: *
141: * @param minx the minimum x value of the new bounding box.
142: * @param maxx the maximum x value of the new bounding box.
143: * @param miny the minimum y value of the new bounding box.
144: * @param maxy the maximum x value of the new bounding box.
145: * @throws IllegalArgumentException If the above criteria are not met this exception is thrown.
146: * @model
147: */
148: public void setBounds(double minx, double maxx, double miny,
149: double maxy) throws IllegalArgumentException;
150:
151: /**
152: * Returns the center of the viewport in world coordinates.
153: *
154: * @return the center of the viewport in world coordinates
155: * @uml.property name="center"
156: * @model volatile="true" transient="true"
157: */
158: public Coordinate getCenter();
159:
160: /**
161: * Sets the value of the '{@link net.refractions.udig.project.internal.render.ViewportModel#getCenter <em>Center</em>}'
162: * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
163: *
164: * @param value the new value of the '<em>Center</em>' attribute.
165: * @see #getCenter()
166: * @generated
167: */
168: void setCenter(Coordinate value);
169:
170: /**
171: * Returns the Viewport's height in world coordinates.
172: *
173: * @return the Viewport's height in world coordinates.
174: * @uml.property name="height"
175: * @model volatile="true" transient="true"
176: */
177: public double getHeight();
178:
179: /**
180: * Sets the value of the '{@link net.refractions.udig.project.internal.render.ViewportModel#getHeight <em>Height</em>}'
181: * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
182: *
183: * @param value the new value of the '<em>Height</em>' attribute.
184: * @see #getHeight()
185: * @generated
186: */
187: void setHeight(double value);
188:
189: /**
190: * Returns the Viewport's width in world coordinates.
191: *
192: * @return the Viewport's width in world coordinates.
193: * @uml.property name="width"
194: * @model volatile="true" transient="true"
195: */
196: public double getWidth();
197:
198: /**
199: * Sets the value of the '{@link net.refractions.udig.project.internal.render.ViewportModel#getWidth <em>Width</em>}'
200: * attribute. <!-- begin-user-doc --> <!-- end-user-doc -->
201: *
202: * @param value the new value of the '<em>Width</em>' attribute.
203: * @see #getWidth()
204: * @generated
205: */
206: void setWidth(double value);
207:
208: /**
209: * Returns the aspect ratio of the viewport.
210: *
211: * @return The aspect ratio of the viewport.
212: * @model volatile="true" changeable="false" transient="true"
213: */
214: public double getAspectRatio();
215:
216: /**
217: * Gets the Map that contains the current ViewportModel
218: *
219: * @return the Map that contains the current ViewportModel
220: * @model opposite="viewportModelInternal" many="false"
221: */
222: public Map getMapInternal();
223:
224: /**
225: * Sets the value of the '{@link net.refractions.udig.project.internal.render.ViewportModel#getMapInternal <em>Map Internal</em>}'
226: * container reference. <!-- begin-user-doc --> <!-- end-user-doc -->
227: *
228: * @param value the new value of the '<em>Map Internal</em>' container reference.
229: * @see #getMapInternal()
230: * @generated
231: */
232: void setMapInternal(Map value);
233:
234: /**
235: * Returns the value of the '<em><b>Render Manager Internal</b></em>' reference. It is
236: * bidirectional and its opposite is '{@link net.refractions.udig.project.internal.render.RenderManager#getViewportModelInternal <em>Viewport Model Internal</em>}'.
237: * <!-- begin-user-doc -->
238: * <p>
239: * If the meaning of the '<em>Render Manager</em>' reference isn't clear, there really
240: * should be more of a description here...
241: * </p>
242: * <!-- end-user-doc -->
243: *
244: * @return the value of the '<em>Render Manager Internal</em>' reference.
245: * @see #setRenderManagerInternal(RenderManager)
246: * @see net.refractions.udig.project.internal.render.RenderPackage#getViewportModel_RenderManagerInternal()
247: * @see net.refractions.udig.project.internal.render.RenderManager#getViewportModelInternal
248: * @model opposite="viewportModelInternal" resolveProxies="false" transient="true"
249: * @generated
250: */
251: RenderManager getRenderManagerInternal();
252:
253: /**
254: * Sets the value of the '{@link net.refractions.udig.project.internal.render.ViewportModel#getRenderManagerInternal <em>Render Manager Internal</em>}'
255: * reference. <!-- begin-user-doc --> <!-- end-user-doc -->
256: *
257: * @param value the new value of the '<em>Render Manager Internal</em>' reference.
258: * @see #getRenderManagerInternal()
259: * @generated
260: */
261: void setRenderManagerInternal(RenderManager value);
262:
263: /**
264: * Gets up the affine transform that will transform from the world to screen. A convenience
265: * method.
266: *
267: * @return a transform that maps from real world coordinates to the screen
268: * @model
269: */
270: public AffineTransform worldToScreenTransform();
271:
272: /**
273: * Returns the pixel on the screen for a given coordinate in world space.
274: *
275: * @param coord A coordinate in world space.
276: * @return The pixel on the screen that the world coordinate is drawn on.
277: * @model
278: */
279: public Point worldToPixel(Coordinate coord);
280:
281: /**
282: * Converts a coordinate expressed on the device space back to real world coordinates
283: *
284: * @param x horizontal coordinate on device space
285: * @param y vertical coordinate on device space
286: * @return The correspondent real world coordinate
287: * @model
288: */
289: public Coordinate pixelToWorld(int x, int y);
290:
291: /**
292: * Returns the size of a pixel in world units.
293: * <p>For example if the world is in WGS 84(lat long) then
294: * the size will be in degrees
295: * </p>
296: * @return the size of a pixel in world units.
297: * @model volatile="true" changeable="false" transient="true"
298: */
299: public Coordinate getPixelSize();
300:
301: /**
302: * Pans the viewport in terms of pixels on the screen. Each pixel represents a distance in world
303: * coordinates, the x and y distances differ, so a pan of 8 pixels in the x direction will be
304: * translated to a pan of 8*xdistance in the world.
305: *
306: * @param xpixels The amount to pan in the x direction
307: * @param ypixels The amount to pan in the y direction
308: * @return this ViewportModel
309: * @model
310: */
311: public ViewportModel panUsingScreenCoords(int xpixels, int ypixels);
312:
313: /**
314: * Pans the viewport in terms of world units.
315: *
316: * @param x The amount to pan in the x direction
317: * @param y The amount to pan in the y direction
318: * @return this ViewportModel
319: * @model
320: */
321: public ViewportModel panUsingWorldCoords(double x, double y);
322:
323: /**
324: * Increases or decreases the size of the viewport(in world space) by a constant factor, zoom.
325: * The zoom is equal in both directions. The function used is: bbox.height=bbox.height/divisor
326: * bbox.width=bbox.width/divisor
327: * <ul>
328: * <li>A zoom must be greater than 1.</li>
329: * <li>A zoom greater than 1 is a zoom towards the map(Feature appear larger.)</li>
330: * <li>A zoom less than 1 is a zoom away from the map</li>
331: * </ul>
332: *
333: * @param zoom the zoom factor
334: * @return This ViewportModel, allows for command chaining.
335: * @model
336: */
337: public ViewportModel zoom(double zoom);
338:
339: /**
340: * sets the Viewport bounding box so that it fully contains the visible map extent
341: *
342: * @model
343: */
344: public void zoomToExtent();
345:
346: /**
347: * sets the Viewport bounding box so that it contains the new box
348: *
349: * @model
350: */
351: public void zoomToBox(Envelope box);
352:
353: /**
354: * Return true if it has been initialized with a display. If no display is active then the
355: * viewportmodel is not initialized.
356: *
357: * @return true if it has been initialized with a display
358: * @uml.property name="initialized"
359: */
360: public boolean isInitialized();
361:
362: /**
363: * Sets the initialized state of ViewportModel.
364: *
365: * @param initialized
366: * @uml.property name="initialized"
367: */
368: public void setInitialized(boolean initialized);
369:
370: /**
371: * Sets the zoom level of the viewport so that the scale denominator will be equal to
372: * scale
373: *
374: * @param scaleDenominator desired scale denominator
375: */
376: public void setScale(double scaleDenominator);
377: }
|