root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / Layout.java @ 1830
History | View | Annotate | Download (35 KB)
1 | 312 | fernando | /*
|
---|---|---|---|
2 | * Created on 20-feb-2004
|
||
3 | *
|
||
4 | */
|
||
5 | 1103 | fjp | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
6 | *
|
||
7 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
8 | *
|
||
9 | * This program is free software; you can redistribute it and/or
|
||
10 | * modify it under the terms of the GNU General Public License
|
||
11 | * as published by the Free Software Foundation; either version 2
|
||
12 | * of the License, or (at your option) any later version.
|
||
13 | *
|
||
14 | * This program is distributed in the hope that it will be useful,
|
||
15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
17 | * GNU General Public License for more details.
|
||
18 | *
|
||
19 | * You should have received a copy of the GNU General Public License
|
||
20 | * along with this program; if not, write to the Free Software
|
||
21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
22 | *
|
||
23 | * For more information, contact:
|
||
24 | *
|
||
25 | * Generalitat Valenciana
|
||
26 | * Conselleria d'Infraestructures i Transport
|
||
27 | * Av. Blasco Ib??ez, 50
|
||
28 | * 46010 VALENCIA
|
||
29 | * SPAIN
|
||
30 | *
|
||
31 | * +34 963862235
|
||
32 | * gvsig@gva.es
|
||
33 | * www.gvsig.gva.es
|
||
34 | *
|
||
35 | * or
|
||
36 | *
|
||
37 | * IVER T.I. S.A
|
||
38 | * Salamanca 50
|
||
39 | * 46005 Valencia
|
||
40 | * Spain
|
||
41 | *
|
||
42 | * +34 963163400
|
||
43 | * dac@iver.es
|
||
44 | */
|
||
45 | 312 | fernando | package com.iver.cit.gvsig.gui.layout; |
46 | |||
47 | 1074 | vcaballero | import com.iver.andami.PluginServices; |
48 | 1328 | fernando | import com.iver.andami.messages.NotificationManager; |
49 | 1074 | vcaballero | import com.iver.andami.ui.mdiManager.SingletonView; |
50 | import com.iver.andami.ui.mdiManager.ViewInfo; |
||
51 | import com.iver.andami.ui.mdiManager.ViewListener; |
||
52 | |||
53 | import com.iver.cit.gvsig.Abrir; |
||
54 | import com.iver.cit.gvsig.fmap.ColorEvent; |
||
55 | import com.iver.cit.gvsig.fmap.DriverException; |
||
56 | import com.iver.cit.gvsig.fmap.ExtentEvent; |
||
57 | import com.iver.cit.gvsig.fmap.ViewPortListener; |
||
58 | 1830 | fernando | import com.iver.cit.gvsig.fmap.layers.XMLException; |
59 | 1074 | vcaballero | import com.iver.cit.gvsig.gui.layout.dialogs.FConfigLayoutDialog; |
60 | import com.iver.cit.gvsig.gui.layout.fframes.FFrame; |
||
61 | import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics; |
||
62 | import com.iver.cit.gvsig.gui.layout.fframes.FFrameLegend; |
||
63 | import com.iver.cit.gvsig.gui.layout.fframes.FFramePicture; |
||
64 | import com.iver.cit.gvsig.gui.layout.fframes.FFrameScaleBar; |
||
65 | import com.iver.cit.gvsig.gui.layout.fframes.FFrameText; |
||
66 | import com.iver.cit.gvsig.gui.layout.fframes.FFrameView; |
||
67 | import com.iver.cit.gvsig.gui.layout.fframes.IFFrame; |
||
68 | import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFrameGraphicsDialog; |
||
69 | import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFrameLegendDialog; |
||
70 | import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFramePictureDialog; |
||
71 | import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFrameScaleBarDialog; |
||
72 | import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFrameTextDialog; |
||
73 | import com.iver.cit.gvsig.gui.layout.fframes.dialogs.FFrameViewDialog; |
||
74 | import com.iver.cit.gvsig.gui.layout.fframes.dialogs.IFFrameDialog; |
||
75 | 1221 | fernando | import com.iver.cit.gvsig.gui.project.MapProperties; |
76 | import com.iver.cit.gvsig.project.Project; |
||
77 | import com.iver.cit.gvsig.project.ProjectMap; |
||
78 | 1074 | vcaballero | |
79 | import com.iver.utiles.XMLEntity; |
||
80 | |||
81 | import org.apache.log4j.Logger; |
||
82 | |||
83 | 312 | fernando | import java.awt.Color; |
84 | import java.awt.Cursor; |
||
85 | import java.awt.Graphics; |
||
86 | import java.awt.Graphics2D; |
||
87 | import java.awt.Image; |
||
88 | import java.awt.Point; |
||
89 | import java.awt.Rectangle; |
||
90 | import java.awt.Toolkit; |
||
91 | import java.awt.event.ActionEvent; |
||
92 | import java.awt.event.KeyEvent; |
||
93 | import java.awt.geom.AffineTransform; |
||
94 | import java.awt.geom.Rectangle2D; |
||
95 | import java.awt.image.BufferedImage; |
||
96 | import java.awt.print.PageFormat; |
||
97 | import java.awt.print.Printable; |
||
98 | import java.awt.print.PrinterException; |
||
99 | import java.awt.print.PrinterJob; |
||
100 | 1550 | vcaballero | |
101 | 1406 | fernando | import java.beans.PropertyChangeEvent; |
102 | import java.beans.PropertyChangeListener; |
||
103 | 1074 | vcaballero | |
104 | 312 | fernando | import java.util.ArrayList; |
105 | 396 | vcaballero | import java.util.Hashtable; |
106 | 312 | fernando | |
107 | import javax.print.Doc; |
||
108 | import javax.print.DocFlavor; |
||
109 | import javax.print.DocPrintJob; |
||
110 | import javax.print.PrintException; |
||
111 | import javax.print.PrintService; |
||
112 | import javax.print.PrintServiceLookup; |
||
113 | import javax.print.ServiceUI; |
||
114 | import javax.print.SimpleDoc; |
||
115 | import javax.print.attribute.PrintRequestAttributeSet; |
||
116 | import javax.print.event.PrintJobAdapter; |
||
117 | import javax.print.event.PrintJobEvent; |
||
118 | import javax.print.event.PrintJobListener; |
||
119 | 1074 | vcaballero | |
120 | 312 | fernando | import javax.swing.AbstractAction; |
121 | import javax.swing.Action; |
||
122 | import javax.swing.ImageIcon; |
||
123 | import javax.swing.JPanel; |
||
124 | import javax.swing.KeyStroke; |
||
125 | |||
126 | |||
127 | /**
|
||
128 | * Mapa.
|
||
129 | *
|
||
130 | * @author Vicente Caballero Navarro
|
||
131 | */
|
||
132 | 1074 | vcaballero | public class Layout extends JPanel implements SingletonView, ViewPortListener, |
133 | ViewListener { |
||
134 | private static Logger logger = Logger.getLogger(Layout.class.getName()); |
||
135 | public static final int ZOOM_MAS = 1; |
||
136 | public static final int ZOOM_MENOS = 2; |
||
137 | public static final int PAN = 3; |
||
138 | public static final int DESACTUALIZADO = 4; |
||
139 | public static final int RECTANGLEVIEW = 5; |
||
140 | public static final int RECTANGLEPICTURE = 6; |
||
141 | public static final int RECTANGLESCALEBAR = 7; |
||
142 | public static final int RECTANGLELEGEND = 8; |
||
143 | public static final int RECTANGLETEXT = 9; |
||
144 | public static final int RECTANGLE = 10; |
||
145 | public static final int ACTUALIZADO = 11; |
||
146 | public static final int SELECT = 12; |
||
147 | public static final int POINT = 13; |
||
148 | public static final int LINE = 14; |
||
149 | public static final int POLYLINE = 15; |
||
150 | public static final int RECTANGLESIMPLE = 16; |
||
151 | public static final int CIRCLE = 17; |
||
152 | public static final int POLYGON = 18; |
||
153 | public static final int GRAPHICS = 19; |
||
154 | public static final int RECTANGLESYMBOL = 20; |
||
155 | public static final int RECTANGLEGROUP = 21; |
||
156 | public static final int VIEW_ZOOMIN = 22; |
||
157 | public static final int VIEW_ZOOMOUT = 23; |
||
158 | public static final int VIEW_FULL = 24; |
||
159 | public static final int VIEW_PAN = 25; |
||
160 | public static final int SET_TAG = 26; |
||
161 | public static final Image iLayoutpan = new ImageIcon(Abrir.class.getClassLoader() |
||
162 | .getResource("images/LayoutHand.gif")).getImage();
|
||
163 | public static final Image ipan = new ImageIcon(Abrir.class.getClassLoader() |
||
164 | .getResource("images/Hand.gif")).getImage();
|
||
165 | public static final Image iLayoutzoomin = new ImageIcon(Abrir.class.getClassLoader() |
||
166 | .getResource("images/LayoutZoomInCursor.gif")).getImage();
|
||
167 | public static final Image izoomin = new ImageIcon(Abrir.class.getClassLoader() |
||
168 | .getResource("images/ZoomInCursor.gif")).getImage();
|
||
169 | public static final Image iLayoutzoomout = new ImageIcon(Abrir.class.getClassLoader() |
||
170 | .getResource("images/LayoutZoomOutCursor.gif")).getImage();
|
||
171 | public static final Image izoomout = new ImageIcon(Abrir.class.getClassLoader() |
||
172 | .getResource("images/ZoomOutCursor.gif")).getImage();
|
||
173 | public static final Image iinfo = new ImageIcon(Abrir.class.getClassLoader() |
||
174 | .getResource("images/InfoCursor.gif")).getImage();
|
||
175 | public static final Image icrux = new ImageIcon(Abrir.class.getClassLoader() |
||
176 | .getResource("images/CruxCursor.png")).getImage();
|
||
177 | public static final Image itag = new ImageIcon(Abrir.class.getClassLoader() |
||
178 | .getResource("images/tagCursor.gif")).getImage();
|
||
179 | public static final Image iPoint = new ImageIcon(Abrir.class.getClassLoader() |
||
180 | .getResource("images/PointCursor.png")).getImage();
|
||
181 | public static final Image iRect = new ImageIcon(Abrir.class.getClassLoader() |
||
182 | .getResource("images/RectCursor.png")).getImage();
|
||
183 | public static final Image iLine = new ImageIcon(Abrir.class.getClassLoader() |
||
184 | .getResource("images/LineCursor.png")).getImage();
|
||
185 | public static final Image iRectangle = new ImageIcon(Abrir.class.getClassLoader() |
||
186 | .getResource("images/RectangleCursor.png")).getImage();
|
||
187 | public static final Image iCircle = new ImageIcon(Abrir.class.getClassLoader() |
||
188 | .getResource("images/CircleCursor.png")).getImage();
|
||
189 | public static final Image iPoligon = new ImageIcon(Abrir.class.getClassLoader() |
||
190 | .getResource("images/PoligonCursor.png")).getImage();
|
||
191 | public static Hashtable nums = new Hashtable(); |
||
192 | private Point origin = new Point(50, 50); |
||
193 | private Point rectOrigin = new Point(origin); |
||
194 | private Rectangle2D.Double rect = new Rectangle2D.Double(rectOrigin.x, |
||
195 | rectOrigin.y, 400, 300); |
||
196 | private Point m_FirstPoint = new Point(0, 0); |
||
197 | private Point m_PointAnt = new Point(0, 0); |
||
198 | private Point m_LastPoint = new Point(0, 0); |
||
199 | private EventsHandler events;
|
||
200 | private int tool = ZOOM_MAS; |
||
201 | private int status = DESACTUALIZADO; |
||
202 | private BufferedImage img = null; |
||
203 | private AffineTransform m_MatrizTransf; |
||
204 | private Rectangle2D rectVisible; |
||
205 | private IFFrameDialog fframedialog = null; |
||
206 | private ArrayList m_fframes = new ArrayList(); |
||
207 | private FConfigLayoutDialog m_configLayout = null; |
||
208 | private MapProperties m_propertiesLayout = null; |
||
209 | private Attributes m_attributes = null; |
||
210 | private PrintService[] m_cachePrintServices = null; |
||
211 | private PrintRequestAttributeSet m_cachePrintRequestAtributeSet = null; |
||
212 | private PrintService m_cachePrintService = null; |
||
213 | private boolean m_bCancelDrawing = false; |
||
214 | private boolean isCuadricula = false; |
||
215 | private boolean initial = true; |
||
216 | private ProjectMap map = null; |
||
217 | private Rectangle reSel = null; |
||
218 | private boolean isReSel = true; |
||
219 | 312 | fernando | |
220 | 1074 | vcaballero | // private String m_name = null;
|
221 | private boolean m_showRuler = true; |
||
222 | private FLayoutDraw layoutPaint = null; |
||
223 | private boolean isDrawCuadricula = true; |
||
224 | private Doc doc = null; |
||
225 | private PrintRequestAttributeSet att = null; |
||
226 | 312 | fernando | |
227 | 1074 | vcaballero | /**
|
228 | * Creates a new Layout object.
|
||
229 | */
|
||
230 | public Layout() {
|
||
231 | this.setLayout(null); |
||
232 | events = new EventsHandler(this); |
||
233 | layoutPaint = new FLayoutDraw(this); |
||
234 | addComponentListener(events); |
||
235 | addMouseMotionListener(events); |
||
236 | addMouseListener(events); |
||
237 | m_MatrizTransf = new AffineTransform(); |
||
238 | m_MatrizTransf.setToIdentity(); |
||
239 | this.initComponents();
|
||
240 | } |
||
241 | 312 | fernando | |
242 | 1074 | vcaballero | /**
|
243 | * Rellena el ProjectMap del Layout.
|
||
244 | *
|
||
245 | * @param m ProjectMap.
|
||
246 | */
|
||
247 | public void setProjectMap(ProjectMap m) { |
||
248 | map = m; |
||
249 | 1550 | vcaballero | map.addPropertyChangeListener(new PropertyChangeListener() { |
250 | public void propertyChange(PropertyChangeEvent evt) { |
||
251 | if (evt.getPropertyName().equals("name")) { |
||
252 | PluginServices.getMDIManager().getViewInfo(Layout.this) |
||
253 | .setTitle(PluginServices.getText(this,
|
||
254 | "Mapa") + " : " + (String) evt.getNewValue()); |
||
255 | } |
||
256 | 1406 | fernando | } |
257 | 1550 | vcaballero | }); |
258 | 1074 | vcaballero | } |
259 | 312 | fernando | |
260 | 1074 | vcaballero | /**
|
261 | * Devuelve el rect?ngulo de selecci?n por rect?ngulo.
|
||
262 | *
|
||
263 | * @return Rect?ngulo de selecci?n.
|
||
264 | */
|
||
265 | public Rectangle getReSel() { |
||
266 | return reSel;
|
||
267 | } |
||
268 | 312 | fernando | |
269 | 1074 | vcaballero | /**
|
270 | * Devuelve true si se debe dibujar el rect?ngulo de selecci?n y realizar
|
||
271 | * la sellecci?n.
|
||
272 | *
|
||
273 | * @return true si se realiza la selecci?n por rect?ngulo.
|
||
274 | */
|
||
275 | public boolean isReSel() { |
||
276 | return isReSel;
|
||
277 | } |
||
278 | 312 | fernando | |
279 | 1074 | vcaballero | /**
|
280 | * Rellena con true si se debe de dibujar y seleccionar por rect?ngulo de
|
||
281 | * selecci?n.
|
||
282 | *
|
||
283 | * @param b boolean.
|
||
284 | */
|
||
285 | public void setIsReSel(boolean b) { |
||
286 | isReSel = b; |
||
287 | } |
||
288 | 312 | fernando | |
289 | 1074 | vcaballero | /**
|
290 | * Devuelve true si el dibujado ha sido cancelado.
|
||
291 | *
|
||
292 | * @return true si el dibujado ha sido cancelado.
|
||
293 | */
|
||
294 | public synchronized boolean isDrawingCancelled() { |
||
295 | return m_bCancelDrawing;
|
||
296 | } |
||
297 | 312 | fernando | |
298 | 1074 | vcaballero | /**
|
299 | * Pone el dibuja a cancelado o no seg?n se quiera.
|
||
300 | *
|
||
301 | * @param b true si se quiere cancelar el dibujado.
|
||
302 | */
|
||
303 | public synchronized void setCancelDrawing(boolean b) { |
||
304 | m_bCancelDrawing = b; |
||
305 | 312 | fernando | |
306 | 1074 | vcaballero | for (int i = 0; i < getFFrames().size(); i++) { |
307 | IFFrame fframe = (IFFrame) getFFrames().get(i); |
||
308 | 312 | fernando | |
309 | 1074 | vcaballero | if (fframe instanceof FFrameView && |
310 | (((FFrameView) fframe).getFMap() != null)) {
|
||
311 | ////TODO((FFrameView) getFFrames().get(i)).getFMap().setCancelDrawing(b);
|
||
312 | } |
||
313 | } |
||
314 | } |
||
315 | 312 | fernando | |
316 | 1074 | vcaballero | /**
|
317 | * Obtiene el ArrayList con todos los FFrames que se han a?adido al Layout.
|
||
318 | *
|
||
319 | * @return Array con todos los fframes que contiene el Layout.
|
||
320 | */
|
||
321 | public ArrayList getFFrames() { |
||
322 | return m_fframes;
|
||
323 | } |
||
324 | 312 | fernando | |
325 | 1074 | vcaballero | /**
|
326 | * Obtiene el rect que se ajusta al tama?o de la ventana, para ver el folio
|
||
327 | * entero.
|
||
328 | */
|
||
329 | public void fullRect() { |
||
330 | rect.setRect(origin.x, origin.y, getWidth() - (origin.x * 2),
|
||
331 | getHeight() - (origin.x * 2));
|
||
332 | 312 | fernando | |
333 | 1074 | vcaballero | if (m_attributes.isLandSpace()) {
|
334 | rect = m_attributes.getRectangleLandscape(rect, getWidth(), |
||
335 | getHeight()); |
||
336 | } else {
|
||
337 | rect = m_attributes.getRectanglePortrait(rect, getWidth(), |
||
338 | getHeight()); |
||
339 | } |
||
340 | 312 | fernando | |
341 | 1074 | vcaballero | status = DESACTUALIZADO; |
342 | repaint(); |
||
343 | } |
||
344 | 312 | fernando | |
345 | 1074 | vcaballero | /**
|
346 | * M?todo para imprimir el Layout sin modificar la matriz de
|
||
347 | * transformaci?n.
|
||
348 | *
|
||
349 | * @param g2
|
||
350 | */
|
||
351 | public void drawLayoutPrint(Graphics2D g2) { |
||
352 | setCancelDrawing(false);
|
||
353 | 312 | fernando | |
354 | 1074 | vcaballero | setCursor(Cursor.getDefaultCursor());
|
355 | 312 | fernando | |
356 | 1074 | vcaballero | double scale = 0; |
357 | 312 | fernando | |
358 | 1074 | vcaballero | ///if (rect.width > rect.height) {
|
359 | /// scale = rect.width / m_attributes.m_sizePaper.getAlto() * 1;
|
||
360 | ///} else {
|
||
361 | scale = rect.height / m_attributes.m_sizePaper.getAlto() * 1;
|
||
362 | 312 | fernando | |
363 | 1074 | vcaballero | ///}
|
364 | AffineTransform escalado = new AffineTransform(); |
||
365 | AffineTransform translacion = new AffineTransform(); |
||
366 | translacion.setToTranslation(rect.getMinX(), rect.getMinY()); |
||
367 | escalado.setToScale(scale, scale); |
||
368 | m_MatrizTransf.setToIdentity(); |
||
369 | m_MatrizTransf.concatenate(translacion); |
||
370 | m_MatrizTransf.concatenate(escalado); |
||
371 | m_attributes.setDistanceUnitX(rect); |
||
372 | m_attributes.setDistanceUnitY(rect); |
||
373 | 312 | fernando | |
374 | 1074 | vcaballero | for (int i = 0; i < getFFrames().size(); i++) { |
375 | try {
|
||
376 | ((IFFrame) getFFrames().get(i)).print(g2, getAT()); |
||
377 | } catch (DriverException e) {
|
||
378 | 1328 | fernando | NotificationManager.addError(e.getMessage(), e); |
379 | 1074 | vcaballero | } |
380 | } |
||
381 | 312 | fernando | |
382 | 1074 | vcaballero | setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); |
383 | } |
||
384 | 312 | fernando | |
385 | 1074 | vcaballero | /**
|
386 | * Clip sobre el rect?ngulo visible.
|
||
387 | *
|
||
388 | * @param g2d Graphics sobre el que hacer el clip.
|
||
389 | */
|
||
390 | private void clipVisibleRect(Graphics2D g2d) { |
||
391 | rectVisible = this.getVisibleRect();
|
||
392 | g2d.clipRect((int) rectVisible.getMinX(), (int) rectVisible.getMinY(), |
||
393 | (int) rectVisible.getWidth(), (int) rectVisible.getHeight()); |
||
394 | } |
||
395 | 312 | fernando | |
396 | 1074 | vcaballero | /**
|
397 | * Inicializa los componentes.
|
||
398 | */
|
||
399 | private void initComponents() { |
||
400 | m_attributes = new Attributes(); |
||
401 | m_attributes.setDistanceUnitX(rect); |
||
402 | m_attributes.setDistanceUnitY(rect); |
||
403 | actionDelFFrame(); |
||
404 | } |
||
405 | 312 | fernando | |
406 | 1074 | vcaballero | /**
|
407 | * Crea un ActionEvent para controlar las teclas que se pulsen cuando este
|
||
408 | * el Layout Focusable a true.
|
||
409 | */
|
||
410 | private void actionDelFFrame() { |
||
411 | Action doNothing = new AbstractAction() { |
||
412 | public void actionPerformed(ActionEvent e) { |
||
413 | for (int i = getFFrames().size() - 1; i >= 0; i--) { |
||
414 | IFFrame fframe = (IFFrame) getFFrames().get(i); |
||
415 | 312 | fernando | |
416 | 1074 | vcaballero | if (fframe.getSelected() != FFrame.NOSELECT) {
|
417 | getFFrames().remove(i); |
||
418 | } |
||
419 | } |
||
420 | 312 | fernando | |
421 | 1074 | vcaballero | refresh(); |
422 | } |
||
423 | }; |
||
424 | 312 | fernando | |
425 | 1074 | vcaballero | this.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0), |
426 | "doNothing");
|
||
427 | this.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_BACK_SPACE, 0), |
||
428 | "doNothing");
|
||
429 | this.getActionMap().put("doNothing", doNothing); |
||
430 | } |
||
431 | 312 | fernando | |
432 | 1074 | vcaballero | /**
|
433 | * paintComponent del Layout.
|
||
434 | *
|
||
435 | * @param g Graphics del Layout.
|
||
436 | */
|
||
437 | protected void paintComponent(Graphics g) { |
||
438 | super.paintComponent(g);
|
||
439 | 1550 | vcaballero | |
440 | 1282 | fjp | clipVisibleRect((Graphics2D) g);
|
441 | 1550 | vcaballero | |
442 | 1281 | fjp | Rectangle rClip = g.getClipBounds();
|
443 | 1550 | vcaballero | |
444 | if (rClip == null) { |
||
445 | System.err.println("clip = null"); |
||
446 | } |
||
447 | |||
448 | 1074 | vcaballero | switch (status) {
|
449 | case ZOOM_MAS:
|
||
450 | logger.debug("zoom mas");
|
||
451 | layoutPaint.drawRectangle((Graphics2D) g);
|
||
452 | 312 | fernando | |
453 | 1074 | vcaballero | g.drawImage(img, 0, 0, this); |
454 | 1550 | vcaballero | |
455 | 1281 | fjp | g.setClip(rClip); |
456 | 1550 | vcaballero | layoutPaint.drawGrid((Graphics2D) g);
|
457 | 1074 | vcaballero | layoutPaint.drawRuler((Graphics2D) g, Color.black); |
458 | g.setColor(Color.black);
|
||
459 | g.setXORMode(Color.white);
|
||
460 | 312 | fernando | |
461 | 1074 | vcaballero | Rectangle r = new Rectangle(); |
462 | 312 | fernando | |
463 | 1074 | vcaballero | r.setFrameFromDiagonal(m_FirstPoint, m_LastPoint); |
464 | g.drawRect(r.x, r.y, r.width, r.height); |
||
465 | 312 | fernando | |
466 | 1074 | vcaballero | break;
|
467 | 312 | fernando | |
468 | 1074 | vcaballero | case RECTANGLE:
|
469 | logger.debug("rectangle");
|
||
470 | layoutPaint.drawRectangle((Graphics2D) g);
|
||
471 | 312 | fernando | |
472 | 1074 | vcaballero | g.drawImage(img, 0, 0, this); |
473 | 1281 | fjp | |
474 | g.setClip(rClip); |
||
475 | 1550 | vcaballero | layoutPaint.drawGrid((Graphics2D) g);
|
476 | 1074 | vcaballero | layoutPaint.drawRuler((Graphics2D) g, Color.black); |
477 | g.setColor(Color.black);
|
||
478 | g.setXORMode(Color.white);
|
||
479 | 312 | fernando | |
480 | 1074 | vcaballero | Rectangle re = new Rectangle(); |
481 | re.setFrameFromDiagonal(m_FirstPoint, m_LastPoint); |
||
482 | 312 | fernando | |
483 | 1074 | vcaballero | if (isCuadricula()) {
|
484 | FLayoutUtilities.setRectGrid(re, |
||
485 | m_attributes.getUnitInPixelsX(), |
||
486 | m_attributes.getUnitInPixelsY(), m_MatrizTransf); |
||
487 | } |
||
488 | 312 | fernando | |
489 | 1074 | vcaballero | g.drawRect(re.x, re.y, re.width, re.height); |
490 | 312 | fernando | |
491 | 1074 | vcaballero | break;
|
492 | 312 | fernando | |
493 | 1074 | vcaballero | case PAN:
|
494 | logger.debug("pan");
|
||
495 | 312 | fernando | |
496 | 1074 | vcaballero | //g.setXORMode(Color.black);
|
497 | rect.x = rectOrigin.x + (m_LastPoint.x - m_PointAnt.x); |
||
498 | rect.y = rectOrigin.y + (m_LastPoint.y - m_PointAnt.y); |
||
499 | 312 | fernando | |
500 | 1074 | vcaballero | //g.clearRect(0, 0, getWidth(), getHeight());
|
501 | layoutPaint.drawRectangle((Graphics2D) g);
|
||
502 | 312 | fernando | |
503 | 1074 | vcaballero | if (img != null) { |
504 | g.drawImage(img, (getLastPoint().x - getPointAnt().x), |
||
505 | (m_LastPoint.y - m_PointAnt.y), this);
|
||
506 | } |
||
507 | 312 | fernando | |
508 | 1281 | fjp | g.setClip(rClip); |
509 | layoutPaint.drawGrid((Graphics2D) g);
|
||
510 | 1074 | vcaballero | layoutPaint.drawRuler((Graphics2D) g, Color.black); |
511 | 312 | fernando | |
512 | 1074 | vcaballero | break;
|
513 | 312 | fernando | |
514 | 1074 | vcaballero | case VIEW_PAN:
|
515 | 312 | fernando | |
516 | 1074 | vcaballero | // logger.debug("View pan");
|
517 | layoutPaint.drawRectangle((Graphics2D) g);
|
||
518 | 312 | fernando | |
519 | 1074 | vcaballero | for (int i = 0; i < getFFrames().size(); i++) { |
520 | if (getFFrames().get(i) instanceof FFrameView) { |
||
521 | FFrameView fframe = (FFrameView) getFFrames().get(i); |
||
522 | 312 | fernando | |
523 | 1074 | vcaballero | if (fframe.getSelected() != FFrame.NOSELECT) {
|
524 | Rectangle2D.Double rec = fframe.getBoundingBox(getAT());
|
||
525 | 312 | fernando | |
526 | 1074 | vcaballero | if (img != null) { |
527 | //g.drawImage(img, 0, 0, this);
|
||
528 | rec = (Rectangle2D.Double) rec.createIntersection(getVisibleRect());
|
||
529 | 312 | fernando | |
530 | 1074 | vcaballero | //((Graphics2D)g).clearRect((int)rec.x,(int)rec.y,(int)rec.width,(int)rec.height);
|
531 | } |
||
532 | 312 | fernando | |
533 | 1074 | vcaballero | if (fframe.getBufferedImage() != null) { |
534 | layoutPaint.drawHandlers((Graphics2D) g,
|
||
535 | Color.black);
|
||
536 | g.clipRect((int) rec.x, (int) rec.y, |
||
537 | (int) rec.width, (int) rec.height); |
||
538 | 312 | fernando | |
539 | 1074 | vcaballero | //g.setColor(Color.gray);
|
540 | //g.fillRect(0,0,getWidth(),getHeight());
|
||
541 | layoutPaint.drawRectangle((Graphics2D) g);
|
||
542 | layoutPaint.drawRuler((Graphics2D) g,
|
||
543 | Color.black);
|
||
544 | 312 | fernando | |
545 | 1074 | vcaballero | g.drawImage(fframe.getBufferedImage(), |
546 | m_LastPoint.x - m_PointAnt.x, |
||
547 | m_LastPoint.y - m_PointAnt.y, this);
|
||
548 | 1550 | vcaballero | |
549 | 1332 | vcaballero | /*System.out.println(
|
550 | 1550 | vcaballero | "m_LastPoint.x - m_PointAnt.x" +
|
551 | (m_LastPoint.x - m_PointAnt.x));
|
||
552 | System.out.println(
|
||
553 | "m_LastPoint.y - m_PointAnt.y" +
|
||
554 | (m_LastPoint.y - m_PointAnt.y));
|
||
555 | */
|
||
556 | 1074 | vcaballero | } |
557 | } |
||
558 | } |
||
559 | } |
||
560 | 1550 | vcaballero | |
561 | 1281 | fjp | g.setClip(rClip); |
562 | layoutPaint.drawGrid((Graphics2D) g);
|
||
563 | layoutPaint.drawRuler((Graphics2D) g, Color.black); |
||
564 | 1550 | vcaballero | |
565 | 1074 | vcaballero | //g.setXORMode(Color.black);
|
566 | break;
|
||
567 | 312 | fernando | |
568 | 1074 | vcaballero | case SELECT:
|
569 | logger.debug("select");
|
||
570 | layoutPaint.drawRectangle((Graphics2D) g);
|
||
571 | 312 | fernando | |
572 | 1074 | vcaballero | g.drawImage(img, 0, 0, this); |
573 | 312 | fernando | |
574 | 1074 | vcaballero | if (isReSel) {
|
575 | reSel = new Rectangle(); |
||
576 | reSel.setFrameFromDiagonal(m_FirstPoint, m_LastPoint); |
||
577 | g.drawRect(reSel.x, reSel.y, reSel.width, reSel.height); |
||
578 | } |
||
579 | 312 | fernando | |
580 | 1074 | vcaballero | for (int i = 0; i < getFFrames().size(); i++) { |
581 | IFFrame fframe = (IFFrame) getFFrames().get(i); |
||
582 | 312 | fernando | |
583 | 1074 | vcaballero | if (fframe.getSelected() != FFrame.NOSELECT) {
|
584 | g.setColor(Color.black);
|
||
585 | fframe.drawHandlers((Graphics2D) g);
|
||
586 | 312 | fernando | |
587 | 1074 | vcaballero | int difx = (m_LastPoint.x - m_FirstPoint.x);
|
588 | int dify = (m_LastPoint.y - m_FirstPoint.y);
|
||
589 | 312 | fernando | |
590 | 1074 | vcaballero | if ((Math.abs(difx) > 3) || (Math.abs(dify) > 3)) { |
591 | Rectangle2D rectangle = fframe.getMovieRect(difx,
|
||
592 | dify); |
||
593 | 312 | fernando | |
594 | 1074 | vcaballero | if (rectangle != null) { |
595 | if (isCuadricula) {
|
||
596 | FLayoutUtilities.setRectGrid(rectangle, |
||
597 | m_attributes.getUnitInPixelsX(), |
||
598 | m_attributes.getUnitInPixelsY(), |
||
599 | m_MatrizTransf); |
||
600 | } |
||
601 | 312 | fernando | |
602 | 1074 | vcaballero | g.drawRect((int) rectangle.getMinX(),
|
603 | (int) rectangle.getMinY(),
|
||
604 | (int) rectangle.getWidth(),
|
||
605 | (int) rectangle.getHeight());
|
||
606 | } |
||
607 | } |
||
608 | } |
||
609 | } |
||
610 | 1550 | vcaballero | |
611 | 1281 | fjp | g.setClip(rClip); |
612 | layoutPaint.drawGrid((Graphics2D) g);
|
||
613 | 1074 | vcaballero | layoutPaint.drawRuler((Graphics2D) g, Color.black); |
614 | 1550 | vcaballero | PluginServices.getMainFrame().enableControls(); |
615 | 312 | fernando | |
616 | 1074 | vcaballero | break;
|
617 | 312 | fernando | |
618 | 1074 | vcaballero | case GRAPHICS:
|
619 | layoutPaint.drawRectangle((Graphics2D) g);
|
||
620 | g.drawImage(img, 0, 0, this); |
||
621 | 1281 | fjp | g.setClip(rClip); |
622 | 1550 | vcaballero | layoutPaint.drawGrid((Graphics2D) g);
|
623 | 1074 | vcaballero | layoutPaint.drawRuler((Graphics2D) g, Color.black); |
624 | 312 | fernando | |
625 | 1074 | vcaballero | break;
|
626 | 312 | fernando | |
627 | 1074 | vcaballero | case DESACTUALIZADO:
|
628 | logger.debug("desactualizado");
|
||
629 | img = new BufferedImage(getWidth(), getHeight(), |
||
630 | BufferedImage.TYPE_INT_ARGB);
|
||
631 | 312 | fernando | |
632 | 1074 | vcaballero | Graphics gimag = img.getGraphics();
|
633 | 1282 | fjp | clipVisibleRect((Graphics2D) gimag);
|
634 | 312 | fernando | |
635 | 1074 | vcaballero | if (initial) {
|
636 | fullRect(); |
||
637 | initial = false;
|
||
638 | } |
||
639 | 1550 | vcaballero | |
640 | 1074 | vcaballero | try {
|
641 | layoutPaint.drawLayout((Graphics2D) gimag, img);
|
||
642 | } catch (DriverException e) {
|
||
643 | e.printStackTrace(); |
||
644 | } |
||
645 | 1550 | vcaballero | |
646 | 1282 | fjp | g.setClip(rClip); |
647 | 1074 | vcaballero | layoutPaint.drawRectangle((Graphics2D) g);
|
648 | 312 | fernando | |
649 | 1074 | vcaballero | g.drawImage(img, 0, 0, this); |
650 | 1281 | fjp | g.setClip(rClip); |
651 | 1550 | vcaballero | layoutPaint.drawGrid((Graphics2D) g);
|
652 | 1074 | vcaballero | layoutPaint.drawHandlers((Graphics2D) g, Color.black); |
653 | layoutPaint.drawRuler((Graphics2D) g, Color.black); |
||
654 | 312 | fernando | |
655 | 1074 | vcaballero | break;
|
656 | 312 | fernando | |
657 | 1074 | vcaballero | case ACTUALIZADO:
|
658 | layoutPaint.drawRectangle((Graphics2D) g);
|
||
659 | 312 | fernando | |
660 | 1074 | vcaballero | g.drawImage(img, 0, 0, this); |
661 | 1281 | fjp | |
662 | g.setClip(rClip); |
||
663 | layoutPaint.drawGrid((Graphics2D) g);
|
||
664 | 1550 | vcaballero | |
665 | 1074 | vcaballero | layoutPaint.drawHandlers((Graphics2D) g, Color.black); |
666 | layoutPaint.drawRuler((Graphics2D) g, Color.black); |
||
667 | } |
||
668 | } |
||
669 | 312 | fernando | |
670 | 1074 | vcaballero | /**
|
671 | * A?ade un fframe al Arraylist m_fframes.
|
||
672 | *
|
||
673 | * @param frame fframe a a?adir.
|
||
674 | * @param clearSelection para que se quede seleccionado ?nicamente el que
|
||
675 | * a?adimos y false si lo que se pretende es que no se
|
||
676 | * deseleccionen lo que ya est?n seleccionados.
|
||
677 | */
|
||
678 | public void addFFrame(IFFrame frame, boolean clearSelection) { |
||
679 | if (clearSelection) {
|
||
680 | for (int i = getFFrames().size() - 1; i >= 0; i--) { |
||
681 | IFFrame fframe1 = (IFFrame) getFFrames().get(i); |
||
682 | fframe1.setSelected(false);
|
||
683 | } |
||
684 | } |
||
685 | 312 | fernando | |
686 | 1074 | vcaballero | if (frame instanceof FFrameView && |
687 | (((FFrameView) frame).getFMap() != null)) {
|
||
688 | 1201 | fernando | ((FFrameView) frame).getFMap().getViewPort().addViewPortListener(this);
|
689 | 1074 | vcaballero | } |
690 | 312 | fernando | |
691 | 1074 | vcaballero | if (nums.containsKey(frame.getClass())) {
|
692 | nums.put(frame.getClass(), |
||
693 | new Integer(Integer.parseInt(nums.get(frame.getClass()) |
||
694 | .toString()) + 1));
|
||
695 | } else {
|
||
696 | nums.put(frame.getClass(), new Integer(0)); |
||
697 | } |
||
698 | 312 | fernando | |
699 | 1074 | vcaballero | frame.setNum(Integer.parseInt(nums.get(frame.getClass()).toString()));
|
700 | getFFrames().add(frame); |
||
701 | frame.setSelected(true);
|
||
702 | } |
||
703 | 312 | fernando | |
704 | 1074 | vcaballero | /**
|
705 | * Abre el di?logo de propiedades del folio, pasando como par?metro el
|
||
706 | * PrinterJob.
|
||
707 | *
|
||
708 | * @param job
|
||
709 | */
|
||
710 | public void showPagePropertiesWindow(PrinterJob job) { |
||
711 | PageFormat pf1; //=new PageFormat(); |
||
712 | 312 | fernando | |
713 | 1074 | vcaballero | pf1 = m_attributes.getPageFormat(); |
714 | pf1 = job.pageDialog(pf1); |
||
715 | m_attributes.setPageFormat(pf1); |
||
716 | refresh(); |
||
717 | } |
||
718 | 312 | fernando | |
719 | 1074 | vcaballero | /**
|
720 | * Refresca el Layout.
|
||
721 | */
|
||
722 | public void refresh() { |
||
723 | rect = m_attributes.obtainRect(false, rect, getWidth(), getHeight());
|
||
724 | status = DESACTUALIZADO; |
||
725 | repaint(); |
||
726 | } |
||
727 | 312 | fernando | |
728 | 1074 | vcaballero | /**
|
729 | * Obtiene el rect?ngulo que representa el folio con las caracter?sticas
|
||
730 | * que contiene attributes y diferenciando si es para visualizar en
|
||
731 | * pantalla o para imprimir.
|
||
732 | *
|
||
733 | * @param isPrint si es para imprimir.
|
||
734 | */
|
||
735 | public void obtainRect(boolean isPrint) { |
||
736 | m_attributes.obtainRect(isPrint, rect, getWidth(), getHeight()); |
||
737 | } |
||
738 | 312 | fernando | |
739 | 1074 | vcaballero | /**
|
740 | * Muestra el di?logo de configuraci?n del Layout.
|
||
741 | */
|
||
742 | public void showFConfig() { |
||
743 | FConfigLayoutDialog m_configLayout = new FConfigLayoutDialog(this); |
||
744 | PluginServices.getMDIManager().addView(m_configLayout); |
||
745 | } |
||
746 | 312 | fernando | |
747 | 1074 | vcaballero | /**
|
748 | * Mestra el di?logo de propiedades del Layout.
|
||
749 | */
|
||
750 | public void showFProperties() { |
||
751 | if (map == null) { |
||
752 | map = new ProjectMap();
|
||
753 | map.setModel(this);
|
||
754 | map.setName(getName()); |
||
755 | } |
||
756 | 312 | fernando | |
757 | 1074 | vcaballero | m_propertiesLayout = new MapProperties(map);
|
758 | PluginServices.getMDIManager().addView(m_propertiesLayout); |
||
759 | } |
||
760 | 312 | fernando | |
761 | 1074 | vcaballero | /**
|
762 | * Muestra el di?logo de imprimir pasandole el printerJob como par?metro.
|
||
763 | *
|
||
764 | * @param job
|
||
765 | */
|
||
766 | public void showPrintDialog(PrinterJob job) { |
||
767 | if (job != null) { |
||
768 | job.printDialog(); |
||
769 | 312 | fernando | |
770 | 1074 | vcaballero | try {
|
771 | job.setPrintable((Printable) PluginServices.getExtension(
|
||
772 | com.iver.cit.gvsig.Print.class)); |
||
773 | job.print(); |
||
774 | } catch (PrinterException e) { |
||
775 | e.printStackTrace(); |
||
776 | } |
||
777 | } else {
|
||
778 | boolean print = false; |
||
779 | 312 | fernando | |
780 | 1074 | vcaballero | //Actualizar attributes
|
781 | att = m_attributes.toPrintAttributes(); |
||
782 | 312 | fernando | |
783 | 1074 | vcaballero | //------------------ The Printing things --------------------- //
|
784 | DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; |
||
785 | 312 | fernando | |
786 | 1074 | vcaballero | // returns the set of printers that support printing a specific document type (such as GIF)
|
787 | // with a specific set of attributes (such as two sided).
|
||
788 | // PrintRequestAttributeSet pras = new HashPrintRequestAttributeSet();
|
||
789 | // interestingly, the printer dialog's default behavior has changed with the new API: by default the dialog is not shown.
|
||
790 | // So we must use the ServiceUI class to create a print dialog
|
||
791 | // returns the default print service.
|
||
792 | if (m_cachePrintServices == null) { |
||
793 | m_cachePrintServices = PrintServiceLookup.lookupPrintServices(flavor,
|
||
794 | null);
|
||
795 | } |
||
796 | 312 | fernando | |
797 | 1074 | vcaballero | PrintService defaultService = null; |
798 | 312 | fernando | |
799 | 1074 | vcaballero | if (m_cachePrintService == null) { |
800 | defaultService = PrintServiceLookup.lookupDefaultPrintService();
|
||
801 | } |
||
802 | 312 | fernando | |
803 | 1074 | vcaballero | if (m_cachePrintService == null) { |
804 | m_cachePrintService = ServiceUI.printDialog(null, 200, 200, |
||
805 | m_cachePrintServices, defaultService, flavor, att); |
||
806 | 312 | fernando | |
807 | 1074 | vcaballero | // m_cachePrintRequestAtributeSet = new HashPrintRequestAttributeSet();
|
808 | // m_cachePrintRequestAtributeSet.addAll(pras);
|
||
809 | } else {
|
||
810 | m_cachePrintService = ServiceUI.printDialog(null, 200, 200, |
||
811 | m_cachePrintServices, m_cachePrintService, flavor, att); |
||
812 | } |
||
813 | 312 | fernando | |
814 | 1074 | vcaballero | if (m_cachePrintService != null) { |
815 | DocPrintJob jobNuevo = m_cachePrintService.createPrintJob();
|
||
816 | PrintJobListener pjlistener = new PrintJobAdapter() { |
||
817 | public void printDataTransferCompleted(PrintJobEvent e) { |
||
818 | System.out.println("Fin de impresi?n"); |
||
819 | } |
||
820 | }; |
||
821 | 312 | fernando | |
822 | 1074 | vcaballero | jobNuevo.addPrintJobListener(pjlistener); |
823 | 312 | fernando | |
824 | 1074 | vcaballero | // DocAttributeSet das = new HashDocAttributeSet();
|
825 | doc = new SimpleDoc((Printable) PluginServices.getExtension( |
||
826 | com.iver.cit.gvsig.Print.class), flavor, null);
|
||
827 | 312 | fernando | |
828 | 1074 | vcaballero | try {
|
829 | jobNuevo.print(doc, att); |
||
830 | 312 | fernando | |
831 | 1074 | vcaballero | // m_attributes.
|
832 | } catch (PrintException pe) { |
||
833 | pe.printStackTrace(); |
||
834 | 312 | fernando | } |
835 | 1074 | vcaballero | } |
836 | } |
||
837 | 312 | fernando | |
838 | 1074 | vcaballero | /* try {
|
839 | print = job.printDialog(att);
|
||
840 | } catch (Exception e) {
|
||
841 | logger.error("Abriendo el Di?logo de imprimir"); //System.out.println("Excepci?n "+e);
|
||
842 | }
|
||
843 | if (print) {
|
||
844 | job.setPrintable((Printable) App.instance.getPc().getExtension(com.iver.cit.gvsig.Print.class));
|
||
845 | try {
|
||
846 | job.print(att);
|
||
847 | } catch (Exception ex) {
|
||
848 | ex.printStackTrace();
|
||
849 | }
|
||
850 | } */
|
||
851 | fullRect(); |
||
852 | } |
||
853 | 312 | fernando | |
854 | 1074 | vcaballero | /**
|
855 | * Sustituye el puntero del rat?n por la imagen que se le pasa como
|
||
856 | * par?metro.
|
||
857 | *
|
||
858 | * @param image
|
||
859 | */
|
||
860 | public void setMapCursor(Image image) { |
||
861 | Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(image, |
||
862 | new Point(16, 16), ""); |
||
863 | setCursor(cur); |
||
864 | } |
||
865 | 312 | fernando | |
866 | 1074 | vcaballero | /**
|
867 | * Cambia el puntero del raton al cusor que se le introduce como par?metro.
|
||
868 | *
|
||
869 | * @param cursor cursor a mostrar en el puntero del rat?n.
|
||
870 | */
|
||
871 | public void setMapCursor(Cursor cursor) { |
||
872 | setCursor(cursor); |
||
873 | } |
||
874 | 312 | fernando | |
875 | 1074 | vcaballero | /**
|
876 | * Pone como seleccionada a la herramienta a partir de su n?mero.
|
||
877 | *
|
||
878 | * @param i
|
||
879 | */
|
||
880 | public void setTool(int i) { |
||
881 | tool = i; |
||
882 | 312 | fernando | |
883 | 1074 | vcaballero | if (getTool() == PAN) {
|
884 | setMapCursor(ipan); |
||
885 | } else if (getTool() == ZOOM_MAS) { |
||
886 | setMapCursor(izoomin); |
||
887 | } else if (getTool() == ZOOM_MENOS) { |
||
888 | setMapCursor(izoomout); |
||
889 | } else if (getTool() == RECTANGLEVIEW) { |
||
890 | setMapCursor(icrux); |
||
891 | } else if (getTool() == RECTANGLEPICTURE) { |
||
892 | setMapCursor(icrux); |
||
893 | } else if (getTool() == RECTANGLESCALEBAR) { |
||
894 | setMapCursor(icrux); |
||
895 | } else if (getTool() == RECTANGLELEGEND) { |
||
896 | setMapCursor(icrux); |
||
897 | } else if (getTool() == RECTANGLETEXT) { |
||
898 | setMapCursor(icrux); |
||
899 | } else if (getTool() == SELECT) { |
||
900 | setCursor(Cursor.getDefaultCursor());
|
||
901 | } else if (getTool() == SET_TAG) { |
||
902 | setMapCursor(itag); |
||
903 | } else if (getTool() == POINT) { |
||
904 | setMapCursor(iPoint); |
||
905 | } else if (getTool() == LINE) { |
||
906 | setMapCursor(iRect); |
||
907 | } else if (getTool() == RECTANGLESIMPLE) { |
||
908 | setMapCursor(iRectangle); |
||
909 | } else if (getTool() == POLYLINE) { |
||
910 | setMapCursor(iLine); |
||
911 | } else if (getTool() == POLYGON) { |
||
912 | setMapCursor(iPoligon); |
||
913 | } else if (getTool() == CIRCLE) { |
||
914 | setMapCursor(iCircle); |
||
915 | } |
||
916 | } |
||
917 | 312 | fernando | |
918 | 1074 | vcaballero | /**
|
919 | * Se crean aqu? los dialogos cada vez que se necesitan.
|
||
920 | *
|
||
921 | * @param fframe Rectangle que representa el lugar que ocupara el elemento
|
||
922 | * a?adido.
|
||
923 | *
|
||
924 | * @return true si se debe de a?adir el fframe.
|
||
925 | */
|
||
926 | public boolean openFFrameDialog(IFFrame fframe) { |
||
927 | switch (tool) {
|
||
928 | case RECTANGLEVIEW:
|
||
929 | fframedialog = new FFrameViewDialog(this, (FFrameView) fframe); |
||
930 | 312 | fernando | |
931 | 1074 | vcaballero | break;
|
932 | 312 | fernando | |
933 | 1074 | vcaballero | case RECTANGLEPICTURE:
|
934 | fframedialog = new FFramePictureDialog(this, |
||
935 | (FFramePicture) fframe); |
||
936 | 312 | fernando | |
937 | 1074 | vcaballero | break;
|
938 | 312 | fernando | |
939 | 1074 | vcaballero | case RECTANGLESCALEBAR:
|
940 | fframedialog = new FFrameScaleBarDialog(this, |
||
941 | (FFrameScaleBar) fframe); |
||
942 | 312 | fernando | |
943 | 1074 | vcaballero | break;
|
944 | 312 | fernando | |
945 | 1074 | vcaballero | case RECTANGLELEGEND:
|
946 | fframedialog = new FFrameLegendDialog(this, |
||
947 | (FFrameLegend) fframe); |
||
948 | 312 | fernando | |
949 | 1074 | vcaballero | break;
|
950 | 312 | fernando | |
951 | 1074 | vcaballero | case RECTANGLETEXT:
|
952 | fframedialog = new FFrameTextDialog(this, (FFrameText) fframe); |
||
953 | 312 | fernando | |
954 | 1074 | vcaballero | break;
|
955 | 312 | fernando | |
956 | 1074 | vcaballero | case GRAPHICS:
|
957 | fframedialog = new FFrameGraphicsDialog(this, |
||
958 | (FFrameGraphics) fframe); |
||
959 | 312 | fernando | |
960 | 1074 | vcaballero | break;
|
961 | 396 | vcaballero | |
962 | 1074 | vcaballero | default:
|
963 | return true; |
||
964 | } |
||
965 | 312 | fernando | |
966 | 1074 | vcaballero | if (fframedialog != null) { |
967 | fframedialog.setRectangle(fframe.getBoundingBox(m_MatrizTransf)); |
||
968 | PluginServices.getMDIManager().addView(fframedialog); |
||
969 | } |
||
970 | 312 | fernando | |
971 | 1074 | vcaballero | return fframedialog.getIsAcepted();
|
972 | } |
||
973 | 312 | fernando | |
974 | 1074 | vcaballero | /**
|
975 | * Devuelve el Rectangle2D que representa en pixels al folio.
|
||
976 | *
|
||
977 | * @return Rectangle2D.Double
|
||
978 | */
|
||
979 | public Rectangle2D.Double getRect() { |
||
980 | return rect;
|
||
981 | } |
||
982 | 312 | fernando | |
983 | 1074 | vcaballero | /**
|
984 | * Obtiene un entero que representa la herramienta seleccionada.
|
||
985 | *
|
||
986 | * @return entero.
|
||
987 | */
|
||
988 | public int getTool() { |
||
989 | return tool;
|
||
990 | } |
||
991 | 312 | fernando | |
992 | 1074 | vcaballero | /**
|
993 | * Devuelve la Matriz transformada que se esta plicando al Layout.
|
||
994 | *
|
||
995 | * @return AffineTransform
|
||
996 | */
|
||
997 | public AffineTransform getAT() { |
||
998 | return m_MatrizTransf;
|
||
999 | } |
||
1000 | 312 | fernando | |
1001 | 1074 | vcaballero | /**
|
1002 | * Devuelve los atributos del Mapa.
|
||
1003 | *
|
||
1004 | * @return Attributes.
|
||
1005 | */
|
||
1006 | public Attributes getAtributes() { |
||
1007 | return m_attributes;
|
||
1008 | } |
||
1009 | 312 | fernando | |
1010 | 1074 | vcaballero | /**
|
1011 | * Pone el estado que se quiera.
|
||
1012 | *
|
||
1013 | * @param s estado.
|
||
1014 | */
|
||
1015 | public void setStatus(int s) { |
||
1016 | status = s; |
||
1017 | } |
||
1018 | 312 | fernando | |
1019 | 1074 | vcaballero | /**
|
1020 | * Devuelve el punto que representa la esquina noroeste del mapa.
|
||
1021 | *
|
||
1022 | * @return un punto.
|
||
1023 | */
|
||
1024 | public Point getRectOrigin() { |
||
1025 | return rectOrigin;
|
||
1026 | } |
||
1027 | 312 | fernando | |
1028 | 1074 | vcaballero | /**
|
1029 | * Devuelve el punto del primer click de rat?n.
|
||
1030 | *
|
||
1031 | * @return un punto.
|
||
1032 | */
|
||
1033 | public Point getFirstPoint() { |
||
1034 | return m_FirstPoint;
|
||
1035 | } |
||
1036 | 312 | fernando | |
1037 | 1074 | vcaballero | /**
|
1038 | * Devuelve el punto de click de rat?n anterior.
|
||
1039 | *
|
||
1040 | * @return un punto.
|
||
1041 | */
|
||
1042 | public Point getPointAnt() { |
||
1043 | return m_PointAnt;
|
||
1044 | } |
||
1045 | 312 | fernando | |
1046 | 1074 | vcaballero | /**
|
1047 | * Devuelve el punto donde se solt? el bot?n del rat?n.
|
||
1048 | *
|
||
1049 | * @return un punto.
|
||
1050 | */
|
||
1051 | public Point getLastPoint() { |
||
1052 | return m_LastPoint;
|
||
1053 | } |
||
1054 | 312 | fernando | |
1055 | 1074 | vcaballero | /**
|
1056 | * Rellena el primer punto de click de rat?n.
|
||
1057 | *
|
||
1058 | * @param p punto.
|
||
1059 | */
|
||
1060 | public void setFirstPoint(Point p) { |
||
1061 | m_FirstPoint = p; |
||
1062 | } |
||
1063 | 312 | fernando | |
1064 | 1074 | vcaballero | /**
|
1065 | * Rellena el punto de click de rat?n anterior.
|
||
1066 | *
|
||
1067 | * @param p punto.
|
||
1068 | */
|
||
1069 | public void setPointAnt(Point p) { |
||
1070 | m_PointAnt = p; |
||
1071 | } |
||
1072 | 312 | fernando | |
1073 | 1074 | vcaballero | /**
|
1074 | * Rellena el punto donde se solto el bot?n del rat?n.
|
||
1075 | *
|
||
1076 | * @param p punto.
|
||
1077 | */
|
||
1078 | public void setLastPoint(Point p) { |
||
1079 | m_LastPoint = p; |
||
1080 | } |
||
1081 | 312 | fernando | |
1082 | 1074 | vcaballero | /**
|
1083 | * @see com.iver.mdiApp.ui.MDIManager.View#getViewInfo()
|
||
1084 | */
|
||
1085 | public ViewInfo getViewInfo() {
|
||
1086 | ViewInfo m_viewinfo = new ViewInfo(ViewInfo.ICONIFIABLE |
|
||
1087 | ViewInfo.MAXIMIZABLE | ViewInfo.RESIZABLE); |
||
1088 | 312 | fernando | |
1089 | 1074 | vcaballero | m_viewinfo.setWidth(500);
|
1090 | m_viewinfo.setHeight(400);
|
||
1091 | 312 | fernando | |
1092 | 1074 | vcaballero | m_viewinfo.setTitle(PluginServices.getText(this, "Mapa") + " : " + |
1093 | getName()); |
||
1094 | 312 | fernando | |
1095 | 1074 | vcaballero | return m_viewinfo;
|
1096 | } |
||
1097 | 312 | fernando | |
1098 | 1074 | vcaballero | /**
|
1099 | * Inserta si se muestra o no la regla del Layout.
|
||
1100 | *
|
||
1101 | * @param b True si se muestra la regla.
|
||
1102 | */
|
||
1103 | public void setRuler(boolean b) { |
||
1104 | m_showRuler = b; |
||
1105 | } |
||
1106 | 312 | fernando | |
1107 | 1074 | vcaballero | /**
|
1108 | * Devuelve si se muestra la regla del Layout.
|
||
1109 | *
|
||
1110 | * @return True si se muestra la regla.
|
||
1111 | */
|
||
1112 | public boolean getRuler() { |
||
1113 | return m_showRuler;
|
||
1114 | } |
||
1115 | 312 | fernando | |
1116 | 1074 | vcaballero | /**
|
1117 | * Devuelve si se esta aplicando en los fframes que se a?den al Layout la
|
||
1118 | * cuadr?cula, o no.
|
||
1119 | *
|
||
1120 | * @return true si se esta aplicando la cuadr?cula.
|
||
1121 | */
|
||
1122 | public boolean isCuadricula() { |
||
1123 | return isCuadricula;
|
||
1124 | } |
||
1125 | 312 | fernando | |
1126 | 1074 | vcaballero | /**
|
1127 | * Se actualiza el estado de la cuadr?cula, si se aplica o no.
|
||
1128 | *
|
||
1129 | * @param b true si se aplica la cuadr?cula.
|
||
1130 | */
|
||
1131 | public void setIsCuadricula(boolean b) { |
||
1132 | isCuadricula = b; |
||
1133 | } |
||
1134 | 312 | fernando | |
1135 | 1074 | vcaballero | /**
|
1136 | * Realiza una exteni?n completa de las capas que contiene la vista del
|
||
1137 | * FFrameView.
|
||
1138 | *
|
||
1139 | * @throws DriverException
|
||
1140 | */
|
||
1141 | public void viewFull() throws DriverException { |
||
1142 | for (int i = 0; i < getFFrames().size(); i++) { |
||
1143 | if (getFFrames().get(i) instanceof FFrameView) { |
||
1144 | FFrameView fframe = (FFrameView) getFFrames().get(i); |
||
1145 | 312 | fernando | |
1146 | 1074 | vcaballero | if (fframe.getSelected() != FFrame.NOSELECT) {
|
1147 | fframe.getFMap().getViewPort().setExtent(fframe.getFMap() |
||
1148 | .getFullExtent()); |
||
1149 | } |
||
1150 | } |
||
1151 | } |
||
1152 | 312 | fernando | |
1153 | 1074 | vcaballero | setStatus(DESACTUALIZADO); |
1154 | repaint(); |
||
1155 | } |
||
1156 | 312 | fernando | |
1157 | 1074 | vcaballero | /**
|
1158 | * Devuelve un Objeto XMLEntity con la informaci?n los atributos necesarios
|
||
1159 | * para poder despu?s volver a crear el objeto original.
|
||
1160 | *
|
||
1161 | * @return XMLEntity.
|
||
1162 | 1830 | fernando | * @throws XMLException
|
1163 | 1074 | vcaballero | */
|
1164 | 1830 | fernando | public XMLEntity getXMLEntity() throws XMLException { |
1165 | 1074 | vcaballero | XMLEntity xml = new XMLEntity();
|
1166 | 1550 | vcaballero | xml.putProperty("className", this.getClass().getName()); |
1167 | 1074 | vcaballero | xml.setName("layout");
|
1168 | xml.putProperty("isCuadricula", isCuadricula());
|
||
1169 | xml.putProperty("m_name", this.getName()); |
||
1170 | xml.addChild(getAtributes().getXMLEntity()); |
||
1171 | 312 | fernando | |
1172 | 1074 | vcaballero | for (int i = 0; i < getFFrames().size(); i++) { |
1173 | xml.addChild(((IFFrame) getFFrames().get(i)).getXMLEntity()); |
||
1174 | } |
||
1175 | 312 | fernando | |
1176 | 1074 | vcaballero | return xml;
|
1177 | } |
||
1178 | 312 | fernando | |
1179 | 1074 | vcaballero | /**
|
1180 | * Crea un Objeto de esta clase a partir de la informaci?n del XMLEntity.
|
||
1181 | *
|
||
1182 | * @param xml XMLEntity
|
||
1183 | * @param p Proyecto.
|
||
1184 | *
|
||
1185 | * @return Objeto de esta clase.
|
||
1186 | */
|
||
1187 | public static Layout createLayout(XMLEntity xml, Project p) { |
||
1188 | Layout layout = new Layout();
|
||
1189 | layout.isCuadricula = xml.getBooleanProperty("isCuadricula");
|
||
1190 | layout.setName(xml.getStringProperty("m_name"));
|
||
1191 | layout.m_attributes = Attributes.createAtributes(xml.getChild(0)); |
||
1192 | 312 | fernando | |
1193 | 1074 | vcaballero | for (int i = 1; i < xml.getNumChild(); i++) { |
1194 | 1094 | vcaballero | if (xml.getChild(i).getStringProperty("className").equals("com.iver.cit.gvsig.gui.layout.fframe.FFrameView")) { |
1195 | 1074 | vcaballero | layout.addFFrame(FFrame.createFFrame(xml.getChild(i), layout, p), |
1196 | true);
|
||
1197 | } |
||
1198 | } |
||
1199 | 312 | fernando | |
1200 | 1074 | vcaballero | for (int i = 1; i < xml.getNumChild(); i++) { |
1201 | 1094 | vcaballero | if (!xml.getChild(i).getStringProperty("className").equals("com.iver.cit.gvsig.gui.layout.fframe.FFrameView")) { |
1202 | 1074 | vcaballero | layout.addFFrame(FFrame.createFFrame(xml.getChild(i), layout, p), |
1203 | true);
|
||
1204 | } |
||
1205 | } |
||
1206 | 312 | fernando | |
1207 | 1074 | vcaballero | return layout;
|
1208 | } |
||
1209 | 312 | fernando | |
1210 | 1074 | vcaballero | /**
|
1211 | * @see com.iver.mdiApp.ui.MDIManager.View#viewActivated()
|
||
1212 | */
|
||
1213 | public void viewActivated() { |
||
1214 | PluginServices.getMainFrame().getStatusBar().setMessage("1",
|
||
1215 | getAtributes().getNameUnit()); |
||
1216 | 312 | fernando | |
1217 | 1074 | vcaballero | ///System.out.println("---------- 1 "+ getAtributes().getNameUnit());
|
1218 | } |
||
1219 | 312 | fernando | |
1220 | 1074 | vcaballero | /**
|
1221 | * @see com.iver.cit.gvsig.fmap.IMapExtentListener#extentChanged(java.awt.geom.Rectangle2D)
|
||
1222 | */
|
||
1223 | public void extentChanged(Rectangle2D newExtent) { |
||
1224 | } |
||
1225 | 312 | fernando | |
1226 | 1074 | vcaballero | /**
|
1227 | * @see com.iver.mdiApp.ui.MDIManager.SingletonView#getViewModel()
|
||
1228 | */
|
||
1229 | public Object getViewModel() { |
||
1230 | 1280 | fernando | return map;
|
1231 | 1074 | vcaballero | } |
1232 | 312 | fernando | |
1233 | 1074 | vcaballero | /**
|
1234 | * Devuelve si se dibuja el Grid en el Layout o no.
|
||
1235 | *
|
||
1236 | * @return True si se dibuja el Grid en el Layout.
|
||
1237 | */
|
||
1238 | public boolean getIsDrawGrid() { |
||
1239 | return isDrawCuadricula;
|
||
1240 | } |
||
1241 | 312 | fernando | |
1242 | 1074 | vcaballero | /**
|
1243 | * Inserta si se muestra el Grid del Layout.
|
||
1244 | *
|
||
1245 | * @param b True si se muestra el Grid del Layout.
|
||
1246 | */
|
||
1247 | public void setIsDrawGrid(boolean b) { |
||
1248 | isDrawCuadricula = b; |
||
1249 | } |
||
1250 | 362 | vcaballero | |
1251 | /**
|
||
1252 | * @see com.iver.cit.gvsig.fmap.ExtentListener#extentChanged(com.iver.cit.gvsig.fmap.ExtentEvent)
|
||
1253 | */
|
||
1254 | public void extentChanged(ExtentEvent e) { |
||
1255 | } |
||
1256 | 899 | vcaballero | |
1257 | /**
|
||
1258 | * @see com.iver.andami.ui.mdiManager.ViewListener#viewClosed()
|
||
1259 | */
|
||
1260 | public void viewClosed() { |
||
1261 | ///PluginServices.getMainFrame().getStatusBar().setMessage("1","");
|
||
1262 | } |
||
1263 | 961 | vcaballero | |
1264 | /**
|
||
1265 | * @see com.iver.cit.gvsig.fmap.ViewPortListener#backColorChanged(com.iver.cit.gvsig.fmap.ColorEvent)
|
||
1266 | */
|
||
1267 | public void backColorChanged(ColorEvent e) { |
||
1268 | } |
||
1269 | 1550 | vcaballero | |
1270 | /**
|
||
1271 | * DOCUMENT ME!
|
||
1272 | *
|
||
1273 | * @return DOCUMENT ME!
|
||
1274 | */
|
||
1275 | public IFFrame[] getFFrameSelected() { |
||
1276 | ArrayList selecList = new ArrayList(); |
||
1277 | |||
1278 | 1210 | vcaballero | for (int i = getFFrames().size() - 1; i >= 0; i--) { |
1279 | IFFrame fframe = (IFFrame) getFFrames().get(i); |
||
1280 | |||
1281 | if (fframe.getSelected() != FFrame.NOSELECT) {
|
||
1282 | selecList.add(fframe); |
||
1283 | } |
||
1284 | } |
||
1285 | 1550 | vcaballero | |
1286 | return (IFFrame[]) selecList.toArray(new IFFrame[0]); |
||
1287 | 1210 | vcaballero | } |
1288 | 312 | fernando | } |