public class MouseHoverInputMode extends Object implements IInputMode
IInputMode
that detects when the mouse hovers over the CanvasControl
.
This implementation will show a getToolTip(PointD)
ToolTip}. In order to make use of this instance one has to register
with the QueryToolTip
event. Setting a custom ValidHoverLocationHitTestable
will restrict the area where a tool tip can be shown.
This mode is Exclusive
by default.
Constructor and Description |
---|
MouseHoverInputMode()
Creates a new instance with default values.
|
MouseHoverInputMode(IEventHandler<ToolTipQueryEventArgs> textProvider)
Creates a new instance using the provided
ToolTip and query callback. |
Modifier and Type | Method and Description |
---|---|
void |
addQueryToolTipListener(IEventHandler<ToolTipQueryEventArgs> queryToolTipEvent)
Adds the given listener for the
QueryToolTip event that occurs when this mode queries the tool tip for a certain
query location. |
void |
cancel()
Called by the client to unconditionally cancel all editing.
|
protected IInputModeContext |
createHoverInputModeContext()
Creates an
IInputModeContext for use with the QueryToolTip event
for the upcoming text query operation. |
protected ConcurrencyController |
getController()
Returns the installed
Controller . |
Duration |
getDelay()
Gets the duration the mouse has to hover in one place to show a tool tip.
|
Duration |
getDuration()
Gets the duration to show the tool tip.
|
IInputModeContext |
getInputModeContext()
Returns the context instance this mode is currently installed in or
null if this instance is not installed. |
int |
getPriority()
The priority of this input mode.
|
protected Tooltip |
getToolTip(PointD location)
Callback method that provides a text for the given location or
null . |
protected PointD |
getToolTipLocation(PointD location)
Finds the position in canvas view coordinates to display the tool tip at for the given world coordinates.
|
PointD |
getToolTipLocationOffset()
Gets the tool tip location offset in view coordinates.
|
IHitTestable |
getValidHoverLocationHitTestable()
Gets an
IHitTestable that determines where the mouse may hover and a tool tip can be
shown . |
void |
hide()
Immediately hides the tool tip.
|
void |
install(IInputModeContext context,
ConcurrencyController controller)
Installs this mode into the given context that is provided by the canvas.
|
boolean |
isEnabled()
Gets the enabled state of this input mode.
|
boolean |
isExclusive()
Gets a value indicating whether this mode will be the only one running when it has the mutex.
|
boolean |
isShowing()
Determines whether the tool tip is currently showing.
|
protected void |
onCanceled()
Called after
cancel() has been called. |
protected void |
onConcurrencyControllerActivated()
|
protected void |
onConcurrencyControllerDeactivated()
|
protected void |
onHide()
Called when the tooltip should be hidden.
|
protected void |
onQueryToolTip(ToolTipQueryEventArgs args)
Raises the
QueryToolTip event. |
protected void |
onShow(PointD location)
Triggered when the mouse hovers over the given coordinates.
|
protected void |
onStopped()
Called after
stop() has been called. |
void |
removeQueryToolTipListener(IEventHandler<ToolTipQueryEventArgs> queryToolTipEvent)
Removes the given listener for the
QueryToolTip event that occurs when this mode queries the tool tip for a
certain query location. |
void |
setDelay(Duration value)
Sets the duration the mouse has to hover in one place to show a tool tip.
|
void |
setDuration(Duration value)
Sets the duration to show the tool tip.
|
void |
setEnabled(boolean value)
Sets the enabled state of this input mode.
|
void |
setExclusive(boolean value)
Sets a value indicating whether this mode will be the only one running when it has the mutex.
|
void |
setPriority(int value)
The priority of this input mode.
|
void |
setShowing(boolean value)
Determines whether the tool tip is currently showing.
|
void |
setToolTipLocationOffset(PointD value)
Sets the tool tip location offset in view coordinates.
|
void |
setValidHoverLocationHitTestable(IHitTestable value)
Sets an
IHitTestable that determines where the mouse may hover and a tool tip can be
shown . |
void |
show(PointD location)
Immediately shows the tool tip at the given location.
|
boolean |
stop()
Overridden to only return
true if this instance does not currently
have the input mutex . |
void |
uninstall(IInputModeContext context)
Uninstalls this mode from the given context.
|
public MouseHoverInputMode()
public MouseHoverInputMode(IEventHandler<ToolTipQueryEventArgs> textProvider)
ToolTip
and query callback.public final void addQueryToolTipListener(IEventHandler<ToolTipQueryEventArgs> queryToolTipEvent)
QueryToolTip
event that occurs when this mode queries the tool tip for a certain
query location.
Handlers should set the ToolTip
property or set/respect the Handled
property accordingly.
queryToolTipEvent
- The listener to add.removeQueryToolTipListener(IEventHandler)
public void cancel()
IInputMode
This will be called prior to the uninstalling of this instance.
In order to stop an active input mode manually, client code should use the following idiom:
cancel
in interface IInputMode
protected IInputModeContext createHoverInputModeContext()
IInputModeContext
for use with the QueryToolTip
event
for the upcoming text query operation.IInputModeContext
.protected final ConcurrencyController getController()
Controller
.public final Duration getDelay()
The default is
1
second.
setDelay(Duration)
public final Duration getDuration()
The default value is 3 seconds.
setDuration(Duration)
public final IInputModeContext getInputModeContext()
IInputMode
null
if this instance is not installed.
Note that this instance should not be passed down to subordinate modes or instances. Instead a corresponding context
that has this instance set as the ParentInputMode
should be used.
getInputModeContext
in interface IInputMode
public final int getPriority()
IInputMode
The priority will influence the order in which the modes will be installed
into the canvas control. The lower the priority value, the earlier it will be installed. If two modes are installed
using the same priority value, the first one will be installed earlier.
getPriority
in interface IInputMode
protected Tooltip getToolTip(PointD location)
null
.location
- The location to find a text for.null
to indicate that no tool tip should be shown.addQueryToolTipListener(IEventHandler)
,
createHoverInputModeContext()
protected PointD getToolTipLocation(PointD location)
This method adds the ToolTipLocationOffset
after converting the given location to
view coordinates.
location
- The position in world coordinates.getToolTipLocationOffset()
public final PointD getToolTipLocationOffset()
The value of this property is used by getToolTipLocation(PointD)
in order to move the tool tip away from the
mouse pointer. The default value is (0,0).
getToolTipLocation(PointD)
,
setToolTipLocationOffset(PointD)
public final IHitTestable getValidHoverLocationHitTestable()
IHitTestable
that determines where the mouse may hover and a tool tip can be
shown
.
The default value of this property is IHitTestable.ALWAYS
setValidHoverLocationHitTestable(IHitTestable)
public void hide()
public void install(IInputModeContext context, ConcurrencyController controller)
In general a mode can only be installed into a single canvas at all times.
This method is called to initialize this instance. Subclasses should override this method to register the corresponding event handler delegates for the various input events they need to register with.
Overriding implementations should call the base implementation, first.
install
in interface IInputMode
context
- The context that this instance shall be installed into. The same instance will be passed to this instance during
IInputMode.uninstall(IInputModeContext)
. A reference to the context may be kept and queried during the time
the mode is installed.controller
- The Controller
for this mode.IInputMode.uninstall(IInputModeContext)
public boolean isEnabled()
Clients can use this property to disable or reenable this instance. This will set the Enabled
property of the installed Controller
so a disabled instance should never try to acquire the
input mutex.
setEnabled(boolean)
public final boolean isExclusive()
The value of this property will be delegated to the Exclusive
property of
the Controller
.
If this mode is marked as exclusive and has the mutex, all other modes added
to the same MultiplexingInputMode
will be deactivated. Otherwise it will always run
concurrently with all other modes.
setExclusive(boolean)
public final boolean isShowing()
setShowing(boolean)
protected void onCanceled()
cancel()
has been called.
Can be overridden in subclasses to perform additional actions after the mode has been canceled.
This implementation does nothing.
protected void onConcurrencyControllerActivated()
Active
property of the installed ConcurrencyController
has been set to true
.
Can be overridden in subclasses to perform additional actions after the mode has been activated.
Overriding implementations should call the base implementation.
protected void onConcurrencyControllerDeactivated()
Active
property of the installed ConcurrencyController
has been set to false
.
Can be overridden in subclasses to perform additional actions after the mode has been deactivated.
Overriding implementations should call the base implementation.
protected void onHide()
protected void onQueryToolTip(ToolTipQueryEventArgs args)
QueryToolTip
event.args
- The ToolTipQueryEventArgs
instance containing the event data.protected void onShow(PointD location)
This method will call getToolTip(PointD)
to query tooltip to display
at the location returned by getToolTipLocation(PointD)
if the content is not null
.
protected void onStopped()
stop()
has been called.
Can be overridden in subclasses to perform additional actions after the mode has been stopped.
This implementation does nothing.
public final void removeQueryToolTipListener(IEventHandler<ToolTipQueryEventArgs> queryToolTipEvent)
QueryToolTip
event that occurs when this mode queries the tool tip for a
certain query location.
Handlers should set the ToolTip
property or set/respect the Handled
property accordingly.
queryToolTipEvent
- The listener to remove.addQueryToolTipListener(IEventHandler)
public final void setDelay(Duration value)
The default is
1
second.
value
- The Delay to set.getDelay()
public final void setDuration(Duration value)
The default value is 3 seconds.
value
- The Duration to set.getDuration()
public void setEnabled(boolean value)
Clients can use this property to disable or reenable this instance. This will set the Enabled
property of the installed Controller
so a disabled instance should never try to acquire the
input mutex.
value
- The Enabled to set.isEnabled()
public final void setExclusive(boolean value)
The value of this property will be delegated to the Exclusive
property of
the Controller
.
If this mode is marked as exclusive and has the mutex, all other modes added
to the same MultiplexingInputMode
will be deactivated. Otherwise it will always run
concurrently with all other modes.
value
- The Exclusive to set.isExclusive()
public final void setPriority(int value)
The priority will influence the order in which the modes will be installed
into the canvas control. The lower the priority value, the earlier it will be installed. If two modes are installed
using the same priority value, the first one will be installed earlier.
value
- The Priority to set.getPriority()
public final void setShowing(boolean value)
value
- The Showing to set.isShowing()
public final void setToolTipLocationOffset(PointD value)
The value of this property is used by getToolTipLocation(PointD)
in order to move the tool tip away from the
mouse pointer. The default value is (0,0).
value
- The ToolTipLocationOffset to set.getToolTipLocation(PointD)
,
getToolTipLocationOffset()
public final void setValidHoverLocationHitTestable(IHitTestable value)
IHitTestable
that determines where the mouse may hover and a tool tip can be
shown
.
The default value of this property is IHitTestable.ALWAYS
value
- The ValidHoverLocationHitTestable to set.getValidHoverLocationHitTestable()
public void show(PointD location)
location
- The location in the world coordinate system.public boolean stop()
true
if this instance does not currently
have the input mutex
.stop
in interface IInputMode
true
iff this instance does not own the mutex
.IInputMode.cancel()
public void uninstall(IInputModeContext context)
This code should clean up all changes made to the canvas in the IInputMode.install(IInputModeContext, ConcurrencyController)
method. After a mode has been uninstalled it can be installed again into the same or another canvas.
Overriding implementations should call the base implementation after their own code.
uninstall
in interface IInputMode
context
- The context to deregister from. This is the same instance that had been passed to IInputMode.install(IInputModeContext, ConcurrencyController)
during installation.