Revision 1548 branches/pilotoDWG/applications/appgvSIG/src/com/iver/cit/gvsig/gui/cad/tools/CircleCadTool.java
CircleCadTool.java | ||
---|---|---|
49 | 49 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
50 | 50 |
import com.iver.cit.gvsig.fmap.edition.EditableFeatureSource; |
51 | 51 |
import com.iver.cit.gvsig.fmap.edition.cad.Status; |
52 |
import com.iver.cit.gvsig.fmap.edition.cad.TrigonometricalFunctions; |
|
52 | 53 |
import com.iver.cit.gvsig.fmap.layers.FBitSet; |
53 | 54 |
import com.iver.cit.gvsig.gui.cad.CadTool; |
54 | 55 |
import com.iver.cit.gvsig.gui.cad.automaton.Circulo; |
... | ... | |
62 | 63 |
*/ |
63 | 64 |
public class CircleCadTool extends AbstractCadTool { |
64 | 65 |
private static Status[] STATUS = { |
65 |
new Status("Precise punto central"), new Status("Precise radio") |
|
66 |
new Status("Precise punto central o [3P]"), |
|
67 |
new Status("Precise radio"), |
|
68 |
new Status("Precise primer punto del c?rculo"), |
|
69 |
new Status("Precise segundo punto del c?rculo"), |
|
70 |
new Status("Precise tercer punto del c?rculo"), |
|
66 | 71 |
}; |
67 | 72 |
private Circulo circleStatus = new Circulo(); |
68 | 73 |
private Point2D center; |
74 |
private Point2D p1; |
|
75 |
private Point2D p2; |
|
76 |
private Point2D p3; |
|
69 | 77 |
|
70 | 78 |
/** |
71 | 79 |
* @see com.iver.cit.gvsig.gui.cad.CadTool#transition(java.lang.String, |
... | ... | |
81 | 89 |
if (status == 0) { |
82 | 90 |
} else if (status == 1) { |
83 | 91 |
center = new Point2D.Double(values[0], values[1]); |
84 |
} else if (status == 2) { |
|
92 |
}else if (status == 2) { |
|
93 |
|
|
94 |
}else if (status == 3) { |
|
95 |
p1=new Point2D.Double(values[0], values[1]); |
|
96 |
}else if (status == 4) { |
|
97 |
p2=new Point2D.Double(values[0], values[1]); |
|
98 |
}else if (status == 5) { |
|
99 |
p3=new Point2D.Double(values[0], values[1]); |
|
100 |
center=TrigonometricalFunctions.getCircleCenter(p1,p2,p3); |
|
101 |
double radio=center.distance(p1); |
|
85 | 102 |
try { |
103 |
editingSource.addGeometry(ShapeFactory.createCircle(center,radio)); |
|
104 |
} catch (DriverIOException e) { |
|
105 |
e.printStackTrace(); |
|
106 |
} catch (IOException e) { |
|
107 |
e.printStackTrace(); |
|
108 |
} |
|
109 |
ret = ret | circleStatus.transition("cancel"); |
|
110 |
} else if (status == 6) { |
|
111 |
try { |
|
86 | 112 |
editingSource.addGeometry(ShapeFactory.createCircle(center, values[0])); |
87 | 113 |
} catch (DriverIOException e) { |
88 | 114 |
e.printStackTrace(); |
... | ... | |
90 | 116 |
e.printStackTrace(); |
91 | 117 |
} |
92 | 118 |
ret = ret | circleStatus.transition("cancel"); |
93 |
} else if (status == 3) {
|
|
119 |
} else if (status == 7) {
|
|
94 | 120 |
try { |
95 | 121 |
editingSource.addGeometry(ShapeFactory.createCircle(center, new Point2D.Double(values[0], values[1]))); |
96 | 122 |
} catch (DriverIOException e) { |
... | ... | |
117 | 143 |
Point2D currentPoint = new Point2D.Double(x, y); |
118 | 144 |
double dist = currentPoint.distance(center); |
119 | 145 |
ShapeFactory.createCircle(center, dist).draw((Graphics2D) g, getCadToolAdapter().getMapControl().getViewPort(), CadTool.modifySymbol); |
146 |
}else if (status == 2){ |
|
147 |
}else if (status == 3){ |
|
148 |
drawLine((Graphics2D)g,p1,new Point2D.Double(x,y)); |
|
149 |
}else if (status == 4){ |
|
150 |
Point2D currentPoint=new Point2D.Double(x,y); |
|
151 |
if (p1.getX()==p2.getX()){ |
|
152 |
p2=new Point2D.Double(p2.getX()+0.0000001,p2.getY()); |
|
153 |
}else if (p1.getY()==p2.getY()){ |
|
154 |
p2=new Point2D.Double(p2.getX(),p2.getY()+0.0000001); |
|
155 |
}/*if (currentPoint.getX()==p1.getX()){ |
|
156 |
currentPoint=new Point2D.Double(currentPoint.getX()+0.0000001,currentPoint.getY()); |
|
157 |
}else if (currentPoint.getY()==p1.getY()){ |
|
158 |
currentPoint=new Point2D.Double(currentPoint.getX(),currentPoint.getY()+0.0000001); |
|
159 |
}if (currentPoint.getX()==p2.getX()){ |
|
160 |
currentPoint=new Point2D.Double(currentPoint.getX()+0.0000001,currentPoint.getY()); |
|
161 |
}else if (currentPoint.getY()==p2.getY()){ |
|
162 |
currentPoint=new Point2D.Double(currentPoint.getX(),currentPoint.getY()+0.0000001); |
|
163 |
}*/ |
|
164 |
Point2D currentCenter=TrigonometricalFunctions.getCircleCenter(p1,p2,currentPoint); |
|
165 |
double radio=currentCenter.distance(p1); |
|
166 |
ShapeFactory.createCircle(currentCenter, radio).draw((Graphics2D) g, getCadToolAdapter().getMapControl().getViewPort(), CadTool.modifySymbol); |
|
120 | 167 |
} |
121 | 168 |
} |
122 | 169 |
|
Also available in: Unified diff