lt.monarch.chart.mapper
Class DateAxisMapper

java.lang.Object
  extended by lt.monarch.chart.mapper.AbstractAxisMapper
      extended by lt.monarch.chart.mapper.AnalogAxisMapper<DateAxisRange>
          extended by lt.monarch.chart.mapper.DateAxisMapper
All Implemented Interfaces:
java.io.Serializable, AxisMapper

public class DateAxisMapper
extends AnalogAxisMapper<DateAxisRange>

Axis mapper, which maps a date range.

See Also:
Serialized Form

Nested Class Summary
Modifier and Type Class and Description
 class DateAxisMapper.DateScale
          Base class for all date scales.
protected  class DateAxisMapper.DefaultDateScale
          The default years scale.
protected  class DateAxisMapper.StepScale
          The date axis scale with custom scale units and step.
 
Constructor Summary
Constructor and Description
DateAxisMapper()
          Empty constructor.
DateAxisMapper(java.util.Date start, java.util.Date end)
          Constructs a new DateAxisMapper with the specified date range.
DateAxisMapper(java.util.Date start, java.util.Date end, AxisMapperRange mapperRange)
          Constructs a new DateAxisMapper with the specified date range and mapper range.
 
Method Summary
Modifier and Type Method and Description
 java.lang.String formatKey(java.lang.Object key)
          Formats and returns the specified Date key according to general date format of the mapper.
 java.util.Calendar getCalendar()
          Gets a calendar of the date axis mapper.
 java.text.DateFormat getDateFormat(int units)
          Gets the general date format of the date axis mapper.
 int getFinestScaleUnits()
          Returns the finest scale units.
protected  java.text.Format[] getFormats()
          Gets axis mapper formats.
 DateAxisRange getRange()
          Returns full date range of the axis.
 AxisScale getScale()
          Returns an axis scale for this axis.
 int getStartingScaleUnits()
          Returns the starting scale units.
 AxisMapperRange getViewRange()
          Gets the visible range as an AxisMapperRange object.
 DateAxisRange getVisibleRange()
          Returns a visible date range of the axis.
 double map(java.lang.Object key)
          Maps the specified Date value into the mapping range.
 java.lang.Object mapBack(double pos)
          Returns a Date object corresponding to the specified position in the mapping range.
 void setCalendar(java.util.Calendar calendar)
          Sets a Calendar for this date axis mapper.
 void setDateFormat(java.text.DateFormat dateFormat, int units)
          Sets the date format for specified scale units.
 void setDateRange(java.util.Date start, java.util.Date end)
          Sets date range for the axis
 void setFinestScaleUnits(int units)
          Sets the finest scale units.
 void setStartingScaleUnits(int units)
          Sets the biggest scale units.
 void setStepScale(int units, int step)
          Sets step scale.
 void setTimeZone(java.util.TimeZone zone)
          Sets time zone for the date axis.
 void setVisibleRange(java.util.Date start, java.util.Date end)
          Sets visible date range for the axis.
 
Methods inherited from class lt.monarch.chart.mapper.AnalogAxisMapper
getPreferredHeight, getPreferredWidth
 
Methods inherited from class lt.monarch.chart.mapper.AbstractAxisMapper
addListener, fireMappingChanged, getProjectionRange, removeListener, setProjectionRange
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DateAxisMapper

public DateAxisMapper()
Empty constructor. Constructs a new DateAxisMapper with date range from current time to 1 day after current time.


DateAxisMapper

public DateAxisMapper(java.util.Date start,
                      java.util.Date end)
Constructs a new DateAxisMapper with the specified date range.

Parameters:
start - start of the range
end - end of the range

DateAxisMapper

public DateAxisMapper(java.util.Date start,
                      java.util.Date end,
                      AxisMapperRange mapperRange)
Constructs a new DateAxisMapper with the specified date range and mapper range.

Parameters:
start - start of the date range
end - end of the date range
mapperRange - the mapper range
Method Detail

setTimeZone

public void setTimeZone(java.util.TimeZone zone)
Sets time zone for the date axis.

Parameters:
zone - TimeZone object. Use new TimeZone.getTimeZone(String timeZoneName). Default is the one which is set on current PC.

setCalendar

