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