lt.monarch.chart.mapper
Class DateAxisMapper.DateScale

java.lang.Object
  extended by lt.monarch.chart.mapper.AnalogAxisScale
      extended by lt.monarch.chart.mapper.DateAxisMapper.DateScale
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, AxisScale
Direct Known Subclasses:
DateAxisMapper.DefaultDateScale, DateAxisMapper.StepScale
Enclosing class:
DateAxisMapper

public abstract class DateAxisMapper.DateScale
extends AnalogAxisScale
implements java.lang.Cloneable

Base class for all date scales.

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
protected  boolean dateFormatSetByUser
          Specifies whether date format for the scale's labels is set by user (setting date format for axis mapper or directly for the scale) or the scale it self should create default date format
protected  java.util.Date[] dates
          An array of Date objects - scale labels
protected  java.util.Locale locale
          Default locale
protected  java.text.DateFormat scaleDateFormat
          The date format used to format labels of the scale
protected  AxisScale subScale
          The sub-scale of the scale
 
Fields inherited from class lt.monarch.chart.mapper.AnalogAxisScale
subscaleTickCount
 
Constructor Summary
Modifier Constructor and Description
protected DateAxisMapper.DateScale(int incrementUnits, int incrementStep)
          Sole constructor.
 
Method Summary
Modifier and Type Method and Description
 int findNearestMark(double d)
          Gets an index of the label or tick mark of the scale nearest to the specified position in mapper's mapping range.
 java.lang.String getLabelAt(int i)
          Gets the scale's label with the specified index.
 java.lang.String getLabelAt(int i, java.util.Locale locale)
          Gets the scale label with the specified index and formated accordingly to the given locale.
protected  java.lang.String getLabelFor(java.util.Date d)
          Converts the specified Date object to String using date format.
 java.util.Locale getLocale()
          Returns current locale used for the DateScale
 int getMarkCount()
          Gets number of scale marks.
 AxisScale getSubScale()
          Gets a sub-scale of the scale.
 double mapMark(int i)
          Returns a position of the i-th scale's label in the mappers mapping range.
 double[] mapMarkTicks(int i)
          Finds the position for the axis measurement mark ticks (some scales marks can have 2 or more ticks).
protected  void setDefaultLabelFormat(java.text.DateFormat dateFormat)
          Sets the default date format for the scale as label format.
protected  void setLabelFormat(java.text.DateFormat dateFormat)
          Sets the specified date format for the scale as label format.
 void setLocale(java.util.Locale locale)
          Sets locale for the label format
 
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

scaleDateFormat

protected java.text.DateFormat scaleDateFormat
The date format used to format labels of the scale


locale

protected java.util.Locale locale
Default locale


dates

protected final java.util.Date[] dates
An array of Date objects - scale labels


dateFormatSetByUser

protected boolean dateFormatSetByUser
Specifies whether date format for the scale's labels is set by user (setting date format for axis mapper or directly for the scale) or the scale it self should create default date format


subScale

protected AxisScale subScale
The sub-scale of the scale

Constructor Detail

DateAxisMapper.DateScale

protected DateAxisMapper.DateScale(int incrementUnits,
                                   int incrementStep)
Sole constructor. (For invocation by subclass constructors). Prepares date scale with the specified increment units and increment step.

Parameters:
incrementUnits - scale's increment units
incrementStep - scale's increment step
Method Detail

setLocale

public void setLocale(java.util.Locale locale)
Sets locale for the label format

Parameters:
locale - locale to set

getLocale

public java.util.Locale getLocale()
Returns current locale used for the DateScale

Returns:
current locale

setLabelFormat

protected void setLabelFormat(java.text.DateFormat dateFormat)
Sets the specified date format for the scale as label format.

Parameters:
dateFormat - the date format

setDefaultLabelFormat

protected void setDefaultLabelFormat(java.text.DateFormat dateFormat)
Sets the default date format for the scale as label format.

Parameters:
dateFormat - the date format

getLabelFor

protected java.lang.String getLabelFor(java.util.Date d)
Converts the specified Date object to String using date format.

Parameters:
d - the Date object to format
Returns:
string representation of the specified Date object

getLabelAt

public java.lang.String getLabelAt(int i)
Gets the scale's label with the specified index.

Specified by:
getLabelAt in interface AxisScale
Parameters:
i - the label index
Returns:
scale's label with the specified index

mapMark

public double mapMark(int i)
Returns a position of the i-th scale's label in the mappers mapping range.

Specified by:
mapMark in interface AxisScale
Parameters:
i - the label index
Returns:
position of the label - value in range [0;1]

findNearestMark

public int findNearestMark(double d)
Gets an index of the label or tick mark of the scale nearest to the specified position in mapper's mapping range.

Specified by:
findNearestMark in interface AxisScale
Parameters:
d - position in mapping range - value in range [0;1]
Returns:
index of nearest label or tick

getMarkCount

public int getMarkCount()
Gets number of scale marks.

Specified by:
getMarkCount in interface AxisScale
Returns:
number of scale marks

getSubScale

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

Specified by:
getSubScale in interface AxisScale
Returns:
sub-scale of the scale

getLabelAt

public java.lang.String getLabelAt(int i,
                                   java.util.Locale locale)
Gets the scale label with the specified index and formated accordingly to the given locale.

Specified by:
getLabelAt in interface AxisScale
Parameters:
i - the label index
locale - locale to format scale label accordingly to
Returns:
the scale label

mapMarkTicks

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

Specified by:
mapMarkTicks in interface AxisScale
Parameters:
i - label index
Returns:
a value array in range [0,1]