Revision 42267 trunk/org.gvsig.desktop/org.gvsig.desktop.compat.cdc/org.gvsig.fmap.geometry/org.gvsig.fmap.geometry.jts/src/main/java/org/gvsig/fmap/geom/jts/primitive/curve/line/AbstractLine.java

View differences:

AbstractLine.java
46 46
import org.gvsig.fmap.geom.jts.primitive.curve.AbstractCurve;
47 47
import org.gvsig.fmap.geom.jts.primitive.point.Point2D;
48 48
import org.gvsig.fmap.geom.jts.primitive.point.PointJTS;
49
import org.gvsig.fmap.geom.jts.utils.ArrayListCoordinateSequence;
50
import org.gvsig.fmap.geom.jts.utils.JTSUtils;
51
import org.gvsig.fmap.geom.jts.utils.ReadOnlyCoordinates;
49
import org.gvsig.fmap.geom.jts.util.ArrayListCoordinateSequence;
50
import org.gvsig.fmap.geom.jts.util.JTSUtils;
51
import org.gvsig.fmap.geom.jts.util.ReadOnlyCoordinates;
52 52
import org.gvsig.fmap.geom.primitive.GeneralPathX;
53 53
import org.gvsig.fmap.geom.primitive.IGeneralPathX;
54 54
import org.gvsig.fmap.geom.primitive.Line;
......
67 67
    private static final Logger logger = LoggerFactory.getLogger(AbstractLine.class);
68 68

  
69 69
    protected ArrayListCoordinateSequence coordinates;
70
    protected PointJTS vertex;
70
    protected PointJTS anyVertex;
71 71

  
72 72
    /**
73 73
    *
......
76 76
        super(Geometry.TYPES.LINE, subtype);
77 77
    }
78 78

  
79
    /**
80
     *
81
     */
82
    public AbstractLine(int subtype, Coordinate[] coordinates, PointJTS aVertex) {
83
        this(subtype);
84
        this.coordinates = new ArrayListCoordinateSequence(new ReadOnlyCoordinates(coordinates));
85
        vertex = aVertex;
86
    }
87

  
88 79
    /*
89 80
     * (non-Javadoc)
90 81
     *
......
100 91
     * @see org.gvsig.fmap.geom.primitive.OrientablePrimitive#getVertex(int)
101 92
     */
102 93
    public Point getVertex(int index) {
103
        vertex.setJTSCoordinate(coordinates.get(index));
104
        return vertex;
94
        anyVertex.setJTSCoordinate(coordinates.get(index));
95
        return anyVertex;
105 96
    }
106 97

  
107 98
    /*
......
114 105
    public void addVertex(Point point) {
115 106
        point = fixPoint(point);
116 107
        coordinates.add(((PointJTS) point).getJTSCoordinate());
108
        anyVertex = (PointJTS) point;
117 109
    }
118 110

  
119 111
    /*
......
259 251
            it.next();
260 252
            i++;
261 253
        }
262

  
263

  
264
        //TODO:
265

  
266 254
    }
267 255

  
268 256
    /*
......
273 261
     * .gvsig.fmap.geom.primitive.Point)
274 262
     */
275 263
    public void addMoveToVertex(Point point) {
264
        notifyDeprecated("Calling deprecated metohd addMoveToVertex in Line");
276 265
        throw new UnsupportedOperationException();
277 266
    }
278 267

  
......
294 283
     * org.gvsig.fmap.geom.primitive.OrientablePrimitive#ensureCapacity(int)
295 284
     */
296 285
    public void ensureCapacity(int capacity) {
297
        // TODO
286
        this.coordinates.ensureCapacity(capacity);
298 287
    }
299 288

  
300 289
    /*
......
353 342
     * @see org.gvsig.fmap.geom.Geometry#getDimension()
354 343
     */
355 344
    public int getDimension() {
356
        return vertex.getDimension();
345
        return anyVertex.getDimension();
357 346
    }
358 347

  
359 348
    /*
......
362 351
     * @see org.gvsig.fmap.geom.Geometry#getShape(java.awt.geom.AffineTransform)
363 352
     */
364 353
    public Shape getShape(AffineTransform affineTransform) {
365
        return new DefaultGeneralPathX(new LineIterator(affineTransform));
354
        return new DefaultGeneralPathX(getPathIterator(affineTransform),false,0);
366 355
    }
367 356

  
368 357
    /*
......
371 360
     * @see org.gvsig.fmap.geom.Geometry#getShape()
372 361
     */
373 362
    public Shape getShape() {
374
        return new DefaultGeneralPathX(new LineIterator(null));
363
        return new DefaultGeneralPathX(getPathIterator(null),false,0);
375 364
    }
376 365

  
377 366
    /*
378 367
     * (non-Javadoc)
379 368
     *
380
     * @see
381
     * org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform
382
     * )
383
     */
384
    public PathIterator getPathIterator(AffineTransform at) {
385
        return getPathIterator(at);
386
    }
387

  
388
    /*
389
     * (non-Javadoc)
390
     *
391 369
     * @see org.gvsig.fmap.geom.Geometry#getHandlers(int)
392 370
     */
393 371
    public Handler[] getHandlers(int type) {
394
        notifyDeprecated("Calling deprecated method getHandlers of a line");
395
        throw new UnsupportedOperationException("Calling deprecated method getHandlers of a line");
372
        String message = "Calling deprecated method getHandlers of a line";
373
        notifyDeprecated(message);
374
        throw new UnsupportedOperationException(message);
396 375
    }
397 376

  
398 377
    /*
......
400 379
     *
401 380
     * @see
402 381
     * org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform
403
     * , double)
382
     * )
404 383
     */
405
    public PathIterator getPathIterator(AffineTransform at, double flatness) {
384
    public PathIterator getPathIterator(AffineTransform at) {
406 385
        LineIterator pi = new LineIterator(at);
407 386
        return pi;
408 387
    }
......
410 389
    /*
411 390
     * (non-Javadoc)
412 391
     *
413
     * @see org.gvsig.fmap.geom.Geometry#getGeneralPath()
392
     * @see
393
     * org.gvsig.fmap.geom.Geometry#getPathIterator(java.awt.geom.AffineTransform
394
     * , double)
414 395
     */
415
    public GeneralPathX getGeneralPath() {
416
        return new DefaultGeneralPathX(new LineIterator(null));
396
    public PathIterator getPathIterator(AffineTransform at, double flatness) {
397
        return getPathIterator(at);
417 398
    }
418 399

  
419
    public class LineIterator extends GeneralPathXIterator {
400
    protected class LineIterator extends GeneralPathXIterator {
420 401

  
421 402
        /** Transform applied on the coordinates during iteration */
422 403
        private AffineTransform at;
......
506 487
     * @see org.gvsig.fmap.geom.jts.GeometryJTS#is3D()
507 488
     */
508 489
    public boolean is3D() {
509
        return vertex.is3D();
490
        return anyVertex.is3D();
510 491
    }
511 492

  
512 493
    /*
......
539 520
        return null;
540 521
    }
541 522

  
542
    /**
543
     * @param arrayList
544
     */
523
    protected boolean isClosed(){
524
        return coordinates.get(0).equals(coordinates.get(coordinates.size()-1));
525
    }
545 526
}

Also available in: Unified diff