Revision 25515 trunk/libraries/libFMap/src/com/iver/cit/gvsig/fmap/core/FPolyline2DM.java
FPolyline2DM.java | ||
---|---|---|
1 | 1 |
package com.iver.cit.gvsig.fmap.core; |
2 | 2 |
|
3 |
import java.awt.Component; |
|
3 |
import java.awt.geom.PathIterator; |
|
4 |
import java.util.ArrayList; |
|
4 | 5 |
|
6 |
import com.iver.cit.gvsig.fmap.core.v02.FConverter; |
|
7 |
import com.vividsolutions.jts.geom.Coordinate; |
|
8 |
import com.vividsolutions.jts.geom.CoordinateArrays; |
|
9 |
import com.vividsolutions.jts.geom.GeometryFactory; |
|
10 |
import com.vividsolutions.jts.geom.LineString; |
|
11 |
|
|
5 | 12 |
//import com.iver.andami.PluginServices; |
6 | 13 |
|
7 | 14 |
|
... | ... | |
60 | 67 |
*/ |
61 | 68 |
public class FPolyline2DM extends FPolyline2D implements FShapeM{ |
62 | 69 |
private static final long serialVersionUID = -617233536274899782L; |
70 |
private static final String NAME = "MULTILINESTRINGM"; |
|
63 | 71 |
double[] pM = null; |
64 | 72 |
|
65 | 73 |
FPolyline2DM(GeneralPathX gpx, double[] pM) { |
... | ... | |
74 | 82 |
public double[] getMs() { |
75 | 83 |
return pM; |
76 | 84 |
} |
77 |
|
|
85 |
|
|
78 | 86 |
/* |
79 | 87 |
* (non-Javadoc) |
80 | 88 |
* @see com.iver.cit.gvsig.fmap.core.FPolyline3D#getShapeType() |
... | ... | |
82 | 90 |
public int getShapeType() { |
83 | 91 |
return FShape.LINE | FShape.M; |
84 | 92 |
} |
85 |
|
|
93 |
|
|
86 | 94 |
/* |
87 | 95 |
* (non-Javadoc) |
88 | 96 |
* @see com.iver.cit.gvsig.fmap.core.FPolyline3D#cloneFShape() |
... | ... | |
108 | 116 |
public boolean isDecreasing() { |
109 | 117 |
return (pM[0] > pM[pM.length-1]); |
110 | 118 |
} |
111 |
|
|
119 |
|
|
112 | 120 |
public void revertMs(){ |
113 | 121 |
double totalDistance = Math.abs(pM[0] - pM[pM.length-1]); |
114 | 122 |
double[] percentages = new double[pM.length]; |
... | ... | |
135 | 143 |
} |
136 | 144 |
pM[pM.length-1] = pm0; |
137 | 145 |
} |
146 |
|
|
147 |
/** |
|
148 |
* This method is used instead of the JTS ToString method. The reason is because |
|
149 |
* JTS doesn't support the M coordinate |
|
150 |
*/ |
|
151 |
public String toText(){ |
|
152 |
StringBuffer str = new StringBuffer(); |
|
153 |
str.append(NAME); |
|
154 |
str.append(" (("); |
|
155 |
int theType; |
|
156 |
double[] theData = new double[6]; |
|
157 |
|
|
158 |
PathIterator theIterator = getPathIterator(null, FConverter.FLATNESS); |
|
159 |
int i = 0; |
|
160 |
|
|
161 |
while (!theIterator.isDone()) { |
|
162 |
//while not done |
|
163 |
theType = theIterator.currentSegment(theData); |
|
164 |
|
|
165 |
switch (theType) { |
|
166 |
case PathIterator.SEG_MOVETO: |
|
167 |
str.append(theData[0] + " " + theData[1] + " " + pM[i] + ","); |
|
168 |
break; |
|
169 |
|
|
170 |
case PathIterator.SEG_LINETO: |
|
171 |
str.append(theData[0] + " " + theData[1] + " " + pM[i] + ","); |
|
172 |
|
|
173 |
break; |
|
174 |
|
|
175 |
case PathIterator.SEG_QUADTO: |
|
176 |
System.out.println("Not supported here"); |
|
177 |
|
|
178 |
break; |
|
179 |
|
|
180 |
case PathIterator.SEG_CUBICTO: |
|
181 |
System.out.println("Not supported here"); |
|
182 |
|
|
183 |
break; |
|
184 |
|
|
185 |
case PathIterator.SEG_CLOSE: |
|
186 |
break; |
|
187 |
} //end switch |
|
188 |
|
|
189 |
theIterator.next(); |
|
190 |
i++; |
|
191 |
} //end while loop |
|
192 |
return str.delete(str.length()-1, str.length()) + "))"; |
|
193 |
} |
|
138 | 194 |
} |
Also available in: Unified diff