public class ItemHoverInputMode extends Object implements IInputMode
GraphControl that fires events when the mouse enters or leaves
the visualization of a graph item.
This mode can be used to determine when the mouse is being moved from one item to the next.
This mode is Exclusive by default.
| Constructor and Description |
|---|
ItemHoverInputMode()
Initializes a new instance of the
ItemHoverInputMode class. |
| Modifier and Type | Method and Description |
|---|---|
void |
addHoveredItemChangedListener(IEventHandler<HoveredItemChangedEventArgs> hoveredItemChangedEvent)
Adds the given listener for the
HoveredItemChanged event that occurs when the item that is being hovered over
with the mouse changes. |
void |
cancel()
Called by the client to unconditionally cancel all editing.
|
protected ConcurrencyController |
getController()
Returns the installed
Controller. |
IModelItem |
getCurrentHoverItem()
Gets the current item the mouse is hovering over.
|
protected Iterable<IModelItem> |
getHitItemsAt(PointD location)
Gets the items that have been hit at the given location.
|
Cursor |
getHoverCursor()
Gets the cursor to use when the mouse is hovering over a
isValidHoverItem(IModelItem) valid hover item. |
GraphItemTypes |
getHoverItems()
Gets which graph items are considered by this input mode.
|
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.
|
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 |
isInvalidItemsDiscardingEnabled()
Determines whether items that have been hit at the current location that are not
valid items
should be ignored or reported as null. |
protected boolean |
isValidHoverItem(IModelItem item)
Determines whether the given item is a valid item to be considered for hovering.
|
protected void |
onCanceled()
Called after
cancel() has been called. |
protected void |
onConcurrencyControllerActivated()
|
protected void |
onConcurrencyControllerDeactivated()
|
protected void |
onHoveredItemChanged(HoveredItemChangedEventArgs hoveredItemChangedEventArgs)
Raises the
HoveredItemChanged event. |
protected void |
onStopped()
Called after
stop() has been called. |
void |
removeHoveredItemChangedListener(IEventHandler<HoveredItemChangedEventArgs> hoveredItemChangedEvent)
Removes the given listener for the
HoveredItemChanged event that occurs when the item that is being hovered over
with the mouse changes. |
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 |
setHoverCursor(Cursor value)
Sets the cursor to use when the mouse is hovering over a
isValidHoverItem(IModelItem) valid hover item. |
void |
setHoverItems(GraphItemTypes value)
Sets which graph items are considered by this input mode.
|
void |
setInvalidItemsDiscardingEnabled(boolean value)
Determines whether items that have been hit at the current location that are not
valid items
should be ignored or reported as null. |
void |
setPriority(int value)
The priority of this input mode.
|
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.
|
void |
updateHover()
Forces a reevaluation of the item that the mouse is currently hovering over or at a specific location.
|
void |
updateHover(PointD location)
Forces a reevaluation of the item that the mouse is currently hovering over or at a specific location.
|
public ItemHoverInputMode()
ItemHoverInputMode class.public final void addHoveredItemChangedListener(IEventHandler<HoveredItemChangedEventArgs> hoveredItemChangedEvent)
HoveredItemChanged event that occurs when the item that is being hovered over
with the mouse changes.
This event is also fired when the mouse pointer leaves an item.
hoveredItemChangedEvent - The listener to add.removeHoveredItemChangedListener(IEventHandler)public void cancel()
IInputModeThis 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 IInputModeprotected final ConcurrencyController getController()
Controller.public final IModelItem getCurrentHoverItem()
null if the mouse is not hovering over a valid item.protected Iterable<IModelItem> getHitItemsAt(PointD location)
location - The location in world coordinates to query.public final Cursor getHoverCursor()
isValidHoverItem(IModelItem) valid hover item.null (the default).setHoverCursor(Cursor)public final GraphItemTypes getHoverItems()
The default is GraphItemTypes.ALL.
setHoverItems(GraphItemTypes)public final IInputModeContext getInputModeContext()
IInputModenull 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 IInputModepublic 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 IInputModepublic 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 IInputModecontext - 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 isInvalidItemsDiscardingEnabled()
valid items
should be ignored or reported as null.true if invalid items should be reported as null; otherwise, false, in which case the hit test
enumeration continues to find the next valid item. The default is true.isValidHoverItem(IModelItem),
setInvalidItemsDiscardingEnabled(boolean)protected boolean isValidHoverItem(IModelItem item)
This implementation checks whether the item is covered by the HoverItems set, only.
item - The item to check.true if it is valid to report a hover over the specified item; false otherwise.isInvalidItemsDiscardingEnabled()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 onHoveredItemChanged(HoveredItemChangedEventArgs hoveredItemChangedEventArgs)
HoveredItemChanged event.hoveredItemChangedEventArgs - The HoveredItemChangedEventArgs instance containing the event data.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 removeHoveredItemChangedListener(IEventHandler<HoveredItemChangedEventArgs> hoveredItemChangedEvent)
HoveredItemChanged event that occurs when the item that is being hovered over
with the mouse changes.
This event is also fired when the mouse pointer leaves an item.
hoveredItemChangedEvent - The listener to remove.addHoveredItemChangedListener(IEventHandler)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 setHoverCursor(Cursor value)
isValidHoverItem(IModelItem) valid hover item.value - The hover cursor or null (the default).getHoverCursor()public final void setHoverItems(GraphItemTypes value)
The default is GraphItemTypes.ALL.
value - The HoverItems to set.getHoverItems()public final void setInvalidItemsDiscardingEnabled(boolean value)
valid items
should be ignored or reported as null.value - true if invalid items should be reported as null; otherwise, false, in which case the hit test
enumeration continues to find the next valid item. The default is true.isValidHoverItem(IModelItem),
isInvalidItemsDiscardingEnabled()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 boolean stop()
true if this instance does not currently
have the input mutex.stop in interface IInputModetrue 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 IInputModecontext - The context to deregister from. This is the same instance that had been passed to IInputMode.install(IInputModeContext, ConcurrencyController)
during installation.public final void updateHover()
This method may be called by code that is aware of the fact that the visualization has changed, but the mouse may not have been moved. By default this implementation will only re-query the items at the mouse location when the mouse has moved. This method can be called to force a reevaluation in other cases.
public final void updateHover(PointD location)
This method may be called by code that is aware of the fact that the visualization has changed, but the mouse may not have been moved. By default this implementation will only re-query the items at the mouse location when the mouse has moved. This method can be called to force a reevaluation in other cases.
location - The query location.