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