com.tensegrity.graphics
Class Coordinate

java.lang.Object
  extended bycom.tensegrity.graphics.Coordinate

public final class Coordinate
extends java.lang.Object

This class represents a single point within a coordinate system and is not restricted to representing a fixed number of dimension components. Instances store its dimension components inside an integer array which can also be passed in a constructor.

There are several overloaded constructors from which to choose from.

As a result of the quick access requirement of Coordinate objects, this class's internals are publicly visible. It is therefore recommended that you declare a local variable when coding, as in the example shown below. This should increase the probability that the internal component array will not be accidentally corrupted!

 Coordinate coordinate = anObject.getCoordinate();
 final int[] components = coordinate.components;
 components[Coordinate.X_COMPONENT] = 100;
 components[Coordinate.Y_COMPONENT] = 100;
 

The component indices within the array are defined by X_COMPONENT, Y_COMPONENT and Z_COMPONENT for 2D and 3D spaces.

Version:
$Id: Coordinate.java,v 1.24 2005/08/22 11:22:01 MichaelKegel Exp $
Author:
MichaelKegel

Field Summary
 int[] components
          instance variable for the single components of the coordinate
static int X_COMPONENT
          constant that tells about the indices of the coordinates components
static int Y_COMPONENT
          constant that tells about the indices of the coordinates components
static int Z_COMPONENT
          constant that tells about the indices of the coordinates components
 
Constructor Summary
Coordinate()
          Default constructor for Coordinate that initializes it for 2D space.
Coordinate(Coordinate coordinate)
          Constructor for Coordinate with a Coordinate given by coordinate to copy the components from.
Coordinate(int dimensions)
          Constructor for Coordinate with given number of dimensions.
Coordinate(int[] components)
          Constructor for Coordinate with array of components given components for a non fixed number of dimensions.
Coordinate(int x, int y)
          Constructor for Coordinate with given components for the x axis and the y axis.
Coordinate(int x, int y, int z)
          Constructor for Coordinate with given components for the x axis, the y axis and the z axis.
 
Method Summary
 boolean equals(Coordinate c)
           
 boolean equals(java.lang.Object other)
           
 int getDimensions()
          Returns the number of dimensions this Coordinate consist of.
 int getX()
          Returns the X component of this coordinate
 int getY()
          Returns the y component of this coordinate
 int getZ()
          Returns the z component of this coordinate
 int hashCode()
           
 void setX(int x)
          Sets the x component of this coordinate
 void setY(int y)
          Sets the y component of this coordinate
 void setZ(int z)
          Sets the z component of this coordinate
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

X_COMPONENT

public static final int X_COMPONENT
constant that tells about the indices of the coordinates components

See Also:
Constant Field Values

Y_COMPONENT

public static final int Y_COMPONENT
constant that tells about the indices of the coordinates components

See Also:
Constant Field Values

Z_COMPONENT

public static final int Z_COMPONENT
constant that tells about the indices of the coordinates components

See Also:
Constant Field Values

components

public int[] components
instance variable for the single components of the coordinate

Constructor Detail

Coordinate

public Coordinate()
Default constructor for Coordinate that initializes it for 2D space.


Coordinate

public Coordinate(int dimensions)
Constructor for Coordinate with given number of dimensions.

Parameters:
dimensions - the number of dimensions for the new Coordinate instance

Coordinate

public Coordinate(int x,
                  int y)
Constructor for Coordinate with given components for the x axis and the y axis.

Parameters:
x - the component for the location on the x axis
y - the component for the location on the y axis

Coordinate

public Coordinate(int x,
                  int y,
                  int z)
Constructor for Coordinate with given components for the x axis, the y axis and the z axis.

Parameters:
x - the component for the location on the x axis
y - the component for the location on the y axis
z - the component for the location on the z axis

Coordinate

public Coordinate(int[] components)
Constructor for Coordinate with array of components given components for a non fixed number of dimensions.

Parameters:
components - the components array for the location on the different axes

Coordinate

public Coordinate(Coordinate coordinate)
Constructor for Coordinate with a Coordinate given by coordinate to copy the components from.

Parameters:
coordinate - the Coordinate to copy the components from
Method Detail

getDimensions

public int getDimensions()
Returns the number of dimensions this Coordinate consist of.

Returns:
int the number of dimension

getX

public int getX()
Returns the X component of this coordinate

Returns:
int the X component of this coordinate

setX

public void setX(int x)
Sets the x component of this coordinate

Parameters:
x - the new x component of this coordinate

getY

public int getY()
Returns the y component of this coordinate

Returns:
int the y component of this coordinate

setY

public void setY(int y)
Sets the y component of this coordinate

Parameters:
y - the new y component for this coordinate

getZ

public int getZ()
Returns the z component of this coordinate

Returns:
int the z component of this coordinate

setZ

public void setZ(int z)
Sets the z component of this coordinate

Parameters:
z - the new z component for this coordinate

equals

public boolean equals(java.lang.Object other)

equals

public boolean equals(Coordinate c)

hashCode

public int hashCode()

toString

public java.lang.String toString()


Copyright © 2005 Tensegrity Software GmbH. All Rights Reserved. Date of creation: 09.06.2006.