Package org.swtchart.internal.axis
Class Axis
- java.lang.Object
-
- org.swtchart.internal.axis.Axis
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.swtchart.IAxis
IAxis.Direction, IAxis.Position
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_LOG_SCALE_MAX
the default maximum value of log scale rangestatic double
DEFAULT_LOG_SCALE_MIN
the default minimum value of log scale rangestatic double
DEFAULT_MAX
the default maximum value of rangestatic double
DEFAULT_MIN
the default minimum value of rangestatic int
MARGIN
the margin in pixels
-
Constructor Summary
Constructors Constructor Description Axis(int id, IAxis.Direction direction, Chart chart)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.
-
-
-
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 indexdirection
- 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.
-
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 interfaceIAxis
- Returns:
- the axis direction
-
getPosition
public IAxis.Position getPosition()
Description copied from interface:IAxis
Gets the axis position.- Specified by:
getPosition
in interfaceIAxis
- Returns:
- the axis position
-
setPosition
public void setPosition(IAxis.Position position)
Description copied from interface:IAxis
Sets the axis position.- Specified by:
setPosition
in interfaceIAxis
- Parameters:
position
- the axis position
-
setRange
public void setRange(Range range)
Description copied from interface:IAxis
Sets the axis range.
-
setRange
public void setRange(Range range, boolean update)
Sets the axis range.- Parameters:
range
- the axis rangeupdate
- true if updating the chart layout
-
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 interfaceIAxis
- 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 interfaceIAxis
- 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.
-
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 interfaceIAxis
-
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.
-
zoomIn
public void zoomIn(double coordinate)
Description copied from interface:IAxis
Zooms in the axis at the given coordinate.
-
zoomOut
public void zoomOut()
Description copied from interface:IAxis
Zooms out the axis.
-
zoomOut
public void zoomOut(double coordinate)
Description copied from interface:IAxis
Zooms out the axis at the given coordinate.
-
scrollUp
public void scrollUp()
Description copied from interface:IAxis
Scrolls up the axis.
-
scrollDown
public void scrollDown()
Description copied from interface:IAxis
Scrolls up the axis.- Specified by:
scrollDown
in interfaceIAxis
-
isCategoryEnabled
public boolean isCategoryEnabled()
Description copied from interface:IAxis
Gets the state indicating if category is enabled.- Specified by:
isCategoryEnabled
in interfaceIAxis
- 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 interfaceIAxis
- 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 interfaceIAxis
- 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 interfaceIAxis
- 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 interfaceIAxis
- 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 coordinatelower
- the min value of rangeupper
- 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 interfaceIAxis
- 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 arealower
- the min value of rangeupper
- 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 interfaceIAxis
- 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
-
-