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