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.
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classZoomer.ZoomStatesmall class used to remember whether the autorange axis was on/off to be able to restore the original state on unzooming
-
Field Summary
Fields Modifier and Type Field Description static java.util.function.Predicate<javafx.scene.input.MouseEvent>DEFAULT_MOUSE_FILTERDefault pan mouse filter passing on left mouse button withcontrol key down.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_RECTstatic java.lang.StringZOOMER_OMIT_AXIS
-
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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description javafx.beans.property.BooleanPropertyanimatedProperty()Whentruezooming will be animated.javafx.beans.property.BooleanPropertyautoZoomEnabledProperty()Whentrueauto-zooming feature is being enabled, ie.javafx.beans.property.IntegerPropertyautoZoomThresholdProperty()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.voidclear(Axis axis)Clears the stack of zoom states saved during zoom-in operations for a specific given axis.javafx.beans.property.ObjectProperty<javafx.scene.Cursor>dragCursorProperty()Mouse cursor to be used during drag operation.intgetAutoZoomThreshold()AxisModegetAxisMode()Returns the value of theaxisModeProperty().javafx.scene.CursorgetDragCursor()Returns the value of thedragCursorProperty()org.controlsfx.control.RangeSlidergetRangeSlider()javafx.scene.CursorgetZoomCursor()Returns the value of thezoomCursorProperty()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().booleanisAutoZoomEnabled()static booleanisOmitZoom(Axis axis)booleanisPannerEnabled()booleanisSliderVisible()Returns the value of thesliderVisibleProperty().booleanisUpdateTickUnit()Returns the value of theanimatedProperty().javafx.collections.ObservableList<Axis>omitAxisZoomList()javafx.beans.property.BooleanPropertypannerEnabledProperty()Whentruepressing the middle mouse button and dragging pans the plotvoidsetAnimated(boolean value)Sets the value of theanimatedProperty().voidsetAutoZoomEnabled(boolean state)Sets the value of theautoZoomEnabledProperty().voidsetAutoZoomThreshold(int value)voidsetAxisMode(AxisMode mode)Sets the value of theaxisModeProperty().voidsetDragCursor(javafx.scene.Cursor cursor)Sets value of thedragCursorProperty().static voidsetOmitZoom(Axis axis, boolean state)voidsetPannerEnabled(boolean state)Sets the value of thesliderVisibleProperty().voidsetSliderVisible(boolean state)Sets the value of thesliderVisibleProperty().voidsetUpdateTickUnit(boolean value)Sets the value of theanimatedProperty().voidsetZoomCursor(javafx.scene.Cursor cursor)Sets value of thezoomCursorProperty().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.scene.Cursor>zoomCursorProperty()Mouse cursor to be used during zoom operation.javafx.beans.property.ObjectProperty<javafx.util.Duration>zoomDurationProperty()Duration of the animated zoom (in and out).booleanzoomOrigin()ObservableDeque<java.util.Map<Axis,Zoomer.ZoomState>>zoomStackDeque()-
Methods inherited from class de.gsi.chart.plugins.ChartPlugin
addButtonsToToolBarProperty, chartProperty, getChart, getChartChildren, getLocationInPlotArea, isAddButtonsToToolBar, layoutChildren, registerInputEventHandler, setAddButtonsToToolBar, setChart, toDataPoint, toDisplayPoint
-
-
-
-
Field Detail
-
ZOOMER_OMIT_AXIS
public static final java.lang.String ZOOMER_OMIT_AXIS
- See Also:
- Constant Field Values
-
STYLE_CLASS_ZOOM_RECT
public static final java.lang.String STYLE_CLASS_ZOOM_RECT
- See Also:
- Constant Field Values
-
DEFAULT_MOUSE_FILTER
public static final java.util.function.Predicate<javafx.scene.input.MouseEvent> DEFAULT_MOUSE_FILTER
Default pan mouse filter passing on left mouse button withcontrol key down.
-
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(AxisMode zoomMode, boolean animated)
Creates a new instance of Zoomer.
-
Zoomer
public Zoomer(boolean animated)
Creates a new instance of Zoomer withzoomModeinitialized toAxisMode.XY.- Parameters:
animated- initial value ofanimatedproperty
-
-
Method Detail
-
animatedProperty
public final javafx.beans.property.BooleanProperty animatedProperty()
Whentruezooming will be animated. By default it'sfalse.- Returns:
- the animated property
- See Also:
zoomDurationProperty()
-
autoZoomEnabledProperty
public final javafx.beans.property.BooleanProperty autoZoomEnabledProperty()
Whentrueauto-zooming feature is being enabled, ie. more horizontal drags do x-zoom only, more vertical drags do y-zoom only, and xy-zoom otherwise- Returns:
- the autoZoom property
-
autoZoomThresholdProperty
public javafx.beans.property.IntegerProperty autoZoomThresholdProperty()
-
axisModeProperty
public final javafx.beans.property.ObjectProperty<AxisMode> axisModeProperty()
The mode defining axis along which the zoom can be performed. By default initialised toAxisMode.XY.- Returns:
- the axis mode property
-
clear
public void clear()
Clears the stack of zoom windows saved during zoom-in operations.
-
clear
public void clear(Axis axis)
Clears the stack of zoom states saved during zoom-in operations for a specific given axis.- Parameters:
axis- axis zoom history that shall be removed
-
dragCursorProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Cursor> dragCursorProperty()
Mouse cursor to be used during drag operation.- Returns:
- the mouse cursor property
-
getAutoZoomThreshold
public int getAutoZoomThreshold()
-
getAxisMode
public final AxisMode getAxisMode()
Returns the value of theaxisModeProperty().- Returns:
- current mode
-
getDragCursor
public final javafx.scene.Cursor getDragCursor()
Returns the value of thedragCursorProperty()- Returns:
- the current cursor
-
getRangeSlider
public org.controlsfx.control.RangeSlider getRangeSlider()
-
getZoomCursor
public final javafx.scene.Cursor getZoomCursor()
Returns the value of thezoomCursorProperty()- Returns:
- the current cursor
-
getZoomDuration
public final javafx.util.Duration getZoomDuration()
Returns the value of thezoomDurationProperty().- Returns:
- the current zoom duration
-
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)
-
getZoomInteractorBar
public javafx.scene.layout.HBox getZoomInteractorBar()
-
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)
-
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)
-
getZoomScrollFilter
public java.util.function.Predicate<javafx.scene.input.ScrollEvent> getZoomScrollFilter()
Returns zoom-scroll filter.- Returns:
- predicate of filter
-
isAnimated
public final boolean isAnimated()
Returns the value of theanimatedProperty().- Returns:
trueif zoom is animated,falseotherwise- See Also:
getZoomDuration()
-
isAutoZoomEnabled
public final boolean isAutoZoomEnabled()
- Returns:
trueif auto-zooming feature is being enabled, ie. more horizontal drags do x-zoom only, more vertical drags do y-zoom only, and xy-zoom otherwise
-
isPannerEnabled
public final boolean isPannerEnabled()
-
isSliderVisible
public final boolean isSliderVisible()
Returns the value of thesliderVisibleProperty().- Returns:
trueif horizontal range slider is shown
-
isUpdateTickUnit
public final boolean isUpdateTickUnit()
Returns the value of theanimatedProperty().- Returns:
trueif zoom is animated,falseotherwise- See Also:
getZoomDuration()
-
omitAxisZoomList
public final javafx.collections.ObservableList<Axis> omitAxisZoomList()
- Returns:
- list of axes that shall be ignored when performing zoom-in or outs
-
pannerEnabledProperty
public final javafx.beans.property.BooleanProperty pannerEnabledProperty()
Whentruepressing the middle mouse button and dragging pans the plot- Returns:
- the pannerEnabled property
-
setAnimated
public final void setAnimated(boolean value)
Sets the value of theanimatedProperty().- Parameters:
value- iftruezoom will be animated- See Also:
setZoomDuration(Duration)
-
setAutoZoomEnabled
public final void setAutoZoomEnabled(boolean state)
Sets the value of theautoZoomEnabledProperty().- Parameters:
state- iftrueauto-zooming feature is being enabled, ie. more horizontal drags do x-zoom only, more vertical drags do y-zoom only, and xy-zoom otherwise
-
setAutoZoomThreshold
public void setAutoZoomThreshold(int value)
-
setAxisMode
public final void setAxisMode(AxisMode mode)
Sets the value of theaxisModeProperty().- Parameters:
mode- the mode to be used
-
setDragCursor
public final void setDragCursor(javafx.scene.Cursor cursor)
Sets value of thedragCursorProperty().- Parameters:
cursor- the cursor to be used by the plugin
-
setPannerEnabled
public final void setPannerEnabled(boolean state)
Sets the value of thesliderVisibleProperty().- Parameters:
state- iftruethe panner (middle mouse button is enabled
-
setSliderVisible
public final void setSliderVisible(boolean state)
Sets the value of thesliderVisibleProperty().- Parameters:
state- iftruethe horizontal range slider is shown
-
setUpdateTickUnit
public final void setUpdateTickUnit(boolean value)
Sets the value of theanimatedProperty().- Parameters:
value- iftruezoom will be animated- See Also:
setZoomDuration(Duration)
-
setZoomCursor
public final void setZoomCursor(javafx.scene.Cursor cursor)
Sets value of thezoomCursorProperty().- Parameters:
cursor- the cursor to be used by the plugin
-
setZoomDuration
public final void setZoomDuration(javafx.util.Duration duration)
Sets the value of thezoomDurationProperty().- Parameters:
duration- duration of the zoom
-
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()
-
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()
-
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()
-
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
-
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()
-
updateTickUnitProperty
public final javafx.beans.property.BooleanProperty updateTickUnitProperty()
Whentruezooming will be animated. By default it'sfalse.- Returns:
- the animated property
- See Also:
zoomDurationProperty()
-
zoomCursorProperty
public final javafx.beans.property.ObjectProperty<javafx.scene.Cursor> zoomCursorProperty()
Mouse cursor to be used during zoom operation.- Returns:
- the mouse cursor property
-
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 initialised to 500ms.- Returns:
- the zoom duration property
-
zoomOrigin
public boolean zoomOrigin()
-
zoomStackDeque
public ObservableDeque<java.util.Map<Axis,Zoomer.ZoomState>> zoomStackDeque()
- Returns:
- observable queue (allows to attach ListChangeListener listener)
-
isOmitZoom
public static boolean isOmitZoom(Axis axis)
- Parameters:
axis- the axis to be modified- Returns:
trueif axis is zoomable,falseotherwise
-
setOmitZoom
public static void setOmitZoom(Axis axis, boolean state)
- Parameters:
axis- the axis to be modifiedstate- true: axis is not taken into account when zooming
-
-