com.davisor.graphics
Class AbstractScale

java.lang.Object
  extended byjava.text.Format
      extended bycom.davisor.data.Type
          extended bycom.davisor.graphics.AbstractScale
All Implemented Interfaces:
java.lang.Cloneable, java.util.Comparator, com.davisor.core.Dupable, java.io.Serializable
Direct Known Subclasses:
PaintScale, ShapeScale

public abstract class AbstractScale
extends Type

Since:
JDK1.2
See Also:
Serialized Form

Nested Class Summary
 class AbstractScale.ScalingPoint
           
 
Nested classes inherited from class java.text.Format
java.text.Format.Field
 
Field Summary
protected static int COUNT
          'COUNT' label code.
protected  java.util.Map M_additionalValues
          Mapping from datavalues to additional values.
protected  Type M_dataType
          User defined datatype for points.
protected  java.lang.String M_defaultMode
          Default interpolation mode for calculating mapping from non-listed datavalues to resulting DataValues.
protected  java.util.Map M_infinityAdditionalValues
          Additional values of infinity point (may be null).
protected  AbstractScale.ScalingPoint M_infinityPoint
          Infinity point (may be null).
protected  java.lang.String M_legendFormat
          Composite value format for legend entries (may be null).
protected  java.util.SortedMap M_points
          Mapping from datavalues to visual effects.
protected  java.util.Map M_stringPoints
          Uses the definition Strings of the datavalues as keys.
protected static int MAX
          'MAX' label code.
protected static int MAXPERCENT
          'MAXPERCENT' label code.
protected static int MIN
          'MIN' label code.
protected static int MINPERCENT
          'MINPERCENT' label code.
static java.lang.String MODE_LINEAR
          Linear interpolation mode definition string ("linear")
static java.lang.String MODE_NONE
          "No interpolation" mode definition string ("none")
protected static java.lang.String[] SCALEFIELDNAMES
          Scale label field names.
protected static int TOTALCOUNT
          'TOTALCOUNT' label code.
 
Fields inherited from class com.davisor.data.Type
METADATA_GROUP, METADATA_NAME, METADATA_PARENT, METADATA_SUBCHANNELS, TYPENAME
 
Constructor Summary
AbstractScale(AbstractScale as)
          Deep copy constructor.
AbstractScale(Type dataType, java.lang.String defaultMode, java.lang.String legendFormat)
          Sets given attributes.
 
Method Summary
 void addPoint(DataValue position, DataValue value, DataValue minValue, java.lang.String mode, java.lang.String positionType, java.lang.String legendFormat)
          Adds transition point into the map of initialized points.
 void addPoint(java.lang.String positionStr, java.lang.String valueStr, java.lang.String minValueStr, java.lang.String mode, java.lang.String positionType, java.lang.String legendFormat)
          Adds transition point into the map of uninitialized points.
 java.util.Map getAdditionalValues()
          Returns the map of additional values.
 java.lang.String getDefaultInterpolationMode()
          Returns interpolation mode of the scale.
protected abstract  DataValue getDeinterpolatedValue(double factor, DataValue minValue, DataValue maxValue)
          Returns a deinterpolated value.
 java.util.Map getInfinityAdditionalValues()
          Returns the additional values of an infinity point.
 AbstractScale.ScalingPoint getInfinityPoint()
          Returns the infinity point of the scale.
 java.lang.String getInfinityPointLegendFormat()
          Returns the legend format of infinity point.
 java.lang.String getInterpolationMode(DataValue key)
          Returns the interpolation mode of the given DataValue.
 java.lang.String getLegendFormat()
          Returns legend value format of the scale.
 java.lang.String getPointLegendFormat(DataValue key)
          Return the legend value format of the given DataValue.
 java.util.List getPoints(boolean descending)
          Returns initialized point keys in asked order.
 DataValue getScaledValue(DataValue value)
          Returns a scaled DataValue according to the scale.
 java.util.List getStringPoints()
          Returns uninitialized position keys.
 java.lang.Class getValueClass()
          Gets value container class.
 DataValue[] getValues(DataValue key)
          Returns maximum and minimum values of the given point.
 void init(DataValue min, DataValue max, java.util.List valueList)
          Initializes positions.
 DataValue toData(java.lang.Object value)
          Returns a scaled value for the given data according to the scale.
 DataValue toData(java.lang.String data, java.text.ParsePosition status)
          Returns a scaled value for the given data according to the scale.
protected  java.lang.String toString(java.lang.String minValue, java.lang.String prefix)
          Returns the xml representation of this scale.
 DataValue zero()
          Gets zero data value for this type.
 
Methods inherited from class com.davisor.data.Type
ceil, check, check, compare, create, create, create, create, create, dup, dup, equals, floor, format, getCompatibility, getDataName, getFormat, getId, getID, getMetaData, getMetaData, getSpecs, getSQLCode, getSQLName, getSQLName, getTypeName, hashCode, isNull, parseObject, register, register, setDataName, setFormat, setId, setID, setMetaData, setMetaData, setSpecs, toData, toData, toString, toXML, xmlEnd, xmlStart
 
Methods inherited from class java.text.Format
clone, format, formatToCharacterIterator, parseObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MODE_NONE

public static final java.lang.String MODE_NONE
"No interpolation" mode definition string ("none")

See Also:
Constant Field Values

MODE_LINEAR

public static final java.lang.String MODE_LINEAR
Linear interpolation mode definition string ("linear")

See Also:
Constant Field Values

SCALEFIELDNAMES

protected static java.lang.String[] SCALEFIELDNAMES
Scale label field names.


COUNT

protected static final int COUNT
'COUNT' label code.

See Also:
Constant Field Values

MAX

protected static final int MAX
'MAX' label code.

See Also:
Constant Field Values

MAXPERCENT

protected static final int MAXPERCENT
'MAXPERCENT' label code.

See Also:
Constant Field Values

MIN

protected static final int MIN
'MIN' label code.

See Also:
Constant Field Values

MINPERCENT

protected static final int MINPERCENT
'MINPERCENT' label code.

See Also:
Constant Field Values

TOTALCOUNT

protected static final int TOTALCOUNT
'TOTALCOUNT' label code.

See Also:
Constant Field Values

M_dataType

protected Type M_dataType
User defined datatype for points.


M_defaultMode

protected java.lang.String M_defaultMode
Default interpolation mode for calculating mapping from non-listed datavalues to resulting DataValues.


M_infinityAdditionalValues

protected java.util.Map M_infinityAdditionalValues
Additional values of infinity point (may be null).


M_infinityPoint

protected AbstractScale.ScalingPoint M_infinityPoint
Infinity point (may be null).


M_additionalValues

protected java.util.Map M_additionalValues
Mapping from datavalues to additional values.


M_points

protected java.util.SortedMap M_points
Mapping from datavalues to visual effects. Only transitions between effects are listed.


M_stringPoints

protected java.util.Map M_stringPoints
Uses the definition Strings of the datavalues as keys. In initialization these values are moved into M_points.


M_legendFormat

protected java.lang.String M_legendFormat
Composite value format for legend entries (may be null).

Constructor Detail

AbstractScale

public AbstractScale(AbstractScale as)
Deep copy constructor.


AbstractScale

public AbstractScale(Type dataType,
                     java.lang.String defaultMode,
                     java.lang.String legendFormat)
Sets given attributes.

Parameters:
dataType - point data type
defaultMode - default interpolation mode
Method Detail

addPoint

public void addPoint(java.lang.String positionStr,
                     java.lang.String valueStr,
                     java.lang.String minValueStr,
                     java.lang.String mode,
                     java.lang.String positionType,
                     java.lang.String legendFormat)
              throws InvalidDataException
Adds transition point into the map of uninitialized points.

Parameters:
positionStr - position of the point
valueStr - value for the upper end of the point
minValueStr - value for the lower end of the point (may be null)
mode - interpolation mode of the point (may be null)
positionType - type of the position string (may be null)
legendFormat - legend value format of this point (may be null)
Throws:
InvalidDataException

addPoint

public void addPoint(DataValue position,
                     DataValue value,
                     DataValue minValue,
                     java.lang.String mode,
                     java.lang.String positionType,
                     java.lang.String legendFormat)
Adds transition point into the map of initialized points.

Parameters:
position - position of the point
value - value for the upper end of the point
minValue - value for the lower end of the point (may be null)
mode - interpolation mode of the point (may be null)
positionType - type of the position (may be null)
legendFormat - legend value format of this point (may be null)

getAdditionalValues

public java.util.Map getAdditionalValues()
Returns the map of additional values. May return null.


getInfinityAdditionalValues

public java.util.Map getInfinityAdditionalValues()
Returns the additional values of an infinity point. May return null.


getInfinityPoint

public AbstractScale.ScalingPoint getInfinityPoint()
Returns the infinity point of the scale. May return null.


getInfinityPointLegendFormat

public java.lang.String getInfinityPointLegendFormat()
Returns the legend format of infinity point. May return null.


getDefaultInterpolationMode

public java.lang.String getDefaultInterpolationMode()
Returns interpolation mode of the scale.

Returns:
interpolation mode (may be null)

getInterpolationMode

public java.lang.String getInterpolationMode(DataValue key)
Returns the interpolation mode of the given DataValue. May return null.

Parameters:
key - data value for which the interpolation mode is wanted

getLegendFormat

public java.lang.String getLegendFormat()
Returns legend value format of the scale.

Returns:
legend value format (may be null)

getPointLegendFormat

public java.lang.String getPointLegendFormat(DataValue key)
Return the legend value format of the given DataValue. May return null.

Parameters:
key - data value for which the legend value format is requested

getPoints

public java.util.List getPoints(boolean descending)
Returns initialized point keys in asked order. May return an empty list.

Parameters:
descending - are point keys wanted in descending order or not

getScaledValue

public DataValue getScaledValue(DataValue value)
                         throws InvalidDataException
Returns a scaled DataValue according to the scale. May return null.

Parameters:
value - DataValue for which the scaled DataValue is wanted
Throws:
InvalidDataException

getStringPoints

public java.util.List getStringPoints()
Returns uninitialized position keys. May return an empty list.


getValues

public DataValue[] getValues(DataValue key)
Returns maximum and minimum values of the given point.

Parameters:
key - key of the point

init

public void init(DataValue min,
                 DataValue max,
                 java.util.List valueList)
          throws InvalidDataException
Initializes positions. After initialization points have a real value that tells their position.

Parameters:
min - minimum value of the channels that belong to this scale
max - maximum value of the channels that belong to this scale
valueList - values of the channels in sorted order
Throws:
InvalidDataException

getValueClass

public java.lang.Class getValueClass()
Gets value container class.

Specified by:
getValueClass in class Type

zero

public DataValue zero()
Gets zero data value for this type. This value is useful as a reference point when polymorphic data is placed on a scalar axis.

Specified by:
zero in class Type
Returns:
a new zero value data object sharing this type
See Also:
DataValue.deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue), DataValue.interpolate(double, com.davisor.data.DataValue)

toData

public DataValue toData(java.lang.String data,
                        java.text.ParsePosition status)
                 throws InvalidDataException
Returns a scaled value for the given data according to the scale.

Specified by:
toData in class Type
Parameters:
data - data string
status - parse status (may be null)
Returns:
a data value object corresponding given string value
Throws:
InvalidDataException - if given string value could not be parsed
See Also:
Type.toData(CallableStatement,int), Type.toData(Object), Type.toData(ResultSet,int), DataValue.toString()

toData

public DataValue toData(java.lang.Object value)
                 throws InvalidDataException
Returns a scaled value for the given data according to the scale.

Overrides:
toData in class Type
Parameters:
value - data object
Returns:
a data value object corresponding to given object value
Throws:
InvalidDataException - if given object value could not be parsed
See Also:
Type.toData(CallableStatement,int), Type.toData(ResultSet,int), Type.toData(String,ParsePosition), DataValue.toString()

toString

protected java.lang.String toString(java.lang.String minValue,
                                    java.lang.String prefix)
Returns the xml representation of this scale.

Parameters:
minValue - Minimum value name (may be null).
prefix - Prefix of the scale (may be null).

getDeinterpolatedValue

protected abstract DataValue getDeinterpolatedValue(double factor,
                                                    DataValue minValue,
                                                    DataValue maxValue)
Returns a deinterpolated value.

Parameters:
factor - scaling factor
minValue - Value to be returned when scaling factor is zero (0)
maxValue - Value to be returned when scaling factor is one (1)


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.