com.tensegrity.composite.coordinate
Class CoordinateSystemUtilities

java.lang.Object
  extended bycom.tensegrity.composite.coordinate.CoordinateSystemUtilities

public final class CoordinateSystemUtilities
extends java.lang.Object

This class provides some general functionalities needed to work with CoordinateSystems.

Version:
$Id: CoordinateSystemUtilities.java,v 1.17 2005/01/20 14:51:23 BurkhardWick Exp $
Author:
MichaelKegel

Field Summary
static java.lang.String COORDINATESYSTEM
          String constant for the CoordinateSystem.
static java.lang.String DELIM
          Delimiter which splits the values in method getDoubles.
static int MAXIMUM_X
          constant that tells about the index of a coordiante system value within an array
static int MAXIMUM_Y
          constant that tells about the index of a coordiante system value within an array
static int MINIMUM_X
          constant that tells about the index of a coordiante system value within an array
static int MINIMUM_Y
          constant that tells about the index of a coordiante system value within an array
static java.lang.String SCALEX
          String constant for the ScaleX field.
static java.lang.String SCALEY
          String constant for the ScaleY field.
 
Method Summary
static double[] convertCoordinateSystemValues(CoordinateSystem sourceSystem, CoordinateSystem targetSystem, double[] values)
          Converts the values given by values from a source coordinate system given by sourceSystem to a target coordinate system given by targetSystem.
static double[] convertCoordinateSystemValues(double sourceSystemMinX, double sourceSystemMaxX, double sourceSystemMinY, double sourceSystemMaxY, double targetSystemMinX, double targetSystemMaxX, double targetSystemMinY, double targetSystemMaxY, double[] values)
          Converts the values given by values from a source coordinate system given by sourceSystem to a target coordinate system given by targetSystem.
static MutableCoordinateSystem convertToMutableCoordinateSystem(CoordinateSystem coordSystem)
          Returns an equivalent mutable version of the given immutable CoordinateSystem.
static CoordinateSystem copy(CoordinateSystem coordSystem)
          Returns a copy of the CoordinateSystem instance given by coordSystem.
static CoordinateSystem createCoordinateSystem(AttributeList list, java.lang.String name)
          Method createCoordinateSystem creates a CoordinateSystem from the given list of double values.
static CoordinateSystem createCoordinateSystem(int xMin, int xMax, int yMin, int yMax)
          Creates a CoordinateSystem with the given minimum and maximum vlues.
static java.lang.String getCanonicalDescription(AttributeList list)
          Method createCoordinateSystem creates a canonical description from the given list of double values.
static java.lang.String getCanonicalDescription(AttributeList list, java.lang.String name)
          Method createCoordinateSystem creates a canonical description from the given list of double values.
static java.lang.String getCanonicalDescription(java.lang.String scaleX, java.lang.String scaleY)
          Returns the canonical description of a CoordinateSystem.
static double[] getDoubles(java.lang.String values)
          Method getDoubles extracts all the double values from a given string and returns it as array of doubles.
static Attribute toAttribute(CoordinateSystem coordSystem)
          Returns an Attribute representing the given CoordinateSystem.
static Attribute toAttribute(CoordinateSystem coordSystem, java.lang.String name)
          Method toAttribute converts an instance of CoordinateSystem to an Attribute.
static java.lang.String toString(double[] arr)
          Converts an array of doubles to a comma separated list of string representable's.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MINIMUM_X

public static final int MINIMUM_X
constant that tells about the index of a coordiante system value within an array

See Also:
Constant Field Values

MAXIMUM_X

public static final int MAXIMUM_X
constant that tells about the index of a coordiante system value within an array

See Also:
Constant Field Values

MINIMUM_Y

public static final int MINIMUM_Y
constant that tells about the index of a coordiante system value within an array

See Also:
Constant Field Values

MAXIMUM_Y

public static final int MAXIMUM_Y
constant that tells about the index of a coordiante system value within an array

See Also:
Constant Field Values

SCALEX

public static final java.lang.String SCALEX
String constant for the ScaleX field.

See Also:
Constant Field Values

SCALEY

public static final java.lang.String SCALEY
String constant for the ScaleY field.

See Also:
Constant Field Values

COORDINATESYSTEM

public static final java.lang.String COORDINATESYSTEM
String constant for the CoordinateSystem.

See Also:
Constant Field Values

DELIM

public static final java.lang.String DELIM
Delimiter which splits the values in method getDoubles.

See Also:
Constant Field Values
Method Detail

copy

public static final CoordinateSystem copy(CoordinateSystem coordSystem)
Returns a copy of the CoordinateSystem instance given by coordSystem.

Parameters:
coordSystem - the CoordinateSystem instance to copy
Returns:
CoordinateSystem the copy of the CoordinateSystem

convertToMutableCoordinateSystem

public static final MutableCoordinateSystem convertToMutableCoordinateSystem(CoordinateSystem coordSystem)
Returns an equivalent mutable version of the given immutable CoordinateSystem.

Parameters:
coordSystem - the CoordinateSystem to convert to a mutable version.
Returns:
the mutable version of the given CoordinateSystem.

convertCoordinateSystemValues

public static final double[] convertCoordinateSystemValues(CoordinateSystem sourceSystem,
                                                           CoordinateSystem targetSystem,
                                                           double[] values)
Converts the values given by values from a source coordinate system given by sourceSystem to a target coordinate system given by targetSystem. The indices of the values in the array are defined by MINIMUM_X, MAXIMUM_X, MINIMUM_Y and MAXIMUM_Y.

