Class pmr.euclid.Int2Vector
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class pmr.euclid.Int2Vector

java.lang.Object
   |
   +----java.util.Vector
           |
           +----pmr.euclid.EuclidVector
                   |
                   +----pmr.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;

Author:
(C) P. Murray-Rust, 1996

Constructor Index

 o Int2Vector()
 o Int2Vector(int)
create a Vector with given number of points
 o Int2Vector(int, int[], int[])
from two parallel arrays of x, y - by REFERENCE
 o Int2Vector(Int2Vector)
copy constructor from Int2Vector COPIES pv
 o Int2Vector(int[])
Formed by feeding in an existing array to a 2xn matrix.
 o Int2Vector(IntArray)
constructor from IntArray - by REFERENCE

Method Index

 o addElement(Int2)
 o getClosestPoint(Int2)
get the closest point (both ranges are assumed to have the same scales
 o getCoordinate(int, Choice2)
get a single coordinate value
 o getInt2(int)
get the i'th Int2
 o getPoint(Int2, int, int)
get the index of the first point within a box centered on p (i.e.
 o getRange(Choice2)
get range of one coordinate
 o getRange2()
get range of both coordinates
 o getXorY(Choice2)
get a single coordinate array - e.g.
 o getXY()
get the coordinate coordinate array as ints x,y,x,y, ...
 o makeString()
we are not allowed a toString() here, as Vector is a final class
 o multiplyBy(int)
multiply all coordinates be a given scalar (i.e.
 o plus(Int2)
add a Int2 to all elements of 'this'; MODIFIES 'this'
 o setElementAt(Int2, int)
 o sortAscending(Choice2)
sort ARRAY on X or Y coordinate; returns new array
 o sortDescending(Choice2)
sort ARRAY on X or Y coordinate; returns new array
 o sortXYAscending()
sort X and Y within each point; MODIFIES array
 o sortXYDescending()
sort X and Y within each point; MODIFIES array
 o subArray(IntSet)
create a NEW subset of the points; points are COPIED
 o subSet(Int2Range)
create a subset of the points within a box
 o subtract(Int2)
translate negatively; MODIFIES 'this'
 o swapXY()
swap all X and Y coordinates; MODIFIES array
 o translateBy(Int2)
translate by a vector, synonym for 'plus'; MODIFIES 'this'

Constructors

 o Int2Vector
  public Int2Vector()
 o Int2Vector
  public Int2Vector(int size)
create a Vector with given number of points
 o Int2Vector
  public Int2Vector(int flarray[]) throws InvalidArgumentException
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: InvalidArgumentException
array must have even number of elements
 o Int2Vector
  public Int2Vector(int n,
                    int x[],
                    int y[])
from two parallel arrays of x, y - by REFERENCE
 o Int2Vector
  public Int2Vector(IntArray m) throws InvalidArgumentException
constructor from IntArray - by REFERENCE
Throws: InvalidArgumentException
array must have even number of elements
 o Int2Vector
  public Int2Vector(Int2Vector pv)
copy constructor from Int2Vector COPIES pv

Methods

 o addElement
  public void addElement(Int2 p)
 o setElementAt
  public void setElementAt(Int2 v,
                           int i) throws ArrayIndexOutOfBoundsException
Throws: ArrayIndexOutOfBoundsException
v does not have an i'th element
 o getRange
  public IntRange getRange(Choice2 ax)
get range of one coordinate
 o getRange2
  public Int2Range getRange2()
get range of both coordinates
 o 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
 o subSet
  public IntSet subSet(Int2Range r)
create a subset of the points within a box
 o getClosestPoint
  public int getClosestPoint(Int2 p)
get the closest point (both ranges are assumed to have the same scales
 o 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
 o translateBy
  public void translateBy(Int2 v)
translate by a vector, synonym for 'plus'; MODIFIES 'this'
 o plus
  public void plus(Int2 p)
add a Int2 to all elements of 'this'; MODIFIES 'this'
 o subtract
  public void subtract(Int2 v)
translate negatively; MODIFIES 'this'
 o multiplyBy
  public void multiplyBy(int f)
multiply all coordinates be a given scalar (i.e. expands scale)
 o getInt2
  public Int2 getInt2(int i)
get the i'th Int2
 o getXY
  public IntArray getXY()
get the coordinate coordinate array as ints x,y,x,y, ...
 o getCoordinate
  public int getCoordinate(int i,
                           Choice2 j)
get a single coordinate value
 o getXorY
  public IntArray getXorY(Choice2 axis)
get a single coordinate array - e.g. all x-coordinates
 o swapXY
  public void swapXY()
swap all X and Y coordinates; MODIFIES array
 o sortXYAscending
  public void sortXYAscending()
sort X and Y within each point; MODIFIES array
 o sortXYDescending
  public void sortXYDescending()
sort X and Y within each point; MODIFIES array
 o sortAscending
  public Int2Vector sortAscending(Choice2 ax)
sort ARRAY on X or Y coordinate; returns new array
 o sortDescending
  public Int2Vector sortDescending(Choice2 ax)
sort ARRAY on X or Y coordinate; returns new array
 o makeString
  public String makeString()
we are not allowed a toString() here, as Vector is a final class

All Packages  Class Hierarchy  This Package  Previous  Next  Index