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