svn-document-layout / trunk / org.gvsig.app.document.layout2.app / org.gvsig.app.document.layout2.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / tools / LayoutEditGraphicsListenerImpl.java @ 772
History | View | Annotate | Download (5.15 KB)
1 | 5 | jldominguez | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | *
|
||
3 | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
||
4 | * of the Valencian Government (CIT)
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | */
|
||
22 | package org.gvsig.app.project.documents.layout.tools; |
||
23 | |||
24 | import java.awt.Image; |
||
25 | |||
26 | import org.gvsig.andami.PluginServices; |
||
27 | import org.gvsig.app.project.documents.layout.FLayoutUtilities; |
||
28 | import org.gvsig.app.project.documents.layout.fframes.IFFrame; |
||
29 | import org.gvsig.app.project.documents.layout.fframes.IFFrameEditableVertex; |
||
30 | import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
||
31 | import org.gvsig.app.project.documents.layout.tools.listener.LayoutMoveListener; |
||
32 | import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
||
33 | import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
||
34 | |||
35 | /**
|
||
36 | * Implementaci�n de la interfaz LayoutMoveListener como herramienta para
|
||
37 | * editar
|
||
38 | * una geometr�a.
|
||
39 | *
|
||
40 | * @author Vicente Caballero Navarro
|
||
41 | */
|
||
42 | public class LayoutEditGraphicsListenerImpl extends AbstractLayoutToolListener |
||
43 | implements LayoutMoveListener {
|
||
44 | |||
45 | public static final Image icrux = PluginServices.getIconTheme() |
||
46 | 24 | jldominguez | .get("cursor-layout-graphic-edit-vertex").getImage();
|
47 | 5 | jldominguez | |
48 | /**
|
||
49 | * Crea un nuevo LayoutSelectionListenerImpl.
|
||
50 | *
|
||
51 | * @param l
|
||
52 | * Layout.
|
||
53 | */
|
||
54 | public LayoutEditGraphicsListenerImpl(LayoutPanel layoutPanel) {
|
||
55 | super(layoutPanel);
|
||
56 | } |
||
57 | |||
58 | /**
|
||
59 | * @see org.gvsig.fmap.mapcontrol.tools.Listeners.PanListener#move(java.awt.geom.Point2D,
|
||
60 | * java.awt.geom.Point2D)
|
||
61 | */
|
||
62 | public void drag(PointEvent event) { |
||
63 | IFFrame[] fframes = layoutPanel.getLayoutContext().getFFrames();
|
||
64 | for (int i = 0; i < fframes.length; i++) { |
||
65 | IFFrame frame = fframes[i]; |
||
66 | if (frame instanceof IFFrameEditableVertex) { |
||
67 | ((IFFrameEditableVertex) frame).pointDragged(FLayoutUtilities |
||
68 | .toSheetPoint(event.getPoint(), layoutPanel |
||
69 | .getLayoutControl().getAT())); |
||
70 | } |
||
71 | } |
||
72 | } |
||
73 | |||
74 | /**
|
||
75 | * @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getCursor()
|
||
76 | */
|
||
77 | public Image getImageCursor() { |
||
78 | return icrux;
|
||
79 | } |
||
80 | |||
81 | /**
|
||
82 | * @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#cancelDrawing()
|
||
83 | */
|
||
84 | public boolean cancelDrawing() { |
||
85 | return true; |
||
86 | } |
||
87 | |||
88 | public void press(PointEvent event) throws BehaviorException { |
||
89 | IFFrame[] fframes = layoutPanel.getLayoutContext().getFFrames();
|
||
90 | for (int i = 0; i < fframes.length; i++) { |
||
91 | IFFrame frame = fframes[i]; |
||
92 | if (frame instanceof IFFrameEditableVertex) { |
||
93 | ((IFFrameEditableVertex) frame).pointPressed(FLayoutUtilities |
||
94 | .toSheetPoint(event.getPoint(), layoutPanel |
||
95 | .getLayoutControl().getAT())); |
||
96 | } |
||
97 | } |
||
98 | } |
||
99 | |||
100 | public void release(PointEvent event) throws BehaviorException { |
||
101 | IFFrame[] fframes = layoutPanel.getLayoutContext().getFFrames();
|
||
102 | for (int i = 0; i < fframes.length; i++) { |
||
103 | IFFrame frame = fframes[i]; |
||
104 | if (frame instanceof IFFrameEditableVertex) { |
||
105 | if (frame.getSelected() != IFFrame.NOSELECT
|
||
106 | && ((IFFrameEditableVertex) frame).isEditing()) { |
||
107 | IFFrame fframeAux; |
||
108 | try {
|
||
109 | fframeAux = (IFFrame) frame.clone(); |
||
110 | ((IFFrameEditableVertex) fframeAux).startEditing(); |
||
111 | ((IFFrameEditableVertex) fframeAux).pointReleased( |
||
112 | FLayoutUtilities.toSheetPoint(event.getPoint(), |
||
113 | layoutPanel.getLayoutControl().getAT()), |
||
114 | ((IFFrameEditableVertex) frame).getGeometry()); |
||
115 | layoutPanel.getLayoutContext().getFrameCommandsRecord() |
||
116 | .update(frame, fframeAux); |
||
117 | fframeAux.getBoundingBox(layoutPanel.getLayoutControl() |
||
118 | .getAT()); |
||
119 | layoutPanel.getLayoutContext().updateFFrames(); |
||
120 | } catch (CloneNotSupportedException e) { |
||
121 | throw new BehaviorException( |
||
122 | "It is not possible to clone the object", e);
|
||
123 | } |
||
124 | } |
||
125 | } |
||
126 | } |
||
127 | layoutPanel.getLayoutControl().refresh(); |
||
128 | } |
||
129 | |||
130 | public void click(PointEvent event) { |
||
131 | } |
||
132 | |||
133 | public void move(PointEvent event) throws BehaviorException { |
||
134 | } |
||
135 | |||
136 | } |