lt.monarch.chart.mapper
Class LogAxisMapper

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

public class LogAxisMapper
extends AnalogAxisMapper<LogMathRange>

Axis mapper for logarithmic scaling. This mapper allows axis to be subdivided logarithmically. This feature is useful when displaying values that differ significantly. The user can use logarithmic scaling to make the grid lines of the axis equidistant but have values that may increase or decrease exponentially. Here is an example of LogAxisMapper usage on x axis:

Here is another example of LogAxisMapper usage on y axis:

See Also:
Serialized Form

Field Summary
Modifier and Type Field and Description
protected  AxisMapperRange mapperRange
          the axis mapper range
protected  LogMathRange range
          the visible range
protected  LogMathRange totalRange
          Mapping range.
 
Constructor Summary
Modifier Constructor and Description
  LogAxisMapper()
          Creates a new LogAxisMapper.
  LogAxisMapper(double min, double max)
          Creates a new logarithmic axis mapper with the specified mapping rage.
  LogAxisMapper(double min, double max, AxisMapperRange mapperRange)
          Creates a new logarithmic axis mapper with the specified initial visible range.
protected LogAxisMapper(LogMathRange totalRange, AxisMapperRange mapperRange)
          Constructs a new LogAxisMapper with the specified mapping range and the specified visible range.
 
Method Summary
Modifier and Type Method and Description
protected  LogMathRange createRange(double min, double max)
           
protected  AxisScale createScale()
          Creates LogAxisScale.
 java.lang.String formatKey(java.lang.Object key)
          Provides text representation of the coordinate value.
 java.text.NumberFormat getCustomNumberFormat()
          Gets custom the number format if used
 int getElementCount()
          Returns element count.
protected  java.text.Format[] getFormats()
          Gets axis mapper formats.
 AxisNumberFormat getNumberFormat()
          Gets predefined number format
 LogMathRange getRange()
          Returns the mapping range of this LogAxisMapper object.
 AxisScale getScale()
          Returns the logrithmic scale for axis.
 AxisMapperRange getViewRange()
          Gets an AxisMapperRange object representing visible axis range.
 LogMathRange getVisibleRange()
          Gets visible range of the mapper.
 double map(double key)
          Finds the position for the coordinate value.
 double map(java.lang.Object key)
          Finds the position for the Number value.
 java.lang.Object mapBack(double pos)
          Converts the position on the coordinate axis to the Double value.
 void setBase(double base)
          Sets base value for mapper.
 void setCustomNumberFormat(java.text.NumberFormat nf)
          Assigns number format used to format labels in logarithmic scale.
 void setDrawSubScale(boolean drawSubScale)
          Sets if the subscale on the axis should be drawn.
 void setNumberFormat(AxisNumberFormat nf)
          Assigns predefined number format used to format labels in logarithmic scale.
 void setRange(double min, double max)
          Sets the mapping range for this mapper object.
 void setVisibleRange(double min, double max)
          Sets the visible range for this mapper.
 void updateRange(double value)
          Updates the mapping range so that specified value will be in the mapping range.
 
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
 

Field Detail

totalRange

protected final LogMathRange totalRange
Mapping range.


mapperRange

protected final AxisMapperRange mapperRange
the axis mapper range


range

protected final LogMathRange range
the visible range

Constructor Detail

LogAxisMapper

public LogAxisMapper()
Creates a new LogAxisMapper.


LogAxisMapper

public LogAxisMapper(double min,
                     double max)
Creates a new logarithmic axis mapper with the specified mapping rage.

Parameters:
min - The beginning of the mapping range
max - The end of the mapping range
Throws:
java.lang.IllegalArgumentException - if min >= max or min <= 0.

LogAxisMapper

public LogAxisMapper(double min,
                     double max,
                     AxisMapperRange mapperRange)
Creates a new logarithmic axis mapper with the specified initial visible range.

Parameters:
min - The beginning of the mapping range
max - The end of the mapping range
mapperRange - the axis mapper range object representing visible range part
Throws:
java.lang.IllegalArgumentException - if min >= max or min <= 0.

LogAxisMapper

protected LogAxisMapper(LogMathRange totalRange,
                        AxisMapperRange mapperRange)
Constructs a new LogAxisMapper with the specified mapping range and the specified visible range.

Parameters:
totalRange - the mapping range
mapperRange - the axis mapper range object representing visible range part
Method Detail

createRange

protected LogMathRange createRange(double min,
                                   double max)

setCustomNumberFormat

public void setCustomNumberFormat(java.text.NumberFormat nf)
Assigns number format used to format labels in logarithmic scale.

Parameters:
nf - the number format

setNumberFormat

public void setNumberFormat(AxisNumberFormat nf)
Assigns predefined number format used to format labels in logarithmic scale.

Parameters:
nf - A constant indicating the format in witch axis labels will be represented. Can be either AxisNumberFormat.EXPONENTIAL (to display numbers in exponential format) or AxisNumberFormat.DECIMAL (to display numbers in decimal format).

setRange

public void setRange(double min,
                     double max)
Sets the mapping range for this mapper object.

Parameters:
min - The beginning of the mapping range
max - The end of the mapping range
Throws:
java.lang.IllegalArgumentException - if min >= max or min <= 0.

getRange

public LogMathRange getRange()
Returns the mapping range of this LogAxisMapper object.

Specified by:
getRange in class AnalogAxisMapper<LogMathRange>
Returns:
The mapping range

getScale

public AxisScale getScale()
Returns the logrithmic scale for axis.

Returns:
The logrithmic scale

setDrawSubScale

public void setDrawSubScale(boolean drawSubScale)
Sets if the subscale on the axis should be drawn.

Parameters:
drawSubScale - True if to draw subscale

map

public double map(double key)
Finds the position for the coordinate value.

Parameters:
key - The value in some coordinate space
Returns:
A value in range [0,1]
Throws:
java.lang.IllegalArgumentException - if Double.isNaN(key) or Double.isInfinite(key)

mapBack

public java.lang.Object mapBack(double pos)
Converts the position on the coordinate axis to the Double value.

Specified by:
mapBack in interface AxisMapper
Overrides:
mapBack in class AbstractAxisMapper
Parameters:
pos - The position in range [0,1]
Returns:
a Double value corresponding the specified position o the axis
Throws:
java.lang.IllegalArgumentException - if Double.isNaN(key) or Double.isInfinite(key).
See Also:
AxisMapper.mapBack(double)

map

public double map(java.lang.Object key)
Finds the position for the Number value.

Parameters:
key - The Number value to map
Returns:
A value in range [0,1]

updateRange

public void updateRange(double value)
Updates the mapping range so that specified value will be in the mapping range. value must be greater than 0.

Parameters:
value - the positive double value
Throws:
java.lang.IllegalArgumentException - if value <= 0

formatKey

public java.lang.String formatKey(java.lang.Object key)
Provides text representation of the coordinate value.

Parameters:
key - The value to be formated
Returns:
Text representation of value

createScale

protected AxisScale createScale()
Creates LogAxisScale.

Returns:
The logarithmic axis scale

getElementCount

public int getElementCount()
Returns element count.

Returns:
0 because this mapper does not have fixed label count.

setBase

public void setBase(double base)
Sets base value for mapper.

Parameters:
base - - logarithm base
Throws:
java.lang.IllegalArgumentException - if base <= 0 or base == 1
java.lang.IllegalArgumentException - if Double.isNaN(base) or Double.isInfinite(base)

getViewRange

public AxisMapperRange getViewRange()
Description copied from interface: AxisMapper
Gets an AxisMapperRange object representing visible axis range. The object can be used to set visible axis range. Returns normalized value from [0..1]

Returns:
AxisMapperRange object representing visible axis range

setVisibleRange

public void setVisibleRange(double min,
                            double max)
Sets the visible range for this mapper. The visible range bounds should be inside mapping range.

Parameters:
min - start of the visible range
max - end of the visible range

getVisibleRange

public LogMathRange getVisibleRange()
Gets visible range of the mapper.

Specified by:
getVisibleRange in class AnalogAxisMapper<LogMathRange>
Returns:
MathRange object representing current visible range

getNumberFormat

public AxisNumberFormat getNumberFormat()
Gets predefined number format

Returns:
Returns the number format

getCustomNumberFormat

public java.text.NumberFormat getCustomNumberFormat()
Gets custom the number format if used

Returns:
Returns the number format

getFormats

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

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