Revision 29001 branches/v2_0_0_prep/libraries/libDwg/src/org/gvsig/dwg/lib/objects/DwgLine.java

View differences:

DwgLine.java
35 35
package org.gvsig.dwg.lib.objects;
36 36

  
37 37
import java.awt.geom.Point2D;
38
import java.util.ArrayList;
39 38
import java.util.List;
40 39
import java.util.Map;
41 40

  
......
45 44
import org.gvsig.dwg.lib.IDwg3DTestable;
46 45
import org.gvsig.dwg.lib.IDwgBlockMember;
47 46
import org.gvsig.dwg.lib.util.AcadExtrusionCalculator;
48
import org.gvsig.dwg.lib.util.FMapUtil;
49 47
import org.gvsig.fmap.geom.Geometry;
50
import org.gvsig.fmap.geom.GeometryFactory;
48
import org.gvsig.fmap.geom.GeometryLocator;
51 49
import org.gvsig.fmap.geom.GeometryManager;
50
import org.gvsig.fmap.geom.exception.CreateGeometryException;
51
import org.gvsig.fmap.geom.primitive.Curve;
52
import org.gvsig.fmap.geom.primitive.Point;
52 53

  
53 54

  
54 55
/**
......
179 180
	  if (!isZflag()) {
180 181
		double z1 = getP1()[2];
181 182
		double z2 = getP2()[2];
182
		if (z1!=0.0 || z2!=0.0)
183
		if (z1!=0.0 || z2!=0.0) {
183 184
			return  true;
185
		}
184 186
	  }//TODO y si zflag vale true? REVISAR
185 187
	  return false;
186 188
	}
......
188 190
		double[] p1 = getP1();
189 191
		double[] p2 = getP2();
190 192
		if(isZflag()){
191
			if (p1[2] == p2[2])
193
			if (p1[2] == p2[2]) {
192 194
				return p1[2];
193
			else
195
			} else {
194 196
				return 0d;
197
			}
195 198
		} else {
196 199
				return 0d;
197 200
		}
198 201
	}
199
	public Geometry toFMapGeometry(boolean is3DFile) {
200
		GeometryFactory gFactory = GeometryManager.getInstance().getGeometryFactory();
202
	public Geometry toFMapGeometry(boolean is3DFile) throws CreateGeometryException {
203
		GeometryManager gMan = GeometryLocator.getGeometryManager();
204

  
201 205
		double[] p1 = getP1();
202 206
		double[] p2 = getP2();
203 207

  
208
		Point point1 = (Point) gMan.create(Geometry.TYPES.POINT,
209
				getGeometrySubType(is3DFile));
210
		point1.setCoordinates(p1);
204 211

  
205
		if (is3DFile && isZflag()) {
206
			return gFactory.createLine2DZ(
207
					new Point2D.Double(p1[0], p1[1]),
208
					new Point2D.Double(p2[0], p2[1]),
209
					p1[2]);
210
		} else if (is3DFile && ! isZflag()) {
211
			return gFactory.createLine2DZ(
212
					new Point2D.Double(p1[0], p1[1]),
213
					new Point2D.Double(p2[0], p2[1]),
214
					0);
215
		} else {
216
			return gFactory.createLine2D(
217
					new Point2D.Double(p1[0], p1[1]),
218
					new Point2D.Double(p2[0], p2[1]));
219
		}
212
		Point point2 = (Point) gMan.create(Geometry.TYPES.POINT,
213
				getGeometrySubType(is3DFile));
214
		point1.setCoordinates(p2);
220 215

  
216
		Curve line = (Curve) gMan.create(getGeometryType(),
217
				getGeometrySubType(is3DFile));
218
		line.setPoints(point1, point2);
219
		return line;
220

  
221 221
	}
222 222
	public String toFMapString(boolean is3DFile) {
223 223
		if(is3DFile){
......
298 298

  
299 299
	}
300 300

  
301
	public int getGeometrySubType(boolean is3DFile) {
302
		if (is3DFile) {
303
			if (isZflag()) {
304
				return Geometry.SUBTYPES.GEOM3DM;
305
			} else {
306
				return Geometry.SUBTYPES.GEOM3D;
307
			}
308
		} else {
309
			if (isZflag()) {
310
				return Geometry.SUBTYPES.GEOM2DM;
311
			} else {
312
				return Geometry.SUBTYPES.GEOM2D;
313
			}
314
		}
315
	}
316

  
317
	public int getGeometryType() {
318
		return Geometry.TYPES.CURVE;
319
	}
320

  
321

  
301 322
}

Also available in: Unified diff