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

View differences:

DwgPolyline2D.java
34 34
 */
35 35
package org.gvsig.dwg.lib.objects;
36 36

  
37
import java.awt.Shape;
38
import java.awt.geom.GeneralPath;
39 37
import java.awt.geom.Point2D;
40 38
import java.util.ArrayList;
41 39
import java.util.List;
......
54 52
import org.gvsig.dwg.lib.util.FMapUtil;
55 53
import org.gvsig.dwg.lib.util.GisModelCurveCalculator;
56 54
import org.gvsig.fmap.geom.Geometry;
57
import org.gvsig.fmap.geom.GeometryFactory;
58
import org.gvsig.fmap.geom.GeometryManager;
59
import org.gvsig.fmap.geom.primitive.impl.Curve2D;
60
import org.gvsig.fmap.geom.primitive.GeneralPathX;
55
import org.gvsig.fmap.geom.exception.CreateGeometryException;
61 56
import org.slf4j.Logger;
62 57
import org.slf4j.LoggerFactory;
63 58

  
......
71 66
	implements IDwgPolyline, IDwgExtrusionable, IDwg3DTestable, IDwg2FMap, IDwgBlockMember{
72 67

  
73 68
	private static Logger logger = LoggerFactory.getLogger(DwgPolyline2D.class.getName());
74
	
69

  
75 70
	private int flags;
76 71
	private int curveType;
77 72
	private double initWidth;
......
462 457
	 * @see com.iver.cit.jdwglib.dwg.IDwgExtrusionable#applyExtrussion()
463 458
	 */
464 459
	public void applyExtrussion() {
465
		  if(getPts() == null)
460
		  if(getPts() == null) {
466 461
			return;
462
		}
467 463
		  List vertices = getPts();
468 464
	      double[] polyline2DExt = getExtrusion();
469 465
	      double elev = getElevation();
......
476 472
	      }
477 473
	      setElevation(elev);
478 474
	      for (int j=0;j<vertices.size();j++) {
479
	          vertices.add(new double[]{((double[])polylinePoints3D[j])[0], ((double[])polylinePoints3D[j])[1]});
475
	          vertices.add(new double[]{(polylinePoints3D[j])[0], (polylinePoints3D[j])[1]});
480 476
	      }
481 477
	      setPts(vertices);
482 478
	}
......
495 491
	/* (non-Javadoc)
496 492
	 * @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapGeometry(boolean)
497 493
	 */
498
	public Geometry toFMapGeometry(boolean is3DFile) {
499
		GeometryFactory gFactory = GeometryManager.getInstance().getGeometryFactory();
500
		List vertices = getPts();
501
		double elev = getElevation();
502

  
503
		if (vertices != null){
504
			GeneralPathX gp = new GeneralPathX();
505
			for (int i = 0; i < vertices.size(); i++) {
506
				Object vertice = vertices.get(i);
507
				if(i==0){
508
					if(vertice instanceof double[]){
509
						gp.moveTo(new Double(((double[])vertice)[0]).floatValue(),new Double(((double[])vertice)[1]).floatValue());
510
					} else if (vertice instanceof Point2D){
511
						gp.moveTo(new Double(((Point2D)vertice).getX()).floatValue(),
512
								new Double(((Point2D)vertice).getY()).floatValue());
513
					}
514
				} else {
515

  
516
					if(vertice instanceof double[]){
517
						gp.lineTo(new Double(((double[])vertice)[0]).floatValue(),new Double(((double[])vertice)[1]).floatValue());
518
					} else if (vertice instanceof Point2D){
519
						gp.lineTo(new Double(((Point2D)vertice).getX()).floatValue(),
520
								new Double(((Point2D)vertice).getY()).floatValue());
521
					}
522
				}
523
			}
524
			if (is3DFile) {
525
				return gFactory.createPolyline3D(gp,new double[] {elev});
526
			} else {
527
				return gFactory.createPolyline2D(gp);
528
			}
529
		} else {
530
			return null;
531
		}
494
	public Geometry toFMapGeometry(boolean is3DFile) throws CreateGeometryException {
495
		return FMapUtil.ptsToMultiCurve(getPts(), getGeometrySubType(is3DFile));
532 496
	}
533 497
	/* (non-Javadoc)
534 498
	 * @see com.iver.cit.jdwglib.dwg.IDwg2FMap#toFMapString(boolean)
535 499
	 */
536 500
	public String toFMapString(boolean is3DFile) {
537
		if(is3DFile)
501
		if(is3DFile) {
538 502
			return "FPolyline3D";
539
		else
503
		} else {
540 504
			return "FPolyline2D";
505
		}
541 506
	}
542 507

  
543 508
	public String toString(){
......
599 564
	public void addVertex(IDwgVertex vertex) {
600 565
		vertices.add(vertex.getPoint());
601 566
	}
567

  
568
	public int getGeometrySubType(boolean is3DFile) {
569
		return Geometry.SUBTYPES.GEOM2D;
570
	}
571

  
572
	public int getGeometryType() {
573
		return Geometry.TYPES.MULTICURVE;
574
	}
575

  
602 576
}

Also available in: Unified diff