com.davisor.graphics.chart
Class AxisMarker

java.lang.Object
  extended bycom.davisor.graphics.chart.AxisMarker
All Implemented Interfaces:
com.davisor.core.Dupable

public class AxisMarker
extends java.lang.Object
implements com.davisor.core.Dupable

AxisMarker represents one marker line or area positioned in an ChartAxis. Markers are used to emphasize a special value on a coordinate axis. A marker consists of a line, a shape in the other end of the line, and a label.

An axis marker is positioned on axis by its position attribute. Every marker needs a position. It is given as String and it is parsed using the Type of the axis minimum value. Markers with positions not inside the axis min and max values are not drawn but they may affect to area filling as well as the following four position keywords defined in AxisAttributes:

'after' and 'max' can be used to fill areas above some visible marker. 'before' and 'min' are currently ignored.

A descriptive label and a special shape can be associated to each marker line. The label is set by labelText attribute. If no label is given, the position string is used as label. Use an empty String to get no label at all.

Value ranges can be emphasized by painting the areas between markers. That is done by defining two markers so that the one with bigger position (according to the natural order of the values in the axis) has got a linePaint. In other words, defining a linePaint for a marker means that the area between that and the previous marker is filled with that paint. If there is no previous marker, then the whole chart background drawing area below the marker defining the paint is filled. The smallest value of the special 'max' and 'after' values and the values bigger than the axis maximum defines the upmost filled area paint.

The following rendering attributes can be used to modify the marker's appearance.

For further information see the XML Attribute Reference and the defaulting rules.

Since:
JDK1.2
See Also:
ChartAxis

Field Summary
protected  java.lang.Number M_labelRotation
          Label rotation
protected  java.lang.String M_labelText
          Marker label.
protected  java.lang.String M_position
          Marker position.
protected  MarkerRenderAttributes M_render
          Marker render attributes.
 
Constructor Summary
AxisMarker(AxisMarker am)
          Deep copy constructor.
AxisMarker(java.lang.String position)
          Creates a new axis marker.
AxisMarker(java.lang.String position, java.lang.String labelText, java.lang.Number labelRotation, MarkerRenderAttributes render)
          Creates a new axis marker with all the information.
 
Method Summary
 com.davisor.core.Dupable dup()
          Duplicates this object.
 boolean equals(java.lang.Object object)
          Test if this axis equals to given axis.
 DataValue getDataValue(Type type)
          Returns the position as DataValue.
 java.lang.Number getLabelRotation()
          Returns the label rotation (radians).
 java.lang.String getLabelText()
          Returns the set label text.
 java.lang.String getPosition()
          Returns the position set in construction.
 MarkerRenderAttributes getRender()
          Returns reference to the render attributes instance.
 int hashCode()
           
 boolean isAbove()
          Returns true if the given position is a special value which is above all the data values (that is max or after).
 boolean isBelow()
          Returns true if the given position is a special value which is below all the data values (that is min or before).
 boolean isInfinite()
          Returns whether the given position is any of the special positions defined in AxisAttributes (that is min,max,after,before) or not.
 void setLabelRotation(java.lang.Number labelRotation)
          Sets the label rotation (radians).
 void setLabelText(java.lang.String labelText)
          Sets the label text.
 java.lang.String toString()
          Gets axis marker XML representation.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

M_position

protected java.lang.String M_position
Marker position.


M_labelText

protected java.lang.String M_labelText
Marker label.


M_render

protected MarkerRenderAttributes M_render
Marker render attributes.


M_labelRotation

protected java.lang.Number M_labelRotation
Label rotation

Constructor Detail

AxisMarker

public AxisMarker(java.lang.String position)
Creates a new axis marker.

Sets the position as String. The value will be interpreted to DataValue using the type of the MIN value of the axis this marker is associated to. There is a special value 'Infinity' which will represent a value above the drawing area. It is useful when you want e.g. to fill the area above the topmost marker.


AxisMarker

public AxisMarker(AxisMarker am)
Deep copy constructor.


AxisMarker

public AxisMarker(java.lang.String position,
                  java.lang.String labelText,
                  java.lang.Number labelRotation,
                  MarkerRenderAttributes render)
Creates a new axis marker with all the information.

Parameters:
position - marker position
labelText - marker name (may be null)
labelRotation - rotation in radians counter-clockwise (may be null)
render - render attributes (may be null)
See Also:
AxisMarker(String)
Method Detail

getDataValue

public DataValue getDataValue(Type type)
                       throws InvalidDataException
Returns the position as DataValue. If the DataValue is already parsed, the old value will be returned, otherwise the data value is parsed by the given type (and stored for further use).

Throws:
InvalidDataException - if chart data iteration fails
See Also:
Type.toData(String,ParsePosition)

getLabelText

public java.lang.String getLabelText()
Returns the set label text.


getLabelRotation

public java.lang.Number getLabelRotation()
Returns the label rotation (radians).

Returns:
label rotation in radians counter-clockwise (may be null)

getPosition

public java.lang.String getPosition()
Returns the position set in construction.


getRender

public MarkerRenderAttributes getRender()
Returns reference to the render attributes instance.


isInfinite

public boolean isInfinite()
Returns whether the given position is any of the special positions defined in AxisAttributes (that is min,max,after,before) or not.

Returns:
true if the position is a special
See Also:
isBelow(), isAbove()

isAbove

public boolean isAbove()
Returns true if the given position is a special value which is above all the data values (that is max or after).

See Also:
isBelow(), isInfinite()

isBelow

public boolean isBelow()
Returns true if the given position is a special value which is below all the data values (that is min or before).

See Also:
isAbove(), isInfinite()

setLabelText

public void setLabelText(java.lang.String labelText)
Sets the label text. If the label text is NULL, then the position value is shown as label.


setLabelRotation

public void setLabelRotation(java.lang.Number labelRotation)
Sets the label rotation (radians).


dup

public com.davisor.core.Dupable dup()
Duplicates this object.

Specified by:
dup in interface com.davisor.core.Dupable

equals

public boolean equals(java.lang.Object object)
Test if this axis equals to given axis.


hashCode

public int hashCode()

toString

public java.lang.String toString()
Gets axis marker XML representation.

See Also:
Strings.toXML(String,Object)


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