Parameters:
sourceSystem - the source coordinate system
targetSystem - the target coordinate system
values - the values to convert
Returns:
double[] the converted values

convertCoordinateSystemValues

public static final double[] convertCoordinateSystemValues(double sourceSystemMinX,
                                                           double sourceSystemMaxX,
                                                           double sourceSystemMinY,
                                                           double sourceSystemMaxY,
                                                           double targetSystemMinX,
                                                           double targetSystemMaxX,
                                                           double targetSystemMinY,
                                                           double targetSystemMaxY,
                                                           double[] values)
Converts the values given by values from a source coordinate system given by sourceSystem to a target coordinate system given by targetSystem. The indices of the values in the array are defined by MINIMUM_X, MAXIMUM_X, MINIMUM_Y and MAXIMUM_Y.

Parameters:
sourceSystemMinX - the minimum x value of the source coordinate system
sourceSystemMaxX - the maximum x value of the source coordinate system
sourceSystemMinY - the minimum y value of the source coordinate system
sourceSystemMaxY - the maximum y value of the source coordinate system
targetSystemMinX - the minimum x value of the target coordinate system
targetSystemMaxX - the maximum x value of the target coordinate system
targetSystemMinY - the minimum y value of the target coordinate system
targetSystemMaxY - the maximum y value of the target coordinate system
values - the values to convert
Returns:
double[] the converted values

getCanonicalDescription

public static final java.lang.String getCanonicalDescription(java.lang.String scaleX,
                                                             java.lang.String scaleY)
Returns the canonical description of a CoordinateSystem.

Parameters:
scaleX - the canonical description of the Scale for the x axis
scaleY - the canonical description of a Scale for the y axis
Returns:
String the canonical description of the CoordinateSystem

toAttribute

public static final Attribute toAttribute(CoordinateSystem coordSystem,
                                          java.lang.String name)
                                   throws IllegalAttributeException,
                                          ConstraintViolationException,
                                          IllegalValueException,
                                          IllegalNameException
Method toAttribute converts an instance of CoordinateSystem to an Attribute.
 Attribute(COORDINATESYSTEM, elements)
      AttributeList(elements)
          Attribute(ScaleX, "scaleMinimumX, scaleMaximumX")
          Attribute(ScaleY, "scaleMinimumY, scaleMaximumY")
 

Parameters:
coordSystem - the instance to convert to an attribute.
name - a name for the returned Attribute.
Returns:
the CoordinateSystem as an Attribute.
Throws:
IllegalAttributeException
ConstraintViolationException
IllegalValueException
IllegalNameException

toAttribute

public static final Attribute toAttribute(CoordinateSystem coordSystem)
                                   throws IllegalAttributeException,
                                          ConstraintViolationException,
                                          IllegalValueException,
                                          IllegalNameException
Returns an Attribute representing the given CoordinateSystem. The String defined in the constant COORDINATESYSTEM will be used as the name of this Attribute.

Parameters:
coordSystem - the CoordinateSystem to convert to an Attribute.
Returns:
an Attribute representing the given CoordinateSystem.
Throws:
IllegalAttributeException
ConstraintViolationException
IllegalValueException
IllegalNameException

createCoordinateSystem

public static final CoordinateSystem createCoordinateSystem(AttributeList list,
                                                            java.lang.String name)
                                                     throws BuildException
Method createCoordinateSystem creates a CoordinateSystem from the given list of double values.

Parameters:
list - AttributeList with the 4 necessary attributes.
name - the name of the Attribute holding the coordinate-information.
Returns:
the resulting CoordinateSystem
Throws:
BuildException

getCanonicalDescription

public static final java.lang.String getCanonicalDescription(AttributeList list,
                                                             java.lang.String name)
                                                      throws BuildException
Method createCoordinateSystem creates a canonical description from the given list of double values.

Parameters:
list - AttributeList containing the list with the 4 necessary attributes.
name - the name of the Attribute holding the list
Returns:
the resulting canonical description
Throws:
BuildException

getCanonicalDescription

public static final java.lang.String getCanonicalDescription(AttributeList list)
                                                      throws BuildException
Method createCoordinateSystem creates a canonical description from the given list of double values.

Parameters:
list - AttributeList with the 4 necessary attributes. coordinate-information.
Returns:
the resulting canonical description
Throws:
BuildException

createCoordinateSystem

public static CoordinateSystem createCoordinateSystem(int xMin,
                                                      int xMax,
                                                      int yMin,
                                                      int yMax)
                                               throws CoordinateSystemParseException
Creates a CoordinateSystem with the given minimum and maximum vlues.

Parameters:
xMin - minimum x-coordinate.
xMax - maximum x-coordinate.
yMin - minimum y-coordinate.
yMax - maximum y-coordinate.
Returns:
the corresponding CoordinateSystem.
Throws:
CoordinateSystemParseException

toString

public static final java.lang.String toString(double[] arr)
Converts an array of doubles to a comma separated list of string representable's.

Parameters:
arr - the array of doubles
Returns:
String a String containing all the doubles from the array separated by a comma.

getDoubles

public static final double[] getDoubles(java.lang.String values)
Method getDoubles extracts all the double values from a given string and returns it as array of doubles.

Parameters:
values - a String containing one or more double values separated by a comma.
Returns:
double[] the resulting array of doubles.


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