Statistics
| Revision:

svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / fframes / IFFrame.java @ 232

History | View | Annotate | Download (11.2 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 */
22
package org.gvsig.app.project.documents.layout.fframes;
23

    
24
import java.awt.Graphics2D;
25
import java.awt.Image;
26
import java.awt.event.MouseEvent;
27
import java.awt.geom.AffineTransform;
28
import java.awt.geom.Point2D;
29
import java.awt.geom.Rectangle2D;
30
import java.awt.image.BufferedImage;
31

    
32
import org.gvsig.app.project.documents.Document;
33
import org.gvsig.app.project.documents.layout.LayoutContext;
34
import org.gvsig.app.project.documents.layout.LayoutControl;
35
import org.gvsig.fmap.mapcontext.rendering.symbols.IPrintable;
36
import org.gvsig.tools.dispose.Disposable;
37
import org.gvsig.tools.lang.Cloneable;
38
import org.gvsig.tools.observer.Observable;
39
import org.gvsig.tools.observer.Observer;
40
import org.gvsig.tools.persistence.Persistent;
41

    
42
/**
43
 * Interface representing a frame that can be added to a LayoutDocument.
44
 * IFFrames are assumed to be rectangular objects that are able to draw themselves
45
 * on a Graphics2D object. They handle selection status and can also be
46
 * rotated. Specific implementations of this interface should be able to persist
47
 * their status.
48
 * 
49
 * @author Vicente Caballero Navarro
50
 * @author Cesar Martinez Izquierdo
51
 */
52
public interface IFFrame extends IPrintable, Persistent, Cloneable, Observable, Disposable {
53

    
54
        //FIXME: ensure the following comments are correct!
55
        /** FFrame has been selected by clicking on its North boundary */
56
        public static final int N = 1;
57
        /** FFrame has been selected by clicking on its North-East corner */
58
    public static final int NE = 2;
59
    /** FFrame has been selected by clicking on its East boundary */
60
    public static final int E = 3;
61
    /** FFrame has been selected by clicking on its South-East corner */
62
    public static final int SE = 4;
63
    /** FFrame has been selected by clicking on its South boundary */
64
    public static final int S = 5;
65
    /** FFrame has been selected by clicking on its South-West corner */
66
    public static final int SO = 6;
67
    /** FFrame has been selected by clicking on its West boundary */
68
    public static final int O = 7;
69
    /** FFrame has been selected by clicking on its North-West corner */
70
    public static final int NO = 8;
71
    /** FFrame has been selected by clicking within the frame rectangle */
72
    public static final int RECT = 9;
73
    /** FFrame is not selected */
74
    public static final int NOSELECT = 0;
75

    
76
    /**
77
     * Returns the bounding box (in pixels) of this FFrame, based on the provided
78
     * AffineTransform. If the AffineTransform is null, it returns the last
79
     * calculated bounding box.
80
     * 
81
     * @param at Affine transform to apply to the sheet coordinates to get the
82
     *                  bounding box in pixels.
83
     * @return Rectangle representing the bounding box (in pixels) of this
84
     * FFrame
85
     */
86
    public Rectangle2D.Double getBoundingBox(AffineTransform at);
87

    
88
    /**
89
     * Returns the bounding box in centimeters of this FFrame, using paper
90
     * coordinates
91
     * 
92
     * @return The bounding box of this FFrame, measured in centimeters.
93
     */
94
    public Rectangle2D.Double getBoundBox();
95

    
96
    /**
97
     * Sets the bounding box in centimeters of this FFrame, using  paper
98
     * coordinates.
99
     * 
100
     * @param r
101
     *            Rectangle in centimeters
102
     */
103
    public void setBoundBox(Rectangle2D rect);
104

    
105
    /**
106
     * Este m?todo se implementa en cada una de las fframe, ya que cada una se
107
     * dibuja de una forma diferente sobre el graphics. M?todo que dibuja
108
     * sobre el graphics que se le pasa como par?metro, seg?n la transformada
109
     * afin que se debe de aplicar y el rect?ngulo que se debe de dibujar.
110
     * 
111
     * @param g
112
     *            Graphics
113
     * @param at
114
     *            Transformada afin.
115
     * @param r
116
     *            rect?ngulo sobre el que hacer un clip.
117
     * @param imgBase
118
     *            Imagen para acelerar el dibujado.
119
     * @throws ReadDriverException
120
     *             TODO
121
     */
122
    public void draw(Graphics2D g, AffineTransform at, Rectangle2D r,
123
        BufferedImage imgBase);
124

    
125
    /**
126
     * Devuelve el nombre que representa al fframe.
127
     * 
128
     * @return String nombre del FFrame.
129
     */
130
    public String getName();
131

    
132
    /**
133
     * Devuelve true, si el punto que se pasa como par?metro esta contenido
134
     * dentro del boundingbox del fframe.
135
     * 
136
     * @param p
137
     *            punto a comprobar.
138
     * 
139
     * @return true si el punto esta dentro del boundingbox.
140
     */
141
    public boolean contains(Point2D p);
142

    
143
    /**
144
     * Dibuja los handlers sobre el boundingBox en el graphics que se pasa como
145
     * par?metro.
146
     * 
147
     * @param g
148
     *            Graphics sobre el que dibujar.
149
     */
150
    public void drawHandlers(Graphics2D g);
151

    
152
    /**
153
     * Sets the type of selection performed on the frame, based on the position
154
     * of the provided Point compared with the boundaries of the FFrame.
155
     * This method is usually called when the user clicks on the FFrame
156
     * 
157
     * @param p
158
     *            Point which should be evaluated to establish if the FFrame must
159
     *            be selected or not
160
     * @param e   Mouse event that triggered this method call
161
     * @see {@link #isSelected()}, {@link #getSelected()}
162
     */
163
    public void setSelected(Point2D b, MouseEvent e);
164

    
165
    /**
166
     * Sets the selected status of the frame.
167
     * 
168
     * @param selected
169
     *            <code>true</code> to select the frame, <code>false</code> to
170
     *            unselect it
171
     * @see {@link #isSelected()}, {@link #getSelected()}
172
     */
173
    public void setSelected(boolean b);
174

    
175
    /**
176
     * Returns an integer representing the type of selection applied to the
177
     * FFrame. Valid values are:
178
     * {@link IFFrame#NOSELECT},
179
     * {@link IFFrame#NO}, {@link IFFrame#N}, {@link IFFrame#NE},
180
     * {@link IFFrame#O}, {@link IFFrame#RECT}, {@link IFFrame#E},
181
     * {@link IFFrame#SO}, {@link IFFrame#S}, {@link IFFrame#SE}.
182
     * 
183
     * @see {@link #isSelected()}, {@link #setSelected(boolean)}
184
     * @return The type of selection that has been applied
185
     */
186
    public int getSelected();
187
    
188
    /**
189
     * Gets the selection status of the frame
190
     * 
191
     * @return <code>true</code> if the frame is selected,
192
     *    <code>false</code> otherwise
193
     * @see {@link #getSelected()}, {@link #setSelected(boolean)}
194
     */
195
    public boolean isSelected();
196

    
197
    /**
198
     * Checks whether the provided point is contained within the FFrame
199
     * rectangle.
200
     * 
201
     * @param p
202
     *            Point to compare
203
     * 
204
     * @return An integer representing the topologic relation of the point and
205
     * the frame rectangle. It can be one of:
206
     * {@link IFFrame#NOSELECT},
207
     * {@link IFFrame#NO}, {@link IFFrame#N}, {@link IFFrame#NE},
208
     * {@link IFFrame#O}, {@link IFFrame#RECT}, {@link IFFrame#E},
209
     * {@link IFFrame#SO}, {@link IFFrame#S}, {@link IFFrame#SE}.
210
     */
211
    public int getContains(Point2D p);
212

    
213
    /**
214
     * Devuelve el Cursor adecuado seg?n como est? contenido el punto, si es
215
     * para desplazamiento, o cambio de tama?o.
216
     * 
217
     * @param p
218
     *            punto a comprobar.
219
     * 
220
     * @return Cursor adecuado a la posici?n.
221
     */
222
    public Image getMapCursor(Point2D p);
223

    
224
    /**
225
     * Devuelve el rect?ngulo a partir del desplazamiento en el eje x y el
226
     * desplazamiento en el eje y.
227
     * 
228
     * @param difx
229
     *            desplazamiento sobre el eje x.
230
     * @param dify
231
     *            desplazamiento sobre el eje y.
232
     * 
233
     * @return rect?ngulo modificado en funci?n del desplazamiento realizado.
234
     */
235
    public Rectangle2D getMovieRect(int difx, int dify);
236

    
237
    /**
238
     * Dibuja un rect?ngulo de color gris, con el nombre en el centro y
239
     * escalado en forma de borrador.
240
     * 
241
     * @param g
242
     *            Graphics sobre el que se dibuja.
243
     */
244
    public void drawDraft(Graphics2D g);
245

    
246
    /**
247
     * Actualiza el BoundBox del FFrame a partir de su rect?ngulo en pixels y
248
     * la matriz de transformaci?n.
249
     * 
250
     * @param r
251
     *            Rect?ngulo.
252
     * @param at
253
     *            Matriz de transformaci?n.
254
     */
255
    public void updateRect(Rectangle2D r, AffineTransform at);
256

    
257
    /**
258
     * Devuelve true si el rect?ngulo primero es null o si es distinto de null
259
     * e intersecta.
260
     * 
261
     * @param rv
262
     *            Rect?ngulo
263
     * @param r
264
     *            Rect?ngulo
265
     * 
266
     * @return True si intersecta o es null.
267
     */
268
    public boolean intersects(Rectangle2D rv, Rectangle2D r);
269

    
270
    /**
271
     * Introduce el n?mero de FFrame en el que de que se trata.
272
     * 
273
     * @param i
274
     *            n?mero de FFrame
275
     */
276
    public void setNum(int i);
277

    
278
    /**
279
     * Devuelve el nombre que representa al tipo de FFrame.
280
     * 
281
     * @return nombre del elemento.
282
     */
283
    public String getNameFFrame();
284

    
285
    /**
286
     * Rellena el tag.
287
     * 
288
     * @param s
289
     *            valor del tag.
290
     */
291
    public void setTag(String s);
292

    
293
    /**
294
     * Devuelve el valor del tag.
295
     * 
296
     * @return String del valor del tag.
297
     */
298
    public String getTag();
299

    
300
    /**
301
     * Dibuja el s?mbolo que indica que el FFrame contiene un tag.
302
     * 
303
     * @param g
304
     *            Graphics sobre el que dibujar.
305
     */
306
    public void drawSymbolTag(Graphics2D g);
307

    
308
    /**
309
     * Sets the rotation of the frame, measured in arc degrees
310
     * 
311
     * @param rotation
312
     *            Rotation to apply to the frame
313
     */
314
    public void setRotation(double rotation);
315

    
316
    /**
317
     * Gets the rotation of the frame, measured in arc degrees
318
     * 
319
     * @return Rotation of the frame
320
     */
321
    public double getRotation();
322

    
323
    /**
324
     * Devuelve el nivel al que se encuentra el FFrame en el Layout.
325
     * 
326
     * @return nivel.
327
     */
328
    public int getLevel();
329

    
330
    /**
331
     * Inserta el nivel de dibujado del FFrame respecto del resto de fframes
332
     * del Layout.
333
     * 
334
     * @param l
335
     *            nivel.
336
     */
337
    public void setLevel(int l);
338

    
339
    public Rectangle2D getLastMoveRect();
340

    
341
    public void setFrameFactory(FrameFactory frameFactory);
342

    
343
    public FrameFactory getFrameFactory();
344
    
345
        public Document getDocument();
346

    
347
        public void setDocument(Document document);
348

    
349
        public LayoutContext getLayoutContext();
350

    
351
        public void setLayoutContext(LayoutContext layoutContext);
352
        
353
        /**
354
         * This method is called when the FFrame has been
355
         * removed from the Layout
356
         */
357
        public void frameRemoved();
358
        
359
        /**
360
         * This method is called when the FFrame has been
361
         * added to the Layout
362
         */
363
        public void frameAdded();
364
}