Revision 1392
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/CadMapControl.java | ||
---|---|---|
56 | 56 |
import com.iver.cit.gvsig.fmap.edition.cad.CadTool; |
57 | 57 |
import com.iver.cit.gvsig.fmap.edition.cad.cadTools.LineCadTool; |
58 | 58 |
import com.iver.cit.gvsig.fmap.edition.cad.cadTools.PointCadTool; |
59 |
import com.iver.cit.gvsig.fmap.edition.cad.cadTools.PolyLineCadTool; |
|
60 |
import com.iver.cit.gvsig.fmap.edition.cad.cadTools.RectangleCadTool; |
|
59 | 61 |
import com.iver.cit.gvsig.fmap.layers.CancelationException; |
60 | 62 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
61 | 63 |
import com.iver.cit.gvsig.fmap.layers.LayerCollectionEvent; |
... | ... | |
98 | 100 |
//Herramienta de CAD de a?adir l?nea |
99 | 101 |
LineCadTool lineCADTool = new LineCadTool(); |
100 | 102 |
addCadTool("line", lineCADTool); |
103 |
//Herramienta de CAD de a?adir polyl?nea |
|
104 |
PolyLineCadTool polylineCADTool = new PolyLineCadTool(); |
|
105 |
addCadTool("polyline", polylineCADTool); |
|
106 |
//Herramienta de CAD de a?adir rect?ngulo. |
|
107 |
RectangleCadTool rectangleCADTool = new RectangleCadTool(); |
|
108 |
addCadTool("rectangle", rectangleCADTool); |
|
101 | 109 |
|
102 | 110 |
this.setLayout(new BorderLayout()); |
103 | 111 |
this.setSize(300,200); |
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/cad/CADToolAdapter.java | ||
---|---|---|
121 | 121 |
|
122 | 122 |
transition("punto", editableFeatureSource, selection, |
123 | 123 |
new double[] { p2.getX(), p2.getY() }); |
124 |
if (e.getButton()==MouseEvent.BUTTON3){ |
|
125 |
transition("aceptar",editableFeatureSource,selection,new double[] { p2.getX(), p2.getY() }); |
|
126 |
}else if (e.getButton()==MouseEvent.BUTTON2){ |
|
127 |
transition("cancel",editableFeatureSource,selection,new double[] { p2.getX(), p2.getY() }); |
|
124 | 128 |
} |
129 |
} |
|
125 | 130 |
|
126 | 131 |
/** |
127 | 132 |
* Ajusta un punto de la imagen que se pasa como |
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/cad/cadTools/LineCadTool.java | ||
---|---|---|
125 | 125 |
* @see com.iver.cit.gvsig.fmap.edition.cad.CadTool#getQuestion() |
126 | 126 |
*/ |
127 | 127 |
public String getQuestion() { |
128 |
if (lineStatus.getStatus()==-1){ |
|
129 |
lineStatus=new Linea(); |
|
130 |
return "Cancel"; |
|
131 |
} |
|
132 |
|
|
128 | 133 |
return STATUS[lineStatus.getStatus()].getQuestion(); |
129 | 134 |
} |
130 | 135 |
} |
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/cad/cadTools/PolyLineCadTool.java | ||
---|---|---|
41 | 41 |
package com.iver.cit.gvsig.fmap.edition.cad.cadTools; |
42 | 42 |
|
43 | 43 |
import java.awt.Graphics; |
44 |
import java.io.IOException; |
|
45 |
import java.util.ArrayList; |
|
44 | 46 |
|
47 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
48 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
49 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
50 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
45 | 51 |
import com.iver.cit.gvsig.fmap.edition.EditableFeatureSource; |
46 | 52 |
import com.iver.cit.gvsig.fmap.edition.cad.CadTool; |
47 | 53 |
import com.iver.cit.gvsig.fmap.edition.cad.Status; |
... | ... | |
59 | 65 |
new Status("Precise punto siguiente"), |
60 | 66 |
}; |
61 | 67 |
private Polilinea polylineStatus = new Polilinea(); |
68 |
private ArrayList points= new ArrayList(); |
|
69 |
private int i=0; |
|
62 | 70 |
|
63 | 71 |
/** |
64 | 72 |
* @see com.iver.cit.gvsig.fmap.edition.cad.CadTool#transition(java.lang.String, |
... | ... | |
67 | 75 |
*/ |
68 | 76 |
public int transition(String text, EditableFeatureSource editingSource, |
69 | 77 |
FBitSet selectedGeometries, double[] values) { |
70 |
return 0; |
|
78 |
int ret = polylineStatus.transition(text); |
|
79 |
|
|
80 |
int status = polylineStatus.getStatus(); |
|
81 |
|
|
82 |
if (status == 0) { |
|
83 |
//firstPoint=new FPoint2D(values[0], values[1]); |
|
84 |
} else if (status == 1) { |
|
85 |
if (values.length != 0) { |
|
86 |
if (points.size() == 0) { |
|
87 |
|
|
88 |
points.add(i,new FPoint2D(values[0], values[1])); |
|
89 |
} |
|
90 |
|
|
91 |
points.add(i++,new FPoint2D(values[0], values[1])); |
|
92 |
} |
|
93 |
}else if(status == 2){ |
|
94 |
points.add(i++,points.get(0)); |
|
95 |
FPoint2D[] paux=(FPoint2D[])points.toArray(new FPoint2D[0]); |
|
96 |
try { |
|
97 |
editingSource.addGeometry(ShapeFactory.createPolygon2D(getGeneralPathX(paux))); |
|
98 |
} catch (DriverIOException e) { |
|
99 |
e.printStackTrace(); |
|
100 |
} catch (IOException e) { |
|
101 |
e.printStackTrace(); |
|
102 |
} |
|
103 |
ret=polylineStatus.transition("cancel"); |
|
104 |
}else if(status == 3){ |
|
105 |
FPoint2D[] paux=(FPoint2D[])points.toArray(new FPoint2D[0]); |
|
106 |
try { |
|
107 |
editingSource.addGeometry(ShapeFactory.createPolygon2D(getGeneralPathX(paux))); |
|
108 |
} catch (DriverIOException e) { |
|
109 |
e.printStackTrace(); |
|
110 |
} catch (IOException e) { |
|
111 |
e.printStackTrace(); |
|
112 |
} |
|
113 |
ret=polylineStatus.transition("cancel"); |
|
114 |
} |
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
return ret; |
|
71 | 119 |
} |
120 |
private GeneralPathX getGeneralPathX(FPoint2D[] paux){ |
|
121 |
int numPoints=paux.length; |
|
122 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, numPoints); |
|
123 |
int numParts=1; |
|
124 |
|
|
125 |
int[] tempParts = new int[numParts]; |
|
72 | 126 |
|
127 |
for (i = 0; i < numParts; i++) { |
|
128 |
} |
|
129 |
|
|
130 |
int j = 0; |
|
131 |
|
|
132 |
for (i = 0; i < numPoints; i++) { |
|
133 |
FPoint2D p = paux[i]; |
|
134 |
|
|
135 |
if (i == tempParts[j]) { |
|
136 |
elShape.moveTo(p.getX(), p.getY()); |
|
137 |
|
|
138 |
if (j < (numParts - 1)) { |
|
139 |
j++; |
|
140 |
} |
|
141 |
} else { |
|
142 |
elShape.lineTo(p.getX(), p.getY()); |
|
143 |
} |
|
144 |
} |
|
145 |
return elShape; |
|
146 |
} |
|
73 | 147 |
/** |
74 | 148 |
* @see com.iver.cit.gvsig.fmap.edition.cad.CadTool#drawOperation(java.awt.Graphics, |
75 | 149 |
* com.iver.cit.gvsig.fmap.edition.EditableFeatureSource, |
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/cad/cadTools/RectangleCadTool.java | ||
---|---|---|
41 | 41 |
package com.iver.cit.gvsig.fmap.edition.cad.cadTools; |
42 | 42 |
|
43 | 43 |
import java.awt.Graphics; |
44 |
import java.io.IOException; |
|
44 | 45 |
|
46 |
import com.iver.cit.gvsig.fmap.core.FPoint2D; |
|
47 |
import com.iver.cit.gvsig.fmap.core.GeneralPathX; |
|
48 |
import com.iver.cit.gvsig.fmap.core.ShapeFactory; |
|
49 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
|
45 | 50 |
import com.iver.cit.gvsig.fmap.edition.EditableFeatureSource; |
46 | 51 |
import com.iver.cit.gvsig.fmap.edition.cad.CadTool; |
47 | 52 |
import com.iver.cit.gvsig.fmap.edition.cad.Status; |
... | ... | |
59 | 64 |
new Status("Precise esquina opuesta"), |
60 | 65 |
}; |
61 | 66 |
private Rectangulo rectangleStatus = new Rectangulo(); |
62 |
|
|
67 |
private FPoint2D firstPoint; |
|
68 |
private FPoint2D lastPoint; |
|
63 | 69 |
/** |
64 | 70 |
* @see com.iver.cit.gvsig.fmap.edition.cad.CadTool#transition(java.lang.String, |
65 | 71 |
* com.iver.cit.gvsig.fmap.edition.EditableFeatureSource, |
... | ... | |
67 | 73 |
*/ |
68 | 74 |
public int transition(String text, EditableFeatureSource editingSource, |
69 | 75 |
FBitSet selectedGeometries, double[] values) { |
70 |
return 0; |
|
76 |
int ret = rectangleStatus.transition(text); |
|
77 |
|
|
78 |
int status = rectangleStatus.getStatus(); |
|
79 |
|
|
80 |
if (status == 0) { |
|
81 |
//firstPoint=new FPoint2D(values[0], values[1]); |
|
82 |
} else if (status == 1) { |
|
83 |
if (firstPoint == null) { |
|
84 |
if (values.length != 0) { |
|
85 |
firstPoint = new FPoint2D(values[0], values[1]); |
|
86 |
} |
|
87 |
} |
|
88 |
|
|
89 |
}else if(status == 2){ |
|
90 |
if (values.length != 0) { |
|
91 |
lastPoint = new FPoint2D(values[0], values[1]); |
|
92 |
} |
|
93 |
|
|
94 |
try { |
|
95 |
GeneralPathX elShape = new GeneralPathX(GeneralPathX.WIND_EVEN_ODD, |
|
96 |
4); |
|
97 |
elShape.moveTo(firstPoint.getX(), firstPoint.getY()); |
|
98 |
elShape.lineTo(lastPoint.getX(), firstPoint.getY()); |
|
99 |
elShape.lineTo(lastPoint.getX(), lastPoint.getY()); |
|
100 |
elShape.lineTo(firstPoint.getX(), lastPoint.getY()); |
|
101 |
elShape.lineTo(firstPoint.getX(), firstPoint.getY()); |
|
102 |
editingSource.addGeometry(ShapeFactory.createPolyline2D( |
|
103 |
elShape)); |
|
104 |
} catch (DriverIOException e) { |
|
105 |
e.printStackTrace(); |
|
106 |
} catch (IOException e) { |
|
107 |
e.printStackTrace(); |
|
108 |
} |
|
109 |
ret = rectangleStatus.transition("cancel"); |
|
110 |
} |
|
111 |
|
|
112 |
return ret; |
|
113 |
|
|
71 | 114 |
} |
72 | 115 |
|
73 | 116 |
/** |
... | ... | |
83 | 126 |
* @see com.iver.cit.gvsig.fmap.edition.cad.CadTool#getQuestion() |
84 | 127 |
*/ |
85 | 128 |
public String getQuestion() { |
129 |
int status=rectangleStatus.getStatus(); |
|
130 |
if (status==-1){ |
|
131 |
return "Cancel"; |
|
132 |
}else if (status==2){ |
|
133 |
return "Aceptar"; |
|
134 |
} |
|
86 | 135 |
return STATUS[rectangleStatus.getStatus()].getQuestion(); |
87 | 136 |
} |
88 | 137 |
} |
branches/pilotoDWG/libraries/libFMap/src/com/iver/cit/gvsig/fmap/edition/cad/cadTools/Polilinea.java | ||
---|---|---|
44 | 44 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS; |
45 | 45 |
} |
46 | 46 |
|
47 |
if ("aceptar".equalsIgnoreCase(label)){ |
|
48 |
status = 3; |
|
49 |
|
|
50 |
return com.iver.fsac.Automaton.TRANSITION_SUCCESS; |
|
51 |
} |
|
52 |
|
|
47 | 53 |
if ("cancel".equalsIgnoreCase(label)){ |
48 | 54 |
status = -1; |
49 | 55 |
|
... | ... | |
62 | 68 |
|
63 | 69 |
break; |
64 | 70 |
|
71 |
case 3: |
|
72 |
|
|
73 |
if ("cancel".equalsIgnoreCase(label)){ |
|
74 |
status = -1; |
|
75 |
|
|
76 |
return com.iver.fsac.Automaton.AUTOMATON_FINISHED; |
|
77 |
} |
|
78 |
|
|
79 |
break; |
|
80 |
|
|
65 | 81 |
} |
66 | 82 |
|
67 | 83 |
return com.iver.fsac.Automaton.TRANSITION_FAILED; |
Also available in: Unified diff