Revision 30335 branches/v2_0_0_prep/extensions/extEditing/src/org/gvsig/editing/gui/cad/tools/InternalPolygonCADTool.java
InternalPolygonCADTool.java | ||
---|---|---|
41 | 41 |
package org.gvsig.editing.gui.cad.tools; |
42 | 42 |
|
43 | 43 |
import java.awt.Component; |
44 |
import java.awt.Graphics; |
|
45 |
import java.awt.Graphics2D; |
|
46 | 44 |
import java.awt.event.InputEvent; |
47 | 45 |
import java.awt.event.MouseEvent; |
48 | 46 |
import java.awt.geom.PathIterator; |
... | ... | |
75 | 73 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
76 | 74 |
import org.gvsig.fmap.geom.primitive.GeneralPathX; |
77 | 75 |
import org.gvsig.fmap.geom.util.Converter; |
76 |
import org.gvsig.fmap.mapcontrol.MapControlDrawer; |
|
78 | 77 |
|
79 | 78 |
import com.vividsolutions.jts.geom.GeometryCollection; |
80 | 79 |
|
... | ... | |
85 | 84 |
* @author Vicente Caballero Navarro |
86 | 85 |
*/ |
87 | 86 |
public class InternalPolygonCADTool extends DefaultCADTool { |
88 |
protected InternalPolygonCADToolContext _fsm;
|
|
89 |
protected ArrayList<Point2D> points=new ArrayList<Point2D>();
|
|
90 |
protected Geometry geometry=null;
|
|
87 |
protected InternalPolygonCADToolContext _fsm;
|
|
88 |
protected ArrayList<Point2D> points=new ArrayList<Point2D>();
|
|
89 |
protected Geometry geometry=null;
|
|
91 | 90 |
|
92 |
/**
|
|
93 |
* Crea un nuevo PolylineCADTool.
|
|
94 |
*/
|
|
95 |
public InternalPolygonCADTool() {
|
|
96 |
}
|
|
91 |
/**
|
|
92 |
* Crea un nuevo PolylineCADTool.
|
|
93 |
*/
|
|
94 |
public InternalPolygonCADTool() {
|
|
95 |
}
|
|
97 | 96 |
|
98 |
/**
|
|
99 |
* M?todo de incio, para poner el c?digo de todo lo que se requiera de una
|
|
100 |
* carga previa a la utilizaci?n de la herramienta.
|
|
101 |
*/
|
|
102 |
public void init() {
|
|
103 |
_fsm = new InternalPolygonCADToolContext(this);
|
|
104 |
points.clear();
|
|
105 |
}
|
|
97 |
/**
|
|
98 |
* M?todo de incio, para poner el c?digo de todo lo que se requiera de una
|
|
99 |
* carga previa a la utilizaci?n de la herramienta.
|
|
100 |
*/
|
|
101 |
public void init() {
|
|
102 |
_fsm = new InternalPolygonCADToolContext(this);
|
|
103 |
points.clear();
|
|
104 |
}
|
|
106 | 105 |
|
107 |
/* (non-Javadoc)
|
|
108 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double, double)
|
|
109 |
*/
|
|
110 |
public void transition(double x, double y, InputEvent event) {
|
|
111 |
_fsm.addPoint(x, y, event);
|
|
112 |
}
|
|
106 |
/* (non-Javadoc)
|
|
107 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double, double)
|
|
108 |
*/
|
|
109 |
public void transition(double x, double y, InputEvent event) {
|
|
110 |
_fsm.addPoint(x, y, event);
|
|
111 |
}
|
|
113 | 112 |
|
114 |
/* (non-Javadoc)
|
|
115 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double)
|
|
116 |
*/
|
|
117 |
public void transition(double d) {
|
|
118 |
_fsm.addValue(d);
|
|
119 |
}
|
|
113 |
/* (non-Javadoc)
|
|
114 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, double)
|
|
115 |
*/
|
|
116 |
public void transition(double d) {
|
|
117 |
_fsm.addValue(d);
|
|
118 |
}
|
|
120 | 119 |
|
121 |
/* (non-Javadoc)
|
|
122 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String)
|
|
123 |
*/
|
|
124 |
public void transition(String s) throws CommandException {
|
|
125 |
if (!super.changeCommand(s)){
|
|
126 |
_fsm.addOption(s);
|
|
127 |
}
|
|
128 |
}
|
|
120 |
/* (non-Javadoc)
|
|
121 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#transition(com.iver.cit.gvsig.fmap.layers.FBitSet, java.lang.String)
|
|
122 |
*/
|
|
123 |
public void transition(String s) throws CommandException {
|
|
124 |
if (!super.changeCommand(s)){
|
|
125 |
_fsm.addOption(s);
|
|
126 |
}
|
|
127 |
}
|
|
129 | 128 |
|
130 |
/**
|
|
131 |
* DOCUMENT ME!
|
|
132 |
*/
|
|
133 |
public void selection() {
|
|
134 |
FeatureSet selection=null;
|
|
135 |
try {
|
|
136 |
selection = (FeatureSet)getVLE().getFeatureStore().getSelection();
|
|
129 |
/**
|
|
130 |
* DOCUMENT ME!
|
|
131 |
*/
|
|
132 |
public void selection() {
|
|
133 |
FeatureSet selection=null;
|
|
134 |
try {
|
|
135 |
selection = (FeatureSet)getVLE().getFeatureStore().getSelection();
|
|
137 | 136 |
|
138 |
if (selection.getSize() == 0 && !CADExtension.getCADTool().getClass().getName().equals("com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool")) { |
|
139 |
CADExtension.setCADTool("_selection",false); |
|
140 |
((SelectionCADTool) CADExtension.getCADTool()).setNextTool( |
|
141 |
"_internalpolygon"); |
|
142 |
} |
|
143 |
} catch (ReadException e) { |
|
144 |
// TODO Auto-generated catch block |
|
145 |
e.printStackTrace(); |
|
146 |
} catch (DataException e) { |
|
137 |
if (selection.getSize() == 0 && !CADExtension.getCADTool().getClass().getName().equals("com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool")) { |
|
138 |
CADExtension.setCADTool("_selection",false); |
|
139 |
((SelectionCADTool) CADExtension.getCADTool()).setNextTool( |
|
140 |
"_internalpolygon"); |
|
141 |
} |
|
142 |
} catch (ReadException e) { |
|
147 | 143 |
// TODO Auto-generated catch block |
148 | 144 |
e.printStackTrace(); |
145 |
} catch (DataException e) { |
|
146 |
// TODO Auto-generated catch block |
|
147 |
e.printStackTrace(); |
|
149 | 148 |
} |
150 |
}
|
|
149 |
}
|
|
151 | 150 |
|
152 |
/** |
|
153 |
* Equivale al transition del prototipo pero sin pasarle como par?metro el |
|
154 |
* editableFeatureSource que ya estar? creado. |
|
155 |
* |
|
156 |
* @param x par?metro x del punto que se pase en esta transici?n. |
|
157 |
* @param y par?metro y del punto que se pase en esta transici?n. |
|
158 |
*/ |
|
159 |
public void addPoint(double x, double y,InputEvent event) { |
|
160 |
if (((MouseEvent)event).getClickCount()==2){ |
|
161 |
addOption(PluginServices.getText(this,"InternalPolygonCADTool.end")); |
|
162 |
return; |
|
163 |
} |
|
164 |
VectorialLayerEdited vle=getVLE(); |
|
165 |
FeatureSet featureCollection=null; |
|
166 |
try { |
|
167 |
featureCollection = (FeatureSet)vle.getFeatureStore().getSelection(); |
|
168 |
if (featureCollection.getSize()==1){ |
|
169 |
Feature feature=(Feature) featureCollection.iterator().next(); |
|
170 |
geometry=(feature.getDefaultGeometry()).cloneGeometry(); |
|
171 |
if (geometry.contains(x,y)){ |
|
172 |
points.add(new Point2D.Double(x,y)); |
|
173 |
}else{ |
|
174 |
JOptionPane.showMessageDialog(((Component)PluginServices.getMainFrame()),PluginServices.getText(this,"debe_insertar_el_punto_dentro_de_los_limites_de_la_geometria")); |
|
175 |
} |
|
176 |
} |
|
177 |
} catch (ReadException e) { |
|
178 |
NotificationManager.addError(e.getMessage(),e); |
|
179 |
} catch (DataException e) { |
|
180 |
NotificationManager.addError(e.getMessage(),e); |
|
151 |
/** |
|
152 |
* Equivale al transition del prototipo pero sin pasarle como par?metro el |
|
153 |
* editableFeatureSource que ya estar? creado. |
|
154 |
* |
|
155 |
* @param x par?metro x del punto que se pase en esta transici?n. |
|
156 |
* @param y par?metro y del punto que se pase en esta transici?n. |
|
157 |
*/ |
|
158 |
public void addPoint(double x, double y,InputEvent event) { |
|
159 |
if (((MouseEvent)event).getClickCount()==2){ |
|
160 |
addOption(PluginServices.getText(this,"InternalPolygonCADTool.end")); |
|
161 |
return; |
|
181 | 162 |
} |
163 |
VectorialLayerEdited vle=getVLE(); |
|
164 |
FeatureSet featureCollection=null; |
|
165 |
try { |
|
166 |
featureCollection = (FeatureSet)vle.getFeatureStore().getSelection(); |
|
167 |
if (featureCollection.getSize()==1){ |
|
168 |
Feature feature=(Feature) featureCollection.iterator().next(); |
|
169 |
geometry=(feature.getDefaultGeometry()).cloneGeometry(); |
|
170 |
if (geometry.contains(x,y)){ |
|
171 |
points.add(new Point2D.Double(x,y)); |
|
172 |
}else{ |
|
173 |
JOptionPane.showMessageDialog(((Component)PluginServices.getMainFrame()),PluginServices.getText(this,"debe_insertar_el_punto_dentro_de_los_limites_de_la_geometria")); |
|
174 |
} |
|
175 |
} |
|
176 |
} catch (ReadException e) { |
|
177 |
NotificationManager.addError(e.getMessage(),e); |
|
178 |
} catch (DataException e) { |
|
179 |
NotificationManager.addError(e.getMessage(),e); |
|
180 |
} |
|
182 | 181 |
} |
183 | 182 |
|
184 | 183 |
/** |
185 |
* M?todo para dibujar la lo necesario para el estado en el que nos
|
|
186 |
* encontremos.
|
|
187 |
*
|
|
188 |
* @param g Graphics sobre el que dibujar.
|
|
189 |
* @param x par?metro x del punto que se pase para dibujar.
|
|
190 |
* @param y par?metro x del punto que se pase para dibujar.
|
|
191 |
*/
|
|
192 |
public void drawOperation(Graphics g, double x, double y) {
|
|
193 |
Point2D[] ps=points.toArray(new Point2D[0]);
|
|
194 |
GeneralPathX gpx=new GeneralPathX();
|
|
195 |
GeneralPathX gpx1=new GeneralPathX();
|
|
184 |
* M?todo para dibujar la lo necesario para el estado en el que nos
|
|
185 |
* encontremos.
|
|
186 |
*
|
|
187 |
* @param g Graphics sobre el que dibujar.
|
|
188 |
* @param x par?metro x del punto que se pase para dibujar.
|
|
189 |
* @param y par?metro x del punto que se pase para dibujar.
|
|
190 |
*/
|
|
191 |
public void drawOperation(MapControlDrawer renderer, double x, double y) {
|
|
192 |
Point2D[] ps=points.toArray(new Point2D[0]);
|
|
193 |
GeneralPathX gpx=new GeneralPathX();
|
|
194 |
GeneralPathX gpx1=new GeneralPathX();
|
|
196 | 195 |
|
197 |
if (ps.length>0){
|
|
198 |
for (int i=0;i<ps.length;i++){
|
|
199 |
if (i==0){
|
|
200 |
gpx.moveTo(ps[i].getX(),ps[i].getY());
|
|
201 |
gpx1.moveTo(ps[i].getX(),ps[i].getY());
|
|
202 |
}else{
|
|
203 |
gpx.lineTo(ps[i].getX(),ps[i].getY());
|
|
204 |
gpx1.lineTo(ps[i].getX(),ps[i].getY());
|
|
205 |
}
|
|
196 |
if (ps.length>0){
|
|
197 |
for (int i=0;i<ps.length;i++){
|
|
198 |
if (i==0){
|
|
199 |
gpx.moveTo(ps[i].getX(),ps[i].getY());
|
|
200 |
gpx1.moveTo(ps[i].getX(),ps[i].getY());
|
|
201 |
}else{
|
|
202 |
gpx.lineTo(ps[i].getX(),ps[i].getY());
|
|
203 |
gpx1.lineTo(ps[i].getX(),ps[i].getY());
|
|
204 |
}
|
|
206 | 205 |
|
207 |
} |
|
208 |
DrawOperationContext doc=new DrawOperationContext(); |
|
209 |
doc.setGraphics((Graphics2D)g); |
|
210 |
doc.setViewPort(getCadToolAdapter().getMapControl().getViewPort()); |
|
211 |
doc.setSymbol(DefaultCADTool.selectionSymbol); |
|
212 |
gpx.lineTo(x,y); |
|
213 |
gpx.closePath(); |
|
214 |
gpx1.closePath(); |
|
215 |
// if (ps.length==1){ |
|
216 |
// Geometry geom=geomFactory.createPolyline2D(gpx); |
|
217 |
// |
|
218 |
// try { |
|
219 |
// geom.invokeOperation(DrawInts.CODE,doc); |
|
220 |
// } catch (GeometryOperationNotSupportedException e) { |
|
221 |
// e.printStackTrace(); |
|
222 |
// } catch (GeometryOperationException e) { |
|
223 |
// e.printStackTrace(); |
|
224 |
// } |
|
225 |
//// geom.drawInts((Graphics2D)g,CADExtension.getEditionManager().getMapControl().getViewPort(),DefaultCADTool.geometrySelectSymbol); |
|
226 |
// } |
|
227 |
Geometry geom = createSurface(gpx); |
|
228 |
Geometry geom1 = createSurface(gpx1); |
|
229 |
try { |
|
206 |
} |
|
207 |
gpx.lineTo(x,y); |
|
208 |
gpx.closePath(); |
|
209 |
gpx1.closePath(); |
|
230 | 210 |
|
231 |
geom1.invokeOperation(DrawInts.CODE,doc); |
|
232 |
} catch (GeometryOperationNotSupportedException e) { |
|
233 |
e.printStackTrace(); |
|
234 |
} catch (GeometryOperationException e) { |
|
235 |
e.printStackTrace(); |
|
236 |
} |
|
211 |
Geometry geom = createSurface(gpx); |
|
212 |
Geometry geom1 = createSurface(gpx1); |
|
237 | 213 |
|
238 |
try { |
|
239 |
doc.setSymbol(DefaultCADTool.geometrySelectSymbol); |
|
240 |
|
|
241 |
geom.invokeOperation(DrawInts.CODE,doc); |
|
242 |
} catch (GeometryOperationNotSupportedException e) { |
|
243 |
e.printStackTrace(); |
|
244 |
} catch (GeometryOperationException e) { |
|
245 |
e.printStackTrace(); |
|
214 |
renderer.draw(geom1, mapControlManager.getSelectionSymbol()); |
|
215 |
renderer.draw(geom,mapControlManager.getGeometrySelectionSymbol()); |
|
246 | 216 |
} |
247 |
} |
|
248 |
} |
|
217 |
} |
|
249 | 218 |
|
250 |
/**
|
|
251 |
* Add a diferent option.
|
|
252 |
*
|
|
253 |
* @param s Diferent option.
|
|
254 |
*/
|
|
255 |
public void addOption(String s) {
|
|
256 |
VectorialLayerEdited vle=getVLE();
|
|
257 |
FeatureStore featureStore=null;
|
|
258 |
try {
|
|
219 |
/**
|
|
220 |
* Add a diferent option.
|
|
221 |
*
|
|
222 |
* @param s Diferent option.
|
|
223 |
*/
|
|
224 |
public void addOption(String s) {
|
|
225 |
VectorialLayerEdited vle=getVLE();
|
|
226 |
FeatureStore featureStore=null;
|
|
227 |
try {
|
|
259 | 228 |
featureStore = vle.getFeatureStore(); |
260 | 229 |
} catch (ReadException e1) { |
261 | 230 |
// TODO Auto-generated catch block |
262 | 231 |
e1.printStackTrace(); |
263 | 232 |
} |
264 |
DisposableIterator iterator = null;
|
|
265 |
try {
|
|
233 |
DisposableIterator iterator = null;
|
|
234 |
try {
|
|
266 | 235 |
iterator = ((FeatureSelection) featureStore.getSelection()) |
267 |
.iterator();
|
|
236 |
.iterator(); |
|
268 | 237 |
if (s.equals(PluginServices.getText(this, "end")) |
269 | 238 |
|| s.equalsIgnoreCase(PluginServices.getText(this, |
270 |
"InternalPolygonCADTool.end"))) {
|
|
239 |
"InternalPolygonCADTool.end"))) { |
|
271 | 240 |
if (points.size() > 0) { |
272 | 241 |
Feature feature = (Feature) iterator.next(); |
273 | 242 |
geometry = (feature.getDefaultGeometry()).cloneGeometry(); |
... | ... | |
294 | 263 |
rows.add(feature); |
295 | 264 |
// vle.setSelectionCache(VectorialLayerEdited.NOTSAVEPREVIOUS, |
296 | 265 |
// rows); |
297 |
}
|
|
298 |
points.clear();
|
|
266 |
}
|
|
267 |
points.clear();
|
|
299 | 268 |
refresh(); |
300 | 269 |
|
301 |
} else if (s.equals(PluginServices.getText(this, "cancel"))) {
|
|
270 |
} else if (s.equals(PluginServices.getText(this, "cancel"))) {
|
|
302 | 271 |
points.clear(); |
303 | 272 |
} |
304 | 273 |
} catch (DataException e1) { |
... | ... | |
306 | 275 |
iterator.dispose(); |
307 | 276 |
} |
308 | 277 |
e1.printStackTrace(); |
309 |
}
|
|
310 |
}
|
|
311 |
/* (non-Javadoc)
|
|
312 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
|
|
313 |
*/
|
|
314 |
public void addValue(double d) {
|
|
315 |
}
|
|
316 |
private Geometry createNewPolygon(Geometry gp,Point2D[] ps) {
|
|
317 |
GeneralPathX newGp = new GeneralPathX();
|
|
318 |
double[] theData = new double[6];
|
|
278 |
}
|
|
279 |
}
|
|
280 |
/* (non-Javadoc)
|
|
281 |
* @see com.iver.cit.gvsig.gui.cad.CADTool#addvalue(double)
|
|
282 |
*/
|
|
283 |
public void addValue(double d) {
|
|
284 |
}
|
|
285 |
private Geometry createNewPolygon(Geometry gp,Point2D[] ps) {
|
|
286 |
GeneralPathX newGp = new GeneralPathX();
|
|
287 |
double[] theData = new double[6];
|
|
319 | 288 |
|
320 |
PathIterator theIterator;
|
|
321 |
int theType;
|
|
322 |
int numParts = 0;
|
|
289 |
PathIterator theIterator;
|
|
290 |
int theType;
|
|
291 |
int numParts = 0;
|
|
323 | 292 |
|
324 | 293 |
|
325 |
theIterator = gp.getPathIterator(null, Converter.FLATNESS);
|
|
326 |
while (!theIterator.isDone()) {
|
|
327 |
theType = theIterator.currentSegment(theData);
|
|
328 |
switch (theType) {
|
|
294 |
theIterator = gp.getPathIterator(null, geomManager.getFlatness());
|
|
295 |
while (!theIterator.isDone()) {
|
|
296 |
theType = theIterator.currentSegment(theData);
|
|
297 |
switch (theType) {
|
|
329 | 298 |
|
330 |
case PathIterator.SEG_MOVETO:
|
|
331 |
numParts++;
|
|
332 |
newGp.moveTo(theData[0], theData[1]);
|
|
333 |
break;
|
|
299 |
case PathIterator.SEG_MOVETO:
|
|
300 |
numParts++;
|
|
301 |
newGp.moveTo(theData[0], theData[1]);
|
|
302 |
break;
|
|
334 | 303 |
|
335 |
case PathIterator.SEG_LINETO:
|
|
336 |
newGp.lineTo(theData[0], theData[1]);
|
|
337 |
break;
|
|
304 |
case PathIterator.SEG_LINETO:
|
|
305 |
newGp.lineTo(theData[0], theData[1]);
|
|
306 |
break;
|
|
338 | 307 |
|
339 |
case PathIterator.SEG_QUADTO:
|
|
340 |
newGp.quadTo(theData[0], theData[1], theData[2], theData[3]);
|
|
341 |
break;
|
|
308 |
case PathIterator.SEG_QUADTO:
|
|
309 |
newGp.quadTo(theData[0], theData[1], theData[2], theData[3]);
|
|
310 |
break;
|
|
342 | 311 |
|
343 |
case PathIterator.SEG_CUBICTO:
|
|
344 |
newGp.curveTo(theData[0], theData[1], theData[2], theData[3], theData[4], theData[5]);
|
|
345 |
break;
|
|
312 |
case PathIterator.SEG_CUBICTO:
|
|
313 |
newGp.curveTo(theData[0], theData[1], theData[2], theData[3], theData[4], theData[5]);
|
|
314 |
break;
|
|
346 | 315 |
|
347 |
case PathIterator.SEG_CLOSE:
|
|
348 |
newGp.closePath();
|
|
349 |
break;
|
|
350 |
} //end switch
|
|
316 |
case PathIterator.SEG_CLOSE:
|
|
317 |
newGp.closePath();
|
|
318 |
break;
|
|
319 |
} //end switch
|
|
351 | 320 |
|
352 |
theIterator.next();
|
|
353 |
} //end while loop
|
|
354 |
GeneralPathX gpxInternal=new GeneralPathX();
|
|
355 |
gpxInternal.moveTo(ps[ps.length-1].getX(),ps[ps.length-1].getY());
|
|
356 |
for (int i=ps.length-1;i>=0;i--){
|
|
357 |
gpxInternal.lineTo(ps[i].getX(),ps[i].getY());
|
|
358 |
}
|
|
359 |
gpxInternal.lineTo(ps[ps.length-1].getX(),ps[ps.length-1].getY());
|
|
360 |
if (!gpxInternal.isCCW()) {
|
|
361 |
gpxInternal.flip();
|
|
362 |
}
|
|
363 |
newGp.append(gpxInternal.getPathIterator(null),false);
|
|
321 |
theIterator.next();
|
|
322 |
} //end while loop
|
|
323 |
GeneralPathX gpxInternal=new GeneralPathX();
|
|
324 |
gpxInternal.moveTo(ps[ps.length-1].getX(),ps[ps.length-1].getY());
|
|
325 |
for (int i=ps.length-1;i>=0;i--){
|
|
326 |
gpxInternal.lineTo(ps[i].getX(),ps[i].getY());
|
|
327 |
}
|
|
328 |
gpxInternal.lineTo(ps[ps.length-1].getX(),ps[ps.length-1].getY());
|
|
329 |
if (!gpxInternal.isCCW()) {
|
|
330 |
gpxInternal.flip();
|
|
331 |
}
|
|
332 |
newGp.append(gpxInternal.getPathIterator(null),false);
|
|
364 | 333 |
|
365 |
return createSurface(newGp);
|
|
366 |
}
|
|
367 |
private Geometry createNewPolygonGC(BaseMultiPrimitive gp,Point2D[] ps) {
|
|
368 |
ArrayList geoms=new ArrayList();
|
|
369 |
Geometry[] geometries=gp.getGeometries();
|
|
370 |
for (int i = 0;i<geometries.length;i++) {
|
|
371 |
geoms.add(geometries[i]);
|
|
372 |
}
|
|
373 |
GeneralPathX gpx=new GeneralPathX();
|
|
334 |
return createSurface(newGp);
|
|
335 |
}
|
|
336 |
private Geometry createNewPolygonGC(BaseMultiPrimitive gp,Point2D[] ps) {
|
|
337 |
ArrayList geoms=new ArrayList();
|
|
338 |
Geometry[] geometries=gp.getGeometries();
|
|
339 |
for (int i = 0;i<geometries.length;i++) {
|
|
340 |
geoms.add(geometries[i]);
|
|
341 |
}
|
|
342 |
GeneralPathX gpx=new GeneralPathX();
|
|
374 | 343 |
gpx.moveTo(ps[ps.length-1].getX(),ps[ps.length-1].getY()); |
375 |
for (int i=ps.length-2;i>=0;i--){
|
|
376 |
gpx.lineTo(ps[i].getX(),ps[i].getY());
|
|
377 |
geoms.add(createCurve(gpx));
|
|
378 |
gpx=new GeneralPathX();
|
|
379 |
gpx.moveTo(ps[i].getX(),ps[i].getY());
|
|
380 |
}
|
|
381 |
gpx.lineTo(ps[ps.length-1].getX(),ps[ps.length-1].getY());
|
|
382 |
geoms.add(createCurve(gpx));
|
|
383 |
MultiPrimitive gc = createMultiPrimitive(((Geometry[])geoms.toArray(new Geometry[0])));
|
|
384 |
return gc;
|
|
385 |
}
|
|
386 |
public String getName() {
|
|
344 |
for (int i=ps.length-2;i>=0;i--){
|
|
345 |
gpx.lineTo(ps[i].getX(),ps[i].getY());
|
|
346 |
geoms.add(createCurve(gpx));
|
|
347 |
gpx=new GeneralPathX();
|
|
348 |
gpx.moveTo(ps[i].getX(),ps[i].getY());
|
|
349 |
}
|
|
350 |
gpx.lineTo(ps[ps.length-1].getX(),ps[ps.length-1].getY());
|
|
351 |
geoms.add(createCurve(gpx));
|
|
352 |
MultiPrimitive gc = createMultiPrimitive(((Geometry[])geoms.toArray(new Geometry[0])));
|
|
353 |
return gc;
|
|
354 |
}
|
|
355 |
public String getName() {
|
|
387 | 356 |
return PluginServices.getText(this,"internal_polygon_"); |
388 | 357 |
} |
389 | 358 |
|
Also available in: Unified diff