Class CoordinateList

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<Coordinate>, java.util.Collection<Coordinate>, java.util.List<Coordinate>, java.util.RandomAccess

    public class CoordinateList
    extends java.util.ArrayList<Coordinate>
    A list of Coordinates, which may be set to prevent repeated coordinates from occurring in the list.
    Version:
    1.7
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      CoordinateList()
      Constructs a new list without any coordinates
      CoordinateList​(Coordinate[] coord)
      Constructs a new list from an array of Coordinates, allowing repeated points.
      CoordinateList​(Coordinate[] coord, boolean allowRepeated)
      Constructs a new list from an array of Coordinates, allowing caller to specify if repeated points are to be removed.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int i, Coordinate coord, boolean allowRepeated)
      Inserts the specified coordinate at the specified position in this list.
      boolean add​(java.lang.Object obj, boolean allowRepeated)
      Adds a coordinate to the list.
      boolean add​(Coordinate[] coord, boolean allowRepeated)
      Adds an array of coordinates to the list.
      boolean add​(Coordinate[] coord, boolean allowRepeated, boolean direction)
      Adds an array of coordinates to the list.
      boolean add​(Coordinate[] coord, boolean allowRepeated, int start, int end)
      Adds a section of an array of coordinates to the list.
      void add​(Coordinate coord, boolean allowRepeated)
      Adds a coordinate to the end of the list.
      boolean addAll​(java.util.Collection<? extends Coordinate> coll, boolean allowRepeated)
      Add an array of coordinates
      java.lang.Object clone()
      Returns a deep copy of this CoordinateList instance.
      void closeRing()
      Ensure this coordList is a ring, by adding the start point if necessary
      Coordinate getCoordinate​(int i)  
      Coordinate[] toCoordinateArray()
      Returns the Coordinates in this collection.
      Coordinate[] toCoordinateArray​(boolean isForward)
      Creates an array containing the coordinates in this list, oriented in the given direction (forward or reverse).
      • Methods inherited from class java.util.ArrayList

        add, add, addAll, addAll, clear, contains, ensureCapacity, equals, forEach, get, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, removeIf, replaceAll, retainAll, set, size, sort, spliterator, subList, toArray, toArray, trimToSize
      • Methods inherited from class java.util.AbstractCollection

        containsAll, toString
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, stream, toArray
      • Methods inherited from interface java.util.List

        containsAll
    • Constructor Detail

      • CoordinateList

        public CoordinateList()
        Constructs a new list without any coordinates
      • CoordinateList

        public CoordinateList​(Coordinate[] coord)
        Constructs a new list from an array of Coordinates, allowing repeated points. (I.e. this constructor produces a CoordinateList with exactly the same set of points as the input array.)
        Parameters:
        coord - the initial coordinates
      • CoordinateList

        public CoordinateList​(Coordinate[] coord,
                              boolean allowRepeated)
        Constructs a new list from an array of Coordinates, allowing caller to specify if repeated points are to be removed.
        Parameters:
        coord - the array of coordinates to load into the list
        allowRepeated - if false, repeated points are removed
    • Method Detail

      • getCoordinate

        public Coordinate getCoordinate​(int i)
      • add

        public boolean add​(Coordinate[] coord,
                           boolean allowRepeated,
                           int start,
                           int end)
        Adds a section of an array of coordinates to the list.
        Parameters:
        coord - The coordinates
        allowRepeated - if set to false, repeated coordinates are collapsed
        start - the index to start from
        end - the index to add up to but not including
        Returns:
        true (as by general collection contract)
      • add

        public boolean add​(Coordinate[] coord,
                           boolean allowRepeated,
                           boolean direction)
        Adds an array of coordinates to the list.
        Parameters:
        coord - The coordinates
        allowRepeated - if set to false, repeated coordinates are collapsed
        direction - if false, the array is added in reverse order
        Returns:
        true (as by general collection contract)
      • add

        public boolean add​(Coordinate[] coord,
                           boolean allowRepeated)
        Adds an array of coordinates to the list.
        Parameters:
        coord - The coordinates
        allowRepeated - if set to false, repeated coordinates are collapsed
        Returns:
        true (as by general collection contract)
      • add

        public boolean add​(java.lang.Object obj,
                           boolean allowRepeated)
        Adds a coordinate to the list.
        Parameters:
        obj - The coordinate to add
        allowRepeated - if set to false, repeated coordinates are collapsed
        Returns:
        true (as by general collection contract)
      • add

        public void add​(Coordinate coord,
                        boolean allowRepeated)
        Adds a coordinate to the end of the list.
        Parameters:
        coord - The coordinates
        allowRepeated - if set to false, repeated coordinates are collapsed
      • add

        public void add​(int i,
                        Coordinate coord,
                        boolean allowRepeated)
        Inserts the specified coordinate at the specified position in this list.
        Parameters:
        i - the position at which to insert
        coord - the coordinate to insert
        allowRepeated - if set to false, repeated coordinates are collapsed
      • addAll

        public boolean addAll​(java.util.Collection<? extends Coordinate> coll,
                              boolean allowRepeated)
        Add an array of coordinates
        Parameters:
        coll - The coordinates
        allowRepeated - if set to false, repeated coordinates are collapsed
        Returns:
        true (as by general collection contract)
      • closeRing

        public void closeRing()
        Ensure this coordList is a ring, by adding the start point if necessary
      • toCoordinateArray

        public Coordinate[] toCoordinateArray()
        Returns the Coordinates in this collection.
        Returns:
        the coordinates
      • toCoordinateArray

        public Coordinate[] toCoordinateArray​(boolean isForward)
        Creates an array containing the coordinates in this list, oriented in the given direction (forward or reverse).
        Parameters:
        isForward - true if the direction is forward, false for reverse
        Returns:
        an oriented array of coordinates
      • clone

        public java.lang.Object clone()
        Returns a deep copy of this CoordinateList instance.
        Overrides:
        clone in class java.util.ArrayList<Coordinate>
        Returns:
        a clone of this CoordinateList instance