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_PRESSED
event 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_CLICKED
event that is accepted byzoom-out filter
. It restores the previous ranges on both axis. - zoom-origin - triggered on
MOUSE_CLICKED
event 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 class
Zoomer.ZoomState
small 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_FILTER
Default pan mouse filter passing on left mouse button withcontrol key down
.java.util.function.Predicate<javafx.scene.input.ScrollEvent>
defaultScrollFilter
Default zoom scroll filter withcontrol key down
.java.util.function.Predicate<javafx.scene.input.MouseEvent>
defaultZoomInMouseFilter
Default zoom-in mouse filter passing on left mouse button (only).java.util.function.Predicate<javafx.scene.input.MouseEvent>
defaultZoomOriginFilter
Default zoom-origin mouse filter passing on right mouse button withcontrol key down
.java.util.function.Predicate<javafx.scene.input.MouseEvent>
defaultZoomOutMouseFilter
Default zoom-out mouse filter passing on right mouse button (only).static java.lang.String
STYLE_CLASS_ZOOM_RECT
static java.lang.String
ZOOMER_OMIT_AXIS
-
Constructor Summary
Constructors Constructor Description Zoomer()
Creates a new instance of Zoomer with animation disabled and withzoomMode
initialized toAxisMode.XY
.Zoomer(boolean animated)
Creates a new instance of Zoomer withzoomMode
initialized 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.BooleanProperty
animatedProperty()
Whentrue
zooming will be animated.javafx.beans.property.BooleanProperty
autoZoomEnabledProperty()
Whentrue
auto-zooming feature is being enabled, ie.javafx.beans.property.IntegerProperty
autoZoomThresholdProperty()
javafx.beans.property.ObjectProperty<AxisMode>
axisModeProperty()
The mode defining axis along which the zoom can be performed.void
clear()
Clears the stack of zoom windows saved during zoom-in operations.void
clear(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.int
getAutoZoomThreshold()
AxisMode
getAxisMode()
Returns the value of theaxisModeProperty()
.javafx.scene.Cursor
getDragCursor()
Returns the value of thedragCursorProperty()
org.controlsfx.control.RangeSlider
getRangeSlider()
javafx.scene.Cursor
getZoomCursor()
Returns the value of thezoomCursorProperty()
javafx.util.Duration
getZoomDuration()
Returns the value of thezoomDurationProperty()
.java.util.function.Predicate<javafx.scene.input.MouseEvent>
getZoomInMouseFilter()
Returns zoom-in mouse event filter.javafx.scene.layout.HBox
getZoomInteractorBar()
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.protected static boolean
hasBoundedRange(Axis axis)
boolean
isAnimated()
Returns the value of theanimatedProperty()
.boolean
isAutoZoomEnabled()
static boolean
isOmitZoom(Axis axis)
boolean
isPannerEnabled()
boolean
isSliderVisible()
Returns the value of thesliderVisibleProperty()
.boolean
isUpdateTickUnit()
Returns the value of theanimatedProperty()
.javafx.collections.ObservableList<Axis>
omitAxisZoomList()
javafx.beans.property.BooleanProperty
pannerEnabledProperty()
Whentrue
pressing the middle mouse button and dragging pans the plotvoid
setAnimated(boolean value)
Sets the value of theanimatedProperty()
.void
setAutoZoomEnabled(boolean state)
Sets the value of theautoZoomEnabledProperty()
.void
setAutoZoomThreshold(int value)
void
setAxisMode(AxisMode mode)
Sets the value of theaxisModeProperty()
.void
setDragCursor(javafx.scene.Cursor cursor)
Sets value of thedragCursorProperty()
.static void
setOmitZoom(Axis axis, boolean state)
void
setPannerEnabled(boolean state)
Sets the value of thepannerEnabledProperty()
.void
setSliderVisible(boolean state)
Sets the value of thesliderVisibleProperty()
.void
setUpdateTickUnit(boolean value)
Sets the value of theanimatedProperty()
.void
setZoomCursor(javafx.scene.Cursor cursor)
Sets value of thezoomCursorProperty()
.void
setZoomDuration(javafx.util.Duration duration)
Sets the value of thezoomDurationProperty()
.void
setZoomInMouseFilter(java.util.function.Predicate<javafx.scene.input.MouseEvent> zoomInMouseFilter)
Sets filter onDRAG_DETECTED
events that should start zoom-in operation.void
setZoomOriginMouseFilter(java.util.function.Predicate<javafx.scene.input.MouseEvent> zoomOriginMouseFilter)
Sets filter onMOUSE_CLICKED
events that should trigger zoom-origin operation.void
setZoomOutMouseFilter(java.util.function.Predicate<javafx.scene.input.MouseEvent> zoomOutMouseFilter)
Sets filter onMOUSE_CLICKED
events that should trigger zoom-out operation.void
setZoomScrollFilter(java.util.function.Predicate<javafx.scene.input.ScrollEvent> zoomScrollFilter)
Sets filter onMOUSE_CLICKED
events that should trigger zoom-origin operation.javafx.beans.property.BooleanProperty
sliderVisibleProperty()
Whentrue
an additional horizontal range slider is shown in a HiddeSidesPane at the bottom.javafx.beans.property.BooleanProperty
updateTickUnitProperty()
Whentrue
zooming 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).boolean
zoomOrigin()
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 withzoomMode
initialized toAxisMode.XY
.
-
Zoomer
public Zoomer(AxisMode zoomMode)
Creates a new instance of Zoomer with animation disabled.- Parameters:
zoomMode
- initial value ofzoomMode
property
-
Zoomer
public Zoomer(AxisMode zoomMode, boolean animated)
Creates a new instance of Zoomer.
-
Zoomer
public Zoomer(boolean animated)
Creates a new instance of Zoomer withzoomMode
initialized toAxisMode.XY
.- Parameters:
animated
- initial value ofanimated
property
-
-
Method Detail
-
animatedProperty
public final javafx.beans.property.BooleanProperty animatedProperty()
Whentrue
zooming will be animated. By default it'sfalse
.- Returns:
- the animated property
- See Also:
zoomDurationProperty()
-
autoZoomEnabledProperty
public final javafx.beans.property.BooleanProperty autoZoomEnabledProperty()
Whentrue
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- 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:
true
if zoom is animated,false
otherwise- See Also:
getZoomDuration()
-
isAutoZoomEnabled
public final boolean isAutoZoomEnabled()
- Returns:
true
if 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:
true
if horizontal range slider is shown
-
isUpdateTickUnit
public final boolean isUpdateTickUnit()
Returns the value of theanimatedProperty()
.- Returns:
true
if zoom is animated,false
otherwise- 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()
Whentrue
pressing 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
- iftrue
zoom will be animated- See Also:
setZoomDuration(Duration)
-
setAutoZoomEnabled
public final void setAutoZoomEnabled(boolean state)
Sets the value of theautoZoomEnabledProperty()
.- Parameters:
state
- iftrue
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
-
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 thepannerEnabledProperty()
.- Parameters:
state
- iftrue
the panner (middle mouse button is enabled
-
setSliderVisible
public final void setSliderVisible(boolean state)
Sets the value of thesliderVisibleProperty()
.- Parameters:
state
- iftrue
the horizontal range slider is shown
-
setUpdateTickUnit
public final void setUpdateTickUnit(boolean value)
Sets the value of theanimatedProperty()
.- Parameters:
value
- iftrue
zoom 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_DETECTED
events that should start zoom-in operation.- Parameters:
zoomInMouseFilter
- the filter to accept zoom-in mouse event. Ifnull
then 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_CLICKED
events that should trigger zoom-origin operation.- Parameters:
zoomOriginMouseFilter
- the filter to accept zoom-origin mouse event. Ifnull
then 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_CLICKED
events that should trigger zoom-out operation.- Parameters:
zoomOutMouseFilter
- the filter to accept zoom-out mouse event. Ifnull
then 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_CLICKED
events that should trigger zoom-origin operation.- Parameters:
zoomScrollFilter
- filter
-
sliderVisibleProperty
public final javafx.beans.property.BooleanProperty sliderVisibleProperty()
Whentrue
an 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()
Whentrue
zooming 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)
-
hasBoundedRange
protected static boolean hasBoundedRange(Axis axis)
-
isOmitZoom
public static boolean isOmitZoom(Axis axis)
- Parameters:
axis
- the axis to be modified- Returns:
true
if axis is zoomable,false
otherwise
-
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
-
-