Revision 4118
trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/v02/FGraphicUtilities.java | ||
---|---|---|
686 | 686 |
g.drawRect((int) (point.getX() - 5), (int) (point.getY() - 5), 10, 10); |
687 | 687 |
} |
688 | 688 |
} |
689 |
|
|
690 |
public static void DrawVertex(Graphics2D g, AffineTransform at, Handler handlers) { |
|
691 |
//for (int i = 0; i < handlers.length; i++) { |
|
692 |
Point2D point = handlers.getPoint(); |
|
693 |
at.transform(point, point); |
|
694 |
g.setColor(Color.red); |
|
695 |
g.drawLine((int)point.getX()-1,(int)point.getY()-10,(int)point.getX()-1,(int)point.getY()+10); |
|
696 |
g.drawLine((int)point.getX()+1,(int)point.getY()-10,(int)point.getX()+1,(int)point.getY()+10); |
|
697 |
g.drawLine((int)point.getX()-10,(int)point.getY()-1,(int)point.getX()+10,(int)point.getY()-1); |
|
698 |
g.drawLine((int)point.getX()-10,(int)point.getY()+1,(int)point.getX()+10,(int)point.getY()+1); |
|
699 |
//} |
|
700 |
} |
|
689 | 701 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/TableCommandStackExtension.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig; |
|
2 |
|
|
3 |
import com.iver.andami.PluginServices; |
|
4 |
import com.iver.andami.plugins.Extension; |
|
5 |
import com.iver.cit.gvsig.fmap.FMap; |
|
6 |
import com.iver.cit.gvsig.fmap.edition.IEditableSource; |
|
7 |
import com.iver.cit.gvsig.fmap.edition.commands.CommandRecord; |
|
8 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
9 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
10 |
import com.iver.cit.gvsig.gui.Table; |
|
11 |
import com.iver.cit.gvsig.gui.View; |
|
12 |
import com.iver.cit.gvsig.gui.command.CommandStackDialog; |
|
13 |
import com.iver.cit.gvsig.project.ProjectTable; |
|
14 |
import com.iver.cit.gvsig.project.ProjectView; |
|
15 |
|
|
16 |
/** |
|
17 |
* DOCUMENT ME! |
|
18 |
* |
|
19 |
* @author Vicente Caballero Navarro |
|
20 |
*/ |
|
21 |
public class TableCommandStackExtension implements Extension { |
|
22 |
/** |
|
23 |
* @see com.iver.andami.plugins.Extension#inicializar() |
|
24 |
*/ |
|
25 |
public void inicializar() { |
|
26 |
} |
|
27 |
|
|
28 |
/** |
|
29 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String) |
|
30 |
*/ |
|
31 |
public void execute(String s) { |
|
32 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
|
33 |
.getActiveView(); |
|
34 |
|
|
35 |
Table table = (Table) f; |
|
36 |
ProjectTable model = table.getModel(); |
|
37 |
if (s.equals("COMMANDSTACK")) { |
|
38 |
CommandRecord cr=null; |
|
39 |
|
|
40 |
if (model.getAssociatedTable()!=null){ |
|
41 |
cr=((IEditableSource)((FLyrVect)model.getAssociatedTable()).getSource()).getCommandRecord(); |
|
42 |
cr.addExecuteCommand(table); |
|
43 |
}else{ |
|
44 |
cr=model.getModelo().getCommandRecord(); |
|
45 |
cr.addExecuteCommand(table); |
|
46 |
} |
|
47 |
CommandStackDialog csd = new CommandStackDialog(cr); |
|
48 |
PluginServices.getMDIManager().addView(csd); |
|
49 |
} |
|
50 |
} |
|
51 |
|
|
52 |
/** |
|
53 |
* @see com.iver.andami.plugins.Extension#isEnabled() |
|
54 |
*/ |
|
55 |
public boolean isEnabled() { |
|
56 |
return true; |
|
57 |
} |
|
58 |
|
|
59 |
/** |
|
60 |
* @see com.iver.andami.plugins.Extension#isVisible() |
|
61 |
*/ |
|
62 |
public boolean isVisible() { |
|
63 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
|
64 |
.getActiveView(); |
|
65 |
if (f instanceof Table){ |
|
66 |
Table table = (Table) f; |
|
67 |
ProjectTable model = table.getModel(); |
|
68 |
if (model.getModelo().isEditing()) |
|
69 |
return true; |
|
70 |
} |
|
71 |
return false; |
|
72 |
|
|
73 |
} |
|
74 |
} |
|
0 | 75 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/ViewCommandStackExtension.java | ||
---|---|---|
1 |
package com.iver.cit.gvsig; |
|
2 |
|
|
3 |
import com.iver.andami.PluginServices; |
|
4 |
import com.iver.andami.plugins.Extension; |
|
5 |
import com.iver.cit.gvsig.fmap.FMap; |
|
6 |
import com.iver.cit.gvsig.fmap.edition.IEditableSource; |
|
7 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
|
8 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
|
9 |
import com.iver.cit.gvsig.gui.View; |
|
10 |
import com.iver.cit.gvsig.gui.command.CommandStackDialog; |
|
11 |
import com.iver.cit.gvsig.project.ProjectView; |
|
12 |
|
|
13 |
/** |
|
14 |
* DOCUMENT ME! |
|
15 |
* |
|
16 |
* @author Vicente Caballero Navarro |
|
17 |
*/ |
|
18 |
public class ViewCommandStackExtension implements Extension { |
|
19 |
/** |
|
20 |
* @see com.iver.andami.plugins.Extension#inicializar() |
|
21 |
*/ |
|
22 |
public void inicializar() { |
|
23 |
} |
|
24 |
|
|
25 |
/** |
|
26 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String) |
|
27 |
*/ |
|
28 |
public void execute(String s) { |
|
29 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
|
30 |
.getActiveView(); |
|
31 |
|
|
32 |
View vista = (View) f; |
|
33 |
ProjectView model = vista.getModel(); |
|
34 |
FMap mapa = model.getMapContext(); |
|
35 |
FLayers layers = mapa.getLayers(); |
|
36 |
if (s.equals("COMMANDSTACK")) { |
|
37 |
for (int i =0;i<layers.getLayersCount();i++){ |
|
38 |
if (layers.getLayer(i) instanceof FLyrVect && ((FLyrVect)layers.getLayer(i)).isEditing()){ |
|
39 |
CommandStackDialog csd=new CommandStackDialog(((IEditableSource)((FLyrVect)layers.getLayer(i)).getSource()).getCommandRecord()); |
|
40 |
PluginServices.getMDIManager().addView(csd); |
|
41 |
} |
|
42 |
} |
|
43 |
|
|
44 |
|
|
45 |
} |
|
46 |
|
|
47 |
//PluginServices.getMainFrame().enableControls(); |
|
48 |
|
|
49 |
} |
|
50 |
|
|
51 |
/** |
|
52 |
* @see com.iver.andami.plugins.Extension#isEnabled() |
|
53 |
*/ |
|
54 |
public boolean isEnabled() { |
|
55 |
return true; |
|
56 |
} |
|
57 |
|
|
58 |
/** |
|
59 |
* @see com.iver.andami.plugins.Extension#isVisible() |
|
60 |
*/ |
|
61 |
public boolean isVisible() { |
|
62 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) |
|
63 |
return true; |
|
64 |
else |
|
65 |
return false; |
|
66 |
|
|
67 |
} |
|
68 |
} |
|
0 | 69 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/UndoViewExtension.java | ||
---|---|---|
86 | 86 |
if (layers.getLayer(i) instanceof FLyrVect && layers.getLayer(i).isEditing() && layers.getLayer(i).isActive()){ |
87 | 87 |
VectorialEditableAdapter vea=(VectorialEditableAdapter)((FLyrVect)layers.getLayer(i)).getSource(); |
88 | 88 |
vea.undo(); |
89 |
vea.getCommandRecord().fireExecuteCommands(null); |
|
89 | 90 |
} |
90 | 91 |
} |
91 | 92 |
} catch (DriverIOException e) { |
... | ... | |
96 | 97 |
e); |
97 | 98 |
} |
98 | 99 |
//vista.getMapControl().cancelDrawing(); |
99 |
vista.getMapControl().drawMap(false); |
|
100 |
//vista.getMapControl().drawMap(false); |
|
101 |
|
|
100 | 102 |
} |
101 | 103 |
|
102 | 104 |
/** |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/RedoViewExtension.java | ||
---|---|---|
81 | 81 |
if (layers.getLayer(i) instanceof FLyrVect && layers.getLayer(i).isEditing() && layers.getLayer(i).isActive()){ |
82 | 82 |
VectorialEditableAdapter vea=(VectorialEditableAdapter)((FLyrVect)layers.getLayer(i)).getSource(); |
83 | 83 |
vea.redo(); |
84 |
vea.getCommandRecord().fireExecuteCommands(null); |
|
84 | 85 |
vea.getSelection().clear(); |
85 | 86 |
} |
86 | 87 |
|
... | ... | |
93 | 94 |
e); |
94 | 95 |
} |
95 | 96 |
|
96 |
vista.getMapControl().drawMap(false); |
|
97 |
//vista.getMapControl().drawMap(false);
|
|
97 | 98 |
} |
98 | 99 |
} |
99 | 100 |
|
trunk/extensions/extCAD/src/com/iver/cit/gvsig/StartEditing.java | ||
---|---|---|
3 | 3 |
import com.iver.andami.PluginServices; |
4 | 4 |
import com.iver.andami.plugins.Extension; |
5 | 5 |
import com.iver.cit.gvsig.fmap.FMap; |
6 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
6 | 7 |
import com.iver.cit.gvsig.fmap.edition.EditionException; |
7 | 8 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
8 | 9 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
... | ... | |
39 | 40 |
if (f instanceof View) { |
40 | 41 |
View vista = (View) f; |
41 | 42 |
vista.showConsole(); |
43 |
MapControl mapControl = (MapControl) vista.getMapControl(); |
|
42 | 44 |
ProjectView model = vista.getModel(); |
43 | 45 |
FMap mapa = model.getMapContext(); |
44 | 46 |
FLayers layers = mapa.getLayers(); |
... | ... | |
57 | 59 |
vea.setOriginalVectorialAdapter(lv.getSource()); |
58 | 60 |
try{ |
59 | 61 |
vea.startEdition(); |
62 |
vea.getCommandRecord().addExecuteCommand(mapControl); |
|
60 | 63 |
}catch (EditionException e) { |
61 | 64 |
// TODO: handle exception |
62 | 65 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/CADExtension.java | ||
---|---|---|
67 | 67 |
import com.iver.cit.gvsig.gui.cad.tools.ArcCADTool; |
68 | 68 |
import com.iver.cit.gvsig.gui.cad.tools.CircleCADTool; |
69 | 69 |
import com.iver.cit.gvsig.gui.cad.tools.CopyCADTool; |
70 |
import com.iver.cit.gvsig.gui.cad.tools.EditVertexCADTool; |
|
70 | 71 |
import com.iver.cit.gvsig.gui.cad.tools.EllipseCADTool; |
71 | 72 |
import com.iver.cit.gvsig.gui.cad.tools.LineCADTool; |
72 | 73 |
import com.iver.cit.gvsig.gui.cad.tools.PointCADTool; |
... | ... | |
107 | 108 |
CopyCADTool copy=new CopyCADTool(); |
108 | 109 |
RotateCADTool rotate=new RotateCADTool(); |
109 | 110 |
ScaleCADTool scale=new ScaleCADTool(); |
111 |
EditVertexCADTool editvertex=new EditVertexCADTool(); |
|
110 | 112 |
addCADTool("selection", selection); |
111 | 113 |
addCADTool("line", line); |
112 | 114 |
addCADTool("point", point); |
... | ... | |
119 | 121 |
addCADTool("copy",copy); |
120 | 122 |
addCADTool("rotate",rotate); |
121 | 123 |
addCADTool("scale",scale); |
124 |
addCADTool("editvertex",editvertex); |
|
122 | 125 |
} |
123 | 126 |
|
124 | 127 |
/** |
... | ... | |
204 | 207 |
setCADTool("rectangle"); |
205 | 208 |
} else if (s.compareTo("POLYGON") == 0) { |
206 | 209 |
setCADTool("polygon"); |
210 |
} else if (s.compareTo("EDITVERTEX") == 0) { |
|
211 |
setCADTool("editvertex"); |
|
207 | 212 |
} |
208 | 213 |
adapter.configureMenu(); |
209 | 214 |
//ViewControls.CANCELED=false; |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/DefaultCADTool.java | ||
---|---|---|
51 | 51 |
import com.hardcode.driverManager.DriverLoadException; |
52 | 52 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
53 | 53 |
import com.hardcode.gdbms.engine.values.Value; |
54 |
import com.hardcode.gdbms.engine.values.ValueFactory; |
|
54 | 55 |
import com.iver.andami.PluginServices; |
55 | 56 |
import com.iver.cit.gvsig.CADExtension; |
56 | 57 |
import com.iver.cit.gvsig.fmap.ViewPort; |
... | ... | |
137 | 138 |
gp.append(geometry.getGeneralPathXIterator(), true); |
138 | 139 |
geometry = ShapeFactory.createPolygon2D(gp); |
139 | 140 |
} |
140 |
|
|
141 |
DefaultFeature df = new DefaultFeature(geometry,new Value[getCadToolAdapter().getVectorialAdapter().getRecordset().getFieldCount()]); |
|
142 |
vea.addRow(df); |
|
141 |
int numAttr=getCadToolAdapter().getVectorialAdapter().getRecordset().getFieldCount(); |
|
142 |
Value[] values=new Value[numAttr]; |
|
143 |
for (int i=0;i<numAttr;i++){ |
|
144 |
values[i]=ValueFactory.createNullValue(); |
|
145 |
} |
|
146 |
DefaultFeature df = new DefaultFeature(geometry,values); |
|
147 |
vea.addRow(df,getName()); |
|
143 | 148 |
} catch (DriverIOException e) { |
144 | 149 |
// TODO Auto-generated catch block |
145 | 150 |
e.printStackTrace(); |
... | ... | |
163 | 168 |
*/ |
164 | 169 |
public void modifyFeature(int index,DefaultFeature row) { |
165 | 170 |
try { |
166 |
getCadToolAdapter().getVectorialAdapter().modifyRow(index, row); |
|
171 |
getCadToolAdapter().getVectorialAdapter().modifyRow(index, row,getName());
|
|
167 | 172 |
} catch (IOException e1) { |
168 | 173 |
// TODO Auto-generated catch block |
169 | 174 |
e1.printStackTrace(); |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/CopyCADTool.java | ||
---|---|---|
148 | 148 |
UtilFunctions.moveGeom(fea.getGeometry(), lastPoint.getX() - |
149 | 149 |
firstPoint.getX(), lastPoint.getY() - firstPoint.getY()); |
150 | 150 |
|
151 |
vea.addRow(fea); |
|
151 |
vea.addRow(fea,getName());
|
|
152 | 152 |
} |
153 | 153 |
|
154 | 154 |
vea.endComplexRow(); |
... | ... | |
225 | 225 |
*/ |
226 | 226 |
public void addValue(double d) { |
227 | 227 |
} |
228 |
|
|
229 |
public String getName() { |
|
230 |
return "COPIAR"; |
|
231 |
} |
|
228 | 232 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/PolylineCADTool.java | ||
---|---|---|
444 | 444 |
/* CADExtension.setCADTool("polyline"); |
445 | 445 |
PluginServices.getMainFrame().setSelectedTool("POLYLINE"); */ |
446 | 446 |
} |
447 |
|
|
448 |
public String getName() { |
|
449 |
return "POLILINEA"; |
|
450 |
} |
|
447 | 451 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/smc/EditVertexCADToolContext.java | ||
---|---|---|
1 |
|
|
2 |
// |
|
3 |
// Vicente Caballero Navarro |
|
4 |
|
|
5 |
|
|
6 |
package com.iver.cit.gvsig.gui.cad.tools.smc; |
|
7 |
|
|
8 |
import com.iver.cit.gvsig.gui.cad.tools.EditVertexCADTool; |
|
9 |
|
|
10 |
public final class EditVertexCADToolContext |
|
11 |
extends statemap.FSMContext |
|
12 |
{ |
|
13 |
//--------------------------------------------------------------- |
|
14 |
// Member methods. |
|
15 |
// |
|
16 |
|
|
17 |
public EditVertexCADToolContext(EditVertexCADTool owner) |
|
18 |
{ |
|
19 |
super(); |
|
20 |
|
|
21 |
_owner = owner; |
|
22 |
setState(EditVertex.SelectVertexOrDelete); |
|
23 |
EditVertex.SelectVertexOrDelete.Entry(this); |
|
24 |
} |
|
25 |
|
|
26 |
public void addOption(String s) |
|
27 |
{ |
|
28 |
_transition = "addOption"; |
|
29 |
getState().addOption(this, s); |
|
30 |
_transition = ""; |
|
31 |
return; |
|
32 |
} |
|
33 |
|
|
34 |
public EditVertexCADToolState getState() |
|
35 |
throws statemap.StateUndefinedException |
|
36 |
{ |
|
37 |
if (_state == null) |
|
38 |
{ |
|
39 |
throw( |
|
40 |
new statemap.StateUndefinedException()); |
|
41 |
} |
|
42 |
|
|
43 |
return ((EditVertexCADToolState) _state); |
|
44 |
} |
|
45 |
|
|
46 |
protected EditVertexCADTool getOwner() |
|
47 |
{ |
|
48 |
return (_owner); |
|
49 |
} |
|
50 |
|
|
51 |
//--------------------------------------------------------------- |
|
52 |
// Member data. |
|
53 |
// |
|
54 |
|
|
55 |
transient private EditVertexCADTool _owner; |
|
56 |
|
|
57 |
//--------------------------------------------------------------- |
|
58 |
// Inner classes. |
|
59 |
// |
|
60 |
|
|
61 |
public static abstract class EditVertexCADToolState |
|
62 |
extends statemap.State |
|
63 |
{ |
|
64 |
//----------------------------------------------------------- |
|
65 |
// Member methods. |
|
66 |
// |
|
67 |
|
|
68 |
protected EditVertexCADToolState(String name, int id) |
|
69 |
{ |
|
70 |
super (name, id); |
|
71 |
} |
|
72 |
|
|
73 |
protected void Entry(EditVertexCADToolContext context) {} |
|
74 |
protected void Exit(EditVertexCADToolContext context) {} |
|
75 |
|
|
76 |
protected void addOption(EditVertexCADToolContext context, String s) |
|
77 |
{ |
|
78 |
Default(context); |
|
79 |
} |
|
80 |
|
|
81 |
protected void Default(EditVertexCADToolContext context) |
|
82 |
{ |
|
83 |
throw ( |
|
84 |
new statemap.TransitionUndefinedException( |
|
85 |
"State: " + |
|
86 |
context.getState().getName() + |
|
87 |
", Transition: " + |
|
88 |
context.getTransition())); |
|
89 |
} |
|
90 |
|
|
91 |
//----------------------------------------------------------- |
|
92 |
// Member data. |
|
93 |
// |
|
94 |
} |
|
95 |
|
|
96 |
/* package */ static abstract class EditVertex |
|
97 |
{ |
|
98 |
//----------------------------------------------------------- |
|
99 |
// Member methods. |
|
100 |
// |
|
101 |
|
|
102 |
//----------------------------------------------------------- |
|
103 |
// Member data. |
|
104 |
// |
|
105 |
|
|
106 |
//------------------------------------------------------- |
|
107 |
// Statics. |
|
108 |
// |
|
109 |
/* package */ static EditVertex_Default.EditVertex_SelectVertexOrDelete SelectVertexOrDelete; |
|
110 |
private static EditVertex_Default Default; |
|
111 |
|
|
112 |
static |
|
113 |
{ |
|
114 |
SelectVertexOrDelete = new EditVertex_Default.EditVertex_SelectVertexOrDelete("EditVertex.SelectVertexOrDelete", 0); |
|
115 |
Default = new EditVertex_Default("EditVertex.Default", -1); |
|
116 |
} |
|
117 |
|
|
118 |
} |
|
119 |
|
|
120 |
protected static class EditVertex_Default |
|
121 |
extends EditVertexCADToolState |
|
122 |
{ |
|
123 |
//----------------------------------------------------------- |
|
124 |
// Member methods. |
|
125 |
// |
|
126 |
|
|
127 |
protected EditVertex_Default(String name, int id) |
|
128 |
{ |
|
129 |
super (name, id); |
|
130 |
} |
|
131 |
|
|
132 |
protected void addOption(EditVertexCADToolContext context, String s) |
|
133 |
{ |
|
134 |
EditVertexCADTool ctxt = context.getOwner(); |
|
135 |
|
|
136 |
if (s.equals("Cancelar")) |
|
137 |
{ |
|
138 |
boolean loopbackFlag = |
|
139 |
context.getState().getName().equals( |
|
140 |
EditVertex.SelectVertexOrDelete.getName()); |
|
141 |
|
|
142 |
if (loopbackFlag == false) |
|
143 |
{ |
|
144 |
(context.getState()).Exit(context); |
|
145 |
} |
|
146 |
|
|
147 |
context.clearState(); |
|
148 |
try |
|
149 |
{ |
|
150 |
ctxt.end(); |
|
151 |
} |
|
152 |
finally |
|
153 |
{ |
|
154 |
context.setState(EditVertex.SelectVertexOrDelete); |
|
155 |
|
|
156 |
if (loopbackFlag == false) |
|
157 |
{ |
|
158 |
(context.getState()).Entry(context); |
|
159 |
} |
|
160 |
|
|
161 |
} |
|
162 |
} |
|
163 |
else |
|
164 |
{ |
|
165 |
super.addOption(context, s); |
|
166 |
} |
|
167 |
|
|
168 |
return; |
|
169 |
} |
|
170 |
|
|
171 |
//----------------------------------------------------------- |
|
172 |
// Inner classse. |
|
173 |
// |
|
174 |
|
|
175 |
|
|
176 |
private static final class EditVertex_SelectVertexOrDelete |
|
177 |
extends EditVertex_Default |
|
178 |
{ |
|
179 |
//------------------------------------------------------- |
|
180 |
// Member methods. |
|
181 |
// |
|
182 |
|
|
183 |
private EditVertex_SelectVertexOrDelete(String name, int id) |
|
184 |
{ |
|
185 |
super (name, id); |
|
186 |
} |
|
187 |
|
|
188 |
protected void Entry(EditVertexCADToolContext context) |
|
189 |
{ |
|
190 |
EditVertexCADTool ctxt = context.getOwner(); |
|
191 |
|
|
192 |
ctxt.selection(); |
|
193 |
ctxt.setQuestion("EDITAR VERTICES" + "\n" + |
|
194 |
"Siguiente vertice, Anterior o Eliminar"); |
|
195 |
ctxt.setDescription(new String[]{"Siguiente", "Anterior", "Eliminar", "Cancelar"}); |
|
196 |
return; |
|
197 |
} |
|
198 |
|
|
199 |
protected void addOption(EditVertexCADToolContext context, String s) |
|
200 |
{ |
|
201 |
EditVertexCADTool ctxt = context.getOwner(); |
|
202 |
|
|
203 |
EditVertexCADToolState endState = context.getState(); |
|
204 |
|
|
205 |
context.clearState(); |
|
206 |
try |
|
207 |
{ |
|
208 |
ctxt.setQuestion("Siguiente vertice, Anterior o Eliminar"); |
|
209 |
ctxt.setDescription(new String[]{"Siguiente", "Anterior", "Eliminar", "Cancelar"}); |
|
210 |
ctxt.addOption(s); |
|
211 |
} |
|
212 |
finally |
|
213 |
{ |
|
214 |
context.setState(endState); |
|
215 |
} |
|
216 |
return; |
|
217 |
} |
|
218 |
|
|
219 |
//------------------------------------------------------- |
|
220 |
// Member data. |
|
221 |
// |
|
222 |
} |
|
223 |
|
|
224 |
//----------------------------------------------------------- |
|
225 |
// Member data. |
|
226 |
// |
|
227 |
} |
|
228 |
} |
|
0 | 229 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/EllipseCADTool.java | ||
---|---|---|
179 | 179 |
} |
180 | 180 |
} |
181 | 181 |
|
182 |
public String getName() { |
|
183 |
return "ELIPSE"; |
|
184 |
} |
|
185 |
|
|
182 | 186 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/RotateCADTool.java | ||
---|---|---|
157 | 157 |
|
158 | 158 |
/* fea.getGeometry().rotate(-Math.atan2(w, h) + (Math.PI / 2), |
159 | 159 |
firstPoint.getX(), firstPoint.getY()); */ |
160 |
getCadToolAdapter().getVectorialAdapter().modifyRow(i, fea); |
|
160 |
getCadToolAdapter().getVectorialAdapter().modifyRow(i, fea,getName());
|
|
161 | 161 |
} |
162 | 162 |
|
163 | 163 |
getCadToolAdapter().getVectorialAdapter().endComplexRow(); |
... | ... | |
270 | 270 |
fea.getGeometry().transform(at); |
271 | 271 |
// fea.getGeometry().rotate(Math.toRadians(d), |
272 | 272 |
// firstPoint.getX(), firstPoint.getY()); |
273 |
getCadToolAdapter().getVectorialAdapter().modifyRow(i, fea); |
|
273 |
getCadToolAdapter().getVectorialAdapter().modifyRow(i, fea,getName());
|
|
274 | 274 |
} |
275 | 275 |
} |
276 | 276 |
} catch (DriverIOException e) { |
... | ... | |
281 | 281 |
|
282 | 282 |
} |
283 | 283 |
} |
284 |
|
|
285 |
public String getName() { |
|
286 |
return "ROTAR"; |
|
287 |
} |
|
284 | 288 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/CircleCADTool.java | ||
---|---|---|
200 | 200 |
} |
201 | 201 |
} |
202 | 202 |
|
203 |
public String getName() { |
|
204 |
return "CIRCULO"; |
|
205 |
} |
|
206 |
|
|
203 | 207 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/EditVertexCADTool.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.Graphics2D; |
|
45 |
import java.awt.geom.AffineTransform; |
|
46 |
import java.awt.geom.PathIterator; |
|
47 |
import java.awt.geom.Point2D; |
|
48 |
import java.io.IOException; |
|
49 |
|
|
50 |
import com.iver.cit.gvsig.CADExtension; |
|
51 |
import com.iver.cit.gvsig.fmap.core.DefaultFeature; |
|
52 |
import com.iver.cit.gvsig.fmap.core.FGeometryCollection; |
|
53 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
54 |
import com.iver.cit.gvsig.fmap.core.FPolygon2D; |
|
55 |
import com.iver.cit.gvsig.fmap.core.FPolyline2D; |
|
56 |
import com.iver.cit.gvsig.fmap.core.FShape; |
|
57 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
58 |
import com.iver.cit.gvsig.fmap.core.GeneralPathXIterator; |
|
59 |
import com.iver.cit.gvsig.fmap.core.Handler; |
|
60 |
import com.iver.cit.gvsig.fmap.core.IFeature; |
|
61 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
|
62 |
import com.iver.cit.gvsig.fmap.core.IRow; |
|
63 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
64 |
import com.iver.cit.gvsig.fmap.core.v02.FGraphicUtilities; |
|
65 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
66 |
import com.iver.cit.gvsig.fmap.edition.IRowEdited; |
|
67 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
|
68 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
|
69 |
import com.iver.cit.gvsig.gui.cad.DefaultCADTool; |
|
70 |
import com.iver.cit.gvsig.gui.cad.tools.smc.EditVertexCADToolContext; |
|
71 |
import com.iver.cit.gvsig.gui.cad.tools.smc.EditVertexCADToolContext.EditVertexCADToolState; |
|
72 |
|
|
73 |
|
|
74 |
/** |
|
75 |
* DOCUMENT ME! |
|
76 |
* |
|
77 |
* @author Vicente Caballero Navarro |
|
78 |
*/ |
|
79 |
public class EditVertexCADTool extends DefaultCADTool { |
|
80 |
private EditVertexCADToolContext _fsm; |
|
81 |
private int numSelect=0; |
|
82 |
private int numHandlers; |
|
83 |
|
|
84 |
/** |
|
85 |
* Crea un nuevo PolylineCADTool. |
|
86 |
*/ |
|
87 |
public EditVertexCADTool() { |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* M?todo de incio, para poner el c?digo de todo lo que se requiera de una |
|
92 |
* carga previa a la utilizaci?n de la herramienta. |
|
93 |
*/ |
|
94 |
public void init() { |
|
95 |
_fsm = new EditVertexCADToolContext(this); |
|
96 |
} |
|
97 |
|
|
98 |
/* (non-Javadoc) |
|
99 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double, double) |
|
100 |
*/ |
|
101 |
public void transition(double x, double y) { |
|
102 |
//_fsm.addPoint(x, y); |
|
103 |
} |
|
104 |
|
|
105 |
/* (non-Javadoc) |
|
106 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double) |
|
107 |
*/ |
|
108 |
public void transition(double d) { |
|
109 |
//_fsm.addValue(sel,d); |
|
110 |
} |
|
111 |
|
|
112 |
/* (non-Javadoc) |
|
113 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String) |
|
114 |
*/ |
|
115 |
public void transition(String s) { |
|
116 |
_fsm.addOption(s); |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* DOCUMENT ME! |
|
121 |
*/ |
|
122 |
public void selection() { |
|
123 |
FBitSet selection = CADExtension.getCADToolAdapter() |
|
124 |
.getVectorialAdapter().getSelection(); |
|
125 |
|
|
126 |
if (selection.cardinality() == 0) { |
|
127 |
CADExtension.setCADTool("selection"); |
|
128 |
((SelectionCADTool) CADExtension.getCADToolAdapter().getCadTool()).setNextTool( |
|
129 |
"editvertex"); |
|
130 |
} |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Equivale al transition del prototipo pero sin pasarle como par?metro el |
|
135 |
* editableFeatureSource que ya estar? creado. |
|
136 |
* |
|
137 |
* @param x par?metro x del punto que se pase en esta transici?n. |
|
138 |
* @param y par?metro y del punto que se pase en esta transici?n. |
|
139 |
*/ |
|
140 |
public void addPoint(double x, double y) { |
|
141 |
} |
|
142 |
|
|
143 |
/** |
|
144 |
* M?todo para dibujar la lo necesario para el estado en el que nos |
|
145 |
* encontremos. |
|
146 |
* |
|
147 |
* @param g Graphics sobre el que dibujar. |
|
148 |
* @param x par?metro x del punto que se pase para dibujar. |
|
149 |
* @param y par?metro x del punto que se pase para dibujar. |
|
150 |
*/ |
|
151 |
public void drawOperation(Graphics g, double x, double y) { |
|
152 |
EditVertexCADToolState actualState = ((EditVertexCADToolContext) _fsm).getState(); |
|
153 |
String status = actualState.getName(); |
|
154 |
VectorialEditableAdapter vea = getCadToolAdapter().getVectorialAdapter(); |
|
155 |
FBitSet selection = vea.getSelection(); |
|
156 |
|
|
157 |
try { |
|
158 |
drawVertex(g, selection, |
|
159 |
getCadToolAdapter().getMapControl().getViewPort() |
|
160 |
.getAffineTransform()); |
|
161 |
} catch (DriverIOException e) { |
|
162 |
// TODO Auto-generated catch block |
|
163 |
e.printStackTrace(); |
|
164 |
} |
|
165 |
} |
|
166 |
|
|
167 |
/** |
|
168 |
* Add a diferent option. |
|
169 |
* |
|
170 |
* @param s Diferent option. |
|
171 |
*/ |
|
172 |
public void addOption(String s) { |
|
173 |
EditVertexCADToolState actualState = (EditVertexCADToolState) _fsm.getPreviousState(); |
|
174 |
String status = actualState.getName(); |
|
175 |
VectorialEditableAdapter vea = getCadToolAdapter().getVectorialAdapter(); |
|
176 |
FBitSet selection = vea.getSelection(); |
|
177 |
IRowEdited row=null; |
|
178 |
IGeometry ig=null; |
|
179 |
Handler[] handlers=null; |
|
180 |
if (selection.cardinality()==1){ |
|
181 |
|
|
182 |
try { |
|
183 |
row = getCadToolAdapter().getVectorialAdapter().getRow(selection.nextSetBit(0)); |
|
184 |
} catch (DriverIOException e) { |
|
185 |
// TODO Auto-generated catch block |
|
186 |
e.printStackTrace(); |
|
187 |
} catch (IOException e) { |
|
188 |
// TODO Auto-generated catch block |
|
189 |
e.printStackTrace(); |
|
190 |
} |
|
191 |
ig=((IFeature)row.getLinkedRow()).getGeometry().cloneGeometry(); |
|
192 |
handlers=ig.getHandlers(IGeometry.SELECTHANDLER); |
|
193 |
numHandlers=handlers.length; |
|
194 |
if (numHandlers ==0){ |
|
195 |
try { |
|
196 |
vea.removeRow(selection.nextSetBit(0),getName()); |
|
197 |
} catch (IOException e) { |
|
198 |
// TODO Auto-generated catch block |
|
199 |
e.printStackTrace(); |
|
200 |
} catch (DriverIOException e) { |
|
201 |
// TODO Auto-generated catch block |
|
202 |
e.printStackTrace(); |
|
203 |
} |
|
204 |
} |
|
205 |
} |
|
206 |
int dif=1;//En el caso de ser pol?gono. |
|
207 |
if (ig instanceof FGeometryCollection){ |
|
208 |
dif=2; |
|
209 |
} |
|
210 |
if (status.equals("EditVertex.SelectVertexOrDelete")){ |
|
211 |
if(s.equals("s") || s.equals("S") || s.equals("Siguiente")){ |
|
212 |
numSelect=numSelect-dif; |
|
213 |
if (numSelect<0){ |
|
214 |
numSelect=numHandlers-1+(numSelect+1); |
|
215 |
} |
|
216 |
}else if(s.equals("a") || s.equals("a") || s.equals("Anterior")){ |
|
217 |
numSelect=numSelect+dif; |
|
218 |
if (numSelect>(numHandlers-1)){ |
|
219 |
numSelect=numSelect-(numHandlers); |
|
220 |
} |
|
221 |
|
|
222 |
}else if(s.equals("e") || s.equals("E") || s.equals("Eliminar")){ |
|
223 |
if (handlers!=null){ |
|
224 |
IGeometry newGeometry=removeVertex(ig,handlers[numSelect]); |
|
225 |
numSelect=0; |
|
226 |
|
|
227 |
IRow newRow=new DefaultFeature(newGeometry,row.getAttributes()); |
|
228 |
try { |
|
229 |
vea.modifyRow(selection.nextSetBit(0),newRow,getName()); |
|
230 |
} catch (IOException e) { |
|
231 |
// TODO Auto-generated catch block |
|
232 |
e.printStackTrace(); |
|
233 |
} catch (DriverIOException e) { |
|
234 |
// TODO Auto-generated catch block |
|
235 |
e.printStackTrace(); |
|
236 |
} |
|
237 |
getCadToolAdapter().getMapControl().drawMap(false); |
|
238 |
} |
|
239 |
} |
|
240 |
} |
|
241 |
} |
|
242 |
public void drawVertex(Graphics g,FBitSet sel,AffineTransform at) throws DriverIOException{ |
|
243 |
for (int i = sel.nextSetBit(0); i >= 0; |
|
244 |
i = sel.nextSetBit(i + 1)) { |
|
245 |
IGeometry ig = getCadToolAdapter().getVectorialAdapter().getShape(i).cloneGeometry(); |
|
246 |
if (ig == null) continue; |
|
247 |
Handler[] handlers=ig.getHandlers(IGeometry.SELECTHANDLER); |
|
248 |
FGraphicUtilities.DrawVertex((Graphics2D)g,at,handlers[numSelect]); |
|
249 |
} |
|
250 |
} |
|
251 |
/* (non-Javadoc) |
|
252 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double) |
|
253 |
*/ |
|
254 |
public void addValue(double d) { |
|
255 |
} |
|
256 |
public IGeometry removeVertex(IGeometry gp,Handler handler) { |
|
257 |
GeneralPathX newGp = new GeneralPathX(); |
|
258 |
double[] theData = new double[6]; |
|
259 |
|
|
260 |
GeneralPathXIterator theIterator; |
|
261 |
int theType; |
|
262 |
int numParts = 0; |
|
263 |
|
|
264 |
Point2D ptSrc = new Point2D.Double(); |
|
265 |
boolean bFirst = false; |
|
266 |
|
|
267 |
theIterator = gp.getGeneralPathXIterator(); //, flatness); |
|
268 |
int numSegmentsAdded = 0; |
|
269 |
while (!theIterator.isDone()) { |
|
270 |
theType = theIterator.currentSegment(theData); |
|
271 |
if (bFirst){ |
|
272 |
newGp.moveTo(theData[0], theData[1]); |
|
273 |
numSegmentsAdded++; |
|
274 |
bFirst=false; |
|
275 |
continue; |
|
276 |
} |
|
277 |
switch (theType) { |
|
278 |
|
|
279 |
case PathIterator.SEG_MOVETO: |
|
280 |
numParts++; |
|
281 |
ptSrc.setLocation(theData[0], theData[1]); |
|
282 |
if (ptSrc.equals(handler.getPoint())){ |
|
283 |
numParts--; |
|
284 |
bFirst=true; |
|
285 |
break; |
|
286 |
} |
|
287 |
newGp.moveTo(ptSrc.getX(), ptSrc.getY()); |
|
288 |
numSegmentsAdded++; |
|
289 |
bFirst = false; |
|
290 |
break; |
|
291 |
|
|
292 |
case PathIterator.SEG_LINETO: |
|
293 |
ptSrc.setLocation(theData[0], theData[1]); |
|
294 |
if (ptSrc.equals(handler.getPoint())){ |
|
295 |
break; |
|
296 |
} |
|
297 |
newGp.lineTo(ptSrc.getX(), ptSrc.getY()); |
|
298 |
bFirst = false; |
|
299 |
numSegmentsAdded++; |
|
300 |
break; |
|
301 |
|
|
302 |
case PathIterator.SEG_QUADTO: |
|
303 |
newGp.quadTo(theData[0], theData[1], theData[2], theData[3]); |
|
304 |
numSegmentsAdded++; |
|
305 |
break; |
|
306 |
|
|
307 |
case PathIterator.SEG_CUBICTO: |
|
308 |
newGp.curveTo(theData[0], theData[1], theData[2], theData[3], theData[4], theData[5]); |
|
309 |
numSegmentsAdded++; |
|
310 |
break; |
|
311 |
|
|
312 |
case PathIterator.SEG_CLOSE: |
|
313 |
if (numSegmentsAdded < 3) |
|
314 |
newGp.lineTo(theData[0], theData[1]); |
|
315 |
newGp.closePath(); |
|
316 |
|
|
317 |
break; |
|
318 |
} //end switch |
|
319 |
|
|
320 |
theIterator.next(); |
|
321 |
} //end while loop |
|
322 |
FShape shp = null; |
|
323 |
switch (gp.getGeometryType()) |
|
324 |
{ |
|
325 |
case FShape.POINT: //Tipo punto |
|
326 |
case FShape.POINT + FShape.Z: |
|
327 |
shp = new FPoint2D(ptSrc.getX(), ptSrc.getY()); |
|
328 |
break; |
|
329 |
|
|
330 |
case FShape.LINE: |
|
331 |
case FShape.LINE + FShape.Z: |
|
332 |
shp = new FPolyline2D(newGp); |
|
333 |
break; |
|
334 |
case FShape.POLYGON: |
|
335 |
case FShape.POLYGON + FShape.Z: |
|
336 |
shp = new FPolygon2D(newGp); |
|
337 |
break; |
|
338 |
} |
|
339 |
return ShapeFactory.createGeometry(shp); |
|
340 |
} |
|
341 |
|
|
342 |
public String getName() { |
|
343 |
return "EDITAR VERTICE"; |
|
344 |
} |
|
345 |
} |
|
0 | 346 |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/RectangleCADTool.java | ||
---|---|---|
227 | 227 |
public void addValue(double d) { |
228 | 228 |
} |
229 | 229 |
|
230 |
public String getName() { |
|
231 |
return "RECTANGULO"; |
|
232 |
} |
|
233 |
|
|
230 | 234 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/ArcCADTool.java | ||
---|---|---|
176 | 176 |
public void addValue(double d) { |
177 | 177 |
} |
178 | 178 |
|
179 |
public String getName() { |
|
180 |
return "ARCO"; |
|
181 |
} |
|
182 |
|
|
179 | 183 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/SelectionCADTool.java | ||
---|---|---|
240 | 240 |
} |
241 | 241 |
|
242 | 242 |
/** |
243 |
* Equivale al transition del prototipo pero sin pasarle como par?metro el |
|
243 |
* Equivale al transition del prototipo pero sin pasarle como par? metro el
|
|
244 | 244 |
* editableFeatureSource que ya estar? creado. |
245 | 245 |
* |
246 | 246 |
* @param selection |
... | ... | |
444 | 444 |
CADExtension.setCADTool(getTool()); |
445 | 445 |
} |
446 | 446 |
|
447 |
public String getName() { |
|
448 |
return "SELECCION"; |
|
449 |
} |
|
450 |
|
|
447 | 451 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/LineCADTool.java | ||
---|---|---|
198 | 198 |
} |
199 | 199 |
} |
200 | 200 |
|
201 |
public String getName() { |
|
202 |
return "LINEA"; |
|
203 |
} |
|
204 |
|
|
201 | 205 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/PolygonCADTool.java | ||
---|---|---|
285 | 285 |
return new FGeometryCollection(geoms); |
286 | 286 |
} |
287 | 287 |
|
288 |
public String getName() { |
|
289 |
return "POLIGONO"; |
|
290 |
} |
|
291 |
|
|
288 | 292 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/ScaleCADTool.java | ||
---|---|---|
298 | 298 |
DefaultFeature df=(DefaultFeature)vea.getRow(i).cloneRow(); |
299 | 299 |
UtilFunctions.scaleGeom(df.getGeometry(), scalePoint, scaleFactor, scaleFactor); |
300 | 300 |
// df.getGeometry().scale(scalePoint, scaleFactor, scaleFactor); |
301 |
vea.modifyRow(i, df); |
|
301 |
vea.modifyRow(i, df,getName());
|
|
302 | 302 |
} |
303 | 303 |
} |
304 | 304 |
vea.endComplexRow(); |
305 | 305 |
} |
306 |
|
|
307 |
public String getName() { |
|
308 |
return "ESCALAR"; |
|
309 |
} |
|
306 | 310 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/tools/PointCADTool.java | ||
---|---|---|
143 | 143 |
// TODO Auto-generated method stub |
144 | 144 |
} |
145 | 145 |
|
146 |
public String getName() { |
|
147 |
return "PUNTO"; |
|
148 |
} |
|
149 |
|
|
146 | 150 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/CADTool.java | ||
---|---|---|
112 | 112 |
public CADToolAdapter getCadToolAdapter(); |
113 | 113 |
public String[] getDescriptions(); |
114 | 114 |
public void setDescription(String[] descriptions); |
115 |
public String getName(); |
|
115 | 116 |
} |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/gui/cad/CADToolAdapter.java | ||
---|---|---|
63 | 63 |
* Pinta de alguna manera especial las geometrias seleccionadas para la |
64 | 64 |
* edici?n. En caso de que el snapping est? activado, pintar? el efecto del |
65 | 65 |
* mismo. |
66 |
*
|
|
66 |
* |
|
67 | 67 |
* @see com.iver.cit.gvsig.fmap.tools.Behavior.Behavior#paintComponent(java.awt.Graphics) |
68 | 68 |
*/ |
69 | 69 |
public void paintComponent(Graphics g) { |
... | ... | |
124 | 124 |
/** |
125 | 125 |
* Ajusta un punto de la imagen que se pasa como par?metro al grid si ?ste |
126 | 126 |
* est? activo y devuelve la distancia de un punto al punto ajustado |
127 |
*
|
|
127 |
* |
|
128 | 128 |
* @param point |
129 | 129 |
* @param mapHandlerAdjustedPoint |
130 | 130 |
* DOCUMENT ME! |
131 |
*
|
|
131 |
* |
|
132 | 132 |
* @return Distancia del punto que se pasa como par?metro al punto ajustado |
133 | 133 |
*/ |
134 | 134 |
private double adjustToHandler(Point2D point, |
... | ... | |
224 | 224 |
|
225 | 225 |
/** |
226 | 226 |
* DOCUMENT ME! |
227 |
*
|
|
227 |
* |
|
228 | 228 |
* @param g |
229 | 229 |
* DOCUMENT ME! |
230 | 230 |
*/ |
... | ... | |
266 | 266 |
|
267 | 267 |
/** |
268 | 268 |
* DOCUMENT ME! |
269 |
*
|
|
269 |
* |
|
270 | 270 |
* @param point |
271 | 271 |
*/ |
272 | 272 |
private void calculateSnapPoint(Point point) { |
... | ... | |
361 | 361 |
/** |
362 | 362 |
* M?todo que realiza las transiciones en las herramientas en funci?n de un |
363 | 363 |
* texto introducido en la consola |
364 |
*
|
|
364 |
* |
|
365 | 365 |
* @param text |
366 | 366 |
* DOCUMENT ME! |
367 | 367 |
*/ |
... | ... | |
398 | 398 |
|
399 | 399 |
/** |
400 | 400 |
* Transici?n por comando ("cancel", actionCommand de una herramienta, etc). |
401 |
*
|
|
401 |
* |
|
402 | 402 |
* @param text |
403 | 403 |
* DOCUMENT ME! |
404 | 404 |
*/ |
... | ... | |
426 | 426 |
|
427 | 427 |
/** |
428 | 428 |
* DOCUMENT ME! |
429 |
*
|
|
429 |
* |
|
430 | 430 |
* @param text |
431 | 431 |
* DOCUMENT ME! |
432 | 432 |
* @param source |
... | ... | |
457 | 457 |
/* |
458 | 458 |
* if ((ret & Automaton.AUTOMATON_FINISHED) == |
459 | 459 |
* Automaton.AUTOMATON_FINISHED) { popCadTool(); |
460 |
*
|
|
460 |
* |
|
461 | 461 |
* if (cadToolStack.isEmpty()) { pushCadTool(new |
462 | 462 |
* com.iver.cit.gvsig.gui.cad.smc.gen.CADTool());//new |
463 | 463 |
* SelectionCadTool()); |
464 | 464 |
* PluginServices.getMainFrame().setSelectedTool("selection"); } |
465 |
*
|
|
465 |
* |
|
466 | 466 |
* askQuestion(); |
467 |
*
|
|
467 |
* |
|
468 | 468 |
* getMapControl().drawMap(false); } else { if (((CadTool) |
469 | 469 |
* cadToolStack.peek()).getAutomaton().checkState('c')) { |
470 | 470 |
* getMapControl().drawMap(false); } |
471 |
*
|
|
471 |
* |
|
472 | 472 |
* if (!questionAsked) { askQuestion(); } } |
473 |
*
|
|
473 |
* |
|
474 | 474 |
* configureMenu(); |
475 | 475 |
*/ |
476 | 476 |
} |
... | ... | |
481 | 481 |
|
482 | 482 |
/** |
483 | 483 |
* DOCUMENT ME! |
484 |
*
|
|
484 |
* |
|
485 | 485 |
* @param text |
486 | 486 |
* DOCUMENT ME! |
487 | 487 |
* @param source |
... | ... | |
515 | 515 |
|
516 | 516 |
/** |
517 | 517 |
* DOCUMENT ME! |
518 |
*
|
|
518 |
* |
|
519 | 519 |
* @param value |
520 | 520 |
* DOCUMENT ME! |
521 | 521 |
*/ |
... | ... | |
527 | 527 |
|
528 | 528 |
/** |
529 | 529 |
* DOCUMENT ME! |
530 |
*
|
|
530 |
* |
|
531 | 531 |
* @param activated |
532 | 532 |
* DOCUMENT ME! |
533 | 533 |
*/ |
... | ... | |
537 | 537 |
|
538 | 538 |
/** |
539 | 539 |
* DOCUMENT ME! |
540 |
*
|
|
540 |
* |
|
541 | 541 |
* @param x |
542 | 542 |
* DOCUMENT ME! |
543 | 543 |
* @param y |
... | ... | |
571 | 571 |
|
572 | 572 |
/** |
573 | 573 |
* DOCUMENT ME! |
574 |
*
|
|
574 |
* |
|
575 | 575 |
* @return DOCUMENT ME! |
576 | 576 |
*/ |
577 | 577 |
public CADTool getCadTool() { |
... | ... | |
580 | 580 |
|
581 | 581 |
/** |
582 | 582 |
* DOCUMENT ME! |
583 |
*
|
|
583 |
* |
|
584 | 584 |
* @param cadTool |
585 | 585 |
* DOCUMENT ME! |
586 | 586 |
*/ |
... | ... | |
592 | 592 |
/* |
593 | 593 |
* int ret = cadTool.transition(null, editableFeatureSource, selection, |
594 | 594 |
* new double[0]); |
595 |
*
|
|
595 |
* |
|
596 | 596 |
* if ((ret & Automaton.AUTOMATON_FINISHED) == |
597 | 597 |
* Automaton.AUTOMATON_FINISHED) { popCadTool(); |
598 |
*
|
|
598 |
* |
|
599 | 599 |
* if (cadToolStack.isEmpty()) { pushCadTool(new |
600 | 600 |
* com.iver.cit.gvsig.gui.cad.smc.gen.CADTool());//new |
601 | 601 |
* SelectionCadTool()); |
602 | 602 |
* PluginServices.getMainFrame().setSelectedTool("selection"); } |
603 |
*
|
|
603 |
* |
|
604 | 604 |
* askQuestion(); |
605 |
*
|
|
605 |
* |
|
606 | 606 |
* getMapControl().drawMap(false); } |
607 | 607 |
*/ |
608 | 608 |
} |
... | ... | |
634 | 634 |
|
635 | 635 |
/** |
636 | 636 |
* DOCUMENT ME! |
637 |
*
|
|
637 |
* |
|
638 | 638 |
* @param cadTool |
639 | 639 |
* DOCUMENT ME! |
640 | 640 |
*/ |
... | ... | |
646 | 646 |
|
647 | 647 |
/** |
648 | 648 |
* DOCUMENT ME! |
649 |
*
|
|
649 |
* |
|
650 | 650 |
* @return DOCUMENT ME! |
651 | 651 |
*/ |
652 | 652 |
public VectorialEditableAdapter getVectorialAdapter() { |
... | ... | |
655 | 655 |
|
656 | 656 |
/** |
657 | 657 |
* DOCUMENT ME! |
658 |
*
|
|
658 |
* |
|
659 | 659 |
* @param editableFeatureSource |
660 | 660 |
* DOCUMENT ME! |
661 | 661 |
* @param selection |
... | ... | |
667 | 667 |
|
668 | 668 |
/** |
669 | 669 |
* DOCUMENT ME! |
670 |
*
|
|
670 |
* |
|
671 | 671 |
* @return DOCUMENT ME! |
672 | 672 |
*/ |
673 | 673 |
/* |
... | ... | |
675 | 675 |
*/ |
676 | 676 |
/** |
677 | 677 |
* DOCUMENT ME! |
678 |
*
|
|
678 |
* |
|
679 | 679 |
* @param cadMapControl |
680 | 680 |
* DOCUMENT ME! |
681 | 681 |
*/ |
... | ... | |
699 | 699 |
// /vea.removeRow(i); |
700 | 700 |
} |
701 | 701 |
for (j = indexesToDel.length - 1; j >= 0; j--) { |
702 |
vea.removeRow(indexesToDel[j]); |
|
702 |
vea.removeRow(indexesToDel[j],"Feature eliminada");
|
|
703 | 703 |
} |
704 | 704 |
} catch (DriverIOException e) { |
705 | 705 |
e.printStackTrace(); |
... | ... | |
721 | 721 |
|
722 | 722 |
/** |
723 | 723 |
* DOCUMENT ME! |
724 |
*
|
|
724 |
* |
|
725 | 725 |
* @param b |
726 | 726 |
*/ |
727 | 727 |
public void setAdjustGrid(boolean b) { |
... | ... | |
730 | 730 |
|
731 | 731 |
/** |
732 | 732 |
* DOCUMENT ME! |
733 |
*
|
|
733 |
* |
|
734 | 734 |
* @param actionCommand |
735 | 735 |
*/ |
736 | 736 |
public void keyPressed(String actionCommand) { |
trunk/extensions/extCAD/src/com/iver/cit/gvsig/StopEditingToShp.java | ||
---|---|---|
8 | 8 |
import com.iver.andami.PluginServices; |
9 | 9 |
import com.iver.andami.plugins.Extension; |
10 | 10 |
import com.iver.cit.gvsig.fmap.FMap; |
11 |
import com.iver.cit.gvsig.fmap.MapControl; |
|
11 | 12 |
import com.iver.cit.gvsig.fmap.edition.VectorialEditableAdapter; |
12 | 13 |
import com.iver.cit.gvsig.fmap.edition.writers.shp.ShpWriter; |
13 | 14 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
... | ... | |
53 | 54 |
for (int i = 0; i < actives.length; i++) |
54 | 55 |
{ |
55 | 56 |
if (actives[i] instanceof FLyrVect && |
56 |
actives[i].isEditing())
|
|
57 |
actives[i].isEditing()) |
|
57 | 58 |
{ |
58 | 59 |
FLyrVect lv = (FLyrVect) actives[i]; |
59 |
stopEditing(lv); |
|
60 |
MapControl mapControl = (MapControl) vista.getMapControl(); |
|
61 |
stopEditing(lv,mapControl); |
|
60 | 62 |
|
61 | 63 |
return; |
62 | 64 |
} |
... | ... | |
75 | 77 |
/** |
76 | 78 |
* DOCUMENT ME! |
77 | 79 |
*/ |
78 |
public void stopEditing(FLyrVect layer) { |
|
80 |
public void stopEditing(FLyrVect layer,MapControl mapControl) {
|
|
79 | 81 |
try { |
80 | 82 |
JFileChooser jfc = new JFileChooser(); |
81 | 83 |
SimpleFileFilter filterShp = new SimpleFileFilter("shp", "Ficheros .shp"); |
82 | 84 |
jfc.setFileFilter(filterShp); |
83 | 85 |
if (jfc.showSaveDialog((Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
84 |
File newFile = jfc.getSelectedFile();
|
|
86 |
File newFile = jfc.getSelectedFile(); |
|
85 | 87 |
VectorialEditableAdapter vea = (VectorialEditableAdapter) layer.getSource(); |
86 |
// File newFile = vea.getDriver().
|
|
88 |
// File newFile = vea.getDriver(). |
|
87 | 89 |
|
88 | 90 |
ShpWriter writer = new ShpWriter(newFile, layer); |
89 | 91 |
|
90 |
|
|
92 |
|
|
91 | 93 |
vea.stopEdition(writer); |
94 |
vea.getCommandRecord().removeExecuteCommand(mapControl); |
|
92 | 95 |
layer.setSource(vea.getOriginalAdapter()); |
93 | 96 |
layer.setEditing(false); |
94 | 97 |
vista.hideConsole(); |
trunk/extensions/extCAD/sm/EditVertexCADTool.sm | ||
---|---|---|
1 |
// -*- tab-width: 4; -*- |
|
2 |
|
|
3 |
%{ |
|
4 |
// |
|
5 |
// Vicente Caballero Navarro |
|
6 |
%} |
|
7 |
|
|
8 |
%start EditVertex::SelectVertexOrDelete |
|
9 |
%class EditVertexCADTool |
|
10 |
%package com.iver.cit.gvsig.gui.cad.tools.smc |
|
11 |
%import com.iver.cit.gvsig.gui.cad.tools.EditVertexCADTool |
|
12 |
|
|
13 |
%map EditVertex |
|
14 |
%% |
|
15 |
// A task begins life in suspended animation. |
|
16 |
|
|
17 |
SelectVertexOrDelete |
|
18 |
Entry { |
|
19 |
selection(); |
|
20 |
setQuestion("EDITAR VERTICES" + "\n" + |
|
21 |
"Siguiente vertice, Anterior o Eliminar"); |
|
22 |
setDescription(new String[]{"Siguiente","Anterior","Eliminar","Cancelar"}); |
|
23 |
|
|
24 |
} |
|
25 |
Exit{ |
|
26 |
} |
|
27 |
|
|
28 |
{ |
|
29 |
addOption(s:String) |
|
30 |
SelectVertexOrDelete { |
|
31 |
setQuestion("Siguiente vertice, Anterior o Eliminar"); |
|
32 |
setDescription(new String[]{"Siguiente","Anterior","Eliminar","Cancelar"}); |
|
33 |
addOption(s); |
|
34 |
} |
|
35 |
} |
|
36 |
|
|
37 |
Default |
|
38 |
{ |
|
39 |
addOption(s:String) |
|
40 |
[s.equals("Cancelar")] |
|
41 |
SelectVertexOrDelete{ |
|
42 |
end(); |
|
43 |
} |
|
44 |
} |
|
45 |
%% |
|
0 | 46 |
Also available in: Unified diff