Revision 26242
branches/v2_0_0_prep/extensions/extEditing/sm/ComplexSelectionCADTool.sm | ||
---|---|---|
9 | 9 |
%class ComplexSelectionCADTool |
10 | 10 |
%package com.iver.cit.gvsig.gui.cad.tools.smc |
11 | 11 |
%import com.iver.cit.gvsig.gui.cad.tools.ComplexSelectionCADTool |
12 |
%import com.iver.cit.gvsig.fmap.layers.FBitSet |
|
13 | 12 |
%import java.awt.event.InputEvent |
14 | 13 |
%import com.iver.andami.PluginServices |
15 | 14 |
|
branches/v2_0_0_prep/extensions/extEditing/sm/SelectionCADTool.sm | ||
---|---|---|
9 | 9 |
%class SelectionCADTool |
10 | 10 |
%package com.iver.cit.gvsig.gui.cad.tools.smc |
11 | 11 |
%import com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool |
12 |
%import com.iver.cit.gvsig.fmap.layers.FBitSet |
|
13 | 12 |
%import java.awt.event.InputEvent |
14 | 13 |
%import com.iver.andami.PluginServices |
15 | 14 |
|
branches/v2_0_0_prep/extensions/extEditing/sm/JoinCADTool.sm | ||
---|---|---|
1 |
// -*- tab-width: 4; -*- |
|
2 |
|
|
3 |
%{ |
|
4 |
// |
|
5 |
// Vicente Caballero Navarro |
|
6 |
%} |
|
7 |
|
|
8 |
%start Join::Execute |
|
9 |
%class JoinCADTool |
|
10 |
%package com.iver.cit.gvsig.gui.cad.tools.smc |
|
11 |
%import com.iver.cit.gvsig.gui.cad.tools.JoinCADTool |
|
12 |
%import java.awt.event.InputEvent |
|
13 |
%import com.iver.andami.PluginServices |
|
14 |
|
|
15 |
%map Join |
|
16 |
%% |
|
17 |
// A task begins life in suspended animation. |
|
18 |
|
|
19 |
Execute |
|
20 |
Entry { |
|
21 |
join(); |
|
22 |
end(); |
|
23 |
} |
|
24 |
Exit{ |
|
25 |
} |
|
26 |
|
|
27 |
{ |
|
28 |
} |
|
29 |
|
|
30 |
Default |
|
31 |
{ |
|
32 |
addOption(s:String) |
|
33 |
[s.equals(PluginServices.getText(this,"cancel"))] |
|
34 |
Execute{ |
|
35 |
end(); |
|
36 |
} |
|
37 |
addOption(s:String) |
|
38 |
Execute{ |
|
39 |
throwOptionException(PluginServices.getText(this,"incorrect_option"),s); |
|
40 |
} |
|
41 |
addValue(d:double) |
|
42 |
Execute{ |
|
43 |
throwValueException(PluginServices.getText(this,"incorrect_value"),d); |
|
44 |
} |
|
45 |
addPoint(pointX:double,pointY:double,event:InputEvent) |
|
46 |
Execute{ |
|
47 |
throwPointException(PluginServices.getText(this,"incorrect_point"),pointX,pointY); |
|
48 |
} |
|
49 |
} |
|
50 |
%% |
branches/v2_0_0_prep/extensions/extEditing/config/config.xml | ||
---|---|---|
169 | 169 |
<selectable-tool icon="edition-geometry-break" action-command="_break" tooltip="break" group="vista" position="9"/> |
170 | 170 |
</tool-bar> |
171 | 171 |
</extension--> |
172 |
<!--extension class-name="com.iver.cit.gvsig.JoinExtension"
|
|
172 |
<extension class-name="com.iver.cit.gvsig.JoinExtension" |
|
173 | 173 |
description="Extensi?n encargada de unir varias geometr?a en edici?n." |
174 | 174 |
active="true"> |
175 | 175 |
<menu text="geometry/modify/join" action-command="_join" icon="edition-geometry-Join"/> |
176 | 176 |
<tool-bar name="modificar" position="31"> |
177 | 177 |
<selectable-tool icon="edition-geometry-Join" action-command="_join" tooltip="join" group="vista" position="10"/> |
178 | 178 |
</tool-bar> |
179 |
</extension-->
|
|
179 |
</extension> |
|
180 | 180 |
<extension class-name="com.iver.cit.gvsig.InternalPolygonExtension" |
181 | 181 |
description="Extensi?n encargada de insertar poligonos internos en una capa en edici?n." |
182 | 182 |
active="true"> |
branches/v2_0_0_prep/extensions/extEditing/src/com/iver/cit/gvsig/StopEditing.java | ||
---|---|---|
213 | 213 |
FeatureTableDocumentPanel table = (FeatureTableDocumentPanel) views[j]; |
214 | 214 |
if (table.getModel().getAssociatedLayer() != null |
215 | 215 |
&& table.getModel().getAssociatedLayer().equals(layer)) { |
216 |
table.stopEditing(); |
|
216 |
// table.stopEditing();
|
|
217 | 217 |
} |
218 | 218 |
} |
219 | 219 |
} |
... | ... | |
260 | 260 |
FeatureTableDocumentPanel table = (FeatureTableDocumentPanel) views[j]; |
261 | 261 |
if (table.getModel().getAssociatedLayer() != null |
262 | 262 |
&& table.getModel().getAssociatedLayer().equals(layer)) { |
263 |
table.stopEditing(); |
|
263 |
// table.stopEditing();
|
|
264 | 264 |
} |
265 | 265 |
} |
266 | 266 |
} |
branches/v2_0_0_prep/extensions/extEditing/src/com/iver/cit/gvsig/JoinExtension.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig; |
|
42 |
|
|
43 |
import org.gvsig.fmap.dal.exception.DataException; |
|
44 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
45 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
46 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
47 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
48 |
|
|
49 |
import com.iver.andami.PluginServices; |
|
50 |
import com.iver.andami.messages.NotificationManager; |
|
51 |
import com.iver.andami.plugins.Extension; |
|
52 |
import com.iver.cit.gvsig.gui.cad.tools.JoinCADTool; |
|
53 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
|
54 |
|
|
55 |
/** |
|
56 |
* Extensi?n que gestiona la uni?n de geometr?as en edici?n. |
|
57 |
* |
|
58 |
* @author Vicente Caballero Navarro |
|
59 |
*/ |
|
60 |
public class JoinExtension extends Extension { |
|
61 |
private View view; |
|
62 |
|
|
63 |
private MapControl mapControl; |
|
64 |
private JoinCADTool joinCADTool; |
|
65 |
|
|
66 |
/** |
|
67 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
68 |
*/ |
|
69 |
public void initialize() { |
|
70 |
joinCADTool=new JoinCADTool(); |
|
71 |
CADExtension.addCADTool("_join",joinCADTool); |
|
72 |
|
|
73 |
registerIcons(); |
|
74 |
} |
|
75 |
|
|
76 |
private void registerIcons(){ |
|
77 |
PluginServices.getIconTheme().registerDefault( |
|
78 |
"edition-geometry-Join", |
|
79 |
this.getClass().getClassLoader().getResource("images/Join.png") |
|
80 |
); |
|
81 |
|
|
82 |
} |
|
83 |
/** |
|
84 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String) |
|
85 |
*/ |
|
86 |
public void execute(String s) { |
|
87 |
CADExtension.initFocus(); |
|
88 |
if (s.equals("_join")) { |
|
89 |
CADExtension.setCADTool(s,true); |
|
90 |
} |
|
91 |
CADExtension.getEditionManager().setMapControl(mapControl); |
|
92 |
CADExtension.getCADToolAdapter().configureMenu(); |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
97 |
*/ |
|
98 |
public boolean isEnabled() { |
|
99 |
|
|
100 |
try { |
|
101 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) { |
|
102 |
view = (View) PluginServices.getMDIManager().getActiveWindow(); |
|
103 |
mapControl = view.getMapControl(); |
|
104 |
if (CADExtension.getEditionManager().getActiveLayerEdited()==null) |
|
105 |
return false; |
|
106 |
FLyrVect lv=(FLyrVect)CADExtension.getEditionManager().getActiveLayerEdited().getLayer(); |
|
107 |
if (joinCADTool.isApplicable(lv.getShapeType()) && ((FeatureSelection)lv.getFeatureStore().getSelection()).getSize()>1){ |
|
108 |
return true; |
|
109 |
} |
|
110 |
} |
|
111 |
} catch (DataException e) { |
|
112 |
NotificationManager.addError(e.getMessage(),e); |
|
113 |
} |
|
114 |
return false; |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
119 |
*/ |
|
120 |
public boolean isVisible() { |
|
121 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) |
|
122 |
return true; |
|
123 |
return false; |
|
124 |
} |
|
125 |
} |
branches/v2_0_0_prep/extensions/extEditing/src/com/iver/cit/gvsig/gui/cad/tools/SelectionCADTool.java | ||
---|---|---|
128 | 128 |
_fsm.addPoint(x, y, event); |
129 | 129 |
}catch (Exception e) { |
130 | 130 |
init(); |
131 |
PluginServices.getMDIManager().restoreCursor(); |
|
131 | 132 |
} |
132 | 133 |
System.out.println("ESTADO ACTUAL: " + getStatus()); |
133 | 134 |
|
... | ... | |
474 | 475 |
|
475 | 476 |
String status = actualState.getName(); |
476 | 477 |
VectorialLayerEdited vle = getVLE(); |
478 |
multipleSelection=event.isControlDown(); |
|
477 | 479 |
|
478 |
|
|
479 | 480 |
if ((status.equals("Selection.FirstPoint")) |
480 | 481 |
|| (status.equals("Selection.WithSelectedFeatures"))) { |
481 | 482 |
PluginServices.getMDIManager().setWaitCursor(); |
branches/v2_0_0_prep/extensions/extEditing/src/com/iver/cit/gvsig/gui/cad/tools/JoinCADTool.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package com.iver.cit.gvsig.gui.cad.tools; |
|
42 |
|
|
43 |
import java.awt.Graphics; |
|
44 |
import java.awt.event.InputEvent; |
|
45 |
import java.util.ArrayList; |
|
46 |
import java.util.Iterator; |
|
47 |
|
|
48 |
import org.gvsig.fmap.dal.exception.DataException; |
|
49 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
50 |
import org.gvsig.fmap.dal.feature.EditableFeature; |
|
51 |
import org.gvsig.fmap.dal.feature.Feature; |
|
52 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
53 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
54 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeature; |
|
55 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
|
56 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
|
57 |
import org.gvsig.fmap.geom.operation.tojts.ToJTS; |
|
58 |
import org.gvsig.fmap.geom.util.Converter; |
|
59 |
import org.gvsig.fmap.geom.util.UtilFunctions; |
|
60 |
|
|
61 |
|
|
62 |
import com.iver.andami.PluginServices; |
|
63 |
import com.iver.andami.messages.NotificationManager; |
|
64 |
import com.iver.cit.gvsig.CADExtension; |
|
65 |
import com.iver.cit.gvsig.gui.cad.DefaultCADTool; |
|
66 |
import com.iver.cit.gvsig.gui.cad.exception.CommandException; |
|
67 |
import com.iver.cit.gvsig.gui.cad.tools.smc.JoinCADToolContext; |
|
68 |
import com.iver.cit.gvsig.layers.VectorialLayerEdited; |
|
69 |
import com.vividsolutions.jts.geom.Geometry; |
|
70 |
|
|
71 |
|
|
72 |
/** |
|
73 |
* DOCUMENT ME! |
|
74 |
* |
|
75 |
* @author Vicente Caballero Navarro |
|
76 |
*/ |
|
77 |
public class JoinCADTool extends DefaultCADTool { |
|
78 |
private JoinCADToolContext _fsm; |
|
79 |
|
|
80 |
/** |
|
81 |
* Crea un nuevo JoinCADTool. |
|
82 |
*/ |
|
83 |
public JoinCADTool() { |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* M?todo de inicio, para poner el c?digo de todo lo que se requiera de una |
|
88 |
* carga previa a la utilizaci?n de la herramienta. |
|
89 |
*/ |
|
90 |
public void init() { |
|
91 |
_fsm = new JoinCADToolContext(this); |
|
92 |
} |
|
93 |
|
|
94 |
/* (non-Javadoc) |
|
95 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double, double) |
|
96 |
*/ |
|
97 |
public void transition(double x, double y, InputEvent event) { |
|
98 |
_fsm.addPoint(x, y, event); |
|
99 |
} |
|
100 |
|
|
101 |
/* (non-Javadoc) |
|
102 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double) |
|
103 |
*/ |
|
104 |
public void transition(double d) { |
|
105 |
_fsm.addValue(d); |
|
106 |
} |
|
107 |
|
|
108 |
/* (non-Javadoc) |
|
109 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String) |
|
110 |
*/ |
|
111 |
public void transition(String s) throws CommandException { |
|
112 |
if (!super.changeCommand(s)){ |
|
113 |
_fsm.addOption(s); |
|
114 |
} |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* DOCUMENT ME! |
|
119 |
*/ |
|
120 |
public void selection() { |
|
121 |
FeatureSet selection = null; |
|
122 |
try { |
|
123 |
selection = (FeatureSet) getVLE().getFeatureStore().getSelection(); |
|
124 |
|
|
125 |
if (selection.getSize() == 0 |
|
126 |
&& !CADExtension |
|
127 |
.getCADTool() |
|
128 |
.getClass() |
|
129 |
.getName() |
|
130 |
.equals( |
|
131 |
"com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool")) { |
|
132 |
CADExtension.setCADTool("_selection", false); |
|
133 |
((SelectionCADTool) CADExtension.getCADTool()) |
|
134 |
.setNextTool("_join"); |
|
135 |
} |
|
136 |
} catch (ReadException e) { |
|
137 |
// TODO Auto-generated catch block |
|
138 |
e.printStackTrace(); |
|
139 |
} catch (DataException e) { |
|
140 |
// TODO Auto-generated catch block |
|
141 |
e.printStackTrace(); |
|
142 |
} |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* Equivale al transition del prototipo pero sin pasarle como par?metro el |
|
147 |
* editableFeatureSource que ya estar? creado. |
|
148 |
* |
|
149 |
* @param x par?metro x del punto que se pase en esta transici?n. |
|
150 |
* @param y par?metro y del punto que se pase en esta transici?n. |
|
151 |
*/ |
|
152 |
public void addPoint(double x, double y,InputEvent event) { |
|
153 |
} |
|
154 |
|
|
155 |
/** |
|
156 |
* M?todo para dibujar la lo necesario para el estado en el que nos |
|
157 |
* encontremos. |
|
158 |
* |
|
159 |
* @param g Graphics sobre el que dibujar. |
|
160 |
* @param x par?metro x del punto que se pase para dibujar. |
|
161 |
* @param y par?metro x del punto que se pase para dibujar. |
|
162 |
*/ |
|
163 |
public void drawOperation(Graphics g, double x, double y) { |
|
164 |
} |
|
165 |
public void join() { |
|
166 |
VectorialLayerEdited vle = getVLE(); |
|
167 |
FeatureStore featureStore = null; |
|
168 |
try { |
|
169 |
featureStore = vle.getFeatureStore(); |
|
170 |
} catch (ReadException e1) { |
|
171 |
NotificationManager.addError(e1.getMessage(),e1); |
|
172 |
} |
|
173 |
try { |
|
174 |
FeatureSet selection = (FeatureSet) featureStore.getSelection(); |
|
175 |
// getSelectedRows(); |
|
176 |
featureStore.beginEditingGroup(getName()); |
|
177 |
Geometry geomTotal=null; |
|
178 |
Iterator<Feature> features=selection.iterator(); |
|
179 |
boolean first=true; |
|
180 |
Feature firstFeature=null; |
|
181 |
while (features.hasNext()) { |
|
182 |
Feature feature = (Feature) features.next(); |
|
183 |
if (first){ |
|
184 |
firstFeature=feature; |
|
185 |
first=false; |
|
186 |
} |
|
187 |
|
|
188 |
org.gvsig.fmap.geom.Geometry geom = ((org.gvsig.fmap.geom.Geometry) feature |
|
189 |
.getDefaultGeometry()).cloneGeometry(); |
|
190 |
featureStore.delete(feature); |
|
191 |
if (geomTotal==null){ |
|
192 |
geomTotal=(Geometry)geom.invokeOperation(ToJTS.CODE, null); |
|
193 |
}else{ |
|
194 |
Geometry geomJTS=(Geometry)geom.invokeOperation(ToJTS.CODE, null); |
|
195 |
geomTotal=geomTotal.union(geomJTS); |
|
196 |
} |
|
197 |
} |
|
198 |
|
|
199 |
EditableFeature eFeature = featureStore.createNewFeature(firstFeature |
|
200 |
.getType(), firstFeature); |
|
201 |
eFeature.setGeometry(featureStore.getDefaultFeatureType() |
|
202 |
.getDefaultGeometryAttributeName(), Converter.jtsToGeometry(geomTotal)); |
|
203 |
featureStore.insert(eFeature); |
|
204 |
refresh(); |
|
205 |
} catch (DataException e) { |
|
206 |
NotificationManager.addError(e.getMessage(),e); |
|
207 |
} catch (GeometryOperationNotSupportedException e) { |
|
208 |
NotificationManager.addError(e.getMessage(),e); |
|
209 |
} catch (GeometryOperationException e) { |
|
210 |
NotificationManager.addError(e.getMessage(),e); |
|
211 |
} |
|
212 |
} |
|
213 |
/** |
|
214 |
* Add a diferent option. |
|
215 |
* |
|
216 |
* @param s |
|
217 |
* Diferent option. |
|
218 |
*/ |
|
219 |
public void addOption(String s) { |
|
220 |
} |
|
221 |
|
|
222 |
/* |
|
223 |
* (non-Javadoc) |
|
224 |
* |
|
225 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double) |
|
226 |
*/ |
|
227 |
public void addValue(double d) { |
|
228 |
|
|
229 |
} |
|
230 |
|
|
231 |
public String getName() { |
|
232 |
return PluginServices.getText(this,"join_"); |
|
233 |
} |
|
234 |
|
|
235 |
public String toString() { |
|
236 |
return "_join"; |
|
237 |
} |
|
238 |
public boolean isApplicable(int shapeType) { |
|
239 |
switch (shapeType) { |
|
240 |
case org.gvsig.fmap.geom.Geometry.TYPES.POINT: |
|
241 |
return false; |
|
242 |
} |
|
243 |
return true; |
|
244 |
} |
|
245 |
} |
Also available in: Unified diff