root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / layout / LayoutControl.java @ 28247
History | View | Annotate | Download (22.6 KB)
1 |
package com.iver.cit.gvsig.project.documents.layout; |
---|---|
2 |
|
3 |
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 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
20 |
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 |
import com.iver.cit.gvsig.project.documents.layout.gui.FPopupMenu; |
26 |
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 |
import com.iver.cit.gvsig.project.documents.layout.tools.behavior.LayoutViewZoomBehavior; |
57 |
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 |
|
61 |
/**
|
62 |
* Control of Layout.
|
63 |
*
|
64 |
* @author Vicente Caballero Navarro
|
65 |
*/
|
66 |
public class LayoutControl extends JComponent implements LayoutDrawListener { |
67 |
public static final int DESACTUALIZADO = 4; |
68 |
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 |
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 |
|
91 |
//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 |
|
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 |
/**
|
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 |
|
118 |
layoutContext.updateFFrames(); |
119 |
|
120 |
LayoutPanListenerImpl lpl = new LayoutPanListenerImpl(layout);
|
121 |
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 |
addLayoutTool("layoutaddrectangle",
|
170 |
new LayoutPointBehavior(larectanglel));
|
171 |
|
172 |
LayoutViewPanListenerImpl lvpl = new LayoutViewPanListenerImpl(layout);
|
173 |
addLayoutTool("layoutviewpan", new LayoutViewMoveBehavior(lvpl)); |
174 |
|
175 |
LayoutViewZoomInListenerImpl lvzil = new LayoutViewZoomInListenerImpl(layout);
|
176 |
addLayoutTool("layoutviewzoomin", new LayoutViewZoomBehavior(lvzil)); |
177 |
|
178 |
LayoutViewZoomOutListenerImpl lvzol = new LayoutViewZoomOutListenerImpl(layout);
|
179 |
addLayoutTool("layoutviewzoomout", new LayoutViewZoomBehavior(lvzol)); |
180 |
|
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 |
FPopupMenu.registerExtensionPoint(); |
189 |
} |
190 |
|
191 |
/**
|
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 |
public void addLayoutTool(String name, LayoutBehavior tool) { |
207 |
namesLayoutTools.put(name, tool); |
208 |
tool.setLayoutControl(this);
|
209 |
} |
210 |
|
211 |
/**
|
212 |
* Inserts the LayoutContext.
|
213 |
*
|
214 |
* @param lc LayoutContext.
|
215 |
*/
|
216 |
public void setLayoutContext(LayoutContext lc) { |
217 |
layoutContext = lc; |
218 |
layoutContext.addLayoutDrawListener(this);
|
219 |
} |
220 |
|
221 |
/**
|
222 |
* paintComponent of Layout.
|
223 |
*
|
224 |
* @param g Graphics of Layout.
|
225 |
*/
|
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 |
case DESACTUALIZADO:
|
237 |
if (getWidth() == 0) { |
238 |
return;
|
239 |
} |
240 |
|
241 |
img = new BufferedImage(getWidth(), getHeight(), |
242 |
BufferedImage.TYPE_INT_ARGB);
|
243 |
imgRuler = new BufferedImage(getWidth(), getHeight(), |
244 |
BufferedImage.TYPE_INT_ARGB);
|
245 |
|
246 |
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 |
} catch (ReadDriverException e) {
|
258 |
e.printStackTrace(); |
259 |
} |
260 |
|
261 |
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 |
|
272 |
break;
|
273 |
|
274 |
case ACTUALIZADO:
|
275 |
layoutDraw.drawRectangle((Graphics2D) g);
|
276 |
|
277 |
if (currentLayoutTool != null) { |
278 |
currentLayoutTool.paintComponent(g); |
279 |
} else {
|
280 |
g.drawImage(img, 0, 0, this); |
281 |
|
282 |
layoutDraw.drawHandlers((Graphics2D) g, Color.black); |
283 |
} |
284 |
|
285 |
g.setClip(rClip); |
286 |
// drawCursor(g);
|
287 |
} |
288 |
} |
289 |
|
290 |
/**
|
291 |
* Inserts the status of Layout.
|
292 |
*
|
293 |
* @param s Status of Layout.
|
294 |
*/
|
295 |
public void setStatus(int s) { |
296 |
status = s; |
297 |
} |
298 |
|
299 |
/**
|
300 |
* Clip on visible rectangle.
|
301 |
*
|
302 |
* @param g2d Graphics.
|
303 |
*/
|
304 |
private void clipVisibleRect(Graphics2D g2d) { |
305 |
rectVisible = this.getVisibleRect();
|
306 |
g2d.clipRect((int) rectVisible.getMinX(), (int) rectVisible.getMinY(), |
307 |
(int) rectVisible.getWidth(), (int) rectVisible.getHeight()); |
308 |
} |
309 |
|
310 |
/**
|
311 |
* Returns the image with the ruler.
|
312 |
*
|
313 |
* @return Ruler image.
|
314 |
*/
|
315 |
public BufferedImage getImgRuler() { |
316 |
return imgRuler;
|
317 |
} |
318 |
|
319 |
/**
|
320 |
* It obtains the rect that is adjusted to the size of the window,
|
321 |
* to see the full extent of layout.
|
322 |
*/
|
323 |
public void fullRect() { |
324 |
rect.setRect(origin.x, origin.y, getWidth() - (origin.x * 2),
|
325 |
getHeight() - (origin.x * 2));
|
326 |
|
327 |
if (layoutContext.getAtributes().isLandSpace()) {
|
328 |
rect = layoutContext.getAtributes().getRectangleLandscape(rect, |
329 |
getWidth(), getHeight()); |
330 |
} else {
|
331 |
rect = layoutContext.getAtributes().getRectanglePortrait(rect, |
332 |
getWidth(), getHeight()); |
333 |
} |
334 |
|
335 |
refresh(); |
336 |
} |
337 |
|
338 |
/**
|
339 |
* Returns the rectangle that represents the sheet.
|
340 |
* In pixels.
|
341 |
*
|
342 |
* @return Rectangle2D.Double Rectangle that represents the sheet.
|
343 |
*/
|
344 |
public Rectangle2D.Double getRect() { |
345 |
return rect;
|
346 |
} |
347 |
|
348 |
/**
|
349 |
* Inserts the rectangle that represents the sheet.
|
350 |
* In pixels.
|
351 |
*
|
352 |
*/
|
353 |
public void setRect(Rectangle2D r) { |
354 |
rect.setRect(r); |
355 |
} |
356 |
|
357 |
/**
|
358 |
* Returns the current image of Layout.
|
359 |
*
|
360 |
* @return Current image of Layout.
|
361 |
*/
|
362 |
public BufferedImage getImage() { |
363 |
return img;
|
364 |
} |
365 |
|
366 |
/**
|
367 |
* Draw the cursor on the Graphics.
|
368 |
*
|
369 |
* @param g Graphics.
|
370 |
*/
|
371 |
private void drawCursor(Graphics g) { |
372 |
if ((imageCursor != null) && (position != null)) { |
373 |
Point pAdjusted = position;
|
374 |
g.drawImage(imageCursor, (int) pAdjusted.getX() - 16, |
375 |
(int) pAdjusted.getY() - 16, this); |
376 |
} |
377 |
} |
378 |
|
379 |
/**
|
380 |
* Changes the pointer of the mouse by the image of parameter.
|
381 |
*
|
382 |
* @param image Image
|
383 |
*/
|
384 |
public void setMapCursor(Cursor cursor) { |
385 |
this.setCursor(cursor);
|
386 |
} |
387 |
|
388 |
/**
|
389 |
* It establishes as selected to the tool from its name of identification.
|
390 |
*
|
391 |
* @param toolName Name of identification tool.
|
392 |
*/
|
393 |
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.getCursor());
|
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 |
} |
412 |
|
413 |
/**
|
414 |
* Start the vertex edition of graphics.
|
415 |
*
|
416 |
*/
|
417 |
public void startEdit() { |
418 |
IFFrame[] fframes = layoutContext.getFFrames();
|
419 |
|
420 |
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 |
public Point getRectOrigin() { |
465 |
return rectOrigin;
|
466 |
} |
467 |
|
468 |
/**
|
469 |
* Returns the object to draw the Layout.
|
470 |
*
|
471 |
* @return FLayoutDraw.
|
472 |
*/
|
473 |
public FLayoutDraw getLayoutDraw() {
|
474 |
return layoutDraw;
|
475 |
} |
476 |
|
477 |
/**
|
478 |
* Returns the current Layout tool.
|
479 |
*
|
480 |
* @return LayoutBehavior Current Layout Tool.
|
481 |
*/
|
482 |
public LayoutBehavior getCurrentLayoutTool() {
|
483 |
return currentLayoutTool;
|
484 |
} |
485 |
|
486 |
/**
|
487 |
* It returns the first click point of mouse.
|
488 |
*
|
489 |
* @return Point.
|
490 |
*/
|
491 |
public Point getFirstPoint() { |
492 |
return m_FirstPoint;
|
493 |
} |
494 |
|
495 |
/**
|
496 |
* Returns the previous click of mouse.
|
497 |
*
|
498 |
* @return Point.
|
499 |
*/
|
500 |
public Point getPointAnt() { |
501 |
return m_PointAnt;
|
502 |
} |
503 |
|
504 |
/**
|
505 |
* Returns the last click point of mouse.
|
506 |
*
|
507 |
* @return Point.
|
508 |
*/
|
509 |
public Point getLastPoint() { |
510 |
return m_LastPoint;
|
511 |
} |
512 |
|
513 |
/**
|
514 |
* Inserts the first click point of mouse.
|
515 |
*
|
516 |
* @param p
|
517 |
* Point.
|
518 |
*/
|
519 |
public void setFirstPoint() { |
520 |
m_FirstPoint = position; |
521 |
} |
522 |
|
523 |
/**
|
524 |
* Inserts the previous click point of mouse.
|
525 |
*
|
526 |
* @param p
|
527 |
* Point.
|
528 |
*/
|
529 |
public void setPointAnt() { |
530 |
m_PointAnt = position; |
531 |
} |
532 |
|
533 |
/**
|
534 |
* 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 |
*
|
546 |
* @param point2 Position.
|
547 |
*/
|
548 |
public void setPosition(Point point2) { |
549 |
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 |
} |
558 |
} |
559 |
|
560 |
/**
|
561 |
* Returns the position adjusted point.
|
562 |
*
|
563 |
* @return
|
564 |
*/
|
565 |
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 |
public AffineTransform getAT() { |
575 |
return layoutContext.getAT();
|
576 |
} |
577 |
|
578 |
/**
|
579 |
* It returns the current GeometryAdapter.
|
580 |
* @return Current GeometryAdapter.
|
581 |
*/
|
582 |
public GeometryAdapter getGeometryAdapter() {
|
583 |
return geometryAdapter;
|
584 |
} |
585 |
|
586 |
/**
|
587 |
* Remove last point of geometryAdapter.
|
588 |
*
|
589 |
*/
|
590 |
public void delLastPoint() { |
591 |
getGeometryAdapter().delLastPoint(); |
592 |
} |
593 |
|
594 |
/**
|
595 |
* Add a new point to geometryAdapter.
|
596 |
*
|
597 |
* @return Number of points in the geometryAdapter.
|
598 |
*/
|
599 |
public int addGeometryAdapterPoint() { |
600 |
return getGeometryAdapter().addPoint(FLayoutUtilities.toSheetPoint(
|
601 |
getPosition(), getAT())); |
602 |
} |
603 |
|
604 |
/**
|
605 |
* Change the position of mousemoved point of geometryAdapter.
|
606 |
*/
|
607 |
public void setGeometryAdapterPoinPosition() { |
608 |
getGeometryAdapter().pointPosition(FLayoutUtilities.toSheetPoint( |
609 |
getPosition(), getAT())); |
610 |
} |
611 |
|
612 |
/**
|
613 |
* Clear the image of pointer of mouse.
|
614 |
*/
|
615 |
// public void clearMouseImage() {
|
616 |
// setCursor(transparentCursor);
|
617 |
// }
|
618 |
|
619 |
/**
|
620 |
* Refres the Layout.
|
621 |
*/
|
622 |
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 |
public synchronized boolean isDrawingCancelled() { |
633 |
return m_bCancelDrawing;
|
634 |
} |
635 |
|
636 |
/**
|
637 |
* It cancels the drawing if the parameter is true.
|
638 |
*
|
639 |
* @param b true if the drawing wants to be canceled
|
640 |
*/
|
641 |
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 |
if (fframe instanceof IFFrameUseFMap && |
648 |
(((IFFrameUseFMap) fframe).getMapContext() != null)) {
|
649 |
// //TODO((FFrameView)
|
650 |
// getFFrames().get(i)).getFMap().setCancelDrawing(b);
|
651 |
} |
652 |
} |
653 |
} |
654 |
|
655 |
/**
|
656 |
* Returns the rectangle of selection.
|
657 |
*
|
658 |
* @return Rectangle of selection.
|
659 |
*/
|
660 |
public Rectangle getReSel() { |
661 |
return reSel;
|
662 |
} |
663 |
|
664 |
/**
|
665 |
* 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 |
public boolean isReSel() { |
670 |
return isReSel;
|
671 |
} |
672 |
|
673 |
/**
|
674 |
* Insert true if should draw the rectangle of selection and does the selection.
|
675 |
*
|
676 |
* @param b boolean.
|
677 |
*/
|
678 |
public void setIsReSel(boolean b) { |
679 |
isReSel = b; |
680 |
} |
681 |
|
682 |
/**
|
683 |
* It does a full extent of the layers that contains the view of the
|
684 |
* FFrameView selected.
|
685 |
*
|
686 |
* @throws ReadDriverException
|
687 |
*/
|
688 |
public void viewFull() throws ReadDriverException { |
689 |
IFFrame[] fframes = layoutContext.getFFrameSelected();
|
690 |
|
691 |
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 |
|
699 |
fframe.refresh(); |
700 |
} |
701 |
} |
702 |
|
703 |
refresh(); |
704 |
} |
705 |
|
706 |
/**
|
707 |
* Returns the object to make zooms.
|
708 |
*
|
709 |
* @return FLayoutZooms.
|
710 |
*/
|
711 |
public FLayoutZooms getLayoutZooms() {
|
712 |
return layoutZooms;
|
713 |
} |
714 |
|
715 |
/**
|
716 |
* Returns the object of FLayoutFunctions.
|
717 |
*
|
718 |
* @return FLayoutFunctions
|
719 |
*/
|
720 |
public FLayoutFunctions getLayoutFunctions() {
|
721 |
return layoutFunctions;
|
722 |
} |
723 |
|
724 |
/**
|
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 |
} |