source: ether_statistics/service/implementation/gov/noaa/pmel/sgt/AbstractPane.java @ 569

Last change on this file since 569 was 569, checked in by vmipsl, 12 years ago

Nouveau projet

File size: 11.5 KB
Line 
1/*
2 * $Id: AbstractPane.java,v 1.24 2003/09/18 21:21:33 dwd Exp $
3 *
4 * This software is provided by NOAA for full, free and open release.  It is
5 * understood by the recipient/user that NOAA assumes no liability for any
6 * errors contained in the code.  Although this software is released without
7 * conditions or restrictions in its use, it is expected that appropriate
8 * credit be given to its author and to the National Oceanic and Atmospheric
9 * Administration should the software be included by the recipient as an
10 * element in other product development.
11 */
12
13package gov.noaa.pmel.sgt;
14
15import java.awt.Graphics;
16import java.awt.Rectangle;
17import java.awt.Point;
18import java.beans.PropertyChangeListener;
19
20/**
21 * Defines the basic sgt Pane functionality. <code>Pane</code> and
22 * <code>JPane</code> implement the <code>AbstractPane</code>
23 * interface.
24 *
25 * @author Donald Denbo
26 * @version $Revision: 1.24 $, $Date: 2003/09/18 21:21:33 $
27 * @since 2.0
28 * @see Pane
29 * @see JPane
30 */
31public interface AbstractPane {
32  /**
33   * Align to top of printer page.
34   */
35  public static final int TOP = 0;
36  /**
37   * Align to middle of printer page.
38   */
39  public static final int MIDDLE = 1;
40  /**
41   * Align to bottom of printer page.
42   */
43  public static final int BOTTOM = 2;
44  /**
45   * Align to left of printer page.
46   */
47  public static final int LEFT = 0;
48  /**
49   * Align to center of printer page.
50   */
51  public static final int CENTER = 1;
52  /**
53   * Align to right of printer page.
54   */
55  public static final int RIGHT = 2;
56  /**
57   * Align to location specified on printer page.
58   */
59  public static final int SPECIFIED_LOCATION = -1;
60  /**
61   * Fit onto printer page.  Magnify or shrink to fit onto printer page.
62   * @since 3.0
63   */
64  public static final int TO_FIT = 0;
65  /**
66   * Default scale for printing.  A value of 1.0 physical units = 72 pts.
67   * @since 3.0
68   */
69  public static final int DEFAULT_SCALE = 1;
70  /**
71   * Shrink to fit onto printer page.  Will not magnify if graphic will already fit.
72   * @since 3.0
73   */
74  public static final int SHRINK_TO_FIT = 2;
75  /**
76   * The <code>AbstractPane</code> and all of the attached Classes
77   * will be drawn. Drawing will occur in an offscreen image and then
78   * copied to the screen. A new offscreen image is created on the
79   * first call to draw() or if the size of the pane has been
80   * changed. The offscreen image will be used as a "double" buffer
81   * when the screen requires redrawing.
82   * <p>
83   * Each <code>Layer</code> that has been added will be drawn in the
84   * order added, except if that order has been change using the
85   * <code>moveLayerUp()</code> or <code>moveLayerDown()</code> methods.
86   *
87   * @see java.awt.Graphics
88   * @see Layer
89   */
90  public void draw();
91  /**
92   * The <code>AbstractPane</code> and all of the attached Classes
93   * will be drawn. Drawing will occur using the supplied
94   * <code>Graphics</code> object.
95   *
96   * @param g User supplied <code>Graphics</code> object
97   *
98   * @see java.awt.Graphics
99   */
100  public void draw(Graphics g);
101  /**
102   * The <code>AbstractPane</code> and all of the attached Classes
103   * will be drawn. Drawing will occur using the supplied
104   * <code>Graphics</code> object. And clipping will be done to the
105   * width and height.
106   *
107   * @param g User supplied <code>Graphics</code> object
108   * @param width clipping width
109   * @param height clipping height
110   *
111   * @see java.awt.Graphics
112   */
113  public void draw(Graphics g, int width, int height);
114  /**
115   * This method is called when the <code>AbstractPane</code> first becomes
116   * visible.  The types of operations that should be implemented here include
117   * those that require a valid <code>Graphics</code> object.
118   */
119   public void init();
120  /**
121   * Test if the current <code>Graphics</code> object is a printer.
122   *
123   * @return true if a printer
124   */
125  public boolean isPrinter();
126  /**
127   * Return an array of objects whose bounds include x,y.
128   *
129   * @since 3.0
130   */
131  public Object[] getObjectsAt(int x, int y);
132  /**
133   * Return an array of objects whose bounds are at point pt.
134   *
135   * @since 3.0
136   */
137  public Object[] getObjectsAt(Point pt);
138  /**
139   * Get the printer page size.
140   *
141   * @return page size
142   */
143  public java.awt.Dimension getPageSize();
144  /**
145   * Get the <code>Pane</code> identifier.
146   *
147   * @return <code>String</code> containing the <code>Pane</code> identifier.
148   */
149  public String getId();
150  /**
151   * Set the <code>Pane</code> identifier
152   */
153  public void setId(String id);
154  /**
155   * Set printing scale mode.  Allowable choices are <code>TO_FIT</code>,
156   * <code>SHRINK_TO_FIT</code> and
157   * <code>DEFAULT_SCALE</code>. Default = DEFAULT_SCALE.
158   * @param mode print page scaling
159   * @since 3.0
160   * @see AbstractPane#DEFAULT_SCALE
161   * @see AbstractPane#TO_FIT
162   * @see AbstractPane#SHRINK_TO_FIT
163   */
164  public void setPageScaleMode(int mode);
165  /**
166   * Set alignment for printing.
167   *
168   * @param vert vertical alignment
169   * @param horz horizontal alignment
170   * @see AbstractPane#TOP
171   * @see AbstractPane#MIDDLE
172   * @see AbstractPane#BOTTOM
173   * @see AbstractPane#LEFT
174   * @see AbstractPane#CENTER
175   * @see AbstractPane#RIGHT
176   * @see AbstractPane#SPECIFIED_LOCATION
177   */
178  public void setPageAlign(int vert, int horz);
179  /**
180   * Set vertical alignment for printing. Allowed choices include <code>TOP</code>,
181   * <code>MIDDLE</code>, and  <code>BOTTOM</code> for vert and
182   * <code>LEFT</code>, <code>CENTER</code>, and <code>RIGHT</code>
183   * for horz.  Either can be <code>SPECIFIED_LOCATION</code>.
184   *
185   * @param vert vertical alignment
186   * @see AbstractPane#TOP
187   * @see AbstractPane#MIDDLE
188   * @see AbstractPane#BOTTOM
189   * @see AbstractPane#SPECIFIED_LOCATION
190   */
191  public void setPageVAlign(int vert);
192  /**
193   * Set horizontal alignment for printing. Allowed choices include <code>TOP</code>,
194   * <code>MIDDLE</code>, and  <code>BOTTOM</code>.
195   *
196   * @param horz horizontal alignment
197   * @see AbstractPane#LEFT
198   * @see AbstractPane#CENTER
199   * @see AbstractPane#RIGHT
200   * @see AbstractPane#SPECIFIED_LOCATION
201   */
202  public void setPageHAlign(int horz);
203  /**
204   * Get printing scale mode.
205   * @return AUTO_SCALE, TO_FIT, or SHRINK_TO_FIT
206   * @since 3.0
207   * @see AbstractPane#DEFAULT_SCALE
208   * @see AbstractPane#TO_FIT
209   * @see AbstractPane#SHRINK_TO_FIT
210   */
211  public int getPageScaleMode();
212  /**
213   * Get vertical alignment for printing. Allowed choices include
214   * <code>LEFT</code>, <code>CENTER</code>, and <code>RIGHT</code>.
215   *
216   * @return vertical alignment
217   * @see AbstractPane#TOP
218   * @see AbstractPane#MIDDLE
219   * @see AbstractPane#BOTTOM
220   * @see AbstractPane#SPECIFIED_LOCATION
221   */
222  public int getPageVAlign();
223  /**
224   * Get horizontal alignment for printing.
225   *
226   * @return horizontal alignment
227   * @see AbstractPane#LEFT
228   * @see AbstractPane#CENTER
229   * @see AbstractPane#RIGHT
230   * @see AbstractPane#SPECIFIED_LOCATION
231   */
232  public int getPageHAlign();
233  /**
234   * Set the printer page origin. Valid for HAlign = <code>SPECIFIED_LOCATION</code> or
235   * VAlign = <code>SPECIFIED_LOCATION</code>.
236   */
237  public void setPageOrigin(java.awt.Point p);
238  /**
239   * Get the printer page origin. Valid for HAlign = <code>SPECIFIED_LOCATION</code> or
240   * VAlign = <code>SPECIFIED_LOCATION</code>.
241   */
242  public java.awt.Point getPageOrigin();
243  /**
244   * Get the first <code>Layer</code> associated with the <code>Pane</code>
245   *
246   * @return the first <code>Layer</code> object
247   */
248  public Layer getFirstLayer();
249  /**
250   * Get the <code>Layer</code> associated with the
251   * <code>Pane</code> indicated by the id.
252   *
253   * @param id identifier.
254   * @exception LayerNotFoundException The <code>Layer</code> indicated by the id was not found.
255   */
256  public Layer getLayer(String id) throws LayerNotFoundException;
257  /**
258   * Get the <code>Layer</code> associated with the
259   * <code>Pane</code> indicated by the data id.
260   *
261   * @param id data identifier
262   * @exception LayerNotFoundException The <code>Layer</code> indicated by the id was not found.
263   *
264   * @see gov.noaa.pmel.sgt.dm.SGTData
265   */
266  public Layer getLayerFromDataId(String id) throws  LayerNotFoundException;
267  /*
268   * methods to get mouse input results
269   */
270  /**
271   * Return the last object selected.  Returns only objects
272   * that are part of <code>Layer</code>s currently connected to the
273   * pane.  <code>AbstractPane</code> tests
274   * each layer after a MOUSE_DOWN event for an object whose bounding box
275   * contains the mouse.  The pane object then passes the event on to the next
276   * level.
277   */
278  public Object getSelectedObject();
279  /**
280   * Primarily used internally by sgt.  This can also be used to mark
281   * an object as selected for use in an event handler.
282   */
283  public void setSelectedObject(Object obj);
284  /**
285   * Return the device coordinates of the zoom action. The coordinates are
286   * in device units and may require transformation to the physical units or
287   * user units.
288   *
289   * @return zoom rectangle
290   */
291  public java.awt.Rectangle getZoomBounds();
292  /**
293   * Return the device coordinates of the start of the zoom action. The <code>Point</code>
294   * is in device coordinates and may require transformation to physical units
295   * or user units.  Zoom start may be useful to indicate which graph to zoom.
296   *
297   * @return zoom start
298   * @since 3.0
299   */
300  public Point getZoomStart();
301  /**
302   * Get the current selected object at a point.  Used internally by
303   * sgt.
304   */
305  public Object getObjectAt(int x, int y);
306  /**
307   * Get the bounding rectangle in pixels (device units).
308   *
309   * @return Rectangle object containing the bounding box for the pane.
310   **/
311  public java.awt.Rectangle getBounds();
312  /**
313   * Get the <code>Component</code> associated with
314   * the pane.
315   */
316  public java.awt.Component getComponent();
317  /*
318   * methods to handle ChangeEvent and PropertyChangeEvent's
319   */
320  /**
321   * Turn on/off batching of updates to the pane.  While
322   * batching is <code>true</code> property change events will
323   * <b>not</b> cause pane to redraw.  When batching is
324   * turned back on if the pane has been modified it
325   * will then redraw.
326   */
327  public void setBatch(boolean batch, String msg);
328  /**
329   * Turn on/off batching of updates to the pane.  While
330   * batching is <code>true</code> property change events will
331   * <b>not</b> cause pane to redraw.  When batching is
332   * turned back on if the pane has been modified it
333   * will then redraw.
334   */
335  public void setBatch(boolean batch);
336  /**
337   * Is batching turned on?
338   */
339  public boolean isBatch();
340  /**
341   * Notify the pane that something has changed and a redraw
342   * is required.  Used internally by sgt.
343   */
344  public void setModified(boolean mod, String mess);
345  /**
346   * Has the plot been modified?
347   */
348  public boolean isModified();
349  /**
350   * Enable/disable the handling of <code>MouseEvent</code>s by
351   * SGT.  Disabling mouse events will turn off object selection,
352   * moveable, selectable, draggable, and zooming.
353   *
354   * @since 3.0
355   */
356  public void setMouseEventsEnabled(boolean enable);
357  /**
358   * Are <code>MouseEvent</code>s enabled for processing by SGT?
359   *
360   * @since 3.0
361   */
362  public boolean isMouseEventsEnabled();
363  /*
364   * Pane PropertyChange methods
365   */
366  /**
367   * Add a PropertyChangeListener to the list. Properties for
368   * <code>Pane</code> and <code>JPane</code> include
369   * "objectSelected" and "zoomRectangle".
370   */
371  public void addPropertyChangeListener(PropertyChangeListener l);
372  /**
373   * Remove the PropertyChangeListener from the list.
374   */
375  public void removePropertyChangeListener(PropertyChangeListener l);
376
377}
Note: See TracBrowser for help on using the repository browser.