jumbo.euclid
Class Int2Vector

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--jumbo.euclid.EuclidVector
                          |
                          +--jumbo.euclid.Int2Vector

public class Int2Vector
extends EuclidVector

Int2Vector - a (Java) Vector of Int2s. (Note that 'Vector' is used by Java to describe an array of objects - there is no relationship to geometrical vectors in this package.)

Support is also given for the two component arrays as IntArrays

Default is an empty (Java) Vector;

See Also:
Serialized Form

Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
Int2Vector()
           
Int2Vector(int size)
          create a Vector with given number of points
Int2Vector(int[] flarray)
          Formed by feeding in an existing array to a 2xn matrix.
Int2Vector(Int2Vector pv)
          copy constructor from Int2Vector COPIES pv
Int2Vector(IntArray m)
          constructor from IntArray - by REFERENCE
Int2Vector(int n, int[] x, int[] y)
          from two parallel arrays of x, y - by REFERENCE
 
Method Summary
 void addElement(Int2 p)
           
 int getClosestPoint(Int2 p)
          get the closest point (both ranges are assumed to have the same scales
 int getCoordinate(int i, Choice2 j)
          get a single coordinate value
 Int2 getInt2(int i)
          get the i'th Int2
 int getPoint(Int2 p, int width, int height)
          get the index of the first point within a box centered on p (i.e.
 IntRange getRange(Choice2 ax)
          get range of one coordinate
 Int2Range getRange2()
          get range of both coordinates
 IntArray getXorY(Choice2 axis)
          get a single coordinate array - e.g.
 IntArray getXY()
          get the coordinate coordinate array as ints x,y,x,y, ...
 java.lang.String makeString()
          we are not allowed a toString() here, as Vector is a final class
 void multiplyBy(int f)
          multiply all coordinates be a given scalar (i.e.
 void plus(Int2 p)
          add a Int2 to all elements of 'this'; MODIFIES 'this'
 void setElementAt(Int2 v, int i)
           
 Int2Vector sortAscending(Choice2 ax)
          sort ARRAY on X or Y coordinate; returns new array
 Int2Vector sortDescending(Choice2 ax)
          sort ARRAY on X or Y coordinate; returns new array
 void sortXYAscending()
          sort X and Y within each point; MODIFIES array
 void sortXYDescending()
          sort X and Y within each point; MODIFIES array
 Int2Vector subArray(IntSet is)
          create a NEW subset of the points; points are COPIED
 IntSet subSet(Int2Range r)
          create a subset of the points within a box
 void subtract(Int2 v)
          translate negatively; MODIFIES 'this'
 void swapXY()
          swap all X and Y coordinates; MODIFIES array
 void translateBy(Int2 v)
          translate by a vector, synonym for 'plus'; MODIFIES 'this'
 
Methods inherited from class jumbo.euclid.EuclidVector
concatenate
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, toString, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Int2Vector

public Int2Vector()

Int2Vector

public Int2Vector(int size)
create a Vector with given number of points

Int2Vector

public Int2Vector(int[] flarray)
           throws BadArgumentException
Formed by feeding in an existing array to a 2xn matrix. THE COLUMN IS THE FASTEST MOVING INDEX, i.e. the matrix is filled as flarray(0,0, flarray(0,1). Primarily for compatibility with other apps
Throws:
BadArgumentException - array must have even number of elements

Int2Vector

public Int2Vector(int n,
                  int[] x,
                  int[] y)
from two parallel arrays of x, y - by REFERENCE

Int2Vector

public Int2Vector(IntArray m)
           throws BadArgumentException
constructor from IntArray - by REFERENCE
Throws:
BadArgumentException - array must have even number of elements

Int2Vector

public Int2Vector(Int2Vector pv)
copy constructor from Int2Vector COPIES pv
Method Detail

addElement

public void addElement(Int2 p)

setElementAt

public void setElementAt(Int2 v,
                         int i)
                  throws java.lang.ArrayIndexOutOfBoundsException
Throws:
java.lang.ArrayIndexOutOfBoundsException - v does not have an i'th element

getRange

public IntRange getRange(Choice2 ax)
get range of one coordinate

getRange2

public Int2Range getRange2()
get range of both coordinates

subArray

public Int2Vector subArray(IntSet is)
                    throws BadSubscriptException
create a NEW subset of the points; points are COPIED
Throws:
BadSubscriptException - an element of is is out of range of this

subSet

public IntSet subSet(Int2Range r)
create a subset of the points within a box

getClosestPoint

public int getClosestPoint(Int2 p)
get the closest point (both ranges are assumed to have the same scales

getPoint

public int getPoint(Int2 p,
                    int width,
                    int height)
get the index of the first point within a box centered on p (i.e. p+- width/2, height/2) or -1 if none

translateBy

public void translateBy(Int2 v)
translate by a vector, synonym for 'plus'; MODIFIES 'this'

plus

public void plus(Int2 p)
add a Int2 to all elements of 'this'; MODIFIES 'this'

subtract

public void subtract(Int2 v)
translate negatively; MODIFIES 'this'

multiplyBy

public void multiplyBy(int f)
multiply all coordinates be a given scalar (i.e. expands scale)

getInt2

public Int2 getInt2(int i)
get the i'th Int2

getXY

public IntArray getXY()
get the coordinate coordinate array as ints x,y,x,y, ...

getCoordinate

public int getCoordinate(int i,
                         Choice2 j)
get a single coordinate value

getXorY

public IntArray getXorY(Choice2 axis)
get a single coordinate array - e.g. all x-coordinates

swapXY

public void swapXY()
swap all X and Y coordinates; MODIFIES array

sortXYAscending

public void sortXYAscending()
sort X and Y within each point; MODIFIES array

sortXYDescending

public void sortXYDescending()
sort X and Y within each point; MODIFIES array

sortAscending

public Int2Vector sortAscending(Choice2 ax)
sort ARRAY on X or Y coordinate; returns new array

sortDescending

public Int2Vector sortDescending(Choice2 ax)
sort ARRAY on X or Y coordinate; returns new array

makeString

public java.lang.String makeString()
we are not allowed a toString() here, as Vector is a final class