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