Package de.gsi.chart.axes.spi
Class AbstractAxis
- java.lang.Object
-
- javafx.scene.Node
-
- javafx.scene.Parent
-
- javafx.scene.layout.Region
-
- javafx.scene.layout.Pane
-
- de.gsi.chart.axes.spi.AbstractAxisParameter
-
- de.gsi.chart.axes.spi.AbstractAxis
-
- All Implemented Interfaces:
Axis,javafx.beans.Observable,javafx.css.Styleable,javafx.event.EventTarget
- Direct Known Subclasses:
DefaultNumericAxis,LinearAxis,LogarithmicAxis,NumericAxis
public abstract class AbstractAxis extends AbstractAxisParameter implements Axis
- Author:
- rstein
-
-
Field Summary
Fields Modifier and Type Field Description protected javafx.animation.Timelineanimatorprotected booleanautoNotificationprotected doublecachedOffsetprotected javafx.beans.property.DoublePropertycurrentLowerBoundThe current value for the lowerBound of this axis, ie min value.protected booleanlabelOverlapprotected java.util.List<javafx.beans.InvalidationListener>listenersprotected java.util.concurrent.locks.ReentrantLocklockprotected doublemaxLabelHeightprotected doublemaxLabelWidthprotected static intRANGE_ANIMATION_DURATION_MSprotected java.util.WeakHashMap<java.lang.Double,TickMark>tickMarkDoubleCacheprotected java.util.WeakHashMap<java.lang.Number,javafx.geometry.Dimension2D>tickMarkSizeCacheprotected java.util.WeakHashMap<java.lang.String,TickMark>tickMarkStringCache-
Fields inherited from class de.gsi.chart.axes.spi.AbstractAxisParameter
autoRange, axisLabel, DEFAULT_MINOR_TICK_COUNT, isInvertedAxis, isTimeAxis, lowerBound, majorTickMarks, majorTickStyle, measureInvalid, minorTickMarkValues, minorTickStyle, oldAxisLength, rangeValid, scaleBinding, tickLabelRotation, tickLabelsVisibleInvalid, tickUnit, upperBound, userRange
-
-
Constructor Summary
Constructors Constructor Description AbstractAxis()AbstractAxis(double lowerBound, double upperBound)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddListener(javafx.beans.InvalidationListener listener)protected AxisRangeautoRange(double length)This calculates the upper and lower bound based on the data provided to invalidateRange() method.protected AxisRangeautoRange(double minValue, double maxValue, double length, double labelSize)javafx.beans.property.ObjectProperty<AxisLabelFormatter>axisLabelFormatterProperty()protected abstract java.util.List<java.lang.Double>calculateMajorTickValues(double length, AxisRange range)Calculate a list of all the data values for each tick mark in rangeprotected abstract java.util.List<java.lang.Double>calculateMinorTickValues()Calculate a list of the data values for every minor tick markprotected doublecalculateNewScale(double length, double lowerBound, double upperBound)Calculate a new scale for this axis.protected voidclearAxisCanvas(javafx.scene.canvas.GraphicsContext gc, double width, double height)abstract doublecomputePreferredTickUnit(double axisLength)Computes the preferred tick unit based on the upper/lower bounds and the length of the axis in screen coordinates.protected doublecomputePrefHeight(double width)Computes the preferred height of this axis for the given width.protected doublecomputePrefWidth(double height)Computes the preferred width of this axis for the given height.protected abstract AxisRangecomputeRange(double minValue, double maxValue, double axisLength, double labelSize)Computes range of this axis, similarly toautoRange(double, double, double, double).protected java.util.List<TickMark>computeTickMarks(AxisRange range, boolean majorTickMark)voiddrawAxis(javafx.scene.canvas.GraphicsContext gc, double axisWidth, double axisHeight)Function allows custom drawing of axes outside the Axis environment (ie.protected voiddrawAxisLabel(javafx.scene.canvas.GraphicsContext gc, double axisLength, double axisWidth, double axisHeight, javafx.scene.text.Text axisLabel, javafx.collections.ObservableList<TickMark> tickMarks, double tickLength)protected voiddrawAxisLabel(javafx.scene.canvas.GraphicsContext gc, double x, double y, javafx.scene.text.Text label)protected voiddrawAxisLine(javafx.scene.canvas.GraphicsContext gc, double axisLength, double axisWidth, double axisHeight)protected voiddrawAxisPost()function to be executed after the axis has been drawn can be used to execute user-specific code (e.g.protected voiddrawAxisPre()function to be executed prior to drawing axis can be used to execute user-specific code (e.g.protected voiddrawTickLabels(javafx.scene.canvas.GraphicsContext gc, double axisWidth, double axisHeight, javafx.collections.ObservableList<TickMark> tickMarks, double tickLength)protected voiddrawTickMarkLabel(javafx.scene.canvas.GraphicsContext gc, double x, double y, double rotation, TickMark tickMark)protected voiddrawTickMarks(javafx.scene.canvas.GraphicsContext gc, double axisLength, double axisWidth, double axisHeight, javafx.collections.ObservableList<TickMark> tickMarks, double tickLength, javafx.scene.shape.Path tickStyle)protected voidexecuteFireInvalidated()voidfireInvalidated()Notifies listeners that the data has been invalidated.voidforceRedraw()forces redrawing of axis (via layoutChildren()).AxisLabelFormattergetAxisLabelFormatter()protected AxisRangegetAxisRange()javafx.scene.canvas.CanvasgetCanvas()doublegetDisplayPosition(double value)Get the display position along this axis for a given value.javafx.scene.canvas.GraphicsContextgetGraphicsContext()protected doublegetMaxTickLabelHeight(java.util.List<TickMark> tickMarks)protected doublegetMaxTickLabelWidth(java.util.List<TickMark> tickMarks)TickMarkgetNewTickMark(java.lang.Double tickValue, java.lang.Double tickPosition, java.lang.String tickMarkLabel)java.lang.StringgetTickMarkLabel(double value)Get the string label name for a tick mark with the given valuedoublegetZeroPosition()Get the display position of the zero line along this axis.protected voidinvalidateRange()Mark the current range invalid, this will cause anything that depends on the range to be recalculated on the next layout.voidinvalidateRange(java.util.List<java.lang.Number> data)Called when data has changed and the range may not be valid any more.booleanisAutoNotification()Checks it automatic notification is enabled.booleanisLabelOverlapping()protected booleanisRangeValid()See if the current range is valid, if it is not then any range dependent calculations need to redone on the next layout passbooleanisValueOnAxis(double value)Checks if the given value is plottable on this axisprotected voidlayoutChildren()Invoked during the layout pass to layout this axis and all its content.protected doublemeasureTickMarkLength(double major)voidrecomputeTickMarks()protected voidrecomputeTickMarks(AxisRange range)voidremoveListener(javafx.beans.InvalidationListener listener)voidrequestAxisLayout()Request that the axis is laid out in the next layout pass.voidsetAutoNotifaction(boolean flag)Set the automatic notification of invalidation listeners.voidsetAxisLabelFormatter(AxisLabelFormatter value)voidsetLowerBound(double value)protected voidsetRange(AxisRange rangeObj, boolean animate)voidsetUpperBound(double value)protected booleanshouldAnimate()This is used to check if any given animation should run.protected voidtickMarksUpdated()Called during layout if the tickmarks have been updated, allowing subclasses to do anything they need to in reaction.protected voidupdateCachedVariables()to be overwritten by derived class that want to cache variables for efficiency reasons-
Methods inherited from class de.gsi.chart.axes.spi.AbstractAxisParameter
animatedProperty, animationDurationProperty, autoGrowRangingProperty, autoRangePaddingProperty, autoRangeRoundingProperty, autoRangingProperty, autoUnitScalingProperty, axisLabelGapProperty, axisLabelTextAlignmentProperty, axisPaddingProperty, centerAxisPositionProperty, decadeRange, getaAxisLabelTextAlignment, getAnimated, getAnimationDuration, getAutoRange, getAutoRangePadding, getAutoUnitScaling, getAxisLabel, getAxisLabelGap, getAxisPadding, getCenterAxisPosition, getClassCssMetaData, getCssMetaData, getLabel, getLength, getLowerBound, getMajorTickStyle, getMinorTickCount, getMinorTickLength, getMinorTickMarks, getMinorTickStyle, getOverlapPolicy, getRange, getScale, getSide, getTickLabelFill, getTickLabelFont, getTickLabelFormatter, getTickLabelGap, getTickLabelRotation, getTickLength, getTickMarks, getTickUnit, getUnit, getUnitScaling, getUpperBound, getUserRange, invertAxis, invertAxisProperty, isAutoGrowRanging, isAutoRangeRounding, isAutoRanging, isInvertedAxis, isMinorTickVisible, isTickLabelsVisible, isTickMarkVisible, isTimeAxis, labelProperty, lowerBoundProperty, minorTickCountProperty, minorTickLengthProperty, minorTickVisibleProperty, overlapPolicyProperty, scaleProperty, setAnimated, setAnimationDuration, setAutoGrowRanging, setAutoRangePadding, setAutoRangeRounding, setAutoRanging, setAutoUnitScaling, setAxisCentrePosition, setAxisLabelAlignment, setAxisLabelGap, setAxisPadding, setLabel, setMinorTickCount, setMinorTickLength, setMinorTickVisible, setOverlapPolicy, setScale, setSide, setTickLabelFill, setTickLabelFont, setTickLabelFormatter, setTickLabelGap, setTickLabelRotation, setTickLabelsVisible, setTickLength, setTickMarkVisible, setTickUnit, setTimeAxis, setUnit, setUnitScaling, setUnitScaling, sideProperty, tickLabelFillProperty, tickLabelFontProperty, tickLabelFormatterProperty, tickLabelGapProperty, tickLabelRotationProperty, tickLabelsVisibleProperty, tickLengthProperty, tickMarkVisibleProperty, tickUnitProperty, timeAxisProperty, unitProperty, unitScalingProperty, updateAxisLabelAndUnit, updateScaleAndUnitPrefix, upperBoundProperty
-
Methods inherited from class javafx.scene.layout.Region
backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, computeMaxHeight, computeMaxWidth, computeMinHeight, computeMinWidth, getBackground, getBorder, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, resize, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty
-
Methods inherited from class javafx.scene.Parent
getBaselineOffset, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBounds
-
Methods inherited from class javafx.scene.Node
accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, relocate, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface de.gsi.chart.axes.Axis
autoGrowRangingProperty, autoRangingProperty, autoUnitScalingProperty, getAutoRange, getAutoUnitScaling, getAxisTransform, getHeight, getLabel, getLength, getLogAxisType, getLowerBound, getMinorTickCount, getMinorTickMarks, getRange, getSide, getTickLabelFill, getTickLabelFont, getTickLabelFormatter, getTickLabelGap, getTickMarks, getTickUnit, getUnit, getUnitScaling, getUpperBound, getUserRange, getValueForDisplay, getWidth, invertAxis, invertAxisProperty, isAutoGrowRanging, isAutoRanging, isInvertedAxis, isLogAxis, isTimeAxis, labelProperty, lowerBoundProperty, setAnimated, setAutoGrowRanging, setAutoRanging, setAutoUnitScaling, setLabel, setSide, setTickUnit, setTimeAxis, setUnit, setUnitScaling, setUnitScaling, sideProperty, tickUnitProperty, timeAxisProperty, unitProperty, unitScalingProperty, upperBoundProperty
-
-
-
-
Field Detail
-
RANGE_ANIMATION_DURATION_MS
protected static final int RANGE_ANIMATION_DURATION_MS
- See Also:
- Constant Field Values
-
tickMarkSizeCache
protected java.util.WeakHashMap<java.lang.Number,javafx.geometry.Dimension2D> tickMarkSizeCache
-
animator
protected final javafx.animation.Timeline animator
-
labelOverlap
protected boolean labelOverlap
-
cachedOffset
protected double cachedOffset
-
listeners
protected final java.util.List<javafx.beans.InvalidationListener> listeners
-
lock
protected final java.util.concurrent.locks.ReentrantLock lock
-
autoNotification
protected boolean autoNotification
-
maxLabelHeight
protected double maxLabelHeight
-
maxLabelWidth
protected double maxLabelWidth
-
currentLowerBound
protected final javafx.beans.property.DoubleProperty currentLowerBound
The current value for the lowerBound of this axis, ie min value. This may be the same as lowerBound or different. It is used by NumberAxis to animate the lowerBound from the old value to the new value.
-
tickMarkStringCache
protected java.util.WeakHashMap<java.lang.String,TickMark> tickMarkStringCache
-
tickMarkDoubleCache
protected java.util.WeakHashMap<java.lang.Double,TickMark> tickMarkDoubleCache
-
-
Method Detail
-
getAxisLabelFormatter
public AxisLabelFormatter getAxisLabelFormatter()
-
setAxisLabelFormatter
public void setAxisLabelFormatter(AxisLabelFormatter value)
-
axisLabelFormatterProperty
public javafx.beans.property.ObjectProperty<AxisLabelFormatter> axisLabelFormatterProperty()
-
computeRange
protected abstract AxisRange computeRange(double minValue, double maxValue, double axisLength, double labelSize)
Computes range of this axis, similarly toautoRange(double, double, double, double). The major difference is that this method is called whenauto-rangeis off.- Parameters:
minValue- The min data value that needs to be plotted on this axismaxValue- The max data value that needs to be plotted on this axisaxisLength- The length of the axis in display coordinateslabelSize- The approximate average size a label takes along the axis- Returns:
- The calculated range
- See Also:
autoRange(double, double, double, double)
-
autoRange
protected AxisRange autoRange(double minValue, double maxValue, double length, double labelSize)
-
autoRange
protected AxisRange autoRange(double length)
This calculates the upper and lower bound based on the data provided to invalidateRange() method. This must not effect the state of the axis, changing any properties of the axis. Any results of the auto-ranging should be returned in the range object. This will we passed to setRange() if it has been decided to adopt this range for this axis.- Parameters:
length- The length of the axis in screen coordinates- Returns:
- Range information, this is implementation dependent
-
calculateNewScale
protected double calculateNewScale(double length, double lowerBound, double upperBound)Calculate a new scale for this axis. This should not effect any state(properties) of this axis.- Parameters:
length- The display length of the axislowerBound- The lower bound valueupperBound- The upper bound value- Returns:
- new scale to fit the range from lower bound to upper bound in the given display length
-
calculateMinorTickValues
protected abstract java.util.List<java.lang.Double> calculateMinorTickValues()
Calculate a list of the data values for every minor tick mark- Returns:
- List of data values where to draw minor tick marks
-
getNewTickMark
public TickMark getNewTickMark(java.lang.Double tickValue, java.lang.Double tickPosition, java.lang.String tickMarkLabel)
-
computeTickMarks
protected java.util.List<TickMark> computeTickMarks(AxisRange range, boolean majorTickMark)
-
recomputeTickMarks
public void recomputeTickMarks()
-
recomputeTickMarks
protected void recomputeTickMarks(AxisRange range)
-
drawAxis
public void drawAxis(javafx.scene.canvas.GraphicsContext gc, double axisWidth, double axisHeight)Description copied from interface:AxisFunction allows custom drawing of axes outside the Axis environment (ie. on another canvas)
-
drawAxisPre
protected void drawAxisPre()
function to be executed prior to drawing axis can be used to execute user-specific code (e.g. modifying tick-marks) prior to drawing
-
drawAxisPost
protected void drawAxisPost()
function to be executed after the axis has been drawn can be used to execute user-specific code (e.g. update of other classes/properties)
-
updateCachedVariables
protected void updateCachedVariables()
to be overwritten by derived class that want to cache variables for efficiency reasons
-
forceRedraw
public void forceRedraw()
Description copied from interface:Axisforces redrawing of axis (via layoutChildren()). This is used to force an update while the main chart area is being updated (a requestLayout()) would be executed only during the next pulse. This is used explicitly in the Chart class. Outside use of this context should be limited to a minimum... handle with care- Specified by:
forceRedrawin interfaceAxis
-
layoutChildren
protected void layoutChildren()
Invoked during the layout pass to layout this axis and all its content.- Overrides:
layoutChildrenin classjavafx.scene.Parent
-
invalidateRange
public void invalidateRange(java.util.List<java.lang.Number> data)
Called when data has changed and the range may not be valid any more. This is only called by the chart if isAutoRanging() returns true. If we are auto ranging it will cause layout to be requested and auto ranging to happen on next layout pass.- Specified by:
invalidateRangein interfaceAxis- Parameters:
data- The current set of all data that needs to be plotted on this axis
-
isValueOnAxis
public boolean isValueOnAxis(double value)
Checks if the given value is plottable on this axis- Specified by:
isValueOnAxisin interfaceAxis- Parameters:
value- The value to check if its on axis- Returns:
- true if the given value is plottable on this axis
-
getCanvas
public javafx.scene.canvas.Canvas getCanvas()
-
isLabelOverlapping
public boolean isLabelOverlapping()
-
getGraphicsContext
public javafx.scene.canvas.GraphicsContext getGraphicsContext()
-
isRangeValid
protected boolean isRangeValid()
See if the current range is valid, if it is not then any range dependent calculations need to redone on the next layout pass- Returns:
- true if current range calculations are valid
-
invalidateRange
protected void invalidateRange()
Mark the current range invalid, this will cause anything that depends on the range to be recalculated on the next layout.- Overrides:
invalidateRangein classAbstractAxisParameter
-
shouldAnimate
protected boolean shouldAnimate()
This is used to check if any given animation should run. It returns true if animation is enabled and the node is visible and in a scene.- Returns:
- true if animations should happen
-
requestAxisLayout
public void requestAxisLayout()
Request that the axis is laid out in the next layout pass. This replaces requestLayout() as it has been overridden to do nothing so that changes to children's bounds etc do not cause a layout. This was done as a optimisation as the Axis knows the exact minimal set of changes that really need layout to be updated. So we only want to request layout then, not on any child change.- Specified by:
requestAxisLayoutin interfaceAxis- Specified by:
requestAxisLayoutin classAbstractAxisParameter
-
calculateMajorTickValues
protected abstract java.util.List<java.lang.Double> calculateMajorTickValues(double length, AxisRange range)Calculate a list of all the data values for each tick mark in range- Parameters:
length- The length of the axis in display unitsrange- A range object returned from autoRange()- Returns:
- A list of tick marks that fit along the axis if it was the given length
-
computePrefHeight
protected double computePrefHeight(double width)
Computes the preferred height of this axis for the given width. If axis orientation is horizontal, it takes into account the tick mark length, tick label gap and label height.- Overrides:
computePrefHeightin classjavafx.scene.layout.Region- Returns:
- the computed preferred width for this axis
-
computePrefWidth
protected double computePrefWidth(double height)
Computes the preferred width of this axis for the given height. If axis orientation is vertical, it takes into account the tick mark length, tick label gap and label height.- Overrides:
computePrefWidthin classjavafx.scene.layout.Region- Returns:
- the computed preferred width for this axis
-
tickMarksUpdated
protected void tickMarksUpdated()
Called during layout if the tickmarks have been updated, allowing subclasses to do anything they need to in reaction.
-
getAxisRange
protected AxisRange getAxisRange()
- Returns:
- axsis range that is supposed to be shown
-
setRange
protected void setRange(AxisRange rangeObj, boolean animate)
-
clearAxisCanvas
protected void clearAxisCanvas(javafx.scene.canvas.GraphicsContext gc, double width, double height)
-
drawAxisLine
protected void drawAxisLine(javafx.scene.canvas.GraphicsContext gc, double axisLength, double axisWidth, double axisHeight)
-
drawTickMarks
protected void drawTickMarks(javafx.scene.canvas.GraphicsContext gc, double axisLength, double axisWidth, double axisHeight, javafx.collections.ObservableList<TickMark> tickMarks, double tickLength, javafx.scene.shape.Path tickStyle)
-
drawTickMarkLabel
protected void drawTickMarkLabel(javafx.scene.canvas.GraphicsContext gc, double x, double y, double rotation, TickMark tickMark)
-
drawTickLabels
protected void drawTickLabels(javafx.scene.canvas.GraphicsContext gc, double axisWidth, double axisHeight, javafx.collections.ObservableList<TickMark> tickMarks, double tickLength)
-
drawAxisLabel
protected void drawAxisLabel(javafx.scene.canvas.GraphicsContext gc, double x, double y, javafx.scene.text.Text label)
-
measureTickMarkLength
protected double measureTickMarkLength(double major)
-
computePreferredTickUnit
public abstract double computePreferredTickUnit(double axisLength)
Computes the preferred tick unit based on the upper/lower bounds and the length of the axis in screen coordinates.- Parameters:
axisLength- the length in screen coordinates- Returns:
- the tick unit
-
getMaxTickLabelWidth
protected double getMaxTickLabelWidth(java.util.List<TickMark> tickMarks)
-
getMaxTickLabelHeight
protected double getMaxTickLabelHeight(java.util.List<TickMark> tickMarks)
-
drawAxisLabel
protected void drawAxisLabel(javafx.scene.canvas.GraphicsContext gc, double axisLength, double axisWidth, double axisHeight, javafx.scene.text.Text axisLabel, javafx.collections.ObservableList<TickMark> tickMarks, double tickLength)
-
getTickMarkLabel
public java.lang.String getTickMarkLabel(double value)
Get the string label name for a tick mark with the given value- Specified by:
getTickMarkLabelin interfaceAxis- Parameters:
value- The value to format into a tick label string- Returns:
- A formatted string for the given value
-
addListener
public void addListener(javafx.beans.InvalidationListener listener)
- Specified by:
addListenerin interfacejavafx.beans.Observable
-
removeListener
public void removeListener(javafx.beans.InvalidationListener listener)
- Specified by:
removeListenerin interfacejavafx.beans.Observable
-
setAutoNotifaction
public void setAutoNotifaction(boolean flag)
Description copied from interface:AxisSet the automatic notification of invalidation listeners. In general, axes should notify registered invalidation listeners, if the axes range or style parameters have changed.- Specified by:
setAutoNotifactionin interfaceAxis- Parameters:
flag- true for automatic notification
-
isAutoNotification
public boolean isAutoNotification()
Description copied from interface:AxisChecks it automatic notification is enabled.- Specified by:
isAutoNotificationin interfaceAxis- Returns:
- true if automatic notification is enabled
-
fireInvalidated
public void fireInvalidated()
Notifies listeners that the data has been invalidated. If the data is added to the chart, it triggers repaint.- Specified by:
fireInvalidatedin classAbstractAxisParameter
-
executeFireInvalidated
protected void executeFireInvalidated()
-
getDisplayPosition
public double getDisplayPosition(double value)
Get the display position along this axis for a given value. If the value is not in the current range, the returned value will be an extrapolation of the display position.- Specified by:
getDisplayPositionin interfaceAxis- Parameters:
value- The data value to work out display position for- Returns:
- display position
-
getZeroPosition
public double getZeroPosition()
Get the display position of the zero line along this axis.- Specified by:
getZeroPositionin interfaceAxis- Returns:
- display position or Double.NaN if zero is not in current range;
-
setLowerBound
public void setLowerBound(double value)
- Specified by:
setLowerBoundin interfaceAxis- Overrides:
setLowerBoundin classAbstractAxisParameter
-
setUpperBound
public void setUpperBound(double value)
- Specified by:
setUpperBoundin interfaceAxis- Overrides:
setUpperBoundin classAbstractAxisParameter
-
-