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.ui.render.displayAdapter;
018:
019: import java.awt.image.BufferedImage;
020:
021: import net.refractions.udig.project.internal.render.RenderManager;
022: import net.refractions.udig.project.render.displayAdapter.IMapDisplay;
023: import net.refractions.udig.project.render.displayAdapter.IMapDisplayListener;
024: import net.refractions.udig.project.ui.commands.IDrawCommand;
025: import net.refractions.udig.project.ui.internal.MapEditor;
026:
027: import org.eclipse.swt.widgets.Control;
028:
029: /**
030: * The ViewportPane is the display area for a Map.
031: * <p>
032: * The default implementation is a java.awt.Pane. It Registers itself with a CompositeRenderer and
033: * obtains the image from the CompositeRenderer if the CompositeRenderer is "ready"
034: * </p>
035: * <p>
036: * <ul>
037: * <li>Models: CompositeRenderer and Viewport
038: * <li>View: ViewportPane
039: * <li>Control: RenderManager
040: * </ul>
041: * <p>
042: * Viewport is responsible for:
043: * <ul>
044: * <li>Image Creation for CompositeRenderer an renders
045: * <li>Listening to redraw requests from CompositeRenderer
046: * <li>Isolating everyone from SWT / AWT graphics pipeline
047: * </ul>
048: *
049: * @author jeichar
050: * @since 0.1
051: */
052: public interface ViewportPane extends IMapDisplay {
053:
054: /**
055: * Create a image that is compatable with this ViewportPane.
056: *
057: * @param w width
058: * @param h height
059: * @return BufferedImage (may be hardware accelarated)
060: */
061: BufferedImage image(int w, int h);
062:
063: /**
064: * Repaints the ViewportPane
065: * <p>
066: * Requests a repaint actually - may not occur right away.
067: * </p>
068: */
069: public void repaint();
070:
071: /**
072: * Requests that the area indicated is repainted
073: * <p>
074: * Requests a repaint actually - may not occur right away.
075: * </p>
076: * @param x x coordinate of the top left corner of the box to repaint
077: * @param y y coordinate of the top left corner of the box to repaint
078: * @param width width of the box to repaint
079: * @param height height of the box to repaint
080: */
081: public void repaint(int x, int y, int width, int height);
082:
083: /**
084: * Sets the mouse cursor.
085: * <p>
086: * Limited to System cursors at the moment. Custom cursors will be forthcoming.
087: * </p>
088: *
089: * @param cursor The cursor to use
090: */
091: public void setCursor(org.eclipse.swt.graphics.Cursor cursor);
092:
093: /**
094: * See {@linkplain java.awt.Component#removeMouseListener(java.awt.event.MouseListener)}
095: *
096: * @param l A mouse listener
097: */
098: public void removeMouseListener(MapMouseListener l);
099:
100: /**
101: * See
102: * {@linkplain java.awt.Component#removeMouseMotionListener(java.awt.event.MouseMotionListener)}
103: *
104: * @param l A mouse listener
105: */
106: public void removeMouseMotionListener(MapMouseMotionListener l);
107:
108: /**
109: * See
110: * {@linkplain java.awt.Component#removeMouseWheelListener(java.awt.event.MouseWheelListener)}
111: *
112: * @param l A mouse listener
113: */
114: public void removeMouseWheelListener(MapMouseWheelListener l);
115:
116: /**
117: * See {@linkplain java.awt.Component#addMouseListener(java.awt.event.MouseListener)}
118: *
119: * @param l A mouse listener
120: */
121: public void addMouseListener(MapMouseListener l);
122:
123: /**
124: * See
125: * {@linkplain java.awt.Component#addMouseMotionListener(java.awt.event.MouseMotionListener)}
126: *
127: * @param l A mouse listener
128: */
129: public void addMouseMotionListener(MapMouseMotionListener l);
130:
131: /**
132: * See {@linkplain java.awt.Component#addMouseWheelListener(java.awt.event.MouseWheelListener)}
133: *
134: * @param l A mouse listener
135: */
136: public void addMouseWheelListener(MapMouseWheelListener l);
137:
138: /**
139: * Adds a listener interested in size changes to the pane
140: */
141: public void addPaneListener(IMapDisplayListener listener);
142:
143: /**
144: * Removes a MapDisplayListener.
145: */
146: public void removePaneListener(IMapDisplayListener listener);
147:
148: /**
149: * disposes of any system resources
150: */
151: public void dispose();
152:
153: /**
154: * Adds a Draw command to the list of draw commands. This will not refresh
155: * the ViewportPane.
156: *
157: * @param command The new draw command.
158: * @model
159: */
160: public void addDrawCommand(IDrawCommand command);
161:
162: /**
163: * Switches <code>ViewportPainter</code> to run custom <code>IDrawCommand</code>s
164: * during map repainting or disable them.
165: *
166: * @param enable <code>true</code> is to run custom draw commands, <code>false</code> otherwise
167: */
168: public void enableDrawCommands(boolean enable);
169:
170: /**
171: * Called when rendering is about to start.
172: */
173: public void renderStarting();
174:
175: /**
176: * Called when renderer has rendered for single Job scheduled run.
177: */
178: public void renderUpdate();
179:
180: /**
181: * Called when a renderer has data that can be displayed.
182: * <p>
183: * May be called when a refresh is required because the rendered data has changed
184: * </p>
185: */
186: public void renderDone();
187:
188: /**
189: * Called to set the owning renderManager()
190: */
191: void setRenderManager(RenderManager manager);
192:
193: /**
194: * Returns the associated MapEditor object.
195: *
196: * @return the associated MapEditor object.
197: */
198: MapEditor getMapEditor();
199:
200: /**
201: * Returns the SWT Control that listeners, including drag and drop, can be added to.
202: * @return the SWT Control that listeners, including drag and drop, can be added to.
203: */
204: Control getControl();
205:
206: /**
207: * Returns true if the viewportPane component is visible.
208: *
209: * @return true if the viewportPane component is visible.
210: */
211: boolean isVisible();
212:
213: /**
214: * returns if the viewportpane has been disposed
215: *
216: * @return true if the viewportpane has been disposed
217: */
218: boolean isDisposed();
219:
220: }
|