public void setCalendar(java.util.Calendar calendar)
Sets a Calendar for this date axis mapper. The Calendar will be used to extract integer fields as YEAR, MONTH, DAY and so on from Date objects.

Parameters:
calendar - the calendar

setDateFormat

public void setDateFormat(java.text.DateFormat dateFormat,
                          int units)
Sets the date format for specified scale units. If parameter is not set the default DataFormat.SHORT format will be used for that scale unit.

Parameters:
dateFormat - : desired DateFormat,
units - Any of these values: Calendar.YEAR, Calendar.MONTH, Calendar.DAY_OF_MONTH

getCalendar

public java.util.Calendar getCalendar()
Gets a calendar of the date axis mapper.

Returns:
calendar of the date axis mapper
See Also:
setCalendar(java.util.Calendar)

getDateFormat

public java.text.DateFormat getDateFormat(int units)
Gets the general date format of the date axis mapper.

Parameters:
units - time scale units
Returns:
general date format of the mapper

getViewRange

public AxisMapperRange getViewRange()
Gets the visible range as an AxisMapperRange object.

Returns:
AxisMapperRange object representing visible mapper range

getVisibleRange

public DateAxisRange getVisibleRange()
Returns a visible date range of the axis.

Specified by:
getVisibleRange in class AnalogAxisMapper<DateAxisRange>
Returns:
DateAxisRange - visible axis range

getRange

public DateAxisRange getRange()
Returns full date range of the axis.

Specified by:
getRange in class AnalogAxisMapper<DateAxisRange>
Returns:
DateAxisRange - full axis range

setDateRange

public void setDateRange(java.util.Date start,
                         java.util.Date end)
Sets date range for the axis

Parameters:
start - start date
end - end date

setVisibleRange

public void setVisibleRange(java.util.Date start,
                            java.util.Date end)
Sets visible date range for the axis.

Parameters:
start - start date
end - end date

setFinestScaleUnits

public void setFinestScaleUnits(int units)
Sets the finest scale units. No units, smaller than specified by the finestScaleUnits property are drawn. Zooming can not be performed beyond this precision.

Parameters:
units - Any of these values: Calendar.YEAR, Calendar.MONTH, Calendar.WEEK_OF_MONTH, Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND

setStartingScaleUnits

public void setStartingScaleUnits(int units)
Sets the biggest scale units. The scale starts with the units specified here.

Parameters:
units - Any of these values: Calendar.YEAR, Calendar.MONTH, Calendar.WEEK_OF_MONTH, Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND

setStepScale

public void setStepScale(int units,
                         int step)
Sets step scale. This is a fixed scale with fixed scale unit and step.

Parameters:
units - Any of these values: Calendar.YEAR, Calendar.MONTH, Calendar.WEEK_OF_MONTH, Calendar.DAY_OF_MONTH, Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND, Calendar.MILLISECOND
step - scale step

getFinestScaleUnits

public int getFinestScaleUnits()
Returns the finest scale units.

Returns:
finest scale units
See Also:
setFinestScaleUnits(int)

getStartingScaleUnits

public int getStartingScaleUnits()
Returns the starting scale units.

Returns:
starting scale units
See Also:
setStartingScaleUnits(int)

map

public double map(java.lang.Object key)
Maps the specified Date value into the mapping range.

Parameters:
key - the Date to map
Returns:
position of key in the date range; a value in range [0,1]

mapBack

public java.lang.Object mapBack(double pos)
Returns a Date object corresponding to the specified position in the mapping range.

Specified by:
mapBack in interface AxisMapper
Overrides:
mapBack in class AbstractAxisMapper
Parameters:
pos - position in range [0;1]
Returns:
Date object corresponding to the specified position
See Also:
AxisMapper.mapBack(double)

getScale

public AxisScale getScale()
Returns an axis scale for this axis.

Returns:
axis scale for this axis

formatKey

public java.lang.String formatKey(java.lang.Object key)
Formats and returns the specified Date key according to general date format of the mapper.

Parameters:
key - the Date key to format
Returns:
string representation of the key

getFormats

protected java.text.Format[] getFormats()
Description copied from class: AnalogAxisMapper
Gets axis mapper formats.

Specified by:
getFormats in class AnalogAxisMapper<DateAxisRange>
Returns:
axis mapper formats