Package de.gsi.chart.plugins
Class Zoomer
- java.lang.Object
-
- de.gsi.chart.plugins.ChartPlugin
-
- de.gsi.chart.plugins.Zoomer
-
public class Zoomer extends ChartPlugin
Zoom capabilities along X, Y or both axis. For every zoom-in operation the current X and Y range is remembered and restored upon following zoom-out operation.- zoom-in - triggered on
MOUSE_PRESSEDevent that is accepted byzoom-in filter. It shows a zooming rectangle determining the zoom window once mouse button is released. - zoom-out - triggered on
MOUSE_CLICKEDevent that is accepted byzoom-out filter. It restores the previous ranges on both axis. - zoom-origin - triggered on
MOUSE_CLICKEDevent that is accepted byzoom-origin filter. It restores the initial ranges on both axis as it was at the moment of the first zoom-in operation.
Zoomerworks properly only if both X and Y axis are instances ofDefaultNumericAxis.CSS class name of the zoom rectangle: "chart-zoom-rect".
- Author:
- Grzegorz Kruk, rstein - adapted to XYChartPane, corrected some features (mouse zoom events outside canvas, auto-ranging on zoom-out, scrolling, toolbar)
- zoom-in - triggered on
-
-
Field Summary
Fields Modifier and Type Field Description java.util.function.Predicate<javafx.scene.input.ScrollEvent>defaultScrollFilterDefault zoom scroll filter withcontrol key down.java.util.function.Predicate<javafx.scene.input.MouseEvent>defaultZoomInMouseFilterDefault zoom-in mouse filter passing on left mouse button (only).java.util.function.Predicate<javafx.scene.input.MouseEvent>defaultZoomOriginFilterDefault zoom-origin mouse filter passing on right mouse button withcontrol key down.java.util.function.Predicate<javafx.scene.input.MouseEvent>defaultZoomOutMouseFilterDefault zoom-out mouse filter passing on right mouse button (only).static java.lang.StringSTYLE_CLASS_ZOOM_RECTName of the CCS class of the zoom rectangle.
-
Constructor Summary
Constructors Constructor Description Zoomer()Creates a new instance of Zoomer with animation disabled and withzoomModeinitialized toAxisMode.XY.Zoomer(boolean animated)Creates a new instance of Zoomer withzoomModeinitialized toAxisMode.XY.Zoomer(AxisMode zoomMode)Creates a new instance of Zoomer with animation disabled.Zoomer(AxisMode zoomMode, boolean animated)Creates a new instance of Zoomer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description javafx.beans.property.BooleanPropertyanimatedProperty()Whentruezooming will be animated.javafx.beans.property.ObjectProperty<AxisMode>axisModeProperty()The mode defining axis along which the zoom can be performed.voidclear()Clears the stack of zoom windows saved during zoom-in operations.javafx.beans.property.ObjectProperty<javafx.scene.Cursor>dragCursorProperty()Mouse cursor to be used during drag operation.AxisModegetAxisMode()Returns the value of theaxisModeProperty().javafx.scene.CursorgetDragCursor()Returns the value of thedragCursorProperty()org.controlsfx.control.RangeSlidergetRangeSlider()javafx.util.DurationgetZoomDuration()Returns the value of thezoomDurationProperty().java.util.function.Predicate<javafx.scene.input.MouseEvent>getZoomInMouseFilter()Returns zoom-in mouse event filter.javafx.scene.layout.HBoxgetZoomInteractorBar()java.util.function.Predicate<javafx.scene.input.MouseEvent>getZoomOriginMouseFilter()Returns zoom-origin mouse filter.java.util.function.Predicate<javafx.scene.input.MouseEvent>getZoomOutMouseFilter()Returns zoom-out mouse filter.java.util.function.Predicate<javafx.scene.input.ScrollEvent>getZoomScrollFilter()Returns zoom-scroll filter.booleanisAnimated()Returns the value of theanimatedProperty().booleanisSliderVisible()Returns the value of thesliderVisibleProperty().booleanisUpdateTickUnit()Returns the value of theanimatedProperty().voidsetAnimated(boolean value)Sets the value of theanimatedProperty().voidsetAxisMode(AxisMode mode)Sets the value of theaxisModeProperty().voidsetDragCursor(javafx.scene.Cursor cursor)Sets value of thedragCursorProperty().voidsetSliderVisible(boolean state)Sets the value of thesliderVisibleProperty().voidsetUpdateTickUnit(boolean value)Sets the value of theanimatedProperty().voidsetZoomDuration(javafx.util.Duration duration)Sets the value of thezoomDurationProperty().voidsetZoomInMouseFilter(java.util.function.Predicate<javafx.scene.input.MouseEvent> zoomInMouseFilter)Sets filter onDRAG_DETECTEDevents that should start zoom-in operation.voidsetZoomOriginMouseFilter(java.util.function.Predicate<javafx.scene.input.MouseEvent> zoomOriginMouseFilter)Sets filter onMOUSE_CLICKEDevents that should trigger zoom-origin operation.voidsetZoomOutMouseFilter(java.util.function.Predicate<javafx.scene.input.MouseEvent> zoomOutMouseFilter)Sets filter onMOUSE_CLICKEDevents that should trigger zoom-out operation.voidsetZoomScrollFilter(java.util.function.Predicate<javafx.scene.input.ScrollEvent> zoomScrollFilter)Sets filter onMOUSE_CLICKEDevents that should trigger zoom-origin operation.javafx.beans.property.BooleanPropertysliderVisibleProperty()Whentruean additional horizontal range slider is shown in a HiddeSidesPane at the bottom.javafx.beans.property.BooleanPropertyupdateTickUnitProperty()Whentruezooming will be animated.javafx.beans.property.ObjectProperty<javafx.util.Duration>zoomDurationProperty()Duration of the animated zoom (in and out).booleanzoomOrigin()-
Methods inherited from class de.gsi.chart.plugins.ChartPlugin
addButtonsToToolBarProperty, chartProperty, getChart, getChartChildren, getLocationInPlotArea, isAddButtonsToToolBar, layoutChildren, registerInputEventHandler, setAddButtonsToToolBar, setChart, toDataPoint, toDisplayPoint
-
-
-
-
Field Detail
-
STYLE_CLASS_ZOOM_RECT
public static final java.lang.String STYLE_CLASS_ZOOM_RECT
Name of the CCS class of the zoom rectangle.- See Also:
- Constant Field Values
-
defaultZoomInMouseFilter
public final java.util.function.Predicate<javafx.scene.input.MouseEvent> defaultZoomInMouseFilter
Default zoom-in mouse filter passing on left mouse button (only).
-
defaultZoomOutMouseFilter
public final java.util.function.Predicate<javafx.scene.input.MouseEvent> defaultZoomOutMouseFilter
Default zoom-out mouse filter passing on right mouse button (only).
-
defaultZoomOriginFilter
public final java.util.function.Predicate<javafx.scene.input.MouseEvent> defaultZoomOriginFilter
Default zoom-origin mouse filter passing on right mouse button withcontrol key down.
-
defaultScrollFilter
public final java.util.function.Predicate<javafx.scene.input.ScrollEvent> defaultScrollFilter
Default zoom scroll filter withcontrol key down.
-
-
Constructor Detail
-
Zoomer
public Zoomer()
Creates a new instance of Zoomer with animation disabled and withzoomModeinitialized toAxisMode.XY.
-
Zoomer
public Zoomer(AxisMode zoomMode)
Creates a new instance of Zoomer with animation disabled.- Parameters:
zoomMode- initial value ofzoomModeproperty
-
Zoomer
public Zoomer(boolean animated)
Creates a new instance of Zoomer withzoomModeinitialized toAxisMode.XY.- Parameters:
animated- initial value ofanimatedproperty
-
-
Method Detail
-
getZoomInteractorBar
public javafx.scene.layout.HBox getZoomInteractorBar()
-
getZoomInMouseFilter
public java.util.function.Predicate<javafx.scene.input.MouseEvent> getZoomInMouseFilter()
Returns zoom-in mouse event filter.- Returns:
- zoom-in mouse event filter
- See Also:
setZoomInMouseFilter(Predicate)
-
setZoomInMouseFilter
public void setZoomInMouseFilter(java.util.function.Predicate<javafx.scene.input.MouseEvent> zoomInMouseFilter)
Sets filter onDRAG_DETECTEDevents that should start zoom-in operation.- Parameters:
zoomInMouseFilter- the filter to accept zoom-in mouse event. Ifnullthen any DRAG_DETECTED event will start zoom-in operation. By default it's set todefaultZoomInMouseFilter.- See Also:
getZoomInMouseFilter()
-
getZoomOutMouseFilter
public java.util.function.Predicate<javafx.scene.input.MouseEvent> getZoomOutMouseFilter()
Returns zoom-out mouse filter.- Returns:
- zoom-out mouse filter
- See Also:
setZoomOutMouseFilter(Predicate)
-
setZoomOutMouseFilter
public void setZoomOutMouseFilter(java.util.function.Predicate<javafx.scene.input.MouseEvent> zoomOutMouseFilter)
Sets filter onMOUSE_CLICKEDevents that should trigger zoom-out operation.- Parameters:
zoomOutMouseFilter- the filter to accept zoom-out mouse event. Ifnullthen any MOUSE_CLICKED event will start zoom-out operation. By default it's set todefaultZoomOutMouseFilter.- See Also:
getZoomOutMouseFilter()
-
getZoomOriginMouseFilter
public java.util.function.Predicate<javafx.scene.input.MouseEvent> getZoomOriginMouseFilter()
Returns zoom-origin mouse filter.- Returns:
- zoom-origin mouse filter
- See Also:
setZoomOriginMouseFilter(Predicate)
-
setZoomOriginMouseFilter
public void setZoomOriginMouseFilter(java.util.function.Predicate<javafx.scene.input.MouseEvent> zoomOriginMouseFilter)
Sets filter onMOUSE_CLICKEDevents that should trigger zoom-origin operation.- Parameters:
zoomOriginMouseFilter- the filter to accept zoom-origin mouse event. Ifnullthen any MOUSE_CLICKED event will start zoom-origin operation. By default it's set todefaultZoomOriginFilter.- See Also:
getZoomOriginMouseFilter()
-
getZoomScrollFilter
public java.util.function.Predicate<javafx.scene.input.ScrollEvent> getZoomScrollFilter()
Returns zoom-scroll filter.- Returns:
- predicate of filter
-
setZoomScrollFilter
public void setZoomScrollFilter(java.util.function.Predicate<javafx.scene.input.ScrollEvent> zoomScrollFilter)
Sets filter onMOUSE_CLICKEDevents that should trigger zoom-origin operation.- Parameters:
zoomScrollFilter- filter
-
axisModeProperty
public final javafx.beans.property.ObjectProperty<AxisMode> axisModeProperty()
The mode defining axis along which the zoom can be performed. By default initialized toAxisMode.XY.- Returns:
- the axis mode property
-
setAxisMode
public final void setAxisMode(AxisMode mode)
Sets the value of theaxisModeProperty().- Parameters:
mode- the mode to be used
-
getAxisMode
public final AxisMode getAxisMode()
Returns the value of theaxisModeProperty().- Returns:
- current mode
-
dragCursorProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Cursor> dragCursorProperty()
Mouse cursor to be used during drag operation.- Returns:
- the mouse cursor property
-
setDragCursor
public final void setDragCursor(javafx.scene.Cursor cursor)
Sets value of thedragCursorProperty().- Parameters:
cursor- the cursor to be used by the plugin
-
getDragCursor
public final javafx.scene.Cursor getDragCursor()
Returns the value of thedragCursorProperty()- Returns:
- the current cursor
-
animatedProperty
public final javafx.beans.property.BooleanProperty animatedProperty()
Whentruezooming will be animated. By default it'sfalse.- Returns:
- the animated property
- See Also:
zoomDurationProperty()
-
setAnimated
public final void setAnimated(boolean value)
Sets the value of theanimatedProperty().- Parameters:
value- iftruezoom will be animated- See Also:
setZoomDuration(Duration)
-
isAnimated
public final boolean isAnimated()
Returns the value of theanimatedProperty().- Returns:
trueif zoom is animated,falseotherwise- See Also:
getZoomDuration()
-
zoomDurationProperty
public final javafx.beans.property.ObjectProperty<javafx.util.Duration> zoomDurationProperty()
Duration of the animated zoom (in and out). Used only whenanimatedProperty()is set totrue. By default initialized to 500ms.- Returns:
- the zoom duration property
-
setZoomDuration
public final void setZoomDuration(javafx.util.Duration duration)
Sets the value of thezoomDurationProperty().- Parameters:
duration- duration of the zoom
-
getZoomDuration
public final javafx.util.Duration getZoomDuration()
Returns the value of thezoomDurationProperty().- Returns:
- the current zoom duration
-
updateTickUnitProperty
public final javafx.beans.property.BooleanProperty updateTickUnitProperty()
Whentruezooming will be animated. By default it'sfalse.- Returns:
- the animated property
- See Also:
zoomDurationProperty()
-
setUpdateTickUnit
public final void setUpdateTickUnit(boolean value)
Sets the value of theanimatedProperty().- Parameters:
value- iftruezoom will be animated- See Also:
setZoomDuration(Duration)
-
isUpdateTickUnit
public final boolean isUpdateTickUnit()
Returns the value of theanimatedProperty().- Returns:
trueif zoom is animated,falseotherwise- See Also:
getZoomDuration()
-
getRangeSlider
public org.controlsfx.control.RangeSlider getRangeSlider()
-
sliderVisibleProperty
public final javafx.beans.property.BooleanProperty sliderVisibleProperty()
Whentruean additional horizontal range slider is shown in a HiddeSidesPane at the bottom. By default it'strue.- Returns:
- the sliderVisible property
- See Also:
getRangeSlider()
-
setSliderVisible
public final void setSliderVisible(boolean state)
Sets the value of thesliderVisibleProperty().- Parameters:
state- iftruethe horizontal range slider is shown
-
isSliderVisible
public final boolean isSliderVisible()
Returns the value of thesliderVisibleProperty().- Returns:
trueif horizontal range slider is shown
-
zoomOrigin
public boolean zoomOrigin()
-
clear
public void clear()
Clears the stack of zoom windows saved during zoom-in operations.
-
-