Package org.swtchart.internal.axis
Class Axis
java.lang.Object
org.swtchart.internal.axis.Axis
- All Implemented Interfaces:
IAxis
An axis.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.swtchart.IAxis
IAxis.Direction, IAxis.Position -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doublethe default maximum value of log scale rangestatic final doublethe default minimum value of log scale rangestatic final doublethe default maximum value of rangestatic final doublethe default minimum value of rangestatic final intthe margin in pixels -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDisposeListener(IDisposeListener listener) Adds the dispose listener.voidAdjusts the axis range to the series belonging to the axis, so that all series are completely shown.voidadjustRange(boolean update) Adjusts the axis range to the series belonging to the axis.protected voiddispose()Disposes the resources.voidenableCategory(boolean enabled) Enables category.voidenableLogScale(boolean enabled) Enables the log scale.String[]Gets the category series.doublegetDataCoordinate(int pixelCoordinate) Gets the data coordinate corresponding to the given pixel coordinate on plot area.doublegetDataCoordinate(int pixelCoordinate, double lower, double upper) Gets the data coordinate corresponding to the given pixel coordinate on plot area.Gets the axis direction.getGrid()Gets the grid.intgetId()Gets the axis id.intGets the number of risers per category.intgetPixelCoordinate(double dataCoordinate) Gets the pixel coordinate corresponding to the given data coordinate.intgetPixelCoordinate(double dataCoordinate, double lower, double upper) Gets the pixel coordinate corresponding to the given data coordinate.Gets the axis position.getRange()Gets the axis range.getTick()Gets the axis tick.getTitle()Gets the axis title.booleanGets the state indicating if category is enabled.booleanGets the state indicating if date is enabled.booleanChecks if the axis is horizontal.booleanGets the state indicating if log scale is enabled.booleanGets the state indicating if the axis is valid category axis.voidrefresh()Refreshes the cache.voidScrolls up the axis.voidscrollUp()Scrolls up the axis.voidsetCategorySeries(String[] series) Sets the category series.voidsetNumRisers(int numRisers) Sets the number of risers per category.voidsetPosition(IAxis.Position position) Sets the axis position.voidSets the axis range.voidSets the axis range.voidUpdates the layout data.voidzoomIn()Zooms in the axis.voidzoomIn(double coordinate) Zooms in the axis at the given coordinate.voidzoomOut()Zooms out the axis.voidzoomOut(double coordinate) Zooms out the axis at the given coordinate.
-
Field Details
-
MARGIN
public static final int MARGINthe margin in pixels- See Also:
-
DEFAULT_MIN
public static final double DEFAULT_MINthe default minimum value of range- See Also:
-
DEFAULT_MAX
public static final double DEFAULT_MAXthe default maximum value of range- See Also:
-
DEFAULT_LOG_SCALE_MIN
public static final double DEFAULT_LOG_SCALE_MINthe default minimum value of log scale range- See Also:
-
DEFAULT_LOG_SCALE_MAX
public static final double DEFAULT_LOG_SCALE_MAXthe default maximum value of log scale range- See Also:
-
-
Constructor Details
-
Axis
Constructor.- Parameters:
id- the axis indexdirection- the axis direction (X or Y)chart- the chart
-
-
Method Details
-
getId
public int getId()Description copied from interface:IAxisGets the axis id.An axis id is automatically assigned when axis is created.
-
getDirection
Description copied from interface:IAxisGets the axis direction.The axis direction is set when axis is created, and won't be changed.
- Specified by:
getDirectionin interfaceIAxis- Returns:
- the axis direction
-
getPosition
Description copied from interface:IAxisGets the axis position.- Specified by:
getPositionin interfaceIAxis- Returns:
- the axis position
-
setPosition
Description copied from interface:IAxisSets the axis position.- Specified by:
setPositionin interfaceIAxis- Parameters:
position- the axis position
-
setRange
Description copied from interface:IAxisSets the axis range. -
setRange
Sets the axis range.- Parameters:
range- the axis rangeupdate- true if updating the chart layout
-
getRange
Description copied from interface:IAxisGets the axis range. -
getTitle
Description copied from interface:IAxisGets the axis title. -
getTick
Description copied from interface:IAxisGets the axis tick. -
enableLogScale
Description copied from interface:IAxisEnables the log scale. If enabling log scale, stacking trace and category axis will be disabled.- Specified by:
enableLogScalein interfaceIAxis- Parameters:
enabled- true if enabling log scales- Throws:
IllegalStateException- if minimum value of series belonging to this axis is less than zero.
-
isLogScaleEnabled
public boolean isLogScaleEnabled()Description copied from interface:IAxisGets the state indicating if log scale is enabled.- Specified by:
isLogScaleEnabledin interfaceIAxis- Returns:
- true if log scale is enabled
-
getGrid
Description copied from interface:IAxisGets 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:IAxisAdjusts the axis range to the series belonging to the axis, so that all series are completely shown.- Specified by:
adjustRangein 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:IAxisZooms in the axis. -
zoomIn
public void zoomIn(double coordinate) Description copied from interface:IAxisZooms in the axis at the given coordinate. -
zoomOut
public void zoomOut()Description copied from interface:IAxisZooms out the axis. -
zoomOut
public void zoomOut(double coordinate) Description copied from interface:IAxisZooms out the axis at the given coordinate. -
scrollUp
public void scrollUp()Description copied from interface:IAxisScrolls up the axis. -
scrollDown
public void scrollDown()Description copied from interface:IAxisScrolls up the axis.- Specified by:
scrollDownin interfaceIAxis
-
isCategoryEnabled
public boolean isCategoryEnabled()Description copied from interface:IAxisGets the state indicating if category is enabled.- Specified by:
isCategoryEnabledin 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:IAxisEnables 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:
enableCategoryin interfaceIAxis- Parameters:
enabled- true if enabling category
-
setCategorySeries
Description copied from interface:IAxisSets the category series. In order to enable category series, enableCategoryAxis(true) has to be invoked.- Specified by:
setCategorySeriesin interfaceIAxis- Parameters:
series- the category series
-
getCategorySeries
Description copied from interface:IAxisGets the category series. If the category series haven't been set yet, null will be returned.- Specified by:
getCategorySeriesin interfaceIAxis- Returns:
- the category series
-
getPixelCoordinate
public int getPixelCoordinate(double dataCoordinate) Description copied from interface:IAxisGets the pixel coordinate corresponding to the given data coordinate.- Specified by:
getPixelCoordinatein 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:IAxisGets the data coordinate corresponding to the given pixel coordinate on plot area.- Specified by:
getDataCoordinatein 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
Description copied from interface:IAxisAdds 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:
addDisposeListenerin 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
-