root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / layout / Layout.java @ 9007
History | View | Annotate | Download (49.7 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 java.awt.Color; |
48 |
import java.awt.Component; |
49 |
import java.awt.Cursor; |
50 |
import java.awt.Graphics; |
51 |
import java.awt.Graphics2D; |
52 |
import java.awt.Image; |
53 |
import java.awt.Point; |
54 |
import java.awt.Rectangle; |
55 |
import java.awt.Toolkit; |
56 |
import java.awt.geom.AffineTransform; |
57 |
import java.awt.geom.Rectangle2D; |
58 |
import java.awt.image.BufferedImage; |
59 |
import java.awt.print.PageFormat; |
60 |
import java.awt.print.Printable; |
61 |
import java.awt.print.PrinterException; |
62 |
import java.awt.print.PrinterJob; |
63 |
import java.beans.PropertyChangeEvent; |
64 |
import java.beans.PropertyChangeListener; |
65 |
import java.io.File; |
66 |
import java.util.ArrayList; |
67 |
import java.util.Hashtable; |
68 |
|
69 |
import javax.print.Doc; |
70 |
import javax.print.DocFlavor; |
71 |
import javax.print.DocPrintJob; |
72 |
import javax.print.PrintException; |
73 |
import javax.print.PrintService; |
74 |
import javax.print.PrintServiceLookup; |
75 |
import javax.print.ServiceUI; |
76 |
import javax.print.SimpleDoc; |
77 |
import javax.print.attribute.PrintRequestAttributeSet; |
78 |
import javax.print.event.PrintJobAdapter; |
79 |
import javax.print.event.PrintJobEvent; |
80 |
import javax.print.event.PrintJobListener; |
81 |
import javax.swing.ImageIcon; |
82 |
import javax.swing.JFileChooser; |
83 |
import javax.swing.JOptionPane; |
84 |
import javax.swing.JPanel; |
85 |
import javax.swing.filechooser.FileFilter; |
86 |
|
87 |
import com.iver.andami.PluginServices; |
88 |
import com.iver.andami.messages.NotificationManager; |
89 |
import com.iver.andami.ui.mdiManager.IWindowListener; |
90 |
import com.iver.andami.ui.mdiManager.SingletonWindow; |
91 |
import com.iver.andami.ui.mdiManager.WindowInfo; |
92 |
import com.iver.cit.gvsig.AddLayer; |
93 |
import com.iver.cit.gvsig.fmap.ColorEvent; |
94 |
import com.iver.cit.gvsig.fmap.DriverException; |
95 |
import com.iver.cit.gvsig.fmap.ExtentEvent; |
96 |
import com.iver.cit.gvsig.fmap.ProjectionEvent; |
97 |
import com.iver.cit.gvsig.fmap.ViewPortListener; |
98 |
import com.iver.cit.gvsig.fmap.core.adapter.CircleAdapter; |
99 |
import com.iver.cit.gvsig.fmap.core.adapter.GeometryAdapter; |
100 |
import com.iver.cit.gvsig.fmap.core.adapter.PointAdapter; |
101 |
import com.iver.cit.gvsig.fmap.core.adapter.PolyLineAdapter; |
102 |
import com.iver.cit.gvsig.fmap.core.adapter.PolygonAdapter; |
103 |
import com.iver.cit.gvsig.fmap.core.adapter.RectangleAdapter; |
104 |
import com.iver.cit.gvsig.fmap.edition.commands.CommandListener; |
105 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
106 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrame; |
107 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGraphics; |
108 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameGroup; |
109 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameLegend; |
110 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameNorth; |
111 |
import com.iver.cit.gvsig.gui.layout.fframes.FFramePicture; |
112 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameScaleBar; |
113 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameTable; |
114 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameText; |
115 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView; |
116 |
import com.iver.cit.gvsig.project.Project; |
117 |
import com.iver.cit.gvsig.project.documents.exceptions.OpenException; |
118 |
import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
119 |
import com.iver.cit.gvsig.project.documents.layout.EventsHandler; |
120 |
import com.iver.cit.gvsig.project.documents.layout.FLayoutDraw; |
121 |
import com.iver.cit.gvsig.project.documents.layout.FLayoutFunctions; |
122 |
import com.iver.cit.gvsig.project.documents.layout.FLayoutUtilities; |
123 |
import com.iver.cit.gvsig.project.documents.layout.ProjectMap; |
124 |
import com.iver.cit.gvsig.project.documents.layout.commands.DefaultEditableFeatureSource; |
125 |
import com.iver.cit.gvsig.project.documents.layout.commands.EditableFeatureSource; |
126 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
127 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameEditableVertex; |
128 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameLayoutDependence; |
129 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameUseFMap; |
130 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameViewDependence; |
131 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameBoxDialog; |
132 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameGraphicsDialog; |
133 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameGroupDialog; |
134 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameLegendDialog; |
135 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameNorthDialog; |
136 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFramePictureDialog; |
137 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameScaleBarDialog; |
138 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameTextDialog; |
139 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.FFrameViewDialog; |
140 |
import com.iver.cit.gvsig.project.documents.layout.fframes.gui.dialogs.IFFrameDialog; |
141 |
import com.iver.cit.gvsig.project.documents.layout.gui.MapProperties; |
142 |
import com.iver.cit.gvsig.project.documents.layout.gui.dialogs.FConfigLayoutDialog; |
143 |
import com.iver.utiles.GenericFileFilter; |
144 |
import com.iver.utiles.XMLEntity; |
145 |
|
146 |
/**
|
147 |
* Mapa.
|
148 |
*
|
149 |
* @author Vicente Caballero Navarro
|
150 |
*/
|
151 |
public class Layout extends JPanel implements SingletonWindow, ViewPortListener, |
152 |
IWindowListener, CommandListener { |
153 |
//private static Logger logger = Logger.getLogger(Layout.class.getName());
|
154 |
|
155 |
public static final int ZOOM_MAS = 1; |
156 |
|
157 |
public static final int ZOOM_MENOS = 2; |
158 |
|
159 |
public static final int PAN = 3; |
160 |
|
161 |
public static final int DESACTUALIZADO = 4; |
162 |
|
163 |
public static final int ACTUALIZADO = 5; |
164 |
|
165 |
public static final int SELECT = 6; |
166 |
|
167 |
public static final int RECTANGLE = 10; |
168 |
|
169 |
public static final int RECTANGLEVIEW = 11; |
170 |
|
171 |
public static final int RECTANGLEPICTURE = 12; |
172 |
|
173 |
public static final int RECTANGLESCALEBAR = 13; |
174 |
|
175 |
public static final int RECTANGLELEGEND = 14; |
176 |
|
177 |
public static final int RECTANGLETEXT = 15; |
178 |
|
179 |
public static final int RECTANGLEGROUP = 16; |
180 |
|
181 |
public static final int RECTANGLESYMBOL = 17; |
182 |
|
183 |
public static final int RECTANGLENORTH = 18; |
184 |
|
185 |
public static final int RECTANGLEBOX = 19; |
186 |
|
187 |
public static final int GRAPHICS = 20; |
188 |
|
189 |
public static final int POINT = 21; |
190 |
|
191 |
public static final int LINE = 22; |
192 |
|
193 |
public static final int POLYLINE = 23; |
194 |
|
195 |
public static final int RECTANGLESIMPLE = 24; |
196 |
|
197 |
public static final int CIRCLE = 25; |
198 |
|
199 |
public static final int POLYGON = 26; |
200 |
|
201 |
public static final int VIEW_ZOOMIN = 30; |
202 |
|
203 |
public static final int VIEW_ZOOMOUT = 31; |
204 |
|
205 |
public static final int VIEW_FULL = 32; |
206 |
|
207 |
public static final int VIEW_PAN = 33; |
208 |
|
209 |
public static final int SET_TAG = 34; |
210 |
|
211 |
public static final int EDIT = 40; |
212 |
|
213 |
public static final Image iLayoutpan = new ImageIcon(AddLayer.class |
214 |
.getClassLoader().getResource("images/LayoutHand.gif")).getImage();
|
215 |
|
216 |
public static final Image ipan = new ImageIcon(AddLayer.class |
217 |
.getClassLoader().getResource("images/Hand.gif")).getImage();
|
218 |
|
219 |
public static final Image iLayoutzoomin = new ImageIcon(AddLayer.class |
220 |
.getClassLoader().getResource("images/LayoutZoomInCursor.gif"))
|
221 |
.getImage(); |
222 |
|
223 |
public static final Image izoomin = new ImageIcon(AddLayer.class |
224 |
.getClassLoader().getResource("images/ZoomInCursor.gif"))
|
225 |
.getImage(); |
226 |
|
227 |
public static final Image iLayoutzoomout = new ImageIcon(AddLayer.class |
228 |
.getClassLoader().getResource("images/LayoutZoomOutCursor.gif"))
|
229 |
.getImage(); |
230 |
|
231 |
public static final Image izoomout = new ImageIcon(AddLayer.class |
232 |
.getClassLoader().getResource("images/ZoomOutCursor.gif"))
|
233 |
.getImage(); |
234 |
|
235 |
public static final Image iinfo = new ImageIcon(AddLayer.class |
236 |
.getClassLoader().getResource("images/InfoCursor.gif")).getImage();
|
237 |
|
238 |
public static final Image icrux = new ImageIcon(AddLayer.class |
239 |
.getClassLoader().getResource("images/CruxCursor.png")).getImage();
|
240 |
|
241 |
public static final Image itag = new ImageIcon(AddLayer.class |
242 |
.getClassLoader().getResource("images/tagCursor.gif")).getImage();
|
243 |
|
244 |
public static final Image iPoint = new ImageIcon(AddLayer.class |
245 |
.getClassLoader().getResource("images/PointCursor.png")).getImage();
|
246 |
|
247 |
public static final Image iRect = new ImageIcon(AddLayer.class |
248 |
.getClassLoader().getResource("images/RectCursor.png")).getImage();
|
249 |
|
250 |
public static final Image iLine = new ImageIcon(AddLayer.class |
251 |
.getClassLoader().getResource("images/LineCursor.png")).getImage();
|
252 |
|
253 |
public static final Image iRectangle = new ImageIcon(AddLayer.class |
254 |
.getClassLoader().getResource("images/RectangleCursor.png"))
|
255 |
.getImage(); |
256 |
|
257 |
public static final Image iCircle = new ImageIcon(AddLayer.class |
258 |
.getClassLoader().getResource("images/CircleCursor.png"))
|
259 |
.getImage(); |
260 |
|
261 |
public static final Image iPoligon = new ImageIcon(AddLayer.class |
262 |
.getClassLoader().getResource("images/PoligonCursor.png"))
|
263 |
.getImage(); |
264 |
|
265 |
public static Hashtable nums = new Hashtable(); |
266 |
|
267 |
private static Boolean defaultShowGrid = null; |
268 |
|
269 |
private static Boolean defaultAdjustToGrid = null; |
270 |
|
271 |
private static Boolean defaultShowRulers = null; |
272 |
|
273 |
private Point origin = new Point(50, 50); |
274 |
|
275 |
private Point rectOrigin = new Point(origin); |
276 |
|
277 |
private Rectangle2D.Double rect = new Rectangle2D.Double(rectOrigin.x, |
278 |
rectOrigin.y, 400, 300); |
279 |
|
280 |
private Point m_FirstPoint = new Point(0, 0); |
281 |
|
282 |
private Point m_PointAnt = new Point(0, 0); |
283 |
|
284 |
private Point m_LastPoint = new Point(0, 0); |
285 |
|
286 |
private EventsHandler events;
|
287 |
|
288 |
private int tool = ZOOM_MAS; |
289 |
|
290 |
private int status = DESACTUALIZADO; |
291 |
|
292 |
private BufferedImage img = null; |
293 |
|
294 |
private BufferedImage imgRuler = null; |
295 |
|
296 |
private AffineTransform m_MatrizTransf; |
297 |
|
298 |
private Rectangle2D rectVisible; |
299 |
|
300 |
private IFFrameDialog fframedialog = null; |
301 |
|
302 |
private IFFrame[] fframes; |
303 |
|
304 |
private MapProperties m_propertiesLayout = null; |
305 |
|
306 |
private Attributes m_attributes = null; |
307 |
|
308 |
private PrintService[] m_cachePrintServices = null; |
309 |
|
310 |
private PrintService m_cachePrintService = null; |
311 |
|
312 |
private boolean m_bCancelDrawing = false; |
313 |
|
314 |
private Boolean adjustToGrid = null; |
315 |
|
316 |
private boolean initial = true; |
317 |
|
318 |
private ProjectMap map = null; |
319 |
|
320 |
private Rectangle reSel = null; |
321 |
|
322 |
private boolean isReSel = true; |
323 |
|
324 |
private Boolean m_showRuler; |
325 |
|
326 |
private FLayoutDraw layoutDraw = null; |
327 |
|
328 |
private Boolean isGridVisible = null; |
329 |
|
330 |
private Doc doc = null; |
331 |
|
332 |
private PrintRequestAttributeSet att = null; |
333 |
|
334 |
private GeometryAdapter geometryAdapter = new PolyLineAdapter(); |
335 |
|
336 |
private DefaultEditableFeatureSource efs;
|
337 |
|
338 |
private boolean isEditable = true; |
339 |
|
340 |
private WindowInfo m_viewInfo = null; |
341 |
|
342 |
private int numBefore = 0; |
343 |
|
344 |
private int numBehind = 0; |
345 |
|
346 |
/**
|
347 |
* Lo usamos cuando estamos haciendo una ficha y asignando tags Se pone en
|
348 |
* modo debug cuando hacemos un VIEW_TAGS
|
349 |
*/
|
350 |
private boolean bModeDebug = false; |
351 |
|
352 |
private boolean editGroup; |
353 |
|
354 |
/**
|
355 |
* Creates a new Layout object.
|
356 |
*/
|
357 |
public Layout() {
|
358 |
efs = new DefaultEditableFeatureSource();
|
359 |
updateFFrames(); |
360 |
this.setLayout(null); |
361 |
events = new EventsHandler(this); |
362 |
layoutDraw = new FLayoutDraw(this); |
363 |
addComponentListener(events); |
364 |
addMouseMotionListener(events); |
365 |
addMouseListener(events); |
366 |
m_MatrizTransf = new AffineTransform(); |
367 |
m_MatrizTransf.setToIdentity(); |
368 |
this.initComponents();
|
369 |
} |
370 |
|
371 |
/**
|
372 |
* Rellena el ProjectMap del Layout.
|
373 |
*
|
374 |
* @param m
|
375 |
* ProjectMap.
|
376 |
*/
|
377 |
public void setProjectMap(ProjectMap m) { |
378 |
map = m; |
379 |
this.setName(m.getName());
|
380 |
map.addPropertyChangeListener(new PropertyChangeListener() { |
381 |
public void propertyChange(PropertyChangeEvent evt) { |
382 |
if (evt.getPropertyName().equals("name")) { |
383 |
PluginServices.getMDIManager().getWindowInfo(Layout.this) |
384 |
.setTitle( |
385 |
PluginServices.getText(this, "Mapa") |
386 |
+ " : "
|
387 |
+ (String) evt.getNewValue());
|
388 |
} |
389 |
} |
390 |
}); |
391 |
} |
392 |
|
393 |
/**
|
394 |
* Devuelve el rect?ngulo de selecci?n por rect?ngulo.
|
395 |
*
|
396 |
* @return Rect?ngulo de selecci?n.
|
397 |
*/
|
398 |
public Rectangle getReSel() { |
399 |
return reSel;
|
400 |
} |
401 |
|
402 |
/**
|
403 |
* Devuelve true si se debe dibujar el rect?ngulo de selecci?n y realizar la
|
404 |
* sellecci?n.
|
405 |
*
|
406 |
* @return true si se realiza la selecci?n por rect?ngulo.
|
407 |
*/
|
408 |
public boolean isReSel() { |
409 |
return isReSel;
|
410 |
} |
411 |
|
412 |
/**
|
413 |
* Rellena con true si se debe de dibujar y seleccionar por rect?ngulo de
|
414 |
* selecci?n.
|
415 |
*
|
416 |
* @param b
|
417 |
* boolean.
|
418 |
*/
|
419 |
public void setIsReSel(boolean b) { |
420 |
isReSel = b; |
421 |
} |
422 |
|
423 |
/**
|
424 |
* Devuelve true si el dibujado ha sido cancelado.
|
425 |
*
|
426 |
* @return true si el dibujado ha sido cancelado.
|
427 |
*/
|
428 |
public synchronized boolean isDrawingCancelled() { |
429 |
return m_bCancelDrawing;
|
430 |
} |
431 |
|
432 |
/**
|
433 |
* Pone el dibuja a cancelado o no seg?n se quiera.
|
434 |
*
|
435 |
* @param b
|
436 |
* true si se quiere cancelar el dibujado.
|
437 |
*/
|
438 |
public synchronized void setCancelDrawing(boolean b) { |
439 |
m_bCancelDrawing = b; |
440 |
|
441 |
for (int i = 0; i < getFFrames().length; i++) { |
442 |
IFFrame fframe = getFFrame(i); |
443 |
|
444 |
if (fframe instanceof IFFrameUseFMap |
445 |
&& (((IFFrameUseFMap) fframe).getMapContext() != null)) {
|
446 |
// //TODO((FFrameView)
|
447 |
// getFFrames().get(i)).getFMap().setCancelDrawing(b);
|
448 |
} |
449 |
} |
450 |
} |
451 |
|
452 |
/**
|
453 |
* Obtiene el ArrayList con todos los FFrames que se han a?adido al Layout.
|
454 |
*
|
455 |
* @return Array con todos los fframes que contiene el Layout.
|
456 |
*/
|
457 |
public IFFrame[] getFFrames() { |
458 |
return fframes;
|
459 |
} |
460 |
|
461 |
public IFFrame getFFrame(int i) { |
462 |
return fframes[i];
|
463 |
} |
464 |
|
465 |
public void updateFFrames() { |
466 |
ArrayList frames = new ArrayList(); |
467 |
IFFrame[] auxfframes = efs.getFFrames();
|
468 |
for (int j = numBehind; j <= numBefore; j++) { |
469 |
for (int i = 0; i < auxfframes.length; i++) { |
470 |
if (auxfframes[i].getLevel() == j) {
|
471 |
frames.add(auxfframes[i]); |
472 |
continue;
|
473 |
} |
474 |
} |
475 |
} |
476 |
fframes = (IFFrame[]) frames.toArray(new IFFrame[0]); |
477 |
} |
478 |
|
479 |
/**
|
480 |
* Obtiene el rect que se ajusta al tama?o de la ventana, para ver el folio
|
481 |
* entero.
|
482 |
*/
|
483 |
public void fullRect() { |
484 |
rect.setRect(origin.x, origin.y, getWidth() - (origin.x * 2),
|
485 |
getHeight() - (origin.x * 2));
|
486 |
|
487 |
if (m_attributes.isLandSpace()) {
|
488 |
rect = m_attributes.getRectangleLandscape(rect, getWidth(), |
489 |
getHeight()); |
490 |
} else {
|
491 |
rect = m_attributes.getRectanglePortrait(rect, getWidth(), |
492 |
getHeight()); |
493 |
} |
494 |
refresh(); |
495 |
} |
496 |
|
497 |
/**
|
498 |
* M?todo para imprimir el Layout sin modificar la matriz de transformaci?n.
|
499 |
*
|
500 |
* @param g2
|
501 |
*/
|
502 |
public void drawLayoutPrint(Graphics2D g2) { |
503 |
setCancelDrawing(false);
|
504 |
|
505 |
setCursor(Cursor.getDefaultCursor());
|
506 |
|
507 |
double scale = 0; |
508 |
scale = rect.height / m_attributes.m_sizePaper.getAlto() * 1;
|
509 |
AffineTransform escalado = new AffineTransform(); |
510 |
AffineTransform translacion = new AffineTransform(); |
511 |
translacion.setToTranslation(rect.getMinX(), rect.getMinY()); |
512 |
escalado.setToScale(scale, scale); |
513 |
m_MatrizTransf.setToIdentity(); |
514 |
m_MatrizTransf.concatenate(translacion); |
515 |
m_MatrizTransf.concatenate(escalado); |
516 |
m_attributes.setDistanceUnitX(rect); |
517 |
m_attributes.setDistanceUnitY(rect); |
518 |
IFFrame[] fframes=getFFrames();
|
519 |
for (int i = 0; i < fframes.length; i++) { |
520 |
try {
|
521 |
fframes[i].print(g2, getAT()); |
522 |
} catch (DriverException e) {
|
523 |
NotificationManager.addError(e.getMessage(), e); |
524 |
} |
525 |
} |
526 |
|
527 |
// TODO Esto es para ver el rect?ngulo que representa el folio en la
|
528 |
// impresi?n.
|
529 |
// g2.drawRect(0, 0, (int) rect.getWidth(), (int) rect.getHeight());
|
530 |
// setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
531 |
} |
532 |
|
533 |
/**
|
534 |
* Clip sobre el rect?ngulo visible.
|
535 |
*
|
536 |
* @param g2d
|
537 |
* Graphics sobre el que hacer el clip.
|
538 |
*/
|
539 |
private void clipVisibleRect(Graphics2D g2d) { |
540 |
rectVisible = this.getVisibleRect();
|
541 |
g2d.clipRect((int) rectVisible.getMinX(), (int) rectVisible.getMinY(), |
542 |
(int) rectVisible.getWidth(), (int) rectVisible.getHeight()); |
543 |
} |
544 |
|
545 |
/**
|
546 |
* Inicializa los componentes.
|
547 |
*/
|
548 |
private void initComponents() { |
549 |
m_attributes = new Attributes(); |
550 |
m_attributes.setDistanceUnitX(rect); |
551 |
m_attributes.setDistanceUnitY(rect); |
552 |
//actionDelFFrame();
|
553 |
setDoubleBuffered(true);
|
554 |
} |
555 |
|
556 |
/**
|
557 |
* paintComponent del Layout.
|
558 |
*
|
559 |
* @param g
|
560 |
* Graphics del Layout.
|
561 |
*/
|
562 |
protected void paintComponent(Graphics g) { |
563 |
super.paintComponent(g);
|
564 |
|
565 |
clipVisibleRect((Graphics2D) g);
|
566 |
|
567 |
Rectangle rClip = g.getClipBounds();
|
568 |
|
569 |
if (rClip == null) { |
570 |
System.err.println("clip = null"); |
571 |
} |
572 |
|
573 |
switch (status) {
|
574 |
case ZOOM_MAS:
|
575 |
//logger.debug("zoom mas");
|
576 |
layoutDraw.drawRectangle((Graphics2D) g);
|
577 |
|
578 |
g.drawImage(img, 0, 0, this); |
579 |
|
580 |
g.setClip(rClip); |
581 |
g.drawImage(imgRuler, 0, 0, this); |
582 |
g.setColor(Color.black);
|
583 |
g.setXORMode(Color.white);
|
584 |
|
585 |
Rectangle r = new Rectangle(); |
586 |
|
587 |
r.setFrameFromDiagonal(m_FirstPoint, m_LastPoint); |
588 |
g.drawRect(r.x, r.y, r.width, r.height); |
589 |
|
590 |
break;
|
591 |
|
592 |
case RECTANGLE:
|
593 |
//logger.debug("rectangle");
|
594 |
layoutDraw.drawRectangle((Graphics2D) g);
|
595 |
|
596 |
g.drawImage(img, 0, 0, this); |
597 |
|
598 |
g.setClip(rClip); |
599 |
g.drawImage(imgRuler, 0, 0, this); |
600 |
g.setColor(Color.black);
|
601 |
g.setXORMode(Color.white);
|
602 |
|
603 |
Rectangle re = new Rectangle(); |
604 |
re.setFrameFromDiagonal(m_FirstPoint, m_LastPoint); |
605 |
|
606 |
if (isAdjustingToGrid()) {
|
607 |
FLayoutUtilities.setRectGrid(re, m_attributes |
608 |
.getUnitInPixelsX(), m_attributes.getUnitInPixelsY(), |
609 |
m_MatrizTransf); |
610 |
} |
611 |
|
612 |
g.drawRect(re.x, re.y, re.width, re.height); |
613 |
|
614 |
break;
|
615 |
|
616 |
case PAN:
|
617 |
//logger.debug("pan");
|
618 |
|
619 |
rect.x = rectOrigin.x + (m_LastPoint.x - m_PointAnt.x); |
620 |
rect.y = rectOrigin.y + (m_LastPoint.y - m_PointAnt.y); |
621 |
|
622 |
layoutDraw.drawRectangle((Graphics2D) g);
|
623 |
|
624 |
if (img != null) { |
625 |
g.drawImage(img, (getLastPoint().x - getPointAnt().x), |
626 |
(getLastPoint().y - getPointAnt().y), this);
|
627 |
} |
628 |
|
629 |
g.setClip(rClip); |
630 |
layoutDraw.drawGrid((Graphics2D) g);
|
631 |
layoutDraw.drawRuler((Graphics2D) g, Color.black); |
632 |
break;
|
633 |
|
634 |
case VIEW_PAN:
|
635 |
|
636 |
//logger.debug("View pan");
|
637 |
layoutDraw.drawRectangle((Graphics2D) g);
|
638 |
|
639 |
for (int i = 0; i < getFFrames().length; i++) { |
640 |
if (getFFrame(i) instanceof IFFrameUseFMap) { |
641 |
IFFrameUseFMap fframe = (IFFrameUseFMap) getFFrame(i); |
642 |
|
643 |
if (((IFFrame) fframe).getSelected() != IFFrame.NOSELECT) {
|
644 |
Rectangle2D.Double rec = ((IFFrame) fframe)
|
645 |
.getBoundingBox(getAT()); |
646 |
|
647 |
if (img != null) { |
648 |
rec = (Rectangle2D.Double) rec
|
649 |
.createIntersection(getVisibleRect()); |
650 |
} |
651 |
|
652 |
if (fframe.getBufferedImage() != null) { |
653 |
layoutDraw |
654 |
.drawHandlers((Graphics2D) g, Color.black); |
655 |
g.clipRect((int) rec.x, (int) rec.y, |
656 |
(int) rec.width, (int) rec.height); |
657 |
|
658 |
layoutDraw.drawRectangle((Graphics2D) g);
|
659 |
layoutDraw.drawRuler((Graphics2D) g, Color.black); |
660 |
Rectangle2D.Double r1 = ((IFFrame) fframe)
|
661 |
.getBoundingBox(getAT()); |
662 |
g.drawImage(fframe.getBufferedImage(), (int) r1
|
663 |
.getX() |
664 |
+ m_LastPoint.x - m_PointAnt.x, (int) r1
|
665 |
.getY() |
666 |
+ m_LastPoint.y - m_PointAnt.y, this);
|
667 |
|
668 |
fframe.refresh(); |
669 |
} |
670 |
} |
671 |
} |
672 |
} |
673 |
|
674 |
g.setClip(rClip); |
675 |
g.drawImage(imgRuler, 0, 0, this); |
676 |
|
677 |
break;
|
678 |
|
679 |
case SELECT:
|
680 |
//logger.debug("select");
|
681 |
layoutDraw.drawRectangle((Graphics2D) g);
|
682 |
|
683 |
g.drawImage(img, 0, 0, this); |
684 |
|
685 |
if (isReSel) {
|
686 |
reSel = new Rectangle(); |
687 |
reSel.setFrameFromDiagonal(m_FirstPoint, m_LastPoint); |
688 |
g.drawRect(reSel.x, reSel.y, reSel.width, reSel.height); |
689 |
} |
690 |
IFFrame[] frames = getFFrameSelected();
|
691 |
for (int i = 0; i < frames.length; i++) { |
692 |
g.setColor(Color.black);
|
693 |
frames[i].drawHandlers((Graphics2D) g);
|
694 |
int difx = (m_LastPoint.x - m_FirstPoint.x);
|
695 |
int dify = (m_LastPoint.y - m_FirstPoint.y);
|
696 |
if ((Math.abs(difx) > 3) || (Math.abs(dify) > 3)) { |
697 |
Rectangle2D rectangle = frames[i].getMovieRect(difx, dify);
|
698 |
if (rectangle == null) |
699 |
return;
|
700 |
((Graphics2D) g).rotate(Math.toRadians(frames[i] |
701 |
.getRotation()), rectangle.getX() |
702 |
+ (rectangle.getWidth() / 2), rectangle.getY()
|
703 |
+ (rectangle.getHeight() / 2));
|
704 |
|
705 |
if (rectangle != null) { |
706 |
if (isAdjustingToGrid()) {
|
707 |
FLayoutUtilities.setRectGrid(rectangle, |
708 |
m_attributes.getUnitInPixelsX(), |
709 |
m_attributes.getUnitInPixelsY(), |
710 |
m_MatrizTransf); |
711 |
} |
712 |
|
713 |
g.drawRect((int) rectangle.getMinX(), (int) rectangle |
714 |
.getMinY(), (int) rectangle.getWidth(),
|
715 |
(int) rectangle.getHeight());
|
716 |
} |
717 |
|
718 |
((Graphics2D) g).rotate(Math.toRadians(-frames[i] |
719 |
.getRotation()), rectangle.getX() |
720 |
+ (rectangle.getWidth() / 2), rectangle.getY()
|
721 |
+ (rectangle.getHeight() / 2));
|
722 |
|
723 |
} |
724 |
} |
725 |
|
726 |
g.setClip(rClip); |
727 |
g.drawImage(imgRuler, 0, 0, this); |
728 |
|
729 |
break;
|
730 |
case GRAPHICS:
|
731 |
//logger.debug("graphics");
|
732 |
layoutDraw.drawRectangle((Graphics2D) g);
|
733 |
g.drawImage(img, 0, 0, this); |
734 |
g.setClip(rClip); |
735 |
layoutDraw.drawHandlers((Graphics2D) g, Color.black); |
736 |
|
737 |
if (getTool() == EDIT) {
|
738 |
IFFrame[] fframeSelect = getFFrameSelected();
|
739 |
for (int i = 0; i < fframeSelect.length; i++) { |
740 |
if (fframeSelect[i] instanceof IFFrameEditableVertex) { |
741 |
((IFFrameEditableVertex) fframeSelect[i]).paint( |
742 |
(Graphics2D) g, getAT());
|
743 |
} |
744 |
} |
745 |
} else {
|
746 |
geometryAdapter.paint((Graphics2D) g, getAT(), true); |
747 |
} |
748 |
g.drawImage(imgRuler, 0, 0, this); |
749 |
break;
|
750 |
|
751 |
case DESACTUALIZADO:
|
752 |
//logger.debug("desactualizado");
|
753 |
img = new BufferedImage(getWidth(), getHeight(), |
754 |
BufferedImage.TYPE_INT_ARGB);
|
755 |
imgRuler = new BufferedImage(getWidth(), getHeight(), |
756 |
BufferedImage.TYPE_INT_ARGB);
|
757 |
Graphics gimag = img.getGraphics();
|
758 |
Graphics gimgRuler = imgRuler.getGraphics();
|
759 |
|
760 |
clipVisibleRect((Graphics2D) gimag);
|
761 |
|
762 |
if (initial) {
|
763 |
fullRect(); |
764 |
initial = false;
|
765 |
} |
766 |
|
767 |
try {
|
768 |
layoutDraw.drawLayout((Graphics2D) gimag, img);
|
769 |
} catch (DriverException e) {
|
770 |
e.printStackTrace(); |
771 |
} |
772 |
|
773 |
g.setClip(rClip); |
774 |
layoutDraw.drawRectangle((Graphics2D) g);
|
775 |
|
776 |
g.drawImage(img, 0, 0, this); |
777 |
g.setClip(rClip); |
778 |
|
779 |
layoutDraw.drawHandlers((Graphics2D) g, Color.black); |
780 |
layoutDraw.drawGrid((Graphics2D) gimgRuler);
|
781 |
layoutDraw.drawRuler((Graphics2D) gimgRuler, Color.black); |
782 |
g.drawImage(imgRuler, 0, 0, this); |
783 |
|
784 |
break;
|
785 |
|
786 |
case ACTUALIZADO:
|
787 |
layoutDraw.drawRectangle((Graphics2D) g);
|
788 |
|
789 |
g.drawImage(img, 0, 0, this); |
790 |
|
791 |
g.setClip(rClip); |
792 |
layoutDraw.drawHandlers((Graphics2D) g, Color.black); |
793 |
g.drawImage(imgRuler, 0, 0, this); |
794 |
} |
795 |
} |
796 |
|
797 |
/**
|
798 |
* A?ade un fframe al Arraylist m_fframes.
|
799 |
*
|
800 |
* @param frame
|
801 |
* fframe a a?adir.
|
802 |
* @param clearSelection
|
803 |
* para que se quede seleccionado ?nicamente el que a?adimos y
|
804 |
* false si lo que se pretende es que no se deseleccionen lo que
|
805 |
* ya est?n seleccionados.
|
806 |
* @param select
|
807 |
* Booleano que indica si se tiene que quedar seleccionado el
|
808 |
* FFrame que se a?ade o no.
|
809 |
*/
|
810 |
public void addFFrame(IFFrame frame, boolean clearSelection, boolean select) { |
811 |
IFFrame[] fframes = getFFrames();
|
812 |
if (clearSelection) {
|
813 |
for (int i = fframes.length - 1; i >= 0; i--) { |
814 |
IFFrame fframe1 = fframes[i]; |
815 |
fframe1.setSelected(false);
|
816 |
} |
817 |
} |
818 |
|
819 |
if (nums.containsKey(frame.getClass())) {
|
820 |
nums.put(frame.getClass(), new Integer(Integer.parseInt(nums.get( |
821 |
frame.getClass()).toString()) + 1));
|
822 |
} else {
|
823 |
nums.put(frame.getClass(), new Integer(0)); |
824 |
} |
825 |
|
826 |
frame.setNum(Integer.parseInt(nums.get(frame.getClass()).toString()));
|
827 |
efs.addFFrame(frame); |
828 |
frame.setSelected(select); |
829 |
frame.setLevel(getNumBefore()); |
830 |
updateFFrames(); |
831 |
} |
832 |
|
833 |
/**
|
834 |
* Abre el di?logo de propiedades del folio, pasando como par?metro el
|
835 |
* PrinterJob.
|
836 |
*
|
837 |
* @param job
|
838 |
*/
|
839 |
public void showPagePropertiesWindow(PrinterJob job) { |
840 |
PageFormat pf1;
|
841 |
|
842 |
pf1 = m_attributes.getPageFormat(); |
843 |
pf1 = job.pageDialog(pf1); |
844 |
m_attributes.setPageFormat(pf1); |
845 |
refresh(); |
846 |
} |
847 |
|
848 |
/**
|
849 |
* Refresca el Layout.
|
850 |
*/
|
851 |
public void refresh() { |
852 |
setStatus(DESACTUALIZADO); |
853 |
repaint(); |
854 |
} |
855 |
public void fullRefresh() { |
856 |
IFFrame[] fframes = getFFrames();
|
857 |
for (int i = 0; i < fframes.length; i++) { |
858 |
if (fframes[i] instanceof IFFrameUseFMap) { |
859 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
860 |
fframe.refresh(); |
861 |
} |
862 |
} |
863 |
refresh(); |
864 |
} |
865 |
/**
|
866 |
* Obtiene el rect?ngulo que representa el folio con las caracter?sticas que
|
867 |
* contiene attributes y diferenciando si es para visualizar en pantalla o
|
868 |
* para imprimir.
|
869 |
*
|
870 |
* @param isPrint
|
871 |
* si es para imprimir.
|
872 |
*/
|
873 |
public void obtainRect(boolean isPrint) { |
874 |
m_attributes.obtainRect(isPrint, rect, getWidth(), getHeight()); |
875 |
} |
876 |
|
877 |
/**
|
878 |
* Muestra el di?logo de configuraci?n del Layout.
|
879 |
*/
|
880 |
public void showFConfig() { |
881 |
FConfigLayoutDialog m_configLayout = new FConfigLayoutDialog(this); |
882 |
PluginServices.getMDIManager().addWindow(m_configLayout); |
883 |
} |
884 |
|
885 |
/**
|
886 |
* Mestra el di?logo de propiedades del Layout.
|
887 |
*/
|
888 |
public void showFProperties() { |
889 |
if (map == null) { |
890 |
map = new ProjectMap();
|
891 |
map.setModel(this);
|
892 |
map.setName(getName()); |
893 |
} |
894 |
|
895 |
m_propertiesLayout = new MapProperties(map);
|
896 |
PluginServices.getMDIManager().addWindow(m_propertiesLayout); |
897 |
} |
898 |
|
899 |
/**
|
900 |
* Muestra el di?logo de imprimir pasandole el printerJob como par?metro.
|
901 |
*
|
902 |
* @param job
|
903 |
*/
|
904 |
public void showPrintDialog(PrinterJob job) { |
905 |
if (job != null) { |
906 |
job.printDialog(); |
907 |
|
908 |
try {
|
909 |
job.setPrintable((Printable) PluginServices
|
910 |
.getExtension(com.iver.cit.gvsig.Print.class)); |
911 |
job.print(); |
912 |
} catch (PrinterException e) { |
913 |
e.printStackTrace(); |
914 |
} |
915 |
} else {
|
916 |
// Actualizar attributes
|
917 |
att = m_attributes.toPrintAttributes(); |
918 |
|
919 |
// ------------------ The Printing things --------------------- //
|
920 |
DocFlavor flavor = DocFlavor.SERVICE_FORMATTED.PRINTABLE; |
921 |
|
922 |
// returns the set of printers that support printing a specific
|
923 |
// document type (such as GIF)
|
924 |
// with a specific set of attributes (such as two sided).
|
925 |
// PrintRequestAttributeSet pras = new
|
926 |
// HashPrintRequestAttributeSet();
|
927 |
// interestingly, the printer dialog's default behavior has changed
|
928 |
// with the new API: by default the dialog is not shown.
|
929 |
// So we must use the ServiceUI class to create a print dialog
|
930 |
// returns the default print service.
|
931 |
if (m_cachePrintServices == null) { |
932 |
m_cachePrintServices = PrintServiceLookup.lookupPrintServices(
|
933 |
flavor, null);
|
934 |
} |
935 |
|
936 |
PrintService defaultService = null; |
937 |
|
938 |
if (m_cachePrintService == null) { |
939 |
defaultService = PrintServiceLookup.lookupDefaultPrintService();
|
940 |
} |
941 |
|
942 |
if ((defaultService == null) && (m_cachePrintService == null)) { |
943 |
JOptionPane.showMessageDialog((Component) PluginServices |
944 |
.getMainFrame(),PluginServices.getText(this,"ninguna_impresora_configurada")); |
945 |
|
946 |
return;
|
947 |
} |
948 |
|
949 |
if (m_cachePrintService == null) { |
950 |
m_cachePrintService = ServiceUI.printDialog(null, 200, 200, |
951 |
m_cachePrintServices, defaultService, flavor, att); |
952 |
|
953 |
// m_cachePrintRequestAtributeSet = new
|
954 |
// HashPrintRequestAttributeSet();
|
955 |
// m_cachePrintRequestAtributeSet.addAll(pras);
|
956 |
} else {
|
957 |
m_cachePrintService = ServiceUI.printDialog(null, 200, 200, |
958 |
m_cachePrintServices, m_cachePrintService, flavor, att); |
959 |
} |
960 |
|
961 |
if (m_cachePrintService != null) { |
962 |
DocPrintJob jobNuevo = m_cachePrintService.createPrintJob();
|
963 |
PrintJobListener pjlistener = new PrintJobAdapter() { |
964 |
public void printDataTransferCompleted(PrintJobEvent e) { |
965 |
System.out.println("Fin de impresi?n"); |
966 |
fullRect(); |
967 |
} |
968 |
}; |
969 |
|
970 |
jobNuevo.addPrintJobListener(pjlistener); |
971 |
|
972 |
// DocAttributeSet das = new HashDocAttributeSet();
|
973 |
doc = new SimpleDoc(PluginServices |
974 |
.getExtension(com.iver.cit.gvsig.Print.class), flavor, |
975 |
null);
|
976 |
|
977 |
try {
|
978 |
jobNuevo.print(doc, att); |
979 |
|
980 |
// m_attributes.
|
981 |
} catch (PrintException pe) { |
982 |
pe.printStackTrace(); |
983 |
} |
984 |
} |
985 |
} |
986 |
|
987 |
/*
|
988 |
* try { print = job.printDialog(att); } catch (Exception e) {
|
989 |
* logger.error("Abriendo el Di?logo de imprimir");
|
990 |
* //System.out.println("Excepci?n "+e); } if (print) {
|
991 |
* job.setPrintable((Printable)
|
992 |
* App.instance.getPc().getExtension(com.iver.cit.gvsig.Print.class));
|
993 |
* try { job.print(att); } catch (Exception ex) { ex.printStackTrace(); } }
|
994 |
*/
|
995 |
} |
996 |
|
997 |
/**
|
998 |
* Sustituye el puntero del rat?n por la imagen que se le pasa como
|
999 |
* par?metro.
|
1000 |
*
|
1001 |
* @param image
|
1002 |
*/
|
1003 |
public void setMapCursor(Image image) { |
1004 |
Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(image, |
1005 |
new Point(16, 16), ""); |
1006 |
setCursor(cur); |
1007 |
} |
1008 |
|
1009 |
/**
|
1010 |
* Cambia el puntero del raton al cusor que se le introduce como par?metro.
|
1011 |
*
|
1012 |
* @param cursor
|
1013 |
* cursor a mostrar en el puntero del rat?n.
|
1014 |
*/
|
1015 |
public void setMapCursor(Cursor cursor) { |
1016 |
setCursor(cursor); |
1017 |
} |
1018 |
|
1019 |
/**
|
1020 |
* Pone como seleccionada a la herramienta a partir de su n?mero.
|
1021 |
*
|
1022 |
* @param i
|
1023 |
*/
|
1024 |
public void setTool(int i) { |
1025 |
tool = i; |
1026 |
|
1027 |
if (getTool() == PAN) {
|
1028 |
setMapCursor(ipan); |
1029 |
} else if (getTool() == ZOOM_MAS) { |
1030 |
setMapCursor(izoomin); |
1031 |
} else if (getTool() == ZOOM_MENOS) { |
1032 |
setMapCursor(izoomout); |
1033 |
} else if (getTool() == RECTANGLEVIEW) { |
1034 |
setMapCursor(icrux); |
1035 |
} else if (getTool() == RECTANGLEPICTURE) { |
1036 |
setMapCursor(icrux); |
1037 |
} else if (getTool() == RECTANGLESCALEBAR) { |
1038 |
setMapCursor(icrux); |
1039 |
} else if (getTool() == RECTANGLELEGEND) { |
1040 |
setMapCursor(icrux); |
1041 |
} else if (getTool() == RECTANGLETEXT) { |
1042 |
setMapCursor(icrux); |
1043 |
} else if (getTool() == RECTANGLENORTH) { |
1044 |
setMapCursor(icrux); |
1045 |
} else if (getTool() == RECTANGLEBOX) { |
1046 |
setMapCursor(icrux); |
1047 |
} else if (getTool() == SELECT) { |
1048 |
setCursor(Cursor.getDefaultCursor());
|
1049 |
} else if (getTool() == SET_TAG) { |
1050 |
setMapCursor(itag); |
1051 |
} else if (getTool() == POINT) { |
1052 |
setMapCursor(iPoint); |
1053 |
} else if (getTool() == LINE) { |
1054 |
setMapCursor(iRect); |
1055 |
} else if (getTool() == RECTANGLESIMPLE) { |
1056 |
setMapCursor(iRectangle); |
1057 |
} else if (getTool() == POLYLINE) { |
1058 |
setMapCursor(iLine); |
1059 |
} else if (getTool() == POLYGON) { |
1060 |
setMapCursor(iPoligon); |
1061 |
} else if (getTool() == CIRCLE) { |
1062 |
setMapCursor(iCircle); |
1063 |
} |
1064 |
if (getTool() == EDIT) {
|
1065 |
setMapCursor(icrux); |
1066 |
startEdit(); |
1067 |
} else {
|
1068 |
stopEdit(); |
1069 |
} |
1070 |
initGeometryAdapter(); |
1071 |
} |
1072 |
|
1073 |
/**
|
1074 |
* Se crean aqu? los dialogos cada vez que se necesitan.
|
1075 |
*
|
1076 |
* @param fframe
|
1077 |
* Rectangle que representa el lugar que ocupara el elemento
|
1078 |
* a?adido.
|
1079 |
*
|
1080 |
* @return true si se debe de a?adir el fframe.
|
1081 |
*/
|
1082 |
public boolean openFFrameDialog(IFFrame fframe) { |
1083 |
switch (tool) {
|
1084 |
case RECTANGLEVIEW:
|
1085 |
fframedialog = new FFrameViewDialog(this, (FFrameView) fframe); |
1086 |
|
1087 |
break;
|
1088 |
|
1089 |
case RECTANGLEPICTURE:
|
1090 |
fframedialog = new FFramePictureDialog(this, (FFramePicture) fframe); |
1091 |
|
1092 |
break;
|
1093 |
|
1094 |
case RECTANGLESCALEBAR:
|
1095 |
fframedialog = new FFrameScaleBarDialog(this, |
1096 |
(FFrameScaleBar) fframe); |
1097 |
|
1098 |
break;
|
1099 |
|
1100 |
case RECTANGLELEGEND:
|
1101 |
fframedialog = new FFrameLegendDialog(this, (FFrameLegend) fframe); |
1102 |
|
1103 |
break;
|
1104 |
|
1105 |
case RECTANGLETEXT:
|
1106 |
fframedialog = new FFrameTextDialog(this, (FFrameText) fframe); |
1107 |
|
1108 |
break;
|
1109 |
|
1110 |
case GRAPHICS:
|
1111 |
fframedialog = new FFrameGraphicsDialog(this, |
1112 |
(FFrameGraphics) fframe); |
1113 |
|
1114 |
break;
|
1115 |
|
1116 |
case RECTANGLEGROUP:
|
1117 |
fframedialog = new FFrameGroupDialog(this, (FFrameGroup) fframe); |
1118 |
|
1119 |
break;
|
1120 |
case RECTANGLENORTH:
|
1121 |
fframedialog = new FFrameNorthDialog(this, (FFrameNorth) fframe); |
1122 |
|
1123 |
break;
|
1124 |
case RECTANGLEBOX:
|
1125 |
fframedialog = new FFrameBoxDialog(this, (FFrameTable) fframe); |
1126 |
|
1127 |
break;
|
1128 |
default:
|
1129 |
return true; |
1130 |
} |
1131 |
|
1132 |
if (fframedialog != null) { |
1133 |
fframedialog.setRectangle(fframe.getBoundingBox(m_MatrizTransf)); |
1134 |
PluginServices.getMDIManager().addWindow(fframedialog); |
1135 |
} |
1136 |
|
1137 |
return fframedialog.getIsAcepted();
|
1138 |
} |
1139 |
|
1140 |
/**
|
1141 |
* Devuelve el Rectangle2D que representa en pixels al folio.
|
1142 |
*
|
1143 |
* @return Rectangle2D.Double
|
1144 |
*/
|
1145 |
public Rectangle2D.Double getRect() { |
1146 |
return rect;
|
1147 |
} |
1148 |
|
1149 |
public void setRect(Rectangle2D r) { |
1150 |
rect.setRect(r); |
1151 |
} |
1152 |
|
1153 |
/**
|
1154 |
* Obtiene un entero que representa la herramienta seleccionada.
|
1155 |
*
|
1156 |
* @return entero.
|
1157 |
*/
|
1158 |
public int getTool() { |
1159 |
return tool;
|
1160 |
} |
1161 |
|
1162 |
/**
|
1163 |
* Devuelve la Matriz transformada que se esta plicando al Layout.
|
1164 |
*
|
1165 |
* @return AffineTransform
|
1166 |
*/
|
1167 |
public AffineTransform getAT() { |
1168 |
return m_MatrizTransf;
|
1169 |
} |
1170 |
|
1171 |
/**
|
1172 |
* Devuelve los atributos del Mapa.
|
1173 |
*
|
1174 |
* @return Attributes.
|
1175 |
*/
|
1176 |
public Attributes getAtributes() { |
1177 |
return m_attributes;
|
1178 |
} |
1179 |
|
1180 |
/**
|
1181 |
* Pone el estado que se quiera.
|
1182 |
*
|
1183 |
* @param s
|
1184 |
* estado.
|
1185 |
*/
|
1186 |
public void setStatus(int s) { |
1187 |
status = s; |
1188 |
} |
1189 |
|
1190 |
/**
|
1191 |
* Devuelve el punto que representa la esquina noroeste del mapa.
|
1192 |
*
|
1193 |
* @return un punto.
|
1194 |
*/
|
1195 |
public Point getRectOrigin() { |
1196 |
return rectOrigin;
|
1197 |
} |
1198 |
|
1199 |
/**
|
1200 |
* Devuelve el punto del primer click de rat?n.
|
1201 |
*
|
1202 |
* @return un punto.
|
1203 |
*/
|
1204 |
public Point getFirstPoint() { |
1205 |
return m_FirstPoint;
|
1206 |
} |
1207 |
|
1208 |
/**
|
1209 |
* Devuelve el punto de click de rat?n anterior.
|
1210 |
*
|
1211 |
* @return un punto.
|
1212 |
*/
|
1213 |
public Point getPointAnt() { |
1214 |
return m_PointAnt;
|
1215 |
} |
1216 |
|
1217 |
/**
|
1218 |
* Devuelve el punto donde se solt? el bot?n del rat?n.
|
1219 |
*
|
1220 |
* @return un punto.
|
1221 |
*/
|
1222 |
public Point getLastPoint() { |
1223 |
return m_LastPoint;
|
1224 |
} |
1225 |
|
1226 |
/**
|
1227 |
* Rellena el primer punto de click de rat?n.
|
1228 |
*
|
1229 |
* @param p
|
1230 |
* punto.
|
1231 |
*/
|
1232 |
public void setFirstPoint(Point p) { |
1233 |
m_FirstPoint = p; |
1234 |
} |
1235 |
|
1236 |
/**
|
1237 |
* Rellena el punto de click de rat?n anterior.
|
1238 |
*
|
1239 |
* @param p
|
1240 |
* punto.
|
1241 |
*/
|
1242 |
public void setPointAnt(Point p) { |
1243 |
m_PointAnt = p; |
1244 |
} |
1245 |
|
1246 |
/**
|
1247 |
* Rellena el punto donde se solto el bot?n del rat?n.
|
1248 |
*
|
1249 |
* @param p
|
1250 |
* punto.
|
1251 |
*/
|
1252 |
public void setLastPoint(Point p) { |
1253 |
m_LastPoint = p; |
1254 |
} |
1255 |
|
1256 |
/**
|
1257 |
* This method is used to get <strong>an initial</strong> ViewInfo object
|
1258 |
* for this Map. It is not intended to retrieve the ViewInfo object in a
|
1259 |
* later time. <strong>Use PluginServices.getMDIManager().getViewInfo(view)
|
1260 |
* to retrieve the ViewInfo object at any time after the creation of the
|
1261 |
* object.
|
1262 |
*
|
1263 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#getWindowInfo()
|
1264 |
*/
|
1265 |
public WindowInfo getWindowInfo() {
|
1266 |
if (m_viewInfo == null) { |
1267 |
m_viewInfo = new WindowInfo(WindowInfo.ICONIFIABLE | WindowInfo.RESIZABLE
|
1268 |
| WindowInfo.MAXIMIZABLE); |
1269 |
m_viewInfo.setWidth(500);
|
1270 |
m_viewInfo.setHeight(400);
|
1271 |
|
1272 |
m_viewInfo.setTitle(PluginServices.getText(this, "Mapa") + " : " |
1273 |
+ map.getName()); |
1274 |
} |
1275 |
return m_viewInfo;
|
1276 |
} |
1277 |
|
1278 |
/**
|
1279 |
* Inserta si se muestra o no la regla del Layout.
|
1280 |
*
|
1281 |
* @param b
|
1282 |
* True si se muestra la regla.
|
1283 |
*/
|
1284 |
public void setRuler(boolean b) { |
1285 |
m_showRuler = new Boolean(b); |
1286 |
} |
1287 |
|
1288 |
/**
|
1289 |
* Devuelve si se muestra la regla del Layout.
|
1290 |
*
|
1291 |
* @return True si se muestra la regla.
|
1292 |
*/
|
1293 |
public boolean getRuler() { |
1294 |
if (m_showRuler == null) { |
1295 |
m_showRuler = new Boolean(getDefaultShowRulers()); |
1296 |
} |
1297 |
return m_showRuler.booleanValue();
|
1298 |
} |
1299 |
|
1300 |
|
1301 |
|
1302 |
/**
|
1303 |
* Devuelve si se esta aplicando en los fframes que se a?den al Layout la
|
1304 |
* cuadr?cula, o no.
|
1305 |
*
|
1306 |
* @return true si se esta aplicando la cuadr?cula.
|
1307 |
*/
|
1308 |
public boolean isAdjustingToGrid() { |
1309 |
if (adjustToGrid == null) { |
1310 |
adjustToGrid = new Boolean(getDefaultAdjustToGrid()); |
1311 |
} |
1312 |
return adjustToGrid.booleanValue();
|
1313 |
} |
1314 |
|
1315 |
/**
|
1316 |
* Devuelve si se esta aplicando en los fframes que se a?den al Layout la
|
1317 |
* cuadr?cula, o no.
|
1318 |
*
|
1319 |
* @return true si se esta aplicando la cuadr?cula.
|
1320 |
*/
|
1321 |
public boolean isGridVisible() { |
1322 |
if (isGridVisible== null) { |
1323 |
isGridVisible = new Boolean(getDefaultShowGrid()); |
1324 |
} |
1325 |
return isGridVisible.booleanValue();
|
1326 |
} |
1327 |
|
1328 |
/**
|
1329 |
* Se actualiza el estado de la cuadr?cula, si se aplica o no.
|
1330 |
*
|
1331 |
* @param b
|
1332 |
* true si se aplica la cuadr?cula.
|
1333 |
*/
|
1334 |
public void setAdjustToGrid(boolean b) { |
1335 |
adjustToGrid = new Boolean(b); |
1336 |
} |
1337 |
|
1338 |
/**
|
1339 |
* Realiza una exteni?n completa de las capas que contiene la vista del
|
1340 |
* FFrameView.
|
1341 |
*
|
1342 |
* @throws DriverException
|
1343 |
*/
|
1344 |
public void viewFull() throws DriverException { |
1345 |
IFFrame[] fframes = getFFrameSelected();
|
1346 |
for (int i = 0; i < fframes.length; i++) { |
1347 |
if (fframes[i] instanceof IFFrameUseFMap) { |
1348 |
IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
1349 |
|
1350 |
if (fframe.getMapContext() != null) { |
1351 |
fframe.fullExtent(); |
1352 |
} |
1353 |
fframe.refresh(); |
1354 |
} |
1355 |
} |
1356 |
refresh(); |
1357 |
} |
1358 |
|
1359 |
/**
|
1360 |
* Devuelve un Objeto XMLEntity con la informaci?n los atributos necesarios
|
1361 |
* para poder despu?s volver a crear el objeto original.
|
1362 |
*
|
1363 |
* @return XMLEntity.
|
1364 |
*
|
1365 |
* @throws XMLException
|
1366 |
*/
|
1367 |
public XMLEntity getXMLEntity() {
|
1368 |
XMLEntity xml = new XMLEntity();
|
1369 |
xml.putProperty("className", this.getClass().getName()); |
1370 |
xml.setName("layout");
|
1371 |
xml.putProperty("isCuadricula", isAdjustingToGrid());
|
1372 |
xml.putProperty("m_name", this.getName()); |
1373 |
xml.putProperty("isEditable", isEditable);
|
1374 |
xml.putProperty("numBehind", numBehind);
|
1375 |
xml.putProperty("numBefore", numBefore);
|
1376 |
xml.addChild(getAtributes().getXMLEntity()); |
1377 |
IFFrame[] fframes=getFFrames();
|
1378 |
for (int i = 0; i < fframes.length; i++) { |
1379 |
try {
|
1380 |
XMLEntity xmlAux = fframes[i].getXMLEntity(); |
1381 |
xml.addChild(xmlAux); |
1382 |
} catch (SaveException e) {
|
1383 |
e.showError(); |
1384 |
} |
1385 |
} |
1386 |
return xml;
|
1387 |
} |
1388 |
|
1389 |
/**
|
1390 |
* Crea un Objeto de esta clase a partir de la informaci?n del XMLEntity.
|
1391 |
*
|
1392 |
* @param xml
|
1393 |
* XMLEntity
|
1394 |
* @param p
|
1395 |
* Proyecto.
|
1396 |
*
|
1397 |
* @return Objeto de esta clase.
|
1398 |
* @throws OpenException
|
1399 |
*/
|
1400 |
public static Layout createLayout(XMLEntity xml, Project p) |
1401 |
throws OpenException {
|
1402 |
Layout layout = new Layout();
|
1403 |
try {
|
1404 |
layout.setAdjustToGrid(xml.getBooleanProperty("isCuadricula"));
|
1405 |
layout.setName(xml.getStringProperty("m_name"));
|
1406 |
layout.m_attributes = Attributes.createAtributes(xml.getChild(0)); |
1407 |
if (xml.contains("isEditable")) { |
1408 |
layout.setEditable(xml.getBooleanProperty("isEditable"));
|
1409 |
} |
1410 |
if (xml.contains("numBehind")) { |
1411 |
layout.numBehind = xml.getIntProperty("numBehind");
|
1412 |
layout.numBefore = xml.getIntProperty("numBefore");
|
1413 |
} |
1414 |
layout.getEFS().startComplexCommand(); |
1415 |
for (int i = 1; i < xml.getChildrenCount(); i++) { |
1416 |
try {
|
1417 |
layout.addFFrame(FFrame.createFFrame(xml.getChild(i), p, |
1418 |
layout), true, false); |
1419 |
} catch (OpenException e) {
|
1420 |
e.showError(); |
1421 |
} |
1422 |
} |
1423 |
layout.getEFS().endComplexCommand(PluginServices.getText(layout,"Inicializando"));
|
1424 |
IFFrame[] fframes = layout.getAllFFrames();
|
1425 |
for (int i = 0; i < fframes.length; i++) { |
1426 |
if (fframes[i] instanceof IFFrameLayoutDependence) { |
1427 |
((IFFrameLayoutDependence) fframes[i]).setLayout(layout); |
1428 |
} |
1429 |
if (fframes[i] instanceof IFFrameViewDependence) { |
1430 |
((IFFrameViewDependence) fframes[i]) |
1431 |
.initDependence(fframes); |
1432 |
} |
1433 |
} |
1434 |
} catch (Exception e) { |
1435 |
throw new OpenException(e, layout.getClass().getName()); |
1436 |
} |
1437 |
return layout;
|
1438 |
} |
1439 |
|
1440 |
/**
|
1441 |
* Crea un Objeto de esta clase a partir de la informaci?n del XMLEntity.
|
1442 |
*
|
1443 |
* @param xml
|
1444 |
* XMLEntity
|
1445 |
* @param p
|
1446 |
* Proyecto.
|
1447 |
*
|
1448 |
* @return Objeto de esta clase.
|
1449 |
*/
|
1450 |
public static Layout createLayout03(XMLEntity xml, Project p) { |
1451 |
Layout layout = new Layout();
|
1452 |
layout.setAdjustToGrid(xml.getBooleanProperty("isCuadricula"));
|
1453 |
layout.setName(xml.getStringProperty("m_name"));
|
1454 |
layout.m_attributes = Attributes.createAtributes03(xml.getChild(0)); |
1455 |
|
1456 |
for (int i = 1; i < xml.getChildrenCount(); i++) { |
1457 |
if (xml.getChild(i).getStringProperty("className").equals( |
1458 |
"com.iver.cit.gvsig.gui.layout.fframe.FFrameView")) {
|
1459 |
layout.addFFrame(FFrame.createFFrame03(xml.getChild(i), layout, |
1460 |
p), true, false); |
1461 |
} |
1462 |
} |
1463 |
|
1464 |
for (int i = 1; i < xml.getChildrenCount(); i++) { |
1465 |
if (!xml.getChild(i).getStringProperty("className").equals( |
1466 |
"com.iver.cit.gvsig.gui.layout.fframe.FFrameView")) {
|
1467 |
layout.addFFrame(FFrame.createFFrame03(xml.getChild(i), layout, |
1468 |
p), true, false); |
1469 |
} |
1470 |
} |
1471 |
|
1472 |
return layout;
|
1473 |
} |
1474 |
|
1475 |
/**
|
1476 |
* @see com.iver.mdiApp.ui.MDIManager.IWindow#windowActivated()
|
1477 |
*/
|
1478 |
public void windowActivated() { |
1479 |
//fullRect();
|
1480 |
refresh(); |
1481 |
PluginServices.getMainFrame().getStatusBar().setMessage("units",
|
1482 |
PluginServices.getText(this, getAtributes().getNameUnit()));
|
1483 |
} |
1484 |
|
1485 |
/**
|
1486 |
* @see com.iver.mdiApp.ui.MDIManager.SingletonWindow#getWindowModel()
|
1487 |
*/
|
1488 |
public Object getWindowModel() { |
1489 |
return map;
|
1490 |
} |
1491 |
|
1492 |
/**
|
1493 |
* Devuelve si se dibuja el Grid en el Layout o no.
|
1494 |
*
|
1495 |
* @return True si se dibuja el Grid en el Layout.
|
1496 |
*/
|
1497 |
public boolean getGridVisible() { |
1498 |
if (isGridVisible== null) { |
1499 |
isGridVisible = new Boolean(getDefaultShowGrid()); |
1500 |
} |
1501 |
return isGridVisible.booleanValue();
|
1502 |
} |
1503 |
|
1504 |
/**
|
1505 |
* Inserta si se muestra el Grid del Layout.
|
1506 |
*
|
1507 |
* @param b
|
1508 |
* True si se muestra el Grid del Layout.
|
1509 |
*/
|
1510 |
public void setGridVisible(boolean b) { |
1511 |
isGridVisible = new Boolean(b); |
1512 |
} |
1513 |
|
1514 |
/**
|
1515 |
* @see com.iver.cit.gvsig.fmap.ExtentListener#extentChanged(com.iver.cit.gvsig.fmap.ExtentEvent)
|
1516 |
*/
|
1517 |
public void extentChanged(ExtentEvent e) { |
1518 |
} |
1519 |
|
1520 |
/**
|
1521 |
* @see com.iver.andami.ui.mdiManager.IWindowListener#windowClosed()
|
1522 |
*/
|
1523 |
public void windowClosed() { |
1524 |
// /PluginServices.getMainFrame().getStatusBar().setMessage("1","");
|
1525 |
} |
1526 |
|
1527 |
/**
|
1528 |
* @see com.iver.cit.gvsig.fmap.ViewPortListener#backColorChanged(com.iver.cit.gvsig.fmap.ColorEvent)
|
1529 |
*/
|
1530 |
public void backColorChanged(ColorEvent e) { |
1531 |
// refresh();
|
1532 |
} |
1533 |
|
1534 |
/**
|
1535 |
* Devuelve un array con los FFrames seleccionados.
|
1536 |
*
|
1537 |
* @return Array con los FFrames seleccionados.
|
1538 |
*/
|
1539 |
public IFFrame[] getFFrameSelected() { |
1540 |
ArrayList selecList = new ArrayList(); |
1541 |
IFFrame[] fframes=getFFrames();
|
1542 |
for (int i = fframes.length - 1; i >= 0; i--) { |
1543 |
IFFrame fframe = fframes[i]; |
1544 |
|
1545 |
if (fframe.getSelected() != IFFrame.NOSELECT) {
|
1546 |
selecList.add(fframe); |
1547 |
} |
1548 |
} |
1549 |
|
1550 |
return (IFFrame[]) selecList.toArray(new IFFrame[0]); |
1551 |
} |
1552 |
|
1553 |
/**
|
1554 |
* Opens a dialog where to pick a PDF-file to save the current Layout
|
1555 |
* suggesting a name for the file given by the first argument
|
1556 |
*
|
1557 |
* @param suggestedName
|
1558 |
*/
|
1559 |
public void layoutToPDF(String suggestedName) { |
1560 |
FileFilter pdfFilter = new GenericFileFilter("pdf", PluginServices |
1561 |
.getText(this, "pdf")); |
1562 |
|
1563 |
JFileChooser jfc = new JFileChooser(); |
1564 |
if (suggestedName != null) |
1565 |
jfc.setSelectedFile(new File(suggestedName)); |
1566 |
jfc.addChoosableFileFilter(pdfFilter); |
1567 |
jfc.setFileFilter(pdfFilter); |
1568 |
|
1569 |
if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
1570 |
File f = jfc.getSelectedFile();
|
1571 |
File faux = null; |
1572 |
|
1573 |
if (f.getName().endsWith(".pdf") || f.getName().endsWith(".PDF")) { |
1574 |
faux = f; |
1575 |
} else {
|
1576 |
faux = new File(f.getPath() + ".pdf"); |
1577 |
} |
1578 |
|
1579 |
layoutDraw.toPDF(faux); |
1580 |
} |
1581 |
} |
1582 |
/**
|
1583 |
* Opens a dialog where to pick a PS-file to save the current Layout
|
1584 |
* suggesting a name for the file given by the first argument
|
1585 |
*
|
1586 |
* @param suggestedName
|
1587 |
*/
|
1588 |
public void layoutToPS(String suggestedName) { |
1589 |
FileFilter pdfFilter = new GenericFileFilter("ps", PluginServices |
1590 |
.getText(this, "ps")); |
1591 |
|
1592 |
JFileChooser jfc = new JFileChooser(); |
1593 |
if (suggestedName != null) |
1594 |
jfc.setSelectedFile(new File(suggestedName)); |
1595 |
jfc.addChoosableFileFilter(pdfFilter); |
1596 |
jfc.setFileFilter(pdfFilter); |
1597 |
|
1598 |
if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
1599 |
File f = jfc.getSelectedFile();
|
1600 |
File faux = null; |
1601 |
|
1602 |
if (f.getName().endsWith(".ps") || f.getName().endsWith(".PS")) { |
1603 |
faux = f; |
1604 |
} else {
|
1605 |
faux = new File(f.getPath() + ".ps"); |
1606 |
} |
1607 |
|
1608 |
layoutDraw.toPS(faux); |
1609 |
} |
1610 |
} |
1611 |
/**
|
1612 |
* Abre un di?logo para seleccionar un fichero pdf donde guardar el Layout
|
1613 |
* en este formato.
|
1614 |
*/
|
1615 |
public void layoutToPDF() { |
1616 |
layoutToPDF(null);
|
1617 |
} |
1618 |
/**
|
1619 |
* Abre un di?logo para seleccionar un fichero ps donde guardar el Layout
|
1620 |
* en este formato.
|
1621 |
*/
|
1622 |
public void layoutToPS() { |
1623 |
layoutToPS(null);
|
1624 |
} |
1625 |
/**
|
1626 |
* @return Returns the bModeDebug.
|
1627 |
*/
|
1628 |
public boolean isModeDebug() { |
1629 |
return bModeDebug;
|
1630 |
} |
1631 |
|
1632 |
/**
|
1633 |
* @param modeDebug
|
1634 |
* The bModeDebug to set.
|
1635 |
*/
|
1636 |
public void setModeDebug(boolean modeDebug) { |
1637 |
bModeDebug = modeDebug; |
1638 |
} |
1639 |
|
1640 |
private ArrayList allFFrames(IFFrame[] fframes, ArrayList all) { |
1641 |
for (int i = 0; i < fframes.length; i++) { |
1642 |
if (fframes[i] instanceof FFrameGroup) { |
1643 |
return allFFrames(((FFrameGroup) fframes[i]).getFFrames(), all);
|
1644 |
|
1645 |
} |
1646 |
all.add(fframes[i]); |
1647 |
} |
1648 |
return all;
|
1649 |
} |
1650 |
|
1651 |
public IFFrame[] getAllFFrames() { |
1652 |
ArrayList all = new ArrayList(); |
1653 |
return (IFFrame[]) allFFrames(getFFrames(), all) |
1654 |
.toArray(new IFFrame[0]); |
1655 |
} |
1656 |
|
1657 |
public GeometryAdapter getGeometryAdapter() {
|
1658 |
return geometryAdapter;
|
1659 |
} |
1660 |
|
1661 |
public boolean isEditable() { |
1662 |
return isEditable;
|
1663 |
} |
1664 |
|
1665 |
public void setEditable(boolean b) { |
1666 |
if (!b) {
|
1667 |
clearSelection(); |
1668 |
setTool(Layout.ZOOM_MAS); |
1669 |
PluginServices.getMainFrame().setSelectedTool("ZOOM_IN");
|
1670 |
} |
1671 |
isEditable = b; |
1672 |
|
1673 |
} |
1674 |
|
1675 |
public void initGeometryAdapter() { |
1676 |
if (getTool() == LINE) {
|
1677 |
geometryAdapter = new PolyLineAdapter();
|
1678 |
} else if (getTool() == RECTANGLESIMPLE) { |
1679 |
geometryAdapter = new RectangleAdapter();
|
1680 |
} else if (getTool() == POLYLINE) { |
1681 |
geometryAdapter = new PolyLineAdapter();
|
1682 |
} else if (getTool() == POLYGON) { |
1683 |
geometryAdapter = new PolygonAdapter();
|
1684 |
} else if (getTool() == CIRCLE) { |
1685 |
geometryAdapter = new CircleAdapter();
|
1686 |
} else if (getTool() == POINT) { |
1687 |
geometryAdapter = new PointAdapter();
|
1688 |
} |
1689 |
} |
1690 |
|
1691 |
public void startEdit() { |
1692 |
IFFrame[] fframes=getFFrames();
|
1693 |
for (int i = 0; i < fframes.length; i++) { |
1694 |
IFFrame frame = fframes[i]; |
1695 |
if (frame instanceof IFFrameEditableVertex) { |
1696 |
if (frame.getSelected() != IFFrame.NOSELECT) {
|
1697 |
((IFFrameEditableVertex) frame).startEditing(); |
1698 |
} else {
|
1699 |
((IFFrameEditableVertex) frame).stopEditing(); |
1700 |
} |
1701 |
} |
1702 |
|
1703 |
} |
1704 |
refresh(); |
1705 |
} |
1706 |
|
1707 |
public void stopEdit() { |
1708 |
boolean refresh = false; |
1709 |
IFFrame[] fframes=getFFrames();
|
1710 |
for (int i = 0; i < fframes.length; i++) { |
1711 |
IFFrame frame = fframes[i]; |
1712 |
if (frame instanceof IFFrameEditableVertex) { |
1713 |
if (((IFFrameEditableVertex) frame).isEditing()) {
|
1714 |
((IFFrameEditableVertex) fframes[i]).stopEditing(); |
1715 |
refresh = true;
|
1716 |
} |
1717 |
} |
1718 |
} |
1719 |
if (refresh)
|
1720 |
refresh(); |
1721 |
} |
1722 |
|
1723 |
public void delFFrameSelected() { |
1724 |
efs.startComplexCommand(); |
1725 |
for (int i = efs.getAllFFrames().length - 1; i >= 0; i--) { |
1726 |
IFFrame fframe = efs.getFFrame(i); |
1727 |
|
1728 |
if (fframe.getSelected() != IFFrame.NOSELECT) {
|
1729 |
efs.removeFFrame(i); |
1730 |
} |
1731 |
} |
1732 |
efs.endComplexCommand(PluginServices.getText(this,"remove_elements")); |
1733 |
updateFFrames(); |
1734 |
} |
1735 |
|
1736 |
public void clearSelection() { |
1737 |
for (int i = efs.getAllFFrames().length - 1; i >= 0; i--) { |
1738 |
IFFrame fframe = efs.getFFrame(i); |
1739 |
if (fframe.getSelected() != IFFrame.NOSELECT) {
|
1740 |
fframe.setSelected(false);
|
1741 |
} |
1742 |
} |
1743 |
} |
1744 |
public void delFFrame(int index) { |
1745 |
for (int i = 0; i < getEFS().getAllFFrames().length; i++) { |
1746 |
if (getEFS().getFFrame(i).equals(getFFrame(index))) {
|
1747 |
getEFS().removeFFrame(i); |
1748 |
} |
1749 |
} |
1750 |
updateFFrames(); |
1751 |
} |
1752 |
|
1753 |
public void delFFrame(IFFrame frame) { |
1754 |
for (int i = 0; i < getEFS().getAllFFrames().length; i++) { |
1755 |
if (getEFS().getFFrame(i).equals(frame)) {
|
1756 |
getEFS().removeFFrame(i); |
1757 |
} |
1758 |
} |
1759 |
updateFFrames(); |
1760 |
} |
1761 |
|
1762 |
public EditableFeatureSource getEFS() {
|
1763 |
return efs;
|
1764 |
} |
1765 |
|
1766 |
public void commandRepaint() { |
1767 |
this.updateFFrames();
|
1768 |
this.refresh();
|
1769 |
} |
1770 |
|
1771 |
public void commandRefresh() { |
1772 |
commandRepaint(); |
1773 |
|
1774 |
} |
1775 |
|
1776 |
/**
|
1777 |
* Introduce la posibilidad de establecer que los cambios que se hacen a
|
1778 |
* partir de ese momento hasta que se vuelva a poner a false, que todas las
|
1779 |
* operaciones que realices son sobre los fframes que implementen
|
1780 |
* IFFrameGroupSelectable.
|
1781 |
*
|
1782 |
* @param b
|
1783 |
*/
|
1784 |
public void setEditGroup(boolean b) { |
1785 |
editGroup = b; |
1786 |
} |
1787 |
|
1788 |
/**
|
1789 |
* Devuelve true si se est? en modo de edici?n de los fframes que
|
1790 |
* implementen IFFrameGroupSelectable.
|
1791 |
*
|
1792 |
* @return
|
1793 |
*/
|
1794 |
public boolean isEditGroup() { |
1795 |
return editGroup;
|
1796 |
} |
1797 |
|
1798 |
public int getNumBehind() { |
1799 |
return --numBehind;
|
1800 |
} |
1801 |
|
1802 |
public int getNumBefore() { |
1803 |
return ++numBefore;
|
1804 |
} |
1805 |
|
1806 |
public void projectionChanged(ProjectionEvent e) { |
1807 |
// TODO Auto-generated method stub
|
1808 |
|
1809 |
} |
1810 |
|
1811 |
public void endGraphic() { |
1812 |
if ((getTool() == Layout.LINE)
|
1813 |
|| (getTool() == Layout.POLYLINE) |
1814 |
|| (getTool() == Layout.POLYGON) |
1815 |
|| (getTool() == Layout.CIRCLE) |
1816 |
|| (getTool() == Layout.RECTANGLESIMPLE) |
1817 |
|| (getTool() == Layout.POINT)) { |
1818 |
getGeometryAdapter().end(); |
1819 |
PluginServices.getMainFrame().enableControls(); |
1820 |
FLayoutFunctions lf=new FLayoutFunctions(this); |
1821 |
lf.addFFrame(); |
1822 |
initGeometryAdapter(); |
1823 |
refresh(); |
1824 |
} |
1825 |
} |
1826 |
|
1827 |
public void delLastPoint() { |
1828 |
getGeometryAdapter().delLastPoint(); |
1829 |
} |
1830 |
|
1831 |
public static boolean getDefaultShowGrid() { |
1832 |
if (defaultShowGrid == null) { |
1833 |
XMLEntity xml = PluginServices.getPluginServices("com.iver.cit.gvsig").getPersistentXML();
|
1834 |
if (xml.contains("DefaultShowLayoutGrid")) { |
1835 |
defaultShowGrid = new Boolean(xml.getBooleanProperty("DefaultShowLayoutGrid")); |
1836 |
} |
1837 |
else {
|
1838 |
// factory default is true
|
1839 |
defaultShowGrid = new Boolean(true); |
1840 |
} |
1841 |
} |
1842 |
return defaultShowGrid.booleanValue();
|
1843 |
} |
1844 |
|
1845 |
public static boolean getDefaultAdjustToGrid() { |
1846 |
if (defaultAdjustToGrid == null) { |
1847 |
XMLEntity xml = PluginServices.getPluginServices("com.iver.cit.gvsig").getPersistentXML();
|
1848 |
if (xml.contains("DefaultEnableLayoutGrid")) { |
1849 |
defaultAdjustToGrid = new Boolean(xml.getBooleanProperty("DefaultEnableLayoutGrid")); |
1850 |
} |
1851 |
else {
|
1852 |
// factory default is false
|
1853 |
defaultAdjustToGrid = new Boolean(false); |
1854 |
} |
1855 |
} |
1856 |
return defaultAdjustToGrid.booleanValue();
|
1857 |
} |
1858 |
|
1859 |
private static boolean getDefaultShowRulers() { |
1860 |
if (defaultShowRulers == null){ |
1861 |
XMLEntity xml = PluginServices.getPluginServices("com.iver.cit.gvsig").getPersistentXML();
|
1862 |
if (xml.contains("DefaultShowLayoutRules")) { |
1863 |
defaultShowRulers = new Boolean(xml.getBooleanProperty("DefaultShowLayoutRules")); |
1864 |
} |
1865 |
else {
|
1866 |
// factory default is true
|
1867 |
defaultShowRulers = new Boolean(true); |
1868 |
} |
1869 |
} |
1870 |
return defaultShowRulers.booleanValue();
|
1871 |
} |
1872 |
|
1873 |
public static void setDefaultShowGrid(boolean showGrid) { |
1874 |
defaultShowGrid = new Boolean(showGrid); |
1875 |
} |
1876 |
|
1877 |
public static void setDefaultAdjustToGrid(boolean gridEnabled) { |
1878 |
defaultAdjustToGrid = new Boolean(gridEnabled); |
1879 |
} |
1880 |
|
1881 |
public static void setDefaultShowRulers(boolean showRules) { |
1882 |
defaultShowRulers = new Boolean(showRules); |
1883 |
} |
1884 |
|
1885 |
} |