/** * Returns the DirectPositions which define the control points of this Curve * * @return */ public List<DirectPosition> asDirectPositions() { List<DirectPosition> rList = new ArrayList<DirectPosition>(); CurveSegment tSegment = null; // Iterate all CurveSegments (= LineStrings) for (int i = 0; i < this.curveSegments.size(); i++) { tSegment = this.curveSegments.get(i); // TODO: This version only handles the CurveSegment type LineString LineStringImpl tLineString = (LineStringImpl) tSegment; Iterator<LineSegment> tLineSegmentIter = tLineString .asLineSegments().iterator(); while (tLineSegmentIter.hasNext()) { LineSegment tLineSegment = tLineSegmentIter.next(); // Add new Coordinate, which is the start point of the actual // LineSegment rList.add( tLineSegment.getStartPoint().getPosition() ); } } // Add new Coordinate, which is the end point of the last curveSegment rList.add( tSegment.getEndPoint() ); return rList; }
/** * Set the point at the given index. * * @param column The location in the array, from 0 inclusive * to the array's {@linkplain #size} exclusive. * @param position The point to set at the given location in this array. * The point coordinates will be copied, i.e. changes to the given * {@code position} after the method call will not be reflected * to this array. * @throws IndexOutOfBoundsException if the index is out of bounds. * * @see List#set */ public void setDirectPosition(int column, DirectPosition position) throws IndexOutOfBoundsException { DirectPosition thisPosition = (DirectPosition) get(column); DirectPosition otherPosition = position.getPosition(); for (int i = 0; i < thisPosition.getDimension(); i++) { thisPosition.setOrdinate(i, otherPosition.getOrdinate(i)); } invalidateCachedJTSPeer(); }