root / tags / v1_1_Build_1005 / extensions / extExpressionField / src / com / iver / cit / gvsig / project / documents / table / GraphicOperator.java @ 12355
History | View | Annotate | Download (1.99 KB)
1 |
package com.iver.cit.gvsig.project.documents.table; |
---|---|
2 |
|
3 |
import java.awt.geom.PathIterator; |
4 |
import java.util.ArrayList; |
5 |
|
6 |
import com.iver.cit.gvsig.fmap.core.IGeometry; |
7 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
8 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
9 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
10 |
/**
|
11 |
* @author Vicente Caballero Navarro
|
12 |
*/
|
13 |
public abstract class GraphicOperator extends AbstractOperator{ |
14 |
private FLyrVect lv=null; |
15 |
public void setLayer(FLyrVect lv) { |
16 |
this.lv=lv;
|
17 |
} |
18 |
public FLyrVect getLayer() {
|
19 |
return lv;
|
20 |
} |
21 |
public abstract double process(Index index) throws DriverIOException; |
22 |
protected Double[][] getXY(IGeometry geometry) { |
23 |
ArrayList xs = new ArrayList(); |
24 |
ArrayList ys = new ArrayList(); |
25 |
double[] theData = new double[6]; |
26 |
|
27 |
//double[] aux = new double[6];
|
28 |
PathIterator theIterator;
|
29 |
int theType;
|
30 |
int numParts = 0; |
31 |
|
32 |
// boolean bFirst = true;
|
33 |
// int xInt, yInt, antX = -1, antY = -1;
|
34 |
theIterator = geometry.getPathIterator(null,FConverter.FLATNESS); //, flatness); |
35 |
|
36 |
// int numSegmentsAdded = 0;
|
37 |
while (!theIterator.isDone()) {
|
38 |
theType = theIterator.currentSegment(theData); |
39 |
|
40 |
switch (theType) {
|
41 |
case PathIterator.SEG_MOVETO: |
42 |
numParts++; |
43 |
xs.add(new Double(theData[0])); |
44 |
ys.add(new Double(theData[1])); |
45 |
|
46 |
|
47 |
break;
|
48 |
|
49 |
case PathIterator.SEG_LINETO: |
50 |
xs.add(new Double(theData[0])); |
51 |
ys.add(new Double(theData[1])); |
52 |
|
53 |
|
54 |
break;
|
55 |
|
56 |
|
57 |
case PathIterator.SEG_CLOSE: |
58 |
xs.add(new Double(theData[0])); |
59 |
ys.add(new Double(theData[1])); |
60 |
|
61 |
break;
|
62 |
} //end switch
|
63 |
|
64 |
theIterator.next(); |
65 |
} //end while loop
|
66 |
|
67 |
Double[] x = (Double[]) xs.toArray(new Double[0]); |
68 |
Double[] y = (Double[]) ys.toArray(new Double[0]); |
69 |
|
70 |
return new Double[][] { x, y }; |
71 |
|
72 |
} |
73 |
|
74 |
} |