com.tensegrity.composite.coordinate
Class DefaultCategoryScale

java.lang.Object
  extended bycom.tensegrity.composite.coordinate.DefaultCategoryScale
All Implemented Interfaces:
CategoryScale, Scale
Direct Known Subclasses:
DefaultMutableCategoryScale, DefaultMutableTableCellCategoryScale

public class DefaultCategoryScale
extends java.lang.Object
implements CategoryScale

This class is the default implementation of a CategoryScale. For the documentation have a look at the CategoryScale interface.

Version:
$Id: DefaultCategoryScale.java,v 1.12 2006/03/02 10:41:25 BurkhardWick Exp $
Author:
MichaelRaue

Field Summary
protected  java.util.List categories
          category range definitions
 
Fields inherited from interface com.tensegrity.composite.coordinate.Scale
TYPE_LINEAR
 
Constructor Summary
DefaultCategoryScale(double scaleMinimum, double scaleMaximum)
          Constructor specifying the minimum and maximum value for the used Scale.
 
Method Summary
 Scale deepCopy()
          Method to deep copy this scale instance.
 double descale(double minimum, double maximum, double valueToDescale)
          Converts the value given by valueToDescale from the range given by minimum and maximum to the range of this Scale.
 boolean equals(java.lang.Object obj)
           
 java.util.List getCategories()
          Returns a List with the CategoryRanges the CategoryScale provides.
 double getDescaleFactor(double minimum, double maximum)
          Returns the scale factor that converts a value from the range given by minimum and maximum to range of this Scale.
 double getScaleFactor(double minimum, double maximum)
          Returns the scale factor that converts a value from the range of this Scale to the range given by minimum and maximum.
 double getScaleMaximum()
          Returns the maximum scale value for this Scale.
 double getScaleMinimum()
          Returns the minimum scale value for this Scale.
 double getScaleRange()
          Returns the scale range for this Scale.
 int getWidth(int cat)
          Returns the width of the category at index cat.
 int getWidth(int from, int to)
          Returns the single width of the category range at the given index.
 int getWidthSum(int to)
          Returns the sum of all category ranges from the left side of the given index to.
 int hashCode()
           
 double scale(double minimum, double maximum, double valueToScale)
          Converts the value given by valueToScale from the range of this Scale to the range given by minimum and maximum.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

categories

protected java.util.List categories
category range definitions

Constructor Detail

DefaultCategoryScale

public DefaultCategoryScale(double scaleMinimum,
                            double scaleMaximum)
Constructor specifying the minimum and maximum value for the used Scale.

Parameters:
scaleMinimum - the minimum of the used Scale.
scaleMaximum - the maximum of the used Scale.
Method Detail

getCategories

public java.util.List getCategories()
Description copied from interface: CategoryScale
Returns a List with the CategoryRanges the CategoryScale provides.

Specified by:
getCategories in interface CategoryScale
Returns:
List of the CategoryRanges

getWidthSum

public int getWidthSum(int to)
Description copied from interface: CategoryScale
Returns the sum of all category ranges from the left side of the given index to.

Specified by:
getWidthSum in interface CategoryScale
Parameters:
to - the index up to set the sum should be builded.
Returns:
the sum of all category ranges from the left side of to.

getWidth

public int getWidth(int cat)
Description copied from interface: CategoryScale
Returns the width of the category at index cat.

Specified by:
getWidth in interface CategoryScale
Parameters:
cat - the index of the CategoryRange to query.
Returns:
the width of the CategoryRange at the given index.

getWidth

public int getWidth(int from,
                    int to)
Description copied from interface: CategoryScale
Returns the single width of the category range at the given index.

Specified by:
getWidth in interface CategoryScale
Parameters:
from - the start index.
to - the stop index.
Returns:
the single width of the category range at the given index.

getScaleMinimum

public double getScaleMinimum()
Description copied from interface: Scale
Returns the minimum scale value for this Scale.

Specified by:
getScaleMinimum in interface Scale
Returns:
double the minimum scale value

getScaleMaximum

public double getScaleMaximum()
Description copied from interface: Scale
Returns the maximum scale value for this Scale.

Specified by:
getScaleMaximum in interface Scale
Returns:
double the maximum scale value

getScaleRange

public double getScaleRange()
Description copied from interface: Scale
Returns the scale range for this Scale. The scale range is defined as the interval between the minimum scale value and the maximum scale value. The mathematical expression for this is:
maximum scale value - minimum scale value.

Specified by:
getScaleRange in interface Scale
Returns:
double the scale range

getScaleFactor

public double getScaleFactor(double minimum,
                             double maximum)
Description copied from interface: Scale
Returns the scale factor that converts a value from the range of this Scale to the range given by minimum and maximum. The mathematical expression for this is:
(maximum - minimum) / (maximum scale value - minimum scale value) .

Specified by:
getScaleFactor in interface Scale
Parameters:
minimum - the minimum value of the range to convert to
maximum - the maximum value of the range to convert to
Returns:
double the scale factor

getDescaleFactor

public double getDescaleFactor(double minimum,
                               double maximum)
Description copied from interface: Scale
Returns the scale factor that converts a value from the range given by minimum and maximum to range of this Scale. The mathematical expression for this is:
(maximum scale value - minimum scale value) / (maximum - minimum) .

Specified by:
getDescaleFactor in interface Scale
Parameters:
minimum - the minimum value of the range to convert from
maximum - the maximum value of the range to convert from
Returns:
double the descale factor

scale

public double scale(double minimum,
                    double maximum,
                    double valueToScale)
Description copied from interface: Scale
Converts the value given by valueToScale from the range of this Scale to the range given by minimum and maximum. The mathematical expression for this is:
valueToScale * (maximum - minimum) / (maximum scale value - minimum scale value) .

Specified by:
scale in interface Scale
Parameters:
minimum - the minimum value of the range to convert to
maximum - the maximum value of the range to convert to
valueToScale - the value to convert
Returns:
double the converted value

descale

public double descale(double minimum,
                      double maximum,
                      double valueToDescale)
Description copied from interface: Scale
Converts the value given by valueToDescale from the range given by minimum and maximum to the range of this Scale. The mathematical expression for this is:
valueToScale * (maximum scale value - minimum scale value) / (maximum - minimum) .

Specified by:
descale in interface Scale
Parameters:
minimum - the minimum value of the range to convert from
maximum - the maximum value of the range to convert from
valueToDescale - the value to convert
Returns:
double the converted value

deepCopy

public Scale deepCopy()
Description copied from interface: Scale
Method to deep copy this scale instance.

Specified by:
deepCopy in interface Scale
Returns:
the copied Scale.

toString

public java.lang.String toString()
See Also:
Object.toString()

equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()


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