svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / LayoutControl.java @ 28407
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 | 28247 | vcaballero | // 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 | 24487 | vcaballero | |
103 | |||
104 | 10007 | caballero | /**
|
105 | * Create a new object of LayoutControl.
|
||
106 | * @param layout
|
||
107 | */
|
||
108 | public LayoutControl(Layout layout) {
|
||
109 | 28247 | vcaballero | setLayoutContext(layout.getLayoutContext()); |
110 | 10007 | caballero | 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 | 28270 | vcaballero | // layoutDraw.drawRectangle((Graphics2D) gimag);
|
263 | 9392 | caballero | |
264 | 28270 | vcaballero | // g.drawImage(img, 0, 0, this);
|
265 | 9392 | caballero | g.setClip(rClip); |
266 | |||
267 | layoutDraw.drawGrid((Graphics2D) gimgRuler);
|
||
268 | layoutDraw.drawRuler((Graphics2D) gimgRuler, Color.black); |
||
269 | setStatus(ACTUALIZADO); |
||
270 | repaint(); |
||
271 | break;
|
||
272 | |||
273 | case ACTUALIZADO:
|
||
274 | 28270 | vcaballero | // layoutDraw.drawRectangle((Graphics2D) g);
|
275 | 9392 | caballero | |
276 | 10007 | caballero | if (currentLayoutTool != null) { |
277 | 9392 | caballero | currentLayoutTool.paintComponent(g); |
278 | 10007 | caballero | } else {
|
279 | g.drawImage(img, 0, 0, this); |
||
280 | 9392 | caballero | |
281 | 10007 | caballero | layoutDraw.drawHandlers((Graphics2D) g, Color.black); |
282 | 9392 | caballero | } |
283 | 10007 | caballero | |
284 | 9392 | caballero | g.setClip(rClip); |
285 | 28247 | vcaballero | // drawCursor(g);
|
286 | 9392 | caballero | } |
287 | 10007 | caballero | } |
288 | 9392 | caballero | |
289 | 10007 | caballero | /**
|
290 | * Inserts the status of Layout.
|
||
291 | *
|
||
292 | * @param s Status of Layout.
|
||
293 | */
|
||
294 | public void setStatus(int s) { |
||
295 | status = s; |
||
296 | 9392 | caballero | } |
297 | |||
298 | 10007 | caballero | /**
|
299 | * Clip on visible rectangle.
|
||
300 | 9392 | caballero | *
|
301 | 10007 | caballero | * @param g2d Graphics.
|
302 | 9392 | caballero | */
|
303 | private void clipVisibleRect(Graphics2D g2d) { |
||
304 | rectVisible = this.getVisibleRect();
|
||
305 | g2d.clipRect((int) rectVisible.getMinX(), (int) rectVisible.getMinY(), |
||
306 | 10007 | caballero | (int) rectVisible.getWidth(), (int) rectVisible.getHeight()); |
307 | 9392 | caballero | } |
308 | 10007 | caballero | |
309 | /**
|
||
310 | * Returns the image with the ruler.
|
||
311 | *
|
||
312 | * @return Ruler image.
|
||
313 | */
|
||
314 | 9392 | caballero | public BufferedImage getImgRuler() { |
315 | 10007 | caballero | return imgRuler;
|
316 | } |
||
317 | |||
318 | 9392 | caballero | /**
|
319 | 10007 | caballero | * It obtains the rect that is adjusted to the size of the window,
|
320 | * to see the full extent of layout.
|
||
321 | */
|
||
322 | 9392 | caballero | public void fullRect() { |
323 | rect.setRect(origin.x, origin.y, getWidth() - (origin.x * 2),
|
||
324 | 10007 | caballero | getHeight() - (origin.x * 2));
|
325 | 9392 | caballero | |
326 | if (layoutContext.getAtributes().isLandSpace()) {
|
||
327 | 10007 | caballero | rect = layoutContext.getAtributes().getRectangleLandscape(rect, |
328 | getWidth(), getHeight()); |
||
329 | 9392 | caballero | } else {
|
330 | 10007 | caballero | rect = layoutContext.getAtributes().getRectanglePortrait(rect, |
331 | getWidth(), getHeight()); |
||
332 | 9392 | caballero | } |
333 | 10007 | caballero | |
334 | 9392 | caballero | refresh(); |
335 | } |
||
336 | |||
337 | /**
|
||
338 | 10007 | caballero | * Returns the rectangle that represents the sheet.
|
339 | * In pixels.
|
||
340 | *
|
||
341 | * @return Rectangle2D.Double Rectangle that represents the sheet.
|
||
342 | */
|
||
343 | 9392 | caballero | public Rectangle2D.Double getRect() { |
344 | return rect;
|
||
345 | } |
||
346 | |||
347 | 10007 | caballero | /**
|
348 | * Inserts the rectangle that represents the sheet.
|
||
349 | * In pixels.
|
||
350 | *
|
||
351 | */
|
||
352 | 9392 | caballero | public void setRect(Rectangle2D r) { |
353 | rect.setRect(r); |
||
354 | } |
||
355 | 10007 | caballero | |
356 | /**
|
||
357 | * Returns the current image of Layout.
|
||
358 | *
|
||
359 | * @return Current image of Layout.
|
||
360 | */
|
||
361 | 9392 | caballero | public BufferedImage getImage() { |
362 | 10007 | caballero | return img;
|
363 | } |
||
364 | |||
365 | /**
|
||
366 | * Draw the cursor on the Graphics.
|
||
367 | *
|
||
368 | * @param g Graphics.
|
||
369 | */
|
||
370 | 28270 | vcaballero | public void drawCursor(Graphics g) { |
371 | 10007 | caballero | if ((imageCursor != null) && (position != null)) { |
372 | Point pAdjusted = position;
|
||
373 | g.drawImage(imageCursor, (int) pAdjusted.getX() - 16, |
||
374 | (int) pAdjusted.getY() - 16, this); |
||
375 | 9392 | caballero | } |
376 | } |
||
377 | 10007 | caballero | |
378 | 9392 | caballero | /**
|
379 | 10007 | caballero | * Changes the pointer of the mouse by the image of parameter.
|
380 | *
|
||
381 | * @param image Image
|
||
382 | */
|
||
383 | 28270 | vcaballero | public void setMapCursor(Cursor cursor) { |
384 | 28247 | vcaballero | this.setCursor(cursor);
|
385 | 9392 | caballero | } |
386 | 10007 | caballero | |
387 | 9392 | caballero | /**
|
388 | 10007 | caballero | * It establishes as selected to the tool from its name of identification.
|
389 | 9392 | caballero | *
|
390 | 10007 | caballero | * @param toolName Name of identification tool.
|
391 | 9392 | caballero | */
|
392 | 10007 | caballero | public void setTool(String toolName) { |
393 | //prevTool=getCurrentTool();
|
||
394 | LayoutBehavior layoutTool = (LayoutBehavior) namesLayoutTools.get(toolName); |
||
395 | currentLayoutTool = layoutTool; |
||
396 | currentLayoutTool.setLayoutControl(this);
|
||
397 | currentTool = toolName; |
||
398 | 28247 | vcaballero | this.setMapCursor(layoutTool.getCursor());
|
399 | 10007 | caballero | |
400 | if (getCurrentLayoutTool().getListener() instanceof ILayoutGraphicListener) { |
||
401 | geometryAdapter = ((ILayoutGraphicListener) getCurrentLayoutTool() |
||
402 | .getListener()).createGeometryAdapter(); |
||
403 | } |
||
404 | |||
405 | if (getCurrentTool().equals("layoutedit")) { |
||
406 | startEdit(); |
||
407 | } else {
|
||
408 | stopEdit(); |
||
409 | } |
||
410 | 9392 | caballero | } |
411 | |||
412 | 10007 | caballero | /**
|
413 | * Start the vertex edition of graphics.
|
||
414 | *
|
||
415 | */
|
||
416 | public void startEdit() { |
||
417 | IFFrame[] fframes = layoutContext.getFFrames();
|
||
418 | 9392 | caballero | |
419 | 10007 | caballero | for (int i = 0; i < fframes.length; i++) { |
420 | IFFrame frame = fframes[i]; |
||
421 | |||
422 | if (frame instanceof IFFrameEditableVertex) { |
||
423 | if (frame.getSelected() != IFFrame.NOSELECT) {
|
||
424 | ((IFFrameEditableVertex) frame).startEditing(); |
||
425 | } else {
|
||
426 | ((IFFrameEditableVertex) frame).stopEditing(); |
||
427 | } |
||
428 | } |
||
429 | } |
||
430 | |||
431 | refresh(); |
||
432 | } |
||
433 | |||
434 | /**
|
||
435 | * Stop the vertex edition of graphics.
|
||
436 | *
|
||
437 | */
|
||
438 | public void stopEdit() { |
||
439 | boolean refresh = false; |
||
440 | IFFrame[] fframes = layoutContext.getFFrames();
|
||
441 | |||
442 | for (int i = 0; i < fframes.length; i++) { |
||
443 | IFFrame frame = fframes[i]; |
||
444 | |||
445 | if (frame instanceof IFFrameEditableVertex) { |
||
446 | if (((IFFrameEditableVertex) frame).isEditing()) {
|
||
447 | ((IFFrameEditableVertex) fframes[i]).stopEditing(); |
||
448 | refresh = true;
|
||
449 | } |
||
450 | } |
||
451 | } |
||
452 | |||
453 | if (refresh) {
|
||
454 | refresh(); |
||
455 | } |
||
456 | } |
||
457 | |||
458 | /**
|
||
459 | * It returns the point that represents the northwest corner of the Layout.
|
||
460 | *
|
||
461 | * @return Point.
|
||
462 | */
|
||
463 | 9392 | caballero | public Point getRectOrigin() { |
464 | return rectOrigin;
|
||
465 | } |
||
466 | 10007 | caballero | |
467 | /**
|
||
468 | * Returns the object to draw the Layout.
|
||
469 | *
|
||
470 | * @return FLayoutDraw.
|
||
471 | */
|
||
472 | 9392 | caballero | public FLayoutDraw getLayoutDraw() {
|
473 | 10007 | caballero | return layoutDraw;
|
474 | } |
||
475 | |||
476 | /**
|
||
477 | * Returns the current Layout tool.
|
||
478 | 9392 | caballero | *
|
479 | 10007 | caballero | * @return LayoutBehavior Current Layout Tool.
|
480 | 9392 | caballero | */
|
481 | 10007 | caballero | public LayoutBehavior getCurrentLayoutTool() {
|
482 | return currentLayoutTool;
|
||
483 | } |
||
484 | |||
485 | /**
|
||
486 | * It returns the first click point of mouse.
|
||
487 | *
|
||
488 | * @return Point.
|
||
489 | */
|
||
490 | 9392 | caballero | public Point getFirstPoint() { |
491 | return m_FirstPoint;
|
||
492 | } |
||
493 | |||
494 | /**
|
||
495 | 10007 | caballero | * Returns the previous click of mouse.
|
496 | *
|
||
497 | * @return Point.
|
||
498 | */
|
||
499 | 9392 | caballero | public Point getPointAnt() { |
500 | return m_PointAnt;
|
||
501 | } |
||
502 | |||
503 | /**
|
||
504 | 10007 | caballero | * Returns the last click point of mouse.
|
505 | *
|
||
506 | * @return Point.
|
||
507 | */
|
||
508 | 9392 | caballero | public Point getLastPoint() { |
509 | return m_LastPoint;
|
||
510 | } |
||
511 | |||
512 | /**
|
||
513 | 10007 | caballero | * Inserts the first click point of mouse.
|
514 | *
|
||
515 | * @param p
|
||
516 | * Point.
|
||
517 | */
|
||
518 | 9392 | caballero | public void setFirstPoint() { |
519 | 10007 | caballero | m_FirstPoint = position; |
520 | 9392 | caballero | } |
521 | |||
522 | /**
|
||
523 | 10007 | caballero | * Inserts the previous click point of mouse.
|
524 | *
|
||
525 | * @param p
|
||
526 | * Point.
|
||
527 | */
|
||
528 | 9392 | caballero | public void setPointAnt() { |
529 | 10007 | caballero | m_PointAnt = position; |
530 | 9392 | caballero | } |
531 | |||
532 | /**
|
||
533 | 10007 | caballero | * Inserts the last click point of mouse.
|
534 | *
|
||
535 | * @param p
|
||
536 | * Point.
|
||
537 | */
|
||
538 | public void setLastPoint() { |
||
539 | m_LastPoint = position; |
||
540 | } |
||
541 | |||
542 | /**
|
||
543 | * Insert the position point and calculate the new position if the grid is actived.
|
||
544 | 9392 | caballero | *
|
545 | 10007 | caballero | * @param point2 Position.
|
546 | 9392 | caballero | */
|
547 | public void setPosition(Point point2) { |
||
548 | 10007 | caballero | if (layoutContext.isAdjustingToGrid() &&
|
549 | getCurrentLayoutTool().isAdjustable()) { |
||
550 | position = FLayoutUtilities.getPointGrid(point2, |
||
551 | layoutContext.getAtributes().getNumUnitsX(), |
||
552 | layoutContext.getAtributes().getNumUnitsY(), |
||
553 | layoutContext.getAT()); |
||
554 | } else {
|
||
555 | position = point2; |
||
556 | 9392 | caballero | } |
557 | } |
||
558 | 10007 | caballero | |
559 | /**
|
||
560 | * Returns the position adjusted point.
|
||
561 | 9392 | caballero | *
|
562 | 10007 | caballero | * @return
|
563 | 9392 | caballero | */
|
564 | 10007 | caballero | public Point getPosition() { |
565 | return position;
|
||
566 | } |
||
567 | |||
568 | /**
|
||
569 | * Returns the AffineTransform that is applying in the Layout.
|
||
570 | *
|
||
571 | * @return AffineTransform
|
||
572 | */
|
||
573 | 9392 | caballero | public AffineTransform getAT() { |
574 | 9806 | caballero | return layoutContext.getAT();
|
575 | 9392 | caballero | } |
576 | 10007 | caballero | |
577 | /**
|
||
578 | * It returns the current GeometryAdapter.
|
||
579 | * @return Current GeometryAdapter.
|
||
580 | */
|
||
581 | 9392 | caballero | public GeometryAdapter getGeometryAdapter() {
|
582 | return geometryAdapter;
|
||
583 | } |
||
584 | 10007 | caballero | |
585 | /**
|
||
586 | * Remove last point of geometryAdapter.
|
||
587 | *
|
||
588 | */
|
||
589 | 9392 | caballero | public void delLastPoint() { |
590 | getGeometryAdapter().delLastPoint(); |
||
591 | } |
||
592 | 10007 | caballero | |
593 | /**
|
||
594 | * Add a new point to geometryAdapter.
|
||
595 | *
|
||
596 | * @return Number of points in the geometryAdapter.
|
||
597 | */
|
||
598 | 9392 | caballero | public int addGeometryAdapterPoint() { |
599 | 10007 | caballero | return getGeometryAdapter().addPoint(FLayoutUtilities.toSheetPoint(
|
600 | getPosition(), getAT())); |
||
601 | 9392 | caballero | } |
602 | |||
603 | 10007 | caballero | /**
|
604 | * Change the position of mousemoved point of geometryAdapter.
|
||
605 | */
|
||
606 | 9392 | caballero | public void setGeometryAdapterPoinPosition() { |
607 | 10007 | caballero | getGeometryAdapter().pointPosition(FLayoutUtilities.toSheetPoint( |
608 | getPosition(), getAT())); |
||
609 | 9392 | caballero | } |
610 | |||
611 | 10007 | caballero | /**
|
612 | * Clear the image of pointer of mouse.
|
||
613 | */
|
||
614 | 28247 | vcaballero | // public void clearMouseImage() {
|
615 | // setCursor(transparentCursor);
|
||
616 | // }
|
||
617 | 9392 | caballero | |
618 | 10007 | caballero | /**
|
619 | * Refres the Layout.
|
||
620 | 9392 | caballero | */
|
621 | 10007 | caballero | public void refresh() { |
622 | setStatus(LayoutControl.DESACTUALIZADO); |
||
623 | repaint(); |
||
624 | } |
||
625 | |||
626 | /**
|
||
627 | * It returns true if the drawing has been canceled.
|
||
628 | *
|
||
629 | * @return true if the drawn has been canceled.
|
||
630 | */
|
||
631 | 9392 | caballero | public synchronized boolean isDrawingCancelled() { |
632 | return m_bCancelDrawing;
|
||
633 | } |
||
634 | |||
635 | /**
|
||
636 | 10007 | caballero | * It cancels the drawing if the parameter is true.
|
637 | *
|
||
638 | * @param b true if the drawing wants to be canceled
|
||
639 | */
|
||
640 | 9392 | caballero | public synchronized void setCancelDrawing(boolean b) { |
641 | m_bCancelDrawing = b; |
||
642 | |||
643 | for (int i = 0; i < layoutContext.getFFrames().length; i++) { |
||
644 | IFFrame fframe = layoutContext.getFFrame(i); |
||
645 | |||
646 | 10007 | caballero | if (fframe instanceof IFFrameUseFMap && |
647 | (((IFFrameUseFMap) fframe).getMapContext() != null)) {
|
||
648 | 9392 | caballero | // //TODO((FFrameView)
|
649 | // getFFrames().get(i)).getFMap().setCancelDrawing(b);
|
||
650 | } |
||
651 | } |
||
652 | } |
||
653 | 9806 | caballero | |
654 | 9392 | caballero | /**
|
655 | 10007 | caballero | * Returns the rectangle of selection.
|
656 | *
|
||
657 | * @return Rectangle of selection.
|
||
658 | */
|
||
659 | 9392 | caballero | public Rectangle getReSel() { |
660 | return reSel;
|
||
661 | } |
||
662 | |||
663 | /**
|
||
664 | 10007 | caballero | * It returns true if should draw the rectangle of selection and does the selection.
|
665 | *
|
||
666 | * @return true if should draw the rectangle of selection.
|
||
667 | */
|
||
668 | 9392 | caballero | public boolean isReSel() { |
669 | return isReSel;
|
||
670 | } |
||
671 | |||
672 | /**
|
||
673 | 10007 | caballero | * Insert true if should draw the rectangle of selection and does the selection.
|
674 | *
|
||
675 | * @param b boolean.
|
||
676 | */
|
||
677 | 9392 | caballero | public void setIsReSel(boolean b) { |
678 | isReSel = b; |
||
679 | } |
||
680 | |||
681 | /**
|
||
682 | 10007 | caballero | * It does a full extent of the layers that contains the view of the
|
683 | * FFrameView selected.
|
||
684 | *
|
||
685 | 10661 | caballero | * @throws ReadDriverException
|
686 | 10007 | caballero | */
|
687 | 10626 | caballero | public void viewFull() throws ReadDriverException { |
688 | 9392 | caballero | IFFrame[] fframes = layoutContext.getFFrameSelected();
|
689 | 10007 | caballero | |
690 | 9392 | caballero | for (int i = 0; i < fframes.length; i++) { |
691 | if (fframes[i] instanceof IFFrameUseFMap) { |
||
692 | IFFrameUseFMap fframe = (IFFrameUseFMap) fframes[i]; |
||
693 | |||
694 | if (fframe.getMapContext() != null) { |
||
695 | fframe.fullExtent(); |
||
696 | } |
||
697 | 10007 | caballero | |
698 | 9392 | caballero | fframe.refresh(); |
699 | } |
||
700 | } |
||
701 | 10007 | caballero | |
702 | 9392 | caballero | refresh(); |
703 | } |
||
704 | |||
705 | 10007 | caballero | /**
|
706 | * Returns the object to make zooms.
|
||
707 | *
|
||
708 | * @return FLayoutZooms.
|
||
709 | */
|
||
710 | 9392 | caballero | public FLayoutZooms getLayoutZooms() {
|
711 | 10007 | caballero | return layoutZooms;
|
712 | } |
||
713 | 9392 | caballero | |
714 | 10007 | caballero | /**
|
715 | * Returns the object of FLayoutFunctions.
|
||
716 | *
|
||
717 | * @return FLayoutFunctions
|
||
718 | */
|
||
719 | public FLayoutFunctions getLayoutFunctions() {
|
||
720 | return layoutFunctions;
|
||
721 | } |
||
722 | 9392 | caballero | |
723 | 10007 | caballero | /**
|
724 | * Returns the LayoutContext.
|
||
725 | *
|
||
726 | * @return LayoutContext.
|
||
727 | */
|
||
728 | public LayoutContext getLayoutContext() {
|
||
729 | return layoutContext;
|
||
730 | } |
||
731 | |||
732 | /**
|
||
733 | * Inserts the geometryAdapter.
|
||
734 | *
|
||
735 | * @param adapter GeometryAdapter.
|
||
736 | */
|
||
737 | public void setGeometryAdapter(GeometryAdapter adapter) { |
||
738 | geometryAdapter = adapter; |
||
739 | } |
||
740 | 9392 | caballero | } |