com.tensegrity.composite.coordinate
Interface Scale

All Known Subinterfaces:
CategoryScale, MutableCategoryScale, MutableScale
All Known Implementing Classes:
DefaultCategoryScale, DefaultMutableCategoryScale, DefaultMutableScaleLinear, DefaultMutableTableCellCategoryScale, DefaultScaleLinear

public interface Scale

A Scale is an object that represents a scale from a mathematical point of view. It consists of two values: the minimum scale value and the maximum scale value, which together define an interval or numerical range. A Scale can be implemented as a linear or logarithmic Scale.

Linear Scale (min: 0, max: 10) Linear Scale (min: -500, max: 2000)

To avoid creating identical Scale objects (same type and interval), instances are pooled in the ScalePool singleton. Since many clients may have a reference to the very same instance, Scale objects are immutable. A mutable version is defined by the MutableScale interface.

To work with these values the Scale provides the methods listed below:

In order to convert a value from one Scale into another, this interface provides the following methods:

Scale that are not in the ScalePool and not reference by any other object will be garbage collected.

Version:
$Id: Scale.java,v 1.14 2005/05/20 14:58:53 AndreasEbbert Exp $
Author:
MichaelKegel

Field Summary
static java.lang.String TYPE_LINEAR
          String constant defining linear Scales
 
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.
 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.
 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.
 

Field Detail

TYPE_LINEAR

public static final java.lang.String TYPE_LINEAR
String constant defining linear Scales

See Also:
Constant Field Values
Method Detail

getScaleMinimum

public double getScaleMinimum()
Returns the minimum scale value for this Scale.

Returns:
double the minimum scale value

getScaleMaximum

public double getScaleMaximum()
Returns the maximum scale value for this Scale.

Returns:
double the maximum scale value

getScaleRange

public double getScaleRange()
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.

Returns:
double the scale range

getScaleFactor

public 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. The mathematical expression for this is:
(maximum - minimum) / (maximum scale value - minimum scale value) .

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

Find more information in the class documentation


getDescaleFactor

public 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. The mathematical expression for this is:
(maximum scale value - minimum scale value) / (maximum - minimum) .

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

Find more information in the class documentation


scale

public 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. The mathematical expression for this is:
valueToScale * (maximum - minimum) / (maximum scale value - minimum scale value) .

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

Find more information in the class documentation


descale

public 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. The mathematical expression for this is:
valueToScale * (maximum scale value - minimum scale value) / (maximum - minimum) .

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

Find more information in the class documentation


deepCopy

public Scale deepCopy()
Method to deep copy this scale instance.

Returns:
the copied Scale.


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