org.swtchart.internal.axis
Class Axis

java.lang.Object
  extended by org.swtchart.internal.axis.Axis
All Implemented Interfaces:
IAxis

public class Axis
extends java.lang.Object
implements IAxis

An axis.


Nested Class Summary
 
Nested classes/interfaces inherited from interface org.swtchart.IAxis
IAxis.Direction, IAxis.Position
 
Field Summary
static double DEFAULT_LOG_SCALE_MAX
          the default maximum value of log scale range
static double DEFAULT_LOG_SCALE_MIN
          the default minimum value of log scale range
static double DEFAULT_MAX
          the default maximum value of range
static double DEFAULT_MIN
          the default minimum value of range
static int MARGIN
          the margin in pixels
 
Constructor Summary
Axis(int id, IAxis.Direction direction, Chart chart)
          Constructor.
 
Method Summary
 void addDisposeListener(IDisposeListener listener)
          Adds the dispose listener.
 void adjustRange()
          Adjusts the axis range to the series belonging to the axis, so that all series are completely shown.
 void adjustRange(boolean update)
          Adjusts the axis range to the series belonging to the axis.
protected  void dispose()
          Disposes the resources.
 void enableCategory(boolean enabled)
          Enables category.
 void enableLogScale(boolean enabled)
          Enables the log scale.
 java.lang.String[] getCategorySeries()
          Gets the category series.
 double getDataCoordinate(int pixelCoordinate)
          Gets the data coordinate corresponding to the given pixel coordinate on plot area.
 double getDataCoordinate(int pixelCoordinate, double lower, double upper)
          Gets the data coordinate corresponding to the given pixel coordinate on plot area.
 IAxis.Direction getDirection()
          Gets the axis direction.
 IGrid getGrid()
          Gets the grid.
 int getId()
          Gets the axis id.
 int getNumRisers()
          Gets the number of risers per category.
 int getPixelCoordinate(double dataCoordinate)
          Gets the pixel coordinate corresponding to the given data coordinate.
 int getPixelCoordinate(double dataCoordinate, double lower, double upper)
          Gets the pixel coordinate corresponding to the given data coordinate.
 IAxis.Position getPosition()
          Gets the axis position.
 Range getRange()
          Gets the axis range.
 AxisTick getTick()
          Gets the axis tick.
 ITitle getTitle()
          Gets the axis title.
 boolean isCategoryEnabled()
          Gets the state indicating if category is enabled.
 boolean isDateEnabled()
          Gets the state indicating if date is enabled.
 boolean isHorizontalAxis()
          Checks if the axis is horizontal.
 boolean isLogScaleEnabled()
          Gets the state indicating if log scale is enabled.
 boolean isValidCategoryAxis()
          Gets the state indicating if the axis is valid category axis.
 void refresh()
          Refreshes the cache.
 void scrollDown()
          Scrolls up the axis.
 void scrollUp()
          Scrolls up the axis.
 void setCategorySeries(java.lang.String[] series)
          Sets the category series.
 void setNumRisers(int numRisers)
          Sets the number of risers per category.
 void setPosition(IAxis.Position position)
          Sets the axis position.
 void setRange(Range range)
          Sets the axis range.
 void setRange(Range range, boolean update)
          Sets the axis range.
 void updateLayoutData()
          Updates the layout data.
 void zoomIn()
          Zooms in the axis.
 void zoomIn(double coordinate)
          Zooms in the axis at the given coordinate.
 void zoomOut()
          Zooms out the axis.
 void zoomOut(double coordinate)
          Zooms out the axis at the given coordinate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MARGIN

public static final int MARGIN
the margin in pixels

See Also:
Constant Field Values

DEFAULT_MIN

public static final double DEFAULT_MIN
the default minimum value of range

See Also:
Constant Field Values

DEFAULT_MAX

public static final double DEFAULT_MAX
the default maximum value of range

See Also:
Constant Field Values

DEFAULT_LOG_SCALE_MIN

public static final double DEFAULT_LOG_SCALE_MIN
the default minimum value of log scale range

See Also:
Constant Field Values

DEFAULT_LOG_SCALE_MAX

public static final double DEFAULT_LOG_SCALE_MAX
the default maximum value of log scale range

See Also:
Constant Field Values
Constructor Detail

Axis

public Axis(int id,
            IAxis.Direction direction,
            Chart chart)
Constructor.

Parameters:
id - the axis index
direction - the axis direction (X or Y)
chart - the chart
Method Detail

getId

public int getId()
Description copied from interface: IAxis
Gets the axis id.

An axis id is automatically assigned when axis is created.

Specified by:
getId in interface IAxis
Returns:
the axis id

getDirection

public IAxis.Direction getDirection()
Description copied from interface: IAxis
Gets the axis direction.

The axis direction is set when axis is created, and won't be changed.

Specified by:
getDirection in interface IAxis
Returns:
the axis direction

getPosition

public IAxis.Position getPosition()
Description copied from interface: IAxis
Gets the axis position.

Specified by:
getPosition in interface IAxis
Returns:
the axis position

setPosition

public void setPosition(IAxis.Position position)
Description copied from interface: IAxis
Sets the axis position.

Specified by:
setPosition in interface IAxis
Parameters:
position - the axis position

setRange

public void setRange(Range range)
Description copied from interface: IAxis
Sets the axis range.

Specified by:
setRange in interface IAxis
Parameters:
range - the axis range

setRange

public void setRange(Range range,
                     boolean update)
Sets the axis range.

Parameters:
range - the axis range
update - true if updating the chart layout

getRange

public Range getRange()
Description copied from interface: IAxis
Gets the axis range.

Specified by:
getRange in interface IAxis
Returns:
the axis range

getTitle

public ITitle getTitle()
Description copied from interface: IAxis
Gets the axis title.

Specified by:
getTitle in interface IAxis
Returns:
the axis title

getTick

public AxisTick getTick()
Description copied from interface: IAxis
Gets the axis tick.

Specified by:
getTick in interface IAxis
Returns:
the axis tick

enableLogScale

public void enableLogScale(boolean enabled)
                    throws java.lang.IllegalStateException
Description copied from interface: IAxis
Enables the log scale. If enabling log scale, stacking trace and category axis will be disabled.

Specified by:
enableLogScale in interface IAxis
Parameters:
enabled - true if enabling log scales
Throws:
java.lang.IllegalStateException - if minimum value of series belonging to this axis is less than zero.

isLogScaleEnabled

public boolean isLogScaleEnabled()
Description copied from interface: IAxis
Gets the state indicating if log scale is enabled.

Specified by:
isLogScaleEnabled in interface IAxis
Returns:
true if log scale is enabled

getGrid

public IGrid getGrid()
Description copied from interface: IAxis
Gets the grid. The gird interval is identical with the position of axis tick marks. The horizontal grid is accessible from vertical axis, and the vertical grid is accessible from horizontal axis.

Specified by:
getGrid in interface IAxis
Returns:
grid the grid

adjustRange

public void adjustRange()
Description copied from interface: IAxis
Adjusts the axis range to the series belonging to the axis, so that all series are completely shown.

Specified by:
adjustRange in interface IAxis

adjustRange

public void adjustRange(boolean update)
Adjusts the axis range to the series belonging to the axis.

Parameters:
update - true if updating chart layout

zoomIn

public void zoomIn()
Description copied from interface: IAxis
Zooms in the axis.

Specified by:
zoomIn in interface IAxis

zoomIn

public void zoomIn(double coordinate)
Description copied from interface: IAxis
Zooms in the axis at the given coordinate.

Specified by:
zoomIn in interface IAxis
Parameters:
coordinate - the coordinate

zoomOut

public void zoomOut()
Description copied from interface: IAxis
Zooms out the axis.

Specified by:
zoomOut in interface IAxis

zoomOut

public void zoomOut(double coordinate)
Description copied from interface: IAxis
Zooms out the axis at the given coordinate.

Specified by:
zoomOut in interface IAxis
Parameters:
coordinate - the coordinate

scrollUp

public void scrollUp()
Description copied from interface: IAxis
Scrolls up the axis.

Specified by:
scrollUp in interface IAxis

scrollDown

public void scrollDown()
Description copied from interface: IAxis
Scrolls up the axis.

Specified by:
scrollDown in interface IAxis

isCategoryEnabled

public boolean isCategoryEnabled()
Description copied from interface: IAxis
Gets the state indicating if category is enabled.

Specified by:
isCategoryEnabled in interface IAxis
Returns:
true if category is enabled

isValidCategoryAxis

public boolean isValidCategoryAxis()
Gets the state indicating if the axis is valid category axis.

Returns:
true if the axis is valid category axis

enableCategory

public void enableCategory(boolean enabled)
Description copied from interface: IAxis
Enables category. Category is applicable only for X axis. If enabling category, log scale will be disabled. If category series are not yet set, category won't be enabled.

Specified by:
enableCategory in interface IAxis
Parameters:
enabled - true if enabling category

setCategorySeries

public void setCategorySeries(java.lang.String[] series)
Description copied from interface: IAxis
Sets the category series. In order to enable category series, enableCategoryAxis(true) has to be invoked.

Specified by:
setCategorySeries in interface IAxis
Parameters:
series - the category series

getCategorySeries

public java.lang.String[] getCategorySeries()
Description copied from interface: IAxis
Gets the category series. If the category series haven't been set yet, null will be returned.

Specified by:
getCategorySeries in interface IAxis
Returns:
the category series

getPixelCoordinate

public int getPixelCoordinate(double dataCoordinate)
Description copied from interface: IAxis
Gets the pixel coordinate corresponding to the given data coordinate.

Specified by:
getPixelCoordinate in interface IAxis
Parameters:
dataCoordinate - the data coordinate
Returns:
the pixel coordinate on plot area

getPixelCoordinate

public int getPixelCoordinate(double dataCoordinate,
                              double lower,
                              double upper)
Gets the pixel coordinate corresponding to the given data coordinate.

Parameters:
dataCoordinate - the data coordinate
lower - the min value of range
upper - the max value of range
Returns:
the pixel coordinate on plot area

getDataCoordinate

public double getDataCoordinate(int pixelCoordinate)
Description copied from interface: IAxis
Gets the data coordinate corresponding to the given pixel coordinate on plot area.

Specified by:
getDataCoordinate in interface IAxis
Parameters:
pixelCoordinate - the pixel coordinate on plot area
Returns:
the data coordinate

getDataCoordinate

public double getDataCoordinate(int pixelCoordinate,
                                double lower,
                                double upper)
Gets the data coordinate corresponding to the given pixel coordinate on plot area.

Parameters:
pixelCoordinate - the pixel coordinate on plot area
lower - the min value of range
upper - the max value of range
Returns:
the data coordinate

setNumRisers

public void setNumRisers(int numRisers)
Sets the number of risers per category.

Parameters:
numRisers - the number of risers per category

getNumRisers

public int getNumRisers()
Gets the number of risers per category.

Returns:
number of riser per category

isHorizontalAxis

public boolean isHorizontalAxis()
Checks if the axis is horizontal. X axis is not always horizontal. Y axis can be horizontal with Chart.setOrientation(SWT.VERTICAL).

Returns:
true if the axis is horizontal

dispose

protected void dispose()
Disposes the resources.


addDisposeListener

public void addDisposeListener(IDisposeListener listener)
Description copied from interface: IAxis
Adds the dispose listener. The newly created color or font for axis can be disposed with the dispose listener when they are no longer needed.

Specified by:
addDisposeListener in interface IAxis
Parameters:
listener - the dispose listener

updateLayoutData

public void updateLayoutData()
Updates the layout data.


refresh

public void refresh()
Refreshes the cache.


isDateEnabled

public boolean isDateEnabled()
Gets the state indicating if date is enabled.

Returns:
true if date is enabled