- java.lang.Object
-
- javafx.scene.Node
-
- javafx.scene.Parent
-
- javafx.scene.layout.Region
-
- javafx.scene.chart.Axis<Date>
-
- eu.ess.xaos.ui.plot.DateAxis
-
- All Implemented Interfaces:
Styleable
,EventTarget
public final class DateAxis extends Axis<Date>
An axis that displays date and time values.Tick labels are usually automatically set and calculated depending on the range unless you explicitly
set a formatter
. You also have the chance to specify fix lower and upper bounds, otherwise they are calculated by the chart data.ObservableList<XYChart.Series<Date, Number>> series = FXCollections.observableArrayList(); ObservableList<XYChart.Data<Date, Number>> series1Data = FXCollections.observableArrayList(); series1Data.add(new XYChart.Data<Date, Number>(new GregorianCalendar(2012, 11, 15).getTime(), 2)); series1Data.add(new XYChart.Data<Date, Number>(new GregorianCalendar(2014, 5, 3).getTime(), 4)); ObservableList<XYChart.Data<Date, Number>> series2Data = FXCollections.observableArrayList(); series2Data.add(new XYChart.Data<Date, Number>(new GregorianCalendar(2014, 0, 13).getTime(), 8)); series2Data.add(new XYChart.Data<Date, Number>(new GregorianCalendar(2014, 7, 27).getTime(), 4)); series.add(new XYChart.Series<>("Series1", series1Data)); series.add(new XYChart.Series<>("Series2", series2Data)); NumberAxis numberAxis = new NumberAxis(); DateAxis dateAxis = new DateAxis(); LineChart<Date, Number> lineChart = new LineChart<>(dateAxis, numberAxis, series);
- Author:
- Christian Schudt (original author)., Diego Cirujano (original author)., claudio.rosati@esss.se
-
-
Property Summary
Properties Type Property Description ObjectProperty<Date>
lowerBound
Gets the lower bound of the axis.ObjectProperty<StringConverter<Date>>
tickLabelFormatter
Gets the tick label formatter for the ticks.ObjectProperty<Date>
upperBound
Gets the upper bound of the axis.-
Properties inherited from class javafx.scene.chart.Axis
animated, autoRanging, label, side, tickLabelFill, tickLabelFont, tickLabelGap, tickLabelRotation, tickLabelsVisible, tickLength, tickMarkVisible
-
Properties inherited from class javafx.scene.layout.Region
background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width
-
Properties inherited from class javafx.scene.Parent
needsLayout
-
Properties inherited from class javafx.scene.Node
accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DateAxis.DateConverter
-
Nested classes/interfaces inherited from class javafx.scene.chart.Axis
Axis.TickMark<T extends Object>
-
-
Field Summary
-
Fields inherited from class javafx.scene.layout.Region
USE_COMPUTED_SIZE, USE_PREF_SIZE
-
Fields inherited from class javafx.scene.Node
BASELINE_OFFSET_SAME_AS_HEIGHT
-
-
Constructor Summary
Constructors Constructor Description DateAxis()
Constructs a default date axis where the lower and upper bound are calculated by the data.DateAxis(String axisLabel, Date lowerBound, Date upperBound)
Constructs a date axis with a label and fix lower and upper bounds.DateAxis(Date lowerBound, Date upperBound)
Constructs a date axis with fix lower and upper bounds.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Object
autoRange(double length)
protected List<Date>
calculateTickValues(double v, Object range)
int
getActualInterval()
DateFormat
getDateFormat()
double
getDisplayPosition(Date date)
Date
getLowerBound()
Gets the lower bound of the axis.protected Object
getRange()
StringConverter<Date>
getTickLabelFormatter()
Gets the tick label formatter for the ticks.protected String
getTickMarkLabel(Date date)
Date
getUpperBound()
Gets the upper bound of the axis.Date
getValueForDisplay(double displayPosition)
double
getZeroPosition()
void
invalidateRange(List<Date> list)
boolean
isValueOnAxis(Date date)
protected void
layoutChildren()
ObjectProperty<Date>
lowerBoundProperty()
Gets the lower bound of the axis.void
setLowerBound(Date date)
Sets the lower bound of the axis.protected void
setRange(Object range, boolean animating)
void
setTickLabelFormatter(StringConverter<Date> value)
Sets the tick label formatter for the ticks.void
setUpperBound(Date date)
Sets the upper bound of the axis.ObjectProperty<StringConverter<Date>>
tickLabelFormatterProperty()
Gets the tick label formatter for the ticks.double
toNumericValue(Date date)
Date
toRealValue(double v)
ObjectProperty<Date>
upperBoundProperty()
Gets the upper bound of the axis.-
Methods inherited from class javafx.scene.chart.Axis
animatedProperty, autoRangingProperty, computePrefHeight, computePrefWidth, getAnimated, getClassCssMetaData, getCssMetaData, getLabel, getSide, getTickLabelFill, getTickLabelFont, getTickLabelGap, getTickLabelRotation, getTickLength, getTickMarks, invalidateRange, isAutoRanging, isRangeValid, isTickLabelsVisible, isTickMarkVisible, labelProperty, measureTickMarkLabelSize, measureTickMarkSize, measureTickMarkSize, requestAxisLayout, requestLayout, setAnimated, setAutoRanging, setLabel, setSide, setTickLabelFill, setTickLabelFont, setTickLabelGap, setTickLabelRotation, setTickLabelsVisible, setTickLength, setTickMarkVisible, shouldAnimate, sideProperty, tickLabelFillProperty, tickLabelFontProperty, tickLabelGapProperty, tickLabelRotationProperty, tickLabelsVisibleProperty, tickLengthProperty, tickMarksUpdated, tickMarkVisibleProperty
-
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, getChildren, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, lookup, needsLayoutProperty, queryAccessibleAttribute, 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 javafx.css.Styleable
getStyleableNode
-
-
-
-
Property Detail
-
lowerBound
public ObjectProperty<Date> lowerBoundProperty
Gets the lower bound of the axis.- See Also:
getLowerBound()
,setLowerBound(Date)
-
tickLabelFormatter
public ObjectProperty<StringConverter<Date>> tickLabelFormatterProperty
Gets the tick label formatter for the ticks.
-
upperBound
public ObjectProperty<Date> upperBoundProperty
Gets the upper bound of the axis.- See Also:
getUpperBound()
,setUpperBound(Date)
-
-
Constructor Detail
-
DateAxis
public DateAxis()
Constructs a default date axis where the lower and upper bound are calculated by the data.
-
DateAxis
public DateAxis(Date lowerBound, Date upperBound)
Constructs a date axis with fix lower and upper bounds.- Parameters:
lowerBound
- The lower bound.upperBound
- The upper bound.
-
-
Method Detail
-
lowerBoundProperty
public ObjectProperty<Date> lowerBoundProperty()
Gets the lower bound of the axis.- See Also:
getLowerBound()
,setLowerBound(Date)
-
getLowerBound
public Date getLowerBound()
Gets the lower bound of the axis.- Returns:
- The lower bound.
- See Also:
lowerBoundProperty()
-
setLowerBound
public void setLowerBound(Date date)
Sets the lower bound of the axis.- Parameters:
date
- The lower bound date.- See Also:
lowerBoundProperty()
-
tickLabelFormatterProperty
public ObjectProperty<StringConverter<Date>> tickLabelFormatterProperty()
Gets the tick label formatter for the ticks.
-
getTickLabelFormatter
public StringConverter<Date> getTickLabelFormatter()
Gets the tick label formatter for the ticks.- Returns:
- The converter.
-
setTickLabelFormatter
public void setTickLabelFormatter(StringConverter<Date> value)
Sets the tick label formatter for the ticks.- Parameters:
value
- The converter.
-
upperBoundProperty
public ObjectProperty<Date> upperBoundProperty()
Gets the upper bound of the axis.- See Also:
getUpperBound()
,setUpperBound(Date)
-
getUpperBound
public Date getUpperBound()
Gets the upper bound of the axis.- Returns:
- The upper bound.
- See Also:
upperBoundProperty()
-
setUpperBound
public void setUpperBound(Date date)
Sets the upper bound of the axis.- Parameters:
date
- The upper bound date.- See Also:
()
-
getActualInterval
public int getActualInterval()
- Returns:
- The actual interval between ticks as
Calendar
codes. Returned value will be one of the following:Calendar.YEAR
,Calendar.MONTH
,Calendar.WEEK_OF_YEAR
,Calendar.DAY_OF_MONTH
,Calendar.HOUR
,Calendar.MINUTE
,Calendar.SECOND
, andCalendar.MILLISECOND
.
-
getDateFormat
public DateFormat getDateFormat()
- Returns:
- A
DateFormat
for theactual interval
.
-
getDisplayPosition
public double getDisplayPosition(Date date)
- Specified by:
getDisplayPosition
in classAxis<Date>
-
getValueForDisplay
public Date getValueForDisplay(double displayPosition)
- Specified by:
getValueForDisplay
in classAxis<Date>
-
getZeroPosition
public double getZeroPosition()
- Specified by:
getZeroPosition
in classAxis<Date>
-
invalidateRange
public void invalidateRange(List<Date> list)
- Overrides:
invalidateRange
in classAxis<Date>
-
isValueOnAxis
public boolean isValueOnAxis(Date date)
- Specified by:
isValueOnAxis
in classAxis<Date>
-
toNumericValue
public double toNumericValue(Date date)
- Specified by:
toNumericValue
in classAxis<Date>
-
toRealValue
public Date toRealValue(double v)
- Specified by:
toRealValue
in classAxis<Date>
-
calculateTickValues
protected List<Date> calculateTickValues(double v, Object range)
- Specified by:
calculateTickValues
in classAxis<Date>
-
getTickMarkLabel
protected String getTickMarkLabel(Date date)
- Specified by:
getTickMarkLabel
in classAxis<Date>
-
layoutChildren
protected void layoutChildren()
- Overrides:
layoutChildren
in classAxis<Date>
-
-