lt.monarch.chart.chart2D.axis
Class Axis2D

java.lang.Object
  extended by lt.monarch.chart.engine.AbstractChartObject<AxisPaintTags>
      extended by lt.monarch.chart.mapper.Axis
          extended by lt.monarch.chart.chart2D.axis.Axis2D
All Implemented Interfaces:
java.io.Serializable, ChartObject, StyleEditorEntity
Direct Known Subclasses:
Axis2DRadar, Axis2DX, Axis2DY

public abstract class Axis2D
extends Axis

Base class for all 2D chart axis classes

See Also:
Serialized Form

Nested Class Summary
Modifier and Type Class and Description
 class Axis2D.AxisLabelEntity
          The axis label entry chart entity.
 
Field Summary
Modifier and Type Field and Description
protected  Polygon2D arrowPolygon
          Arrow area
protected  Polygon2D arrowPolygon2
          Arrow2 area
protected  ArrowSettings arrowSettings
          Axis arrow settings
protected  Alignment axisAlign
          Specifies whether the axis is aligned.
protected  Orientation axisOrientation
          Axis orientation
protected  DataModel dataModel
           
protected  double dragFrom
          Drag from point
protected  double dragTo
          Drag to point
protected  AxisScale finestVisibleScale
          finest visible scale
protected  boolean isMoreZoomAvailable
          Is there more zoom available
protected  boolean isScrollable
          Is axis scrollable, user defined
protected  boolean isVisible
          Is axis visible, user defined
protected  boolean isZooming
          Is now axis zooming
protected  boolean isZoomingEnabled
          Is zooming enabled by user
protected  LabelSettings labelSettings
          Axis arrow settings
protected  Axis mappedAxis
          Axis to which this axis is mapped according to mapping value
protected  java.lang.Object mappedValue
          Mapped value of axis position
protected  double mappedValueCoord
          Mapped coordinate for the axis value,
protected  MetaDataModel metaModel
          Meta data model
protected  java.awt.Point mouseClick
          Point where mouse clicked
protected  java.awt.event.MouseListener mouseListener
          Mouse event listener
protected  java.awt.event.MouseMotionListener mouseMotionListener
          Mouse movement listener
protected  PolarPoint pt2D1
          Temporary point
protected  PolarPoint pt2D2
          Temporary point
protected  AxisMapperRange range
          Axis mapper range
protected  lt.monarch.chart.chart2D.axis.Axis2D.RangeListener rangeListener
          Axis range listener
protected  TickSettings tickSettings
          Axis tick settings
 
Fields inherited from class lt.monarch.chart.mapper.Axis
isInvertedMapper, mapper, textStyle
 
Fields inherited from class lt.monarch.chart.engine.AbstractChartObject
AXIS_SORT_POSITION, BREAK_LINE_POSITION, DEFAULT_SORT_POSITION, GRID_SORT_POSITION, MARKER_SERIES_SORT_POSITION, MARKERS_SORT_POSITION, paintStyle, SERIES_SORT_POSITION, sortPosition, style
 
Constructor Summary
Modifier Constructor and Description
  Axis2D(AxisMapper mapper, Orientation axisOrientation)
          Sole constructor.
protected Axis2D(AxisMapper mapper, Orientation axisOrientation, MetaDataModel metaModel, DataModel dataModel)
          Sole constructor.
 
Method Summary
Modifier and Type Method and Description
protected  void activate()
          Activates the axis.
protected  AxisLabel createAxisLabel(java.lang.String labelText, Rectangle2D bounds, java.awt.Font font, double tickPos, double relativeLabelPosition, double tickHeight, double labelOffset, double labelRotation, java.awt.FontMetrics fm, int level, int index, boolean isKeyLabel, Orientation orientation)
          Creates an axis label.
protected  void deactivate()
          Deactivates the axis.
protected  double digitizePosition(double pos)
          Digitizes the position of the selection
 void draw(AbstractGraphics g)
          Paints axis.
protected  void drawArrow(AbstractGraphics g)
          Draws an arrow on axis
protected abstract  void drawAxis(AbstractGraphics g)
          Draws axis line
protected abstract  void drawLabels(AbstractGraphics g, LinearLabelLayouter layouter)
          Draws the labels of the axis in the specified Graphics context.
protected  void drawSecondArrow(AbstractGraphics g)
          Draws a revesed arrow
protected abstract  void drawTicksLabels(AbstractGraphics g, LinearLabelLayouter layouter)
           
protected abstract  void drawTitle(AbstractGraphics g, LinearLabelLayouter layouter, AxisTitle title)
          Draws the title of the axis and updates label layouter that is used to layout the axis labels.
protected  void drawZoomRectangle(AbstractGraphics g, double coord1, double coord2)
          Paints a zoom rectangle with the specified start and end in the specified Graphics context.
protected abstract  Rectangle2D getActiveArea()
          Returns the Rectangle representing active area.
 Polygon2D getArrowPolygon()
          Gets the arrowPolygon value
 ArrowSettings getArrowSettings()
          Gets the arrowSettings object
 Alignment getAxisAlign()
          Gets the axisAlign value.
 Alignment getAxisAlignment()
          Gets the axis alignment value.
 Rectangle2D getBounds()
          Gets the bounds of this axis in the form of a Rectangle object.
 Rectangle2D getChartObjectBounds()
          Gets bounds of chart object
 AxisScale getFinestScale()
          Returns the finest visible scale.
 LabelSettings getLabelSettings()
          Gets the labelSettings object
 Axis getMappedAxis()
          Gets mapped axis
 java.lang.Object getMappedValue()
          Gets mapped value
 double getMappedValueCoord()
          Gets mapped value coordinate for the axis
 MetaDataModel getMetaDataModel()
          Gets the meta data model object
 java.awt.Insets getPreferredInsets()
          Queries preferred insets for the axis.
 Projector2D getProjector()
          Returns modified projector.
 AbstractStyle<?> getStyle(StyleType styleType)
          Gets style object for the stylesheet attributes specified by style type.
protected  int getTickLength()
          Gets overall tick length with offset
 TickSettings getTickSettings()
          Gets the tickSettings object
abstract  AbstractAxisLabel[] getVisibleLabels()
          Returns objects of visible labels.
protected abstract  Axis2D[] getZoomableAxes()
          Gets all zoomable axes for the specified orientation
 boolean isScrollable()
          Returns true if axis is scrollable
 boolean isVisible()
          Get axis visibility
 boolean isZoomingEnabled()
          Identifies whether or not this axis allows zooming through GUI using mouse gestures and particular key modifiers.
abstract  void prepare(AbstractGraphics g)
          Calculates axis boundaries and range.
 void setAxisAlign(Alignment axisAlign)
          Sets the axisAlign value.
 void setAxisPosition(Axis axis, java.lang.Object value)
          Sets axis position mapping it to some other axis value.
 void setBounds(Rectangle2D bounds)
          Moves and resizes this axis to conform to the new bounding rectangle r.
 void setMappedValueCoord(double mappedValueCoord)
          Sets mapped value coordinate for the axis
 void setScrollable(boolean scrollable)
          Set axis scrollable
 void setVisible(boolean visible)
          Set axis visibility
 void setZoomingEnabled(boolean enabled)
          Sets whether the axis should accept zooming gestures.
 
Methods inherited from class lt.monarch.chart.mapper.Axis
getFont, getMapper, getSortPosition, getTextStyle, getTitle, getTitles, getTitleSettings, setTitle, setTitle
 
Methods inherited from class lt.monarch.chart.engine.AbstractChartObject
chart, copy, dispose, finalize, getChart, getPaintStyle, getParent, getStyle, invalidate, layout, repaint, repaint, setChart
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

axisOrientation

protected final Orientation axisOrientation
Axis orientation


metaModel

protected MetaDataModel metaModel
Meta data model


dataModel

protected DataModel dataModel

mappedValueCoord

protected double mappedValueCoord
Mapped coordinate for the axis value,


mappedValue

protected transient java.lang.Object mappedValue
Mapped value of axis position


pt2D1

protected PolarPoint pt2D1
Temporary point


pt2D2

protected PolarPoint pt2D2
Temporary point


mappedAxis

protected Axis mappedAxis
Axis to which this axis is mapped according to mapping value


finestVisibleScale

protected AxisScale finestVisibleScale
finest visible scale


axisAlign

protected Alignment axisAlign
Specifies whether the axis is aligned.


isZoomingEnabled

protected boolean isZoomingEnabled
Is zooming enabled by user


isMoreZoomAvailable

protected boolean isMoreZoomAvailable
Is there more zoom available


mouseClick

protected java.awt.Point mouseClick
Point where mouse clicked


isZooming

protected boolean isZooming
Is now axis zooming


dragFrom

protected double dragFrom
Drag from point


dragTo

protected double dragTo
Drag to point


isScrollable

protected boolean isScrollable
Is axis scrollable, user defined


isVisible

protected boolean isVisible
Is axis visible, user defined


rangeListener

protected final lt.monarch.chart.chart2D.axis.Axis2D.RangeListener rangeListener
Axis range listener


range

protected AxisMapperRange range
Axis mapper range


mouseListener

protected java.awt.event.MouseListener mouseListener
Mouse event listener


mouseMotionListener

protected java.awt.event.MouseMotionListener mouseMotionListener
Mouse movement listener


tickSettings

protected final TickSettings tickSettings
Axis tick settings


arrowSettings

protected final ArrowSettings arrowSettings
Axis arrow settings


labelSettings

protected final LabelSettings labelSettings
Axis arrow settings


arrowPolygon

protected Polygon2D arrowPolygon
Arrow area


arrowPolygon2

protected Polygon2D arrowPolygon2
Arrow2 area

Constructor Detail

Axis2D

public Axis2D(AxisMapper mapper,
              Orientation axisOrientation)
Sole constructor. (For invocation by subclass constructors).

Parameters:
mapper - the axis mapper
axisOrientation - axis orientation

Axis2D

protected Axis2D(AxisMapper mapper,
                 Orientation axisOrientation,
                 MetaDataModel metaModel,
                 DataModel dataModel)
Sole constructor. (For invocation by subclass constructors).

Parameters:
mapper - the axis mapper
axisOrientation - axis orientation
metaModel - meta data model
dataModel - data model
Method Detail

getFinestScale

public AxisScale getFinestScale()
Returns the finest visible scale.

Returns:
reference to the finest visible scale

setBounds

public void setBounds(Rectangle2D bounds)
Moves and resizes this axis to conform to the new bounding rectangle r.

Parameters:
bounds - The new bounding rectangle for this axis

getBounds

public Rectangle2D getBounds()
Gets the bounds of this axis in the form of a Rectangle object.

Returns:
A rectangle indicating this axis's bounds

getPreferredInsets

public java.awt.Insets getPreferredInsets()
Queries preferred insets for the axis. Chart2D shrinks the chart area based on the inset information, collected from all axis objects, to make sure axis have enough space around the chart to draw all their labels correctly.

Returns:
Insets space, required between axis bounds and chart bounds.

getVisibleLabels

public abstract AbstractAxisLabel[] getVisibleLabels()
Returns objects of visible labels.

Returns:
array of visible labels

drawArrow

protected void drawArrow(AbstractGraphics g)
Draws an arrow on axis

Parameters:
g - graphics context

drawSecondArrow

protected void drawSecondArrow(AbstractGraphics g)
Draws a revesed arrow

Parameters:
g - graphics context

getProjector

public Projector2D getProjector()
Returns modified projector.

Returns:
projector the modified projector

setMappedValueCoord

public void setMappedValueCoord(double mappedValueCoord)
Sets mapped value coordinate for the axis

Parameters:
mappedValueCoord - mapped value coordinate

getMappedValueCoord

public double getMappedValueCoord()
Gets mapped value coordinate for the axis

Returns:
mapped value coordinate

prepare

public abstract void prepare(AbstractGraphics g)
Calculates axis boundaries and range.

Parameters:
g - current Graphics context.

draw

public void draw(AbstractGraphics g)
Paints axis.

Parameters:
g - current graphics context.

getAxisAlignment

public Alignment getAxisAlignment()
Gets the axis alignment value. For y axis it is left or right, for x top or bottom.

Returns:
Returns axis alignment value

drawZoomRectangle

protected void drawZoomRectangle(AbstractGraphics g,
                                 double coord1,
                                 double coord2)
Paints a zoom rectangle with the specified start and end in the specified Graphics context.

Parameters:
g - the Graphics context in which to paint zoom rectangle
coord1 - the beginning of the zoom rectangle; should be in range [0,1]
coord2 - the end of the zoom rectangle; should be in range [0,1]

digitizePosition

protected double digitizePosition(double pos)
Digitizes the position of the selection

Parameters:
pos - position
Returns:
digitizes position

isScrollable

public boolean isScrollable()
Returns true if axis is scrollable

Returns:
true if axis is scrollable

setScrollable

public void setScrollable(boolean scrollable)
Set axis scrollable

Parameters:
scrollable - true if axis is scrollable

setVisible

public void setVisible(boolean visible)
Set axis visibility

Overrides:
setVisible in class AbstractChartObject<AxisPaintTags>
Parameters:
visible - sets axis visible

isVisible

public boolean isVisible()
Get axis visibility

Specified by:
isVisible in interface ChartObject
Overrides:
isVisible in class AbstractChartObject<AxisPaintTags>
Returns:
true, if axis is visible

setZoomingEnabled

public void setZoomingEnabled(boolean enabled)
Sets whether the axis should accept zooming gestures. When enabled, user can use mouse gestures with particular key modifiers to zoom in/out the visible range of values. By default zooming through GUI is enabled.

Parameters:
enabled - value to enable/disable zooming

isZoomingEnabled

public boolean isZoomingEnabled()
Identifies whether or not this axis allows zooming through GUI using mouse gestures and particular key modifiers.

Returns:
true, if zooming operations can be performed by user

getActiveArea

protected abstract Rectangle2D getActiveArea()
Returns the Rectangle representing active area. The active area is area where user can scroll and zoom axis by clicking and dragging mouse.

Returns:
the Rectangle representing active area

activate

protected void activate()
Activates the axis. If scrollable, then registers mouse and mouse motion listeners.

Overrides:
activate in class Axis

deactivate

protected void deactivate()
Deactivates the axis. If scrollable, then unregisters mouse and mouse motion listeners.

Overrides:
deactivate in class Axis

drawTitle

protected abstract void drawTitle(AbstractGraphics g,
                                  LinearLabelLayouter layouter,
                                  AxisTitle title)
Draws the title of the axis and updates label layouter that is used to layout the axis labels. The layouter is updated by setting its visible range.

Parameters:
g - the Graphics context in which the axis title to paint
layouter - the label layouter used to layout axis labels
title - the axis title to draw

drawLabels

protected abstract void drawLabels(AbstractGraphics g,
                                   LinearLabelLayouter layouter)
Draws the labels of the axis in the specified Graphics context.

Parameters:
g - the Graphics context in which the axis labels to paint
layouter - the Layouter used to layout axis labels

getZoomableAxes

protected abstract Axis2D[] getZoomableAxes()
Gets all zoomable axes for the specified orientation

Returns:
array of zoomable axes

getMappedValue

public java.lang.Object getMappedValue()
Gets mapped value

Returns:
the mappedValue

getMappedAxis

public Axis getMappedAxis()
Gets mapped axis

Returns:
the mappedAxis

setAxisPosition

public void setAxisPosition(Axis axis,
                            java.lang.Object value)
Sets axis position mapping it to some other axis value.

Parameters:
axis - the axis to which value this axis is mapped
value - the value on the axis to which this axis should be mapped

getTickSettings

public TickSettings getTickSettings()
Gets the tickSettings object

Returns:
the tickSettings object

getArrowSettings

public ArrowSettings getArrowSettings()
Gets the arrowSettings object

Returns:
the arrowSettings object

getLabelSettings

public LabelSettings getLabelSettings()
Gets the labelSettings object

Returns:
the labelSettings object

getMetaDataModel

public MetaDataModel getMetaDataModel()
Gets the meta data model object

Returns:
the meta data model object

getArrowPolygon

public Polygon2D getArrowPolygon()
Gets the arrowPolygon value

Returns:
the arrowPolygon value

drawAxis

protected abstract void drawAxis(AbstractGraphics g)
Draws axis line

Parameters:
g - graphics context

getTickLength

protected int getTickLength()
Gets overall tick length with offset

Returns:
tick length

createAxisLabel

protected AxisLabel createAxisLabel(java.lang.String labelText,
                                    Rectangle2D bounds,
                                    java.awt.Font font,
                                    double tickPos,
                                    double relativeLabelPosition,
                                    double tickHeight,
                                    double labelOffset,
                                    double labelRotation,
                                    java.awt.FontMetrics fm,
                                    int level,
                                    int index,
                                    boolean isKeyLabel,
                                    Orientation orientation)
Creates an axis label.

Parameters:
labelText - label text
bounds - axisBounds
font - label font
tickPos - tick position
relativeLabelPosition - relative label position
tickHeight - tick height
labelOffset - label offset
labelRotation - label rotation
fm - font metrics
level - label level
index - index of the label in the axis
isKeyLabel - is key label
orientation - axis orientation
Returns:
created axis label

drawTicksLabels

protected abstract void drawTicksLabels(AbstractGraphics g,
                                        LinearLabelLayouter layouter)

getAxisAlign

public Alignment getAxisAlign()
Gets the axisAlign value. Internal API. DO NOT USE.

Returns:
the axisAlign value

setAxisAlign

public void setAxisAlign(Alignment axisAlign)
Sets the axisAlign value. Internal API. DO NOT USE.

Parameters:
axisAlign - the axisAlign value

getStyle

public AbstractStyle<?> getStyle(StyleType styleType)
Description copied from interface: ChartObject
Gets style object for the stylesheet attributes specified by style type.

Specified by:
getStyle in interface ChartObject
Specified by:
getStyle in interface StyleEditorEntity
Overrides:
getStyle in class Axis
Parameters:
styleType - style type attributes
Returns:
the style object

getChartObjectBounds

public Rectangle2D getChartObjectBounds()
Description copied from interface: StyleEditorEntity
Gets bounds of chart object

Specified by:
getChartObjectBounds in interface StyleEditorEntity
Overrides:
getChartObjectBounds in class AbstractChartObject<AxisPaintTags>
Returns:
A rectangle indicating this chart object bounds