svn-document-layout / tags / 2059 / org.gvsig.app.document.layout.app.mainplugin / src / main / java / org / gvsig / app / project / documents / layout / tools / LayoutEditGraphicsListenerImpl.java @ 46
History | View | Annotate | Download (5.2 KB)
1 |
/* 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 |
.get("cursor-layout-graphic-edit-vertex").getImage();
|
47 |
|
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 |
// layout.setStatus(Layout.GRAPHICS);
|
71 |
|
72 |
} |
73 |
} |
74 |
} |
75 |
|
76 |
/**
|
77 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#getCursor()
|
78 |
*/
|
79 |
public Image getImageCursor() { |
80 |
return icrux;
|
81 |
} |
82 |
|
83 |
/**
|
84 |
* @see org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener#cancelDrawing()
|
85 |
*/
|
86 |
public boolean cancelDrawing() { |
87 |
return true; |
88 |
} |
89 |
|
90 |
public void press(PointEvent event) throws BehaviorException { |
91 |
IFFrame[] fframes = layoutPanel.getLayoutContext().getFFrames();
|
92 |
for (int i = 0; i < fframes.length; i++) { |
93 |
IFFrame frame = fframes[i]; |
94 |
if (frame instanceof IFFrameEditableVertex) { |
95 |
((IFFrameEditableVertex) frame).pointPressed(FLayoutUtilities |
96 |
.toSheetPoint(event.getPoint(), layoutPanel |
97 |
.getLayoutControl().getAT())); |
98 |
} |
99 |
} |
100 |
} |
101 |
|
102 |
public void release(PointEvent event) throws BehaviorException { |
103 |
IFFrame[] fframes = layoutPanel.getLayoutContext().getFFrames();
|
104 |
for (int i = 0; i < fframes.length; i++) { |
105 |
IFFrame frame = fframes[i]; |
106 |
if (frame instanceof IFFrameEditableVertex) { |
107 |
if (frame.getSelected() != IFFrame.NOSELECT
|
108 |
&& ((IFFrameEditableVertex) frame).isEditing()) { |
109 |
IFFrame fframeAux; |
110 |
try {
|
111 |
fframeAux = (IFFrame) frame.clone(); |
112 |
((IFFrameEditableVertex) fframeAux).startEditing(); |
113 |
((IFFrameEditableVertex) fframeAux).pointReleased( |
114 |
FLayoutUtilities.toSheetPoint(event.getPoint(), |
115 |
layoutPanel.getLayoutControl().getAT()), |
116 |
((IFFrameEditableVertex) frame).getGeometry()); |
117 |
layoutPanel.getLayoutContext().getFrameCommandsRecord() |
118 |
.update(frame, fframeAux); |
119 |
fframeAux.getBoundingBox(layoutPanel.getLayoutControl() |
120 |
.getAT()); |
121 |
layoutPanel.getLayoutContext().updateFFrames(); |
122 |
} catch (CloneNotSupportedException e) { |
123 |
throw new BehaviorException( |
124 |
"It is not possible to clone the object", e);
|
125 |
} |
126 |
} |
127 |
} |
128 |
} |
129 |
layoutPanel.getLayoutControl().refresh(); |
130 |
} |
131 |
|
132 |
public void click(PointEvent event) { |
133 |
} |
134 |
|
135 |
public void move(PointEvent event) throws BehaviorException { |
136 |
} |
137 |
|
138 |
} |