lt.monarch.chart.mapper
Class MathAxisScale

java.lang.Object
  extended by lt.monarch.chart.mapper.AnalogAxisScale
      extended by lt.monarch.chart.mapper.MathAxisScale
All Implemented Interfaces:
java.io.Serializable, AxisScale
Direct Known Subclasses:
MathAxisScale.SubScale

public class MathAxisScale
extends AnalogAxisScale

Axis scale implementation for MathAxisMapper.

See Also:
Serialized Form

Nested Class Summary
Modifier and Type Class and Description
static class MathAxisScale.SubScale
          The sub-scale of MathAxisScale.
 
Field Summary
Modifier and Type Field and Description
protected  NormalizedMathRange range
          The mapping range
 
Fields inherited from class lt.monarch.chart.mapper.AnalogAxisScale
subscaleTickCount
 
Constructor Summary
Constructor and Description
MathAxisScale(NormalizedMathRange range)
          Constructs a new MathAxisScale with the specified mapping range.
 
Method Summary
Modifier and Type Method and Description
protected  AnalogAxisScale createSubScale()
          Creates a new sub-scale of the scale.
 int findNearestMark(double d)
          Gets the index of label nearest to the specified position on axis.
protected  java.lang.String formatKey(double key)
          Formats and converts the specified double value to string.
protected  java.text.NumberFormat getDefaultNumberFormat()
          Gets default number format.
 java.lang.String getLabelAt(int i)
          Gets a label at the specified position.
 java.lang.String getLabelAt(int i, java.util.Locale locale)
          Gets a scale's label at the specified position.
protected  java.util.Locale getLastLocale()
          Gets last user set locale.
protected  java.text.NumberFormat getLastNumberFormat()
          Gets last user set number format.
 int getMarkCount()
          Gets a number of marks in the scale.
 java.text.NumberFormat getNumberFormat()
          Returns the user-assigned number format used to format scale's labels.
 AxisScale getSubScale()
          Gets a sub-scale of the scale.
 double mapMark(int i)
          Finds position on axis of scale's label with the specified index.
 double[] mapMarkTicks(int i)
          Finds the position for the axis measurement mark ticks (some scales marks can have 2 or more ticks).
protected  void setDrawSubScale(boolean drawSubScale)
          Sets if the sub-scale on the axis should be drawn
protected  void setLastLocale(java.util.Locale lastLocale)
          Sets last user set locale.
protected  void setLastNumberFormat(java.text.NumberFormat lastNumberFormat)
          Gets last user set number format.
protected  void setNumberFormat(java.text.NumberFormat nf)
          Sets the number format for this scale.
 
Methods inherited from class lt.monarch.chart.mapper.AnalogAxisScale
getSubscaleTickCount, setSubscaleTickCount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

range

protected final NormalizedMathRange range
The mapping range

Constructor Detail

MathAxisScale

public MathAxisScale(NormalizedMathRange range)
Constructs a new MathAxisScale with the specified mapping range.

Parameters:
range - the mapping range
Method Detail

mapMark

public double mapMark(int i)
Finds position on axis of scale's label with the specified index.

Parameters:
i - the label index
Returns:
label's position on axis

setDrawSubScale

protected void setDrawSubScale(boolean drawSubScale)
Sets if the sub-scale on the axis should be drawn

Parameters:
drawSubScale - True if to draw sub-scale

findNearestMark

public int findNearestMark(double d)
Gets the index of label nearest to the specified position on axis.

Parameters:
d - the position on axis; value in range [0,1]
Returns:
index of nearest label

getMarkCount

public int getMarkCount()
Gets a number of marks in the scale.

Returns:
number of marks

getLabelAt

public java.lang.String getLabelAt(int i)
Gets a label at the specified position.

Parameters:
i - the label index
Returns:
the label at the specified position

getLabelAt

public java.lang.String getLabelAt(int i,
                                   java.util.Locale locale)
Gets a scale's label at the specified position. The number format set by setNumberFormat method is used to format number. If number format isn't set then default number format for the specified locale is used.

Parameters:
i - the label index
locale - the locale
Returns:
the scale's label at the specified position

formatKey

protected java.lang.String formatKey(double key)
Formats and converts the specified double value to string. The double value is forwarded to format method of mapping range.

Parameters:
key - the double value to format
Returns:
string representation of the double value

getSubScale

public AxisScale getSubScale()
Gets a sub-scale of the scale.

Returns:
sub-scale of the scale

createSubScale

protected AnalogAxisScale createSubScale()
Creates a new sub-scale of the scale.

Returns:
new sub-scale of the scale; an object instance of MathAxisScale.SubScale

setNumberFormat

protected void setNumberFormat(java.text.NumberFormat nf)
Sets the number format for this scale. The number format is used to format scale's labels.

Parameters:
nf - the number format

getNumberFormat

public java.text.NumberFormat getNumberFormat()
Returns the user-assigned number format used to format scale's labels.

Returns:
number format

mapMarkTicks

public double[] mapMarkTicks(int i)
Finds the position for the axis measurement mark ticks (some scales marks can have 2 or more ticks).

Parameters:
i - label index
Returns:
a value array in range [0,1]

getLastLocale

protected java.util.Locale getLastLocale()
Gets last user set locale.

Returns:
locale

getLastNumberFormat

protected java.text.NumberFormat getLastNumberFormat()
Gets last user set number format.

Returns:
number format

setLastLocale

protected void setLastLocale(java.util.Locale lastLocale)
Sets last user set locale.

Parameters:
lastLocale - last user set locale

setLastNumberFormat

protected void setLastNumberFormat(java.text.NumberFormat lastNumberFormat)
Gets last user set number format.

Parameters:
lastNumberFormat - number format

getDefaultNumberFormat

protected java.text.NumberFormat getDefaultNumberFormat()
Gets default number format.

Returns:
number format