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 @ 1714

History | View | Annotate | Download (11.6 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
import org.gvsig.app.project.documents.Document;
32
import org.gvsig.app.project.documents.layout.LayoutContext;
33
import org.gvsig.fmap.mapcontext.rendering.symbols.IPrintable;
34
import org.gvsig.tools.dispose.Disposable;
35
import org.gvsig.tools.lang.Cloneable;
36
import org.gvsig.tools.observer.Observable;
37
import org.gvsig.tools.persistence.Persistent;
38

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
234
    /**
235
     * Devuelve el rect?ngulo a partir del desplazamiento en el eje x y el
236
     * desplazamiento en el eje y.
237
     * 
238
     * @param difx
239
     *            desplazamiento sobre el eje x.
240
     * @param dify
241
     *            desplazamiento sobre el eje y.
242
     * @param prop
243
     *            true para un desplazamiento proporcional
244
     * 
245
     * @return rect?ngulo modificado en funci?n del desplazamiento realizado.
246
     */
247
    public Rectangle2D getMovieRect(int difx, int dify, boolean prop);
248
    
249
    /**
250
     * Dibuja un rect?ngulo de color gris, con el nombre en el centro y
251
     * escalado en forma de borrador.
252
     * 
253
     * @param g
254
     *            Graphics sobre el que se dibuja.
255
     */
256
    public void drawDraft(Graphics2D g);
257

    
258
    /**
259
     * Actualiza el BoundBox del FFrame a partir de su rect?ngulo en pixels y
260
     * la matriz de transformaci?n.
261
     * 
262
     * @param r
263
     *            Rect?ngulo.
264
     * @param at
265
     *            Matriz de transformaci?n.
266
     */
267
    public void updateRect(Rectangle2D r, AffineTransform at);
268

    
269
    /**
270
     * Devuelve true si el rect?ngulo primero es null o si es distinto de null
271
     * e intersecta.
272
     * 
273
     * @param rv
274
     *            Rect?ngulo
275
     * @param r
276
     *            Rect?ngulo
277
     * 
278
     * @return True si intersecta o es null.
279
     */
280
    public boolean intersects(Rectangle2D rv, Rectangle2D r);
281

    
282
    /**
283
     * Introduce el n?mero de FFrame en el que de que se trata.
284
     * 
285
     * @param i
286
     *            n?mero de FFrame
287
     */
288
    public void setNum(int i);
289

    
290
    /**
291
     * Devuelve el nombre que representa al tipo de FFrame.
292
     * 
293
     * @return nombre del elemento.
294
     */
295
    public String getNameFFrame();
296

    
297
    /**
298
     * Rellena el tag.
299
     * 
300
     * @param s
301
     *            valor del tag.
302
     */
303
    public void setTag(String s);
304

    
305
    /**
306
     * Devuelve el valor del tag.
307
     * 
308
     * @return String del valor del tag.
309
     */
310
    public String getTag();
311

    
312
    /**
313
     * Dibuja el s?mbolo que indica que el FFrame contiene un tag.
314
     * 
315
     * @param g
316
     *            Graphics sobre el que dibujar.
317
     */
318
    public void drawSymbolTag(Graphics2D g);
319

    
320
    /**
321
     * Sets the rotation of the frame, measured in arc degrees
322
     * 
323
     * @param rotation
324
     *            Rotation to apply to the frame
325
     */
326
    public void setRotation(double rotation);
327

    
328
    /**
329
     * Gets the rotation of the frame, measured in arc degrees
330
     * 
331
     * @return Rotation of the frame
332
     */
333
    public double getRotation();
334

    
335
    /**
336
     * Devuelve el nivel al que se encuentra el FFrame en el Layout.
337
     * 
338
     * @return nivel.
339
     */
340
    public int getLevel();
341

    
342
    /**
343
     * Inserta el nivel de dibujado del FFrame respecto del resto de fframes
344
     * del Layout.
345
     * 
346
     * @param l
347
     *            nivel.
348
     */
349
    public void setLevel(int l);
350

    
351
    public Rectangle2D getLastMoveRect();
352

    
353
    public void setFrameFactory(FrameFactory frameFactory);
354

    
355
    public FrameFactory getFrameFactory();
356
    
357
        public Document getDocument();
358

    
359
        public void setDocument(Document document);
360

    
361
        public LayoutContext getLayoutContext();
362

    
363
        public void setLayoutContext(LayoutContext layoutContext);
364
        
365
        /**
366
         * This method is called when the FFrame has been
367
         * removed from the Layout
368
         */
369
        public void frameRemoved();
370
        
371
        /**
372
         * This method is called when the FFrame has been
373
         * added to the Layout
374
         */
375
        public void frameAdded();
376
}