root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / LayoutControl.java @ 27352
History | View | Annotate | Download (22.6 KB)
1 | 9392 | caballero | package com.iver.cit.gvsig.project.documents.layout; |
---|---|---|---|
2 | |||
3 | 12826 | jaume | import java.awt.Color; |
4 | import java.awt.Cursor; |
||
5 | import java.awt.Graphics; |
||
6 | import java.awt.Graphics2D; |
||
7 | import java.awt.Image; |
||
8 | import java.awt.Point; |
||
9 | import java.awt.Rectangle; |
||
10 | import java.awt.Toolkit; |
||
11 | import java.awt.geom.AffineTransform; |
||
12 | import java.awt.geom.Rectangle2D; |
||
13 | import java.awt.image.BufferedImage; |
||
14 | import java.awt.image.MemoryImageSource; |
||
15 | import java.util.HashMap; |
||
16 | |||
17 | import javax.swing.JComponent; |
||
18 | |||
19 | 10626 | caballero | import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
20 | 9392 | caballero | import com.iver.cit.gvsig.fmap.core.adapter.GeometryAdapter; |
21 | import com.iver.cit.gvsig.fmap.core.adapter.PolyLineAdapter; |
||
22 | import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
||
23 | import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameEditableVertex; |
||
24 | import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrameUseFMap; |
||
25 | 10007 | caballero | import com.iver.cit.gvsig.project.documents.layout.gui.FPopupMenu; |
26 | 9392 | caballero | import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
27 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddBoxListenerImpl; |
||
28 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddCircleListenerImpl; |
||
29 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddLegendListenerImpl; |
||
30 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddLineListenerImpl; |
||
31 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddNorthListenerImpl; |
||
32 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddOverViewListenerImpl; |
||
33 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPictureListenerImpl; |
||
34 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPointListenerImpl; |
||
35 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPolygonListenerImpl; |
||
36 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddPolylineListenerImpl; |
||
37 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddRectangleListenerImpl; |
||
38 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddScaleListenerImpl; |
||
39 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddTextListenerImpl; |
||
40 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutAddViewListenerImpl; |
||
41 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutEditGraphicsListenerImpl; |
||
42 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutPanListenerImpl; |
||
43 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutSelectListenerImpl; |
||
44 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutViewPanListenerImpl; |
||
45 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutViewZoomInListenerImpl; |
||
46 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutViewZoomOutListenerImpl; |
||
47 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutZoomInListenerImpl; |
||
48 | import com.iver.cit.gvsig.project.documents.layout.tools.LayoutZoomOutListenerImpl; |
||
49 | import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutBehavior; |
||
50 | import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutEditBehavior; |
||
51 | import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutMoveBehavior; |
||
52 | import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutPointBehavior; |
||
53 | import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutRectangleBehavior; |
||
54 | import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutSelectBehavior; |
||
55 | import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutViewMoveBehavior; |
||
56 | 9557 | caballero | import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutViewZoomBehavior; |
57 | 9392 | caballero | import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutZoomBehavior; |
58 | import com.iver.cit.gvsig.project.documents.layout.tools.listener.ILayoutGraphicListener; |
||
59 | |||
60 | 10007 | caballero | |
61 | 9392 | caballero | /**
|
62 | 10007 | caballero | * Control of Layout.
|
63 | 9392 | caballero | *
|
64 | * @author Vicente Caballero Navarro
|
||
65 | */
|
||
66 | 9806 | caballero | public class LayoutControl extends JComponent implements LayoutDrawListener { |
67 | 10007 | caballero | public static final int DESACTUALIZADO = 4; |
68 | 9392 | caballero | public static final int ACTUALIZADO = 5; |
69 | private int status = DESACTUALIZADO; |
||
70 | private Rectangle2D rectVisible; |
||
71 | private BufferedImage img = null; |
||
72 | private BufferedImage imgRuler = null; |
||
73 | private boolean initial = true; |
||
74 | 10007 | caballero | private LayoutContext layoutContext;
|
75 | private Point origin = new Point(50, 50); |
||
76 | private Point rectOrigin = new Point(origin); |
||
77 | private Rectangle2D.Double rect = new Rectangle2D.Double(rectOrigin.x, |
||
78 | rectOrigin.y, 400, 300); |
||
79 | private FLayoutDraw layoutDraw = null; |
||
80 | private FLayoutFunctions layoutFunctions = null; |
||
81 | private LayoutBehavior currentLayoutTool = null; |
||
82 | private Image imageCursor = null; |
||
83 | private HashMap namesLayoutTools = new HashMap(); |
||
84 | private Point m_FirstPoint = new Point(0, 0); |
||
85 | private Point m_PointAnt = new Point(0, 0); |
||
86 | private Point m_LastPoint = new Point(0, 0); |
||
87 | private LayoutEvents layoutEvents;
|
||
88 | private Point position; |
||
89 | private GeometryAdapter geometryAdapter = new PolyLineAdapter(); |
||
90 | 9392 | caballero | |
91 | 10007 | caballero | //private String prevTool;
|
92 | private String currentTool; |
||
93 | private boolean m_bCancelDrawing = false; |
||
94 | private Rectangle reSel = null; |
||
95 | private boolean isReSel = true; |
||
96 | private FLayoutZooms layoutZooms;
|
||
97 | 24487 | vcaballero | |
98 | private static Cursor transparentCursor = Toolkit.getDefaultToolkit() |
||
99 | .createCustomCursor(Toolkit.getDefaultToolkit().createImage(new MemoryImageSource( |
||
100 | 16, 16, new int[16 * 16], 0, 16)), |
||
101 | new Point(0, 0), "invisiblecursor"); |
||
102 | |||
103 | |||
104 | 10007 | caballero | /**
|
105 | * Create a new object of LayoutControl.
|
||
106 | * @param layout
|
||
107 | */
|
||
108 | public LayoutControl(Layout layout) {
|
||
109 | setLayoutContext(layout.getLayoutContext()); |
||
110 | layoutDraw = new FLayoutDraw(layout);
|
||
111 | layoutEvents = new LayoutEvents(layout);
|
||
112 | layoutZooms = new FLayoutZooms(layout);
|
||
113 | layoutFunctions = new FLayoutFunctions(layout);
|
||
114 | addComponentListener(layoutEvents); |
||
115 | addMouseMotionListener(layoutEvents); |
||
116 | addMouseListener(layoutEvents); |
||
117 | 9392 | caballero | |
118 | 10007 | caballero | layoutContext.updateFFrames(); |
119 | 9392 | caballero | |
120 | 10007 | caballero | LayoutPanListenerImpl lpl = new LayoutPanListenerImpl(layout);
|
121 | 9392 | caballero | addLayoutTool("layoutpan", new LayoutMoveBehavior(lpl)); |
122 | |||
123 | LayoutZoomInListenerImpl lzil = new LayoutZoomInListenerImpl(layout);
|
||
124 | addLayoutTool("layoutzoomin", new LayoutZoomBehavior(lzil)); |
||
125 | |||
126 | LayoutZoomOutListenerImpl lzol = new LayoutZoomOutListenerImpl(layout);
|
||
127 | addLayoutTool("layoutzoomout", new LayoutZoomBehavior(lzol)); |
||
128 | |||
129 | LayoutAddViewListenerImpl lavl = new LayoutAddViewListenerImpl(layout);
|
||
130 | addLayoutTool("layoutaddview", new LayoutRectangleBehavior(lavl)); |
||
131 | |||
132 | LayoutAddOverViewListenerImpl laovl = new LayoutAddOverViewListenerImpl(layout);
|
||
133 | addLayoutTool("layoutaddoverview", new LayoutRectangleBehavior(laovl)); |
||
134 | |||
135 | LayoutAddPictureListenerImpl lapl = new LayoutAddPictureListenerImpl(layout);
|
||
136 | addLayoutTool("layoutaddpicture", new LayoutRectangleBehavior(lapl)); |
||
137 | |||
138 | LayoutAddNorthListenerImpl lanorthl = new LayoutAddNorthListenerImpl(layout);
|
||
139 | addLayoutTool("layoutaddnorth", new LayoutRectangleBehavior(lanorthl)); |
||
140 | |||
141 | LayoutAddScaleListenerImpl lasl = new LayoutAddScaleListenerImpl(layout);
|
||
142 | addLayoutTool("layoutaddscale", new LayoutRectangleBehavior(lasl)); |
||
143 | |||
144 | LayoutAddLegendListenerImpl lall = new LayoutAddLegendListenerImpl(layout);
|
||
145 | addLayoutTool("layoutaddlegend", new LayoutRectangleBehavior(lall)); |
||
146 | |||
147 | LayoutAddTextListenerImpl latl = new LayoutAddTextListenerImpl(layout);
|
||
148 | addLayoutTool("layoutaddtext", new LayoutRectangleBehavior(latl)); |
||
149 | |||
150 | LayoutAddBoxListenerImpl labl = new LayoutAddBoxListenerImpl(layout);
|
||
151 | addLayoutTool("layoutaddbox", new LayoutRectangleBehavior(labl)); |
||
152 | |||
153 | LayoutAddPointListenerImpl lapointl = new LayoutAddPointListenerImpl(layout);
|
||
154 | addLayoutTool("layoutaddpoint", new LayoutPointBehavior(lapointl)); |
||
155 | |||
156 | LayoutAddLineListenerImpl lalinel = new LayoutAddLineListenerImpl(layout);
|
||
157 | addLayoutTool("layoutaddline", new LayoutPointBehavior(lalinel)); |
||
158 | |||
159 | LayoutAddPolygonListenerImpl lapolygonl = new LayoutAddPolygonListenerImpl(layout);
|
||
160 | addLayoutTool("layoutaddpolygon", new LayoutPointBehavior(lapolygonl)); |
||
161 | |||
162 | LayoutAddPolylineListenerImpl lapolylinel = new LayoutAddPolylineListenerImpl(layout);
|
||
163 | addLayoutTool("layoutaddpolyline", new LayoutPointBehavior(lapolylinel)); |
||
164 | |||
165 | LayoutAddCircleListenerImpl lacirclel = new LayoutAddCircleListenerImpl(layout);
|
||
166 | addLayoutTool("layoutaddcircle", new LayoutPointBehavior(lacirclel)); |
||
167 | |||
168 | LayoutAddRectangleListenerImpl larectanglel = new LayoutAddRectangleListenerImpl(layout);
|
||
169 | 10007 | caballero | addLayoutTool("layoutaddrectangle",
|
170 | new LayoutPointBehavior(larectanglel));
|
||
171 | 9392 | caballero | |
172 | LayoutViewPanListenerImpl lvpl = new LayoutViewPanListenerImpl(layout);
|
||
173 | addLayoutTool("layoutviewpan", new LayoutViewMoveBehavior(lvpl)); |
||
174 | |||
175 | LayoutViewZoomInListenerImpl lvzil = new LayoutViewZoomInListenerImpl(layout);
|
||
176 | 9557 | caballero | addLayoutTool("layoutviewzoomin", new LayoutViewZoomBehavior(lvzil)); |
177 | 9392 | caballero | |
178 | LayoutViewZoomOutListenerImpl lvzol = new LayoutViewZoomOutListenerImpl(layout);
|
||
179 | 9557 | caballero | addLayoutTool("layoutviewzoomout", new LayoutViewZoomBehavior(lvzol)); |
180 | 9392 | caballero | |
181 | LayoutSelectListenerImpl lselectl = new LayoutSelectListenerImpl(layout);
|
||
182 | addLayoutTool("layoutselect", new LayoutSelectBehavior(lselectl)); |
||
183 | |||
184 | LayoutEditGraphicsListenerImpl leditl = new LayoutEditGraphicsListenerImpl(layout);
|
||
185 | addLayoutTool("layoutedit", new LayoutEditBehavior(leditl)); |
||
186 | |||
187 | setTool("layoutzoomin");
|
||
188 | 9806 | caballero | FPopupMenu.registerExtensionPoint(); |
189 | 10007 | caballero | } |
190 | 9392 | caballero | |
191 | 10007 | caballero | /**
|
192 | * Returns the name of the current selected tool on this Layout
|
||
193 | *
|
||
194 | * @return A tool name.
|
||
195 | */
|
||
196 | public String getCurrentTool() { |
||
197 | return currentTool;
|
||
198 | } |
||
199 | |||
200 | /**
|
||
201 | * Add a new Layout tool.
|
||
202 | *
|
||
203 | * @param name Name of tool.
|
||
204 | * @param tool LayoutBehavior
|
||
205 | */
|
||
206 | 9392 | caballero | public void addLayoutTool(String name, LayoutBehavior tool) { |
207 | 10007 | caballero | namesLayoutTools.put(name, tool); |
208 | tool.setLayoutControl(this);
|
||
209 | } |
||
210 | 9392 | caballero | |
211 | 10007 | caballero | /**
|
212 | * Inserts the LayoutContext.
|
||
213 | *
|
||
214 | * @param lc LayoutContext.
|
||
215 | */
|
||
216 | 9392 | caballero | public void setLayoutContext(LayoutContext lc) { |
217 | 10007 | caballero | layoutContext = lc; |
218 | layoutContext.addLayoutDrawListener(this);
|
||
219 | 9392 | caballero | } |
220 | 10007 | caballero | |
221 | 9392 | caballero | /**
|
222 | 10007 | caballero | * paintComponent of Layout.
|
223 | 9392 | caballero | *
|
224 | 10007 | caballero | * @param g Graphics of Layout.
|
225 | 9392 | caballero | */
|
226 | protected void paintComponent(Graphics g) { |
||
227 | clipVisibleRect((Graphics2D) g);
|
||
228 | |||
229 | Rectangle rClip = g.getClipBounds();
|
||
230 | |||
231 | if (rClip == null) { |
||
232 | System.err.println("clip = null"); |
||
233 | } |
||
234 | |||
235 | switch (status) {
|
||
236 | 10007 | caballero | case DESACTUALIZADO:
|
237 | if (getWidth() == 0) { |
||
238 | return;
|
||
239 | } |
||
240 | |||
241 | 9392 | caballero | img = new BufferedImage(getWidth(), getHeight(), |
242 | BufferedImage.TYPE_INT_ARGB);
|
||
243 | imgRuler = new BufferedImage(getWidth(), getHeight(), |
||
244 | BufferedImage.TYPE_INT_ARGB);
|
||
245 | 10007 | caballero | |
246 | 9392 | caballero | Graphics gimag = img.getGraphics();
|
247 | Graphics gimgRuler = imgRuler.getGraphics();
|
||
248 | clipVisibleRect((Graphics2D) gimag);
|
||
249 | |||
250 | if (initial) {
|
||
251 | fullRect(); |
||
252 | initial = false;
|
||
253 | } |
||
254 | |||
255 | try {
|
||
256 | layoutDraw.drawLayout((Graphics2D) gimag, img);
|
||
257 | 10626 | caballero | } catch (ReadDriverException e) {
|
258 | 9392 | caballero | e.printStackTrace(); |
259 | } |
||
260 | 10007 | caballero | |
261 | 9392 | caballero | g.setClip(rClip); |
262 | layoutDraw.drawRectangle((Graphics2D) g);
|
||
263 | |||
264 | g.drawImage(img, 0, 0, this); |
||
265 | g.setClip(rClip); |
||
266 | |||
267 | layoutDraw.drawGrid((Graphics2D) gimgRuler);
|
||
268 | layoutDraw.drawRuler((Graphics2D) gimgRuler, Color.black); |
||
269 | setStatus(ACTUALIZADO); |
||
270 | repaint(); |
||
271 | 10007 | caballero | |
272 | 9392 | caballero | break;
|
273 | |||
274 | case ACTUALIZADO:
|
||
275 | layoutDraw.drawRectangle((Graphics2D) g);
|
||
276 | |||
277 | 10007 | caballero | if (currentLayoutTool != null) { |
278 | 9392 | caballero | currentLayoutTool.paintComponent(g); |
279 | 10007 | caballero | } else {
|
280 | g.drawImage(img, 0, 0, this); |
||
281 | 9392 | caballero | |
282 | 10007 | caballero | layoutDraw.drawHandlers((Graphics2D) g, Color.black); |
283 | 9392 | caballero | } |
284 | 10007 | caballero | |
285 | 9392 | caballero | g.setClip(rClip); |
286 | drawCursor(g); |
||
287 | } |
||
288 | 10007 | caballero | } |
289 | 9392 | caballero | |
290 | 10007 | caballero | /**
|
291 | * Inserts the status of Layout.
|
||
292 | *
|
||
293 | * @param s Status of Layout.
|
||
294 | */
|
||
295 | public void setStatus(int s) { |
||
296 | status = s; |
||
297 | 9392 | caballero | } |
298 | |||
299 | 10007 | caballero | /**
|
300 | * Clip on visible rectangle.
|
||
301 | 9392 | caballero | *
|
302 | 10007 | caballero | * @param g2d Graphics.
|
303 | 9392 | caballero | */
|
304 | private void clipVisibleRect(Graphics2D g2d) { |
||
305 | rectVisible = this.getVisibleRect();
|
||
306 | g2d.clipRect((int) rectVisible.getMinX(), (int) rectVisible.getMinY(), |
||
307 | 10007 | caballero | (int) rectVisible.getWidth(), (int) rectVisible.getHeight()); |
308 | 9392 | caballero | } |
309 | 10007 | caballero | |
310 | /**
|
||
311 | * Returns the image with the ruler.
|
||
312 | *
|
||
313 | * @return Ruler image.
|
||
314 | */
|
||
315 | 9392 | caballero | public BufferedImage getImgRuler() { |
316 | 10007 | caballero | return imgRuler;
|
317 | } |
||
318 | |||
319 | 9392 | caballero | /**
|
320 | 10007 | caballero | * It obtains the rect that is adjusted to the size of the window,
|
321 | * to see the full extent of layout.
|
||
322 | */
|
||
323 | 9392 | caballero | public void fullRect() { |
324 | rect.setRect(origin.x, origin.y, getWidth() - (origin.x * 2),
|
||
325 | 10007 | caballero | getHeight() - (origin.x * 2));
|
326 | 9392 | caballero | |
327 | if (layoutContext.getAtributes().isLandSpace()) {
|
||
328 | 10007 | caballero | rect = layoutContext.getAtributes().getRectangleLandscape(rect, |
329 | getWidth(), getHeight()); |
||
330 | 9392 | caballero | } else {
|
331 | 10007 | caballero | rect = layoutContext.getAtributes().getRectanglePortrait(rect, |
332 | getWidth(), getHeight()); |
||
333 | 9392 | caballero | } |
334 | 10007 | caballero | |
335 | 9392 | caballero | refresh(); |
336 | } |
||
337 | |||
338 | /**
|
||
339 | 10007 | caballero | * Returns the rectangle that represents the sheet.
|
340 | * In pixels.
|
||
341 | *
|
||
342 | * @return Rectangle2D.Double Rectangle that represents the sheet.
|
||
343 | */
|
||
344 | 9392 | caballero | public Rectangle2D.Double getRect() { |
345 | return rect;
|
||
346 | } |
||
347 | |||
348 | 10007 | caballero | /**
|
349 | * Inserts the rectangle that represents the sheet.
|
||
350 | * In pixels.
|
||
351 | *
|
||
352 | */
|
||
353 | 9392 | caballero | public void setRect(Rectangle2D r) { |
354 | rect.setRect(r); |
||
355 | } |
||
356 | 10007 | caballero | |
357 | /**
|
||
358 | * Returns the current image of Layout.
|
||
359 | *
|
||
360 | * @return Current image of Layout.
|
||
361 | */
|
||
362 | 9392 | caballero | public BufferedImage getImage() { |
363 | 10007 | caballero | return img;
|
364 | } |
||
365 | |||
366 | /**
|
||
367 | * Draw the cursor on the Graphics.
|
||
368 | *
|
||
369 | * @param g Graphics.
|
||
370 | */
|
||
371 | 9392 | caballero | private void drawCursor(Graphics g) { |
372 | 10007 | caballero | if ((imageCursor != null) && (position != null)) { |
373 | Point pAdjusted = position;
|
||
374 | g.drawImage(imageCursor, (int) pAdjusted.getX() - 16, |
||
375 | (int) pAdjusted.getY() - 16, this); |
||
376 | 9392 | caballero | } |
377 | } |
||
378 | 10007 | caballero | |
379 | 9392 | caballero | /**
|
380 | 10007 | caballero | * Changes the pointer of the mouse by the image of parameter.
|
381 | *
|
||
382 | * @param image Image
|
||
383 | */
|
||
384 | 9392 | caballero | public void setMapCursor(Image image) { |
385 | 10007 | caballero | imageCursor = image; |
386 | 9392 | caballero | } |
387 | 10007 | caballero | |
388 | 9392 | caballero | /**
|
389 | 10007 | caballero | * It establishes as selected to the tool from its name of identification.
|
390 | 9392 | caballero | *
|
391 | 10007 | caballero | * @param toolName Name of identification tool.
|
392 | 9392 | caballero | */
|
393 | 10007 | caballero | public void setTool(String toolName) { |
394 | //prevTool=getCurrentTool();
|
||
395 | LayoutBehavior layoutTool = (LayoutBehavior) namesLayoutTools.get(toolName); |
||
396 | currentLayoutTool = layoutTool; |
||
397 | currentLayoutTool.setLayoutControl(this);
|
||
398 | currentTool = toolName; |
||
399 | this.setMapCursor(layoutTool.getImageCursor());
|
||
400 | |||
401 | if (getCurrentLayoutTool().getListener() instanceof ILayoutGraphicListener) { |
||
402 | geometryAdapter = ((ILayoutGraphicListener) getCurrentLayoutTool() |
||
403 | .getListener()).createGeometryAdapter(); |
||
404 | } |
||
405 | |||
406 | if (getCurrentTool().equals("layoutedit")) { |
||
407 | startEdit(); |
||
408 | } else {
|
||
409 | stopEdit(); |
||
410 | } |
||
411 | 9392 | caballero | } |
412 | |||
413 | 10007 | caballero | /**
|
414 | * Start the vertex edition of graphics.
|
||
415 | *
|
||
416 | */
|
||
417 | public void startEdit() { |
||
418 | IFFrame[] fframes = layoutContext.getFFrames();
|
||
419 | 9392 | caballero | |
420 | 10007 | caballero | for (int i = 0; i < fframes.length; i++) { |
421 | IFFrame frame = fframes[i]; |
||
422 | |||
423 | if (frame instanceof IFFrameEditableVertex) { |
||
424 | if (frame.getSelected() != IFFrame.NOSELECT) {
|
||
425 | ((IFFrameEditableVertex) frame).startEditing(); |
||
426 | } else {
|
||
427 | ((IFFrameEditableVertex) frame).stopEditing(); |
||
428 | } |
||
429 | } |
||
430 | } |
||
431 | |||
432 | refresh(); |
||
433 | } |
||
434 | |||
435 | /**
|
||
436 | * Stop the vertex edition of graphics.
|
||
437 | *
|
||
438 | */
|
||
439 | public void stopEdit() { |
||
440 | boolean refresh = false; |
||
441 | IFFrame[] fframes = layoutContext.getFFrames();
|
||
442 | |||
443 | for (int i = 0; i < fframes.length; i++) { |
||
444 | IFFrame frame = fframes[i]; |
||
445 | |||
446 | if (frame instanceof IFFrameEditableVertex) { |
||
447 | if (((IFFrameEditableVertex) frame).isEditing()) {
|
||
448 | ((IFFrameEditableVertex) fframes[i]).stopEditing(); |
||
449 | refresh = true;
|
||
450 | } |
||
451 | } |
||
452 | } |
||
453 | |||
454 | if (refresh) {
|
||
455 | refresh(); |
||
456 | } |
||
457 | } |
||
458 | |||
459 | /**
|
||
460 | * It returns the point that represents the northwest corner of the Layout.
|
||
461 | *
|
||
462 | * @return Point.
|
||
463 | */
|
||
464 | 9392 | caballero | public Point getRectOrigin() { |
465 | return rectOrigin;
|
||
466 | } |
||
467 | 10007 | caballero | |
468 | /**
|
||
469 | * Returns the object to draw the Layout.
|
||
470 | *
|
||
471 | * @return FLayoutDraw.
|
||
472 | */
|
||
473 | 9392 | caballero | public FLayoutDraw getLayoutDraw() {
|
474 | 10007 | caballero | return layoutDraw;
|
475 | } |
||
476 | |||
477 | /**
|
||
478 | * Returns the current Layout tool.
|
||
479 | 9392 | caballero | *
|
480 | 10007 | caballero | * @return LayoutBehavior Current Layout Tool.
|
481 | 9392 | caballero | */
|
482 | 10007 | caballero | public LayoutBehavior getCurrentLayoutTool() {
|
483 | return currentLayoutTool;
|
||
484 | } |
||
485 | |||
486 | /**
|
||
487 | * It returns the first click point of mouse.
|
||
488 | *
|
||
489 | * @return Point.
|
||
490 | */
|
||
491 | 9392 | caballero | public Point getFirstPoint() { |
492 | return m_FirstPoint;
|
||
493 | } |
||
494 | |||
495 | /**
|
||
496 | 10007 | caballero | * Returns the previous click of mouse.
|
497 | *
|
||
498 | * @return Point.
|
||
499 | */
|
||
500 | 9392 | caballero | public Point getPointAnt() { |
501 | return m_PointAnt;
|
||
502 | } |
||
503 | |||
504 | /**
|
||
505 | 10007 | caballero | * Returns the last click point of mouse.
|
506 | *
|
||
507 | * @return Point.
|
||
508 | */
|
||
509 | 9392 | caballero | public Point getLastPoint() { |
510 | return m_LastPoint;
|
||
511 | } |
||
512 | |||
513 | /**
|
||
514 | 10007 | caballero | * Inserts the first click point of mouse.
|
515 | *
|
||
516 | * @param p
|
||
517 | * Point.
|
||
518 | */
|
||
519 | 9392 | caballero | public void setFirstPoint() { |
520 | 10007 | caballero | m_FirstPoint = position; |
521 | 9392 | caballero | } |
522 | |||
523 | /**
|
||
524 | 10007 | caballero | * Inserts the previous click point of mouse.
|
525 | *
|
||
526 | * @param p
|
||
527 | * Point.
|
||
528 | */
|
||
529 | 9392 | caballero | public void setPointAnt() { |
530 | 10007 | caballero | m_PointAnt = position; |
531 | 9392 | caballero | } |
532 | |||
533 | /**
|
||
534 | 10007 | caballero | * Inserts the last click point of mouse.
|
535 | *
|
||
536 | * @param p
|
||
537 | * Point.
|
||
538 | */
|
||
539 | public void setLastPoint() { |
||
540 | m_LastPoint = position; |
||
541 | } |
||
542 | |||
543 | /**
|
||
544 | * Insert the position point and calculate the new position if the grid is actived.
|
||
545 | 9392 | caballero | *
|
546 | 10007 | caballero | * @param point2 Position.
|
547 | 9392 | caballero | */
|
548 | public void setPosition(Point point2) { |
||
549 | 10007 | caballero | if (layoutContext.isAdjustingToGrid() &&
|
550 | getCurrentLayoutTool().isAdjustable()) { |
||
551 | position = FLayoutUtilities.getPointGrid(point2, |
||
552 | layoutContext.getAtributes().getNumUnitsX(), |
||
553 | layoutContext.getAtributes().getNumUnitsY(), |
||
554 | layoutContext.getAT()); |
||
555 | } else {
|
||
556 | position = point2; |
||
557 | 9392 | caballero | } |
558 | } |
||
559 | 10007 | caballero | |
560 | /**
|
||
561 | * Returns the position adjusted point.
|
||
562 | 9392 | caballero | *
|
563 | 10007 | caballero | * @return
|
564 | 9392 | caballero | */
|
565 | 10007 | caballero | public Point getPosition() { |
566 | return position;
|
||
567 | } |
||
568 | |||
569 | /**
|
||
570 | * Returns the AffineTransform that is applying in the Layout.
|
||
571 | *
|
||
572 | * @return AffineTransform
|
||
573 | */
|
||
574 | 9392 | caballero | public AffineTransform getAT() { |
575 | 9806 | caballero | return layoutContext.getAT();
|
576 | 9392 | caballero | } |
577 | 10007 | caballero | |
578 | /**
|
||
579 | * It returns the current GeometryAdapter.
|
||
580 | * @return Current GeometryAdapter.
|
||
581 | */
|
||
582 | 9392 | caballero | public GeometryAdapter getGeometryAdapter() {
|
583 | return geometryAdapter;
|
||
584 | } |
||
585 | 10007 | caballero | |
586 | /**
|
||
587 | * Remove last point of geometryAdapter.
|
||
588 | *
|
||
589 | */
|
||
590 | 9392 | caballero | public void delLastPoint() { |
591 | getGeometryAdapter().delLastPoint(); |
||
592 | } |
||
593 | 10007 | caballero | |
594 | /**
|
||
595 | * Add a new point to geometryAdapter.
|
||
596 | *
|
||
597 | * @return Number of points in the geometryAdapter.
|
||
598 | */
|
||
599 | 9392 | caballero | public int addGeometryAdapterPoint() { |
600 | 10007 | caballero | return getGeometryAdapter().addPoint(FLayoutUtilities.toSheetPoint(
|
601 | getPosition(), getAT())); |
||
602 | 9392 | caballero | } |
603 | |||
604 | 10007 | caballero | /**
|
605 | * Change the position of mousemoved point of geometryAdapter.
|
||
606 | */
|
||
607 | 9392 | caballero | public void setGeometryAdapterPoinPosition() { |
608 | 10007 | caballero | getGeometryAdapter().pointPosition(FLayoutUtilities.toSheetPoint( |
609 | getPosition(), getAT())); |
||
610 | 9392 | caballero | } |
611 | |||
612 | 10007 | caballero | /**
|
613 | * Clear the image of pointer of mouse.
|
||
614 | */
|
||
615 | public void clearMouseImage() { |
||
616 | setCursor(transparentCursor); |
||
617 | } |
||
618 | 9392 | caballero | |
619 | 10007 | caballero | /**
|
620 | * Refres the Layout.
|
||
621 | 9392 | caballero | */
|
622 | 10007 | caballero | public void refresh() { |
623 | setStatus(LayoutControl.DESACTUALIZADO); |
||
624 | repaint(); |
||
625 | } |
||
626 | |||
627 | /**
|
||
628 | * It returns true if the drawing has been canceled.
|
||
629 | *
|
||
630 | * @return true if the drawn has been canceled.
|
||
631 | */
|
||
632 | 9392 | caballero | public synchronized boolean isDrawingCancelled() { |
633 | return m_bCancelDrawing;
|
||
634 | } |
||
635 | |||
636 | /**
|
||
637 | 10007 | caballero | * It cancels the drawing if the parameter is true.
|
638 | *
|
||
639 | * @param b true if the drawing wants to be canceled
|
||
640 | */
|
||
641 | 9392 | caballero | public synchronized void setCancelDrawing(boolean b) { |
642 | m_bCancelDrawing = b; |
||
643 | |||
644 | for (int i = 0; i < layoutContext.getFFrames().length; i++) { |
||
645 | IFFrame fframe = layoutContext.getFFrame(i); |
||
646 | |||
647 | 10007 | caballero | if (fframe instanceof IFFrameUseFMap && |
648 | (((IFFrameUseFMap) fframe).getMapContext() != null)) {
|
||
649 | 9392 | caballero | // //TODO((FFrameView)
|
650 | // getFFrames().get(i)).getFMap().setCancelDrawing(b);
|
||
651 | } |
||
652 | } |
||
653 | } |
||
654 | 9806 | caballero | |
655 | 9392 | caballero | /**
|
656 | 10007 | caballero | * Returns the rectangle of selection.
|
657 | *
|
||
658 | * @return Rectangle of selection.
|
||
659 | */
|
||
660 | 9392 | caballero | public Rectangle getReSel() { |
661 | return reSel;
|
||
662 | } |
||
663 | |||
664 | /**
|
||
665 | 10007 | caballero | * It returns true if should draw the rectangle of selection and does the selection.
|
666 | *
|
||
667 | * @return true if should draw the rectangle of selection.
|
||
668 | */
|
||
669 | 9392 | caballero | public boolean isReSel() { |
670 | return isReSel;
|
||
671 | } |
||
672 | |||
673 | /**
|
||
674 | 10007 | caballero | * Insert true if should draw the rectangle of selection and does the selection.
|
675 | *
|
||
676 | * @param b boolean.
|
||
677 | */
|
||
678 | 9392 | caballero | public void setIsReSel(boolean b) { |
679 | isReSel = b; |
||
680 | } |
||
681 | |||
682 | /**
|
||
683 | 10007 | caballero | * It does a full extent of the layers that contains the view of the
|
684 | * FFrameView selected.
|
||
685 | *
|
||
686 | 10661 | caballero | * @throws ReadDriverException
|
687 | 10007 | caballero | */
|
688 | 10626 | caballero | public void viewFull() throws ReadDriverException { |
689 | 9392 | caballero | IFFrame[] fframes = layoutContext.getFFrameSelected();
|
690 | 10007 | caballero | |
691 | 9392 | caballero | for (int i = 0; i < fframes.length; i++) { |
692 | if (fframes[i] instanceof IFFrameUseFMap) { |
||
693 | IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
||
694 | |||
695 | if (fframe.getMapContext() != null) { |
||
696 | fframe.fullExtent(); |
||
697 | } |
||
698 | 10007 | caballero | |
699 | 9392 | caballero | fframe.refresh(); |
700 | } |
||
701 | } |
||
702 | 10007 | caballero | |
703 | 9392 | caballero | refresh(); |
704 | } |
||
705 | |||
706 | 10007 | caballero | /**
|
707 | * Returns the object to make zooms.
|
||
708 | *
|
||
709 | * @return FLayoutZooms.
|
||
710 | */
|
||
711 | 9392 | caballero | public FLayoutZooms getLayoutZooms() {
|
712 | 10007 | caballero | return layoutZooms;
|
713 | } |
||
714 | 9392 | caballero | |
715 | 10007 | caballero | /**
|
716 | * Returns the object of FLayoutFunctions.
|
||
717 | *
|
||
718 | * @return FLayoutFunctions
|
||
719 | */
|
||
720 | public FLayoutFunctions getLayoutFunctions() {
|
||
721 | return layoutFunctions;
|
||
722 | } |
||
723 | 9392 | caballero | |
724 | 10007 | caballero | /**
|
725 | * Returns the LayoutContext.
|
||
726 | *
|
||
727 | * @return LayoutContext.
|
||
728 | */
|
||
729 | public LayoutContext getLayoutContext() {
|
||
730 | return layoutContext;
|
||
731 | } |
||
732 | |||
733 | /**
|
||
734 | * Inserts the geometryAdapter.
|
||
735 | *
|
||
736 | * @param adapter GeometryAdapter.
|
||
737 | */
|
||
738 | public void setGeometryAdapter(GeometryAdapter adapter) { |
||
739 | geometryAdapter = adapter; |
||
740 | } |
||
741 | 9392 | caballero | } |