Class Tool
java.lang.Object
com.levigo.jadice.web.client.tool.Tool
- All Implemented Interfaces:
MenuContributor
- Direct Known Subclasses:
AnnotationTool,AreaSelectionTool,CrossHairTool,DoubleTapZoomTool,GalleryNavigationTool,GoogleMapsTool,GoogleSearchTool,GridTool,HighlightTool,HoverLensTool,KeyboardNavigationTool,LinkTool,MouseWheelScrollTool,MouseWheelZoomTool,PanForceTool,PanTool,PDFSignatureBoxTool,PointerScrollTool,PopupMenuTool,PopupSubMenuTool,SelectPageTool,SetCurrentPageTool,TextSearchTool,TextSelectionTool,TextSelectionTouchTool,TextToSpeechTool,ThumbnailTool,TwoFingerGestureTool,VisibleBoundsTool,WikipediaSearchTool
This abstract class must be sub-classed in order to contribute additional functionality to
page-visualization components like the
JadicePageView, or the ThumbnailView.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class describes an auto-activation request issued by a tool in response to an event. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe default priority used with respect to dispatching or rendering.static final intThe maximum priority a tool is supposed to use with respect to dispatching or rendering.static final intThe minimum priority a tool is supposed to use with respect to dispatching or rendering. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcontribute(ContributionContext context, MenuBuilder menuBuilder) This method is called in order to give the menu contributor a chance to contribute context menu entries via the suppliedMenuBuilder.voidensureDebugId(String baseID) protected Tool.ActivationRequestProvide feedback for the user about what would happen, if the mouse were pressed at the current location.protected Tool.ActivationRequestProvide feedback for the user about what would happen, if the finger were moved from the current location.protected Tool.ActivationRequestReturn the auto-activation request for this this tool in response to the given event.protected Tool.ActivationRequestReturn the auto-activation request for this this tool in response to the given key press.protected Tool.ActivationRequestReturn the auto-activation request for this this tool in response to the given mouse drag event.protected Tool.ActivationRequestReturn the auto-activation request for this this tool in response to the given mouse press.protected Tool.ActivationRequestReturn the auto-activation request for this this tool in response to a touch move.protected Tool.ActivationRequestReturn the auto-activation request for this this tool in response to a touch start.protected intReturn the dispatch priority for this tool.protected ToolManagerReturn the current tool manager.protected intReturn the render priority for this tool.protected voidhandleEditEvent(boolean isActive, EditEvent e) Handle the givenEditEvent.protected voidInvoked when a multi touch gesture changed.protected voidInvoked when a multi touch gesture ended.protected voidInvoked when a multi touch gesture started.protected voidhandleKeyPressed(KeyEditEvent e, boolean isActive) Invoked when a key has been pressed.protected voidhandleKeyReleased(KeyEditEvent e, boolean isActive) Invoked when a key has been released.protected voidhandleKeyTyped(KeyEditEvent e, boolean isActive) Invoked when a key has been typed.protected voidhandleMouseClicked(MouseEditEvent e, boolean isActive) Invoked when the mouse button has been clicked (pressed and released) on a component.protected voidhandleMouseDragged(MouseEditEvent e, boolean isActive) Invoked when a mouse button is pressed on a component and then dragged.protected voidhandleMouseEntered(MouseEditEvent e, boolean isActive) Invoked when the mouse cursor enters the unobscured part of component's geometry.protected voidhandleMouseExited(MouseEditEvent e, boolean isActive) Invoked when the mouse cursor exits the unobscured part of component's geometry.protected voidhandleMouseMoved(MouseEditEvent e, boolean isActive) Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.protected voidhandleMousePressed(MouseEditEvent e, boolean isActive) Invoked when a mouse button has been pressed on a component.protected voidhandleMouseReleased(MouseEditEvent e, boolean isActive) Invoked when a mouse button has been released on a component.protected voidhandleMouseWheelMoved(MouseWheelEditEvent e, boolean isActive) Invoked when the mouse wheel is rotated.protected voidhandlePointerDown(PointerEditEvent e, boolean isActive) Invoked when a pointer event starts.protected voidhandlePointerMove(PointerEditEvent e, boolean isActive) Invoked when a pointer event move.protected voidhandlePointerUp(PointerEditEvent e, boolean isActive) Invoked when a pointer event ends.protected voidhandleTouchEnd(TouchEditEvent e, boolean isActive) Invoked when a touch ended.protected voidhandleTouchMove(TouchEditEvent e, boolean isActive) Invoked when a touch changed.protected voidhandleTouchStart(TouchEditEvent e, boolean isActive) Invoked when a touch started.protected voidpropagatePropertyChange(String name, Object oldValue, Object newValue) protected voidrender(RenderParameters parameters, boolean isActive) Renders the Tool's UI onto the givenGraphics2Dcontext using the givenRenderControls.protected voidsetActive(boolean active) Receive notification from the tool manager about the tool's active state.protected voidsetCursor(com.google.gwt.dom.client.Style.Cursor cursor) Deprecated.Use setCursor(String) instead.protected voidSet the cursor on the associated view component.protected voidsetEnabled(boolean enabled) Receive notification from the tool manager about the tool's enabled state.protected voidsetManager(ToolManager manager) Receives theToolManagerinstance, which theToolimplementation has been registered for.protected voidsetStatusFeedback(String feedback) Set the status feedback message published by the tool manager usingToolManager.getStatusFeedback().
-
Field Details
-
MIN_PRIORITY
public static final int MIN_PRIORITYThe minimum priority a tool is supposed to use with respect to dispatching or rendering.- See Also:
-
MAX_PRIORITY
public static final int MAX_PRIORITYThe maximum priority a tool is supposed to use with respect to dispatching or rendering.- See Also:
-
DEFAULT_PRIORITY
public static final int DEFAULT_PRIORITYThe default priority used with respect to dispatching or rendering.- See Also:
-
-
Constructor Details
-
Tool
public Tool()
-
-
Method Details
-
ensureDebugId
-
render
Renders the Tool's UI onto the givenGraphics2Dcontext using the givenRenderControls.This render method is called within the context and during the rendering of a single page. The page being rendered is passed to implementors of this method in order to be able to control and influence the page rendering.
- Parameters:
parameters- the view component which is currently being renderedisActive- whether the called tool is currently active
-
handleEditEvent
Handle the givenEditEvent. This method dispatches the edit event to the individualhandleXYZ()-Methods. However, implementors may want and are allowed to override this method in order to perform standard handling tasks common to all types of events.- Parameters:
isActive- whether this tool is currently activee- the event
-
handleGestureEnd
Invoked when a multi touch gesture ended.- Parameters:
e- theGestureEditEvent
-
handleGestureChange
Invoked when a multi touch gesture changed.- Parameters:
e- theGestureEditEvent
-
handleGestureStart
Invoked when a multi touch gesture started.- Parameters:
e- theGestureEditEvent
-
handleTouchMove
Invoked when a touch changed.- Parameters:
e- theTouchEditEventisActive- whether this tool is currently active
-
handleTouchStart
Invoked when a touch started.- Parameters:
e- theTouchEditEventisActive- whether this tool is currently active
-
handleTouchEnd
Invoked when a touch ended.- Parameters:
e- theTouchEditEventisActive- whether this tool is currently active
-
handlePointerDown
Invoked when a pointer event starts.- Parameters:
e- thePointerEditEventisActive- whether this tool is currently active
-
handlePointerMove
Invoked when a pointer event move.- Parameters:
e- thePointerEditEventisActive- whether this tool is currently active
-
handlePointerUp
Invoked when a pointer event ends.- Parameters:
e- thePointerEditEventisActive- whether this tool is currently active
-
handleMouseClicked
Invoked when the mouse button has been clicked (pressed and released) on a component.- Parameters:
e- theMouseEditEventisActive- whether this tool is currently active
-
handleMousePressed
Invoked when a mouse button has been pressed on a component.- Parameters:
e- the eventisActive- whether this tool is currently active
-
handleMouseReleased
Invoked when a mouse button has been released on a component.- Parameters:
e- the eventisActive- whether this tool is currently active
-
handleMouseDragged
Invoked when a mouse button is pressed on a component and then dragged.MOUSE_DRAGGEDevents will continue to be delivered to the component where the drag originated until the mouse button is released (regardless of whether the mouse position is within the bounds of the component).Due to platform-dependent DragDrop implementations,
MouseDragEventevents may not be delivered during a native Drag&Drop operation.- Parameters:
e- the eventisActive- whether this tool is currently active
-
handleMouseMoved
Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.- Parameters:
e- the eventisActive- whether this tool is currently active
-
handleMouseEntered
Invoked when the mouse cursor enters the unobscured part of component's geometry.- Parameters:
e- theMouseEditEventisActive- whether this tool is currently active
-
handleMouseExited
Invoked when the mouse cursor exits the unobscured part of component's geometry.- Parameters:
e- theMouseEditEventisActive- whether this tool is currently active
-
handleMouseWheelMoved
Invoked when the mouse wheel is rotated.- Parameters:
e- theMouseEditEventisActive- whether this tool is currently active
-
handleKeyTyped
Invoked when a key has been typed. See the class description forKeyEventfor a definition of a key typed event.- Parameters:
e- theMouseEditEventisActive- whether this tool is currently active
-
handleKeyPressed
Invoked when a key has been pressed. See the class description forKeyEventfor a definition of a key pressed event.- Parameters:
e- theMouseEditEventisActive- whether this tool is currently active
-
handleKeyReleased
Invoked when a key has been released. See the class description forKeyEventfor a definition of a key released event.- Parameters:
e- theMouseEditEventisActive- whether this tool is currently active
-
getActivationRequest
Return the auto-activation request for this this tool in response to the given event. This method is only called for events of the following type:MouseDownEventMouseDragEventKeyDownEvent
Tool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to theToolActivationPolicyused be the tool manager.- Parameters:
e- theMouseEditEvent- Returns:
- an
Tool.ActivationRequestornullif the tool does not seek to be auto-activated at this time.
-
getActivationRequestForMousePressed
Return the auto-activation request for this this tool in response to the given mouse press. If the tool returns anTool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to theToolActivationPolicyused be the tool manager.- Parameters:
e- theKeyEditEvent- Returns:
- an
Tool.ActivationRequestornullif the tool does not seek to be auto-activated at this time.
-
getActivationRequestForMouseDragged
Return the auto-activation request for this this tool in response to the given mouse drag event. If the tool returns anTool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to theToolActivationPolicyused be the tool manager. Caveat: some tools may only be able to decide about their activation once the mouse starts dragging. However, this means that they may take the back seat with respect to tools requesting their auto-activation during the mouse-press already.- Parameters:
e- theKeyEditEvent- Returns:
- an
Tool.ActivationRequestornullif the tool does not seek to be auto-activated at this time.
-
getActivationRequestForKeyPressed
Return the auto-activation request for this this tool in response to the given key press. If the tool returns anTool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to theToolActivationPolicyused be the tool manager.- Parameters:
e- theKeyEditEvent- Returns:
- an
Tool.ActivationRequestornullif the tool does not seek to be auto-activated at this time.
-
getActivationRequestForTouchStart
Return the auto-activation request for this this tool in response to a touch start. If the tool returns anTool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to theToolActivationPolicyused be the tool manager.- Parameters:
e- theKeyEditEvent- Returns:
- an
Tool.ActivationRequestornullif the tool does not seek to be auto-activated at this time.
-
getActivationRequestForTouchMove
Return the auto-activation request for this this tool in response to a touch move. If the tool returns anTool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to theToolActivationPolicyused be the tool manager.- Parameters:
e- theKeyEditEvent- Returns:
- an
Tool.ActivationRequestornullif the tool does not seek to be auto-activated at this time.
-
getActivationFeedback
Provide feedback for the user about what would happen, if the mouse were pressed at the current location. This method is called while handlingMouseMoveEvents. If this method returnsnullno feedback is provided at all. The activation request returned from this method is the same object that is used duringgetActivationRequestForKeyPressed(KeyEditEvent)to signal the auto-activation candidacy. This method should only return an activation request if it will actually candidate for auto-activation later on usinggetActivationRequestForMousePressed(MouseEditEvent)orgetActivationRequestForMouseDragged(MouseEditEvent).- Parameters:
e- theMouseEditEvent- Returns:
- the
Tool.ActivationRequest
-
getActivationFeedback
Provide feedback for the user about what would happen, if the finger were moved from the current location. This method is called while handlingTouchMoveEventevents. If this method returnsnullno feedback is provided at all. This method should only return an activation request if it will actually candidate for auto-activation later on usinggetActivationRequestForTouchStart(TouchEditEvent)orgetActivationRequestForTouchMove(TouchEditEvent).- Parameters:
e- theTouchEditEvent- Returns:
- the
Tool.ActivationRequest
-
getRenderPriority
protected int getRenderPriority()Return the render priority for this tool. Tools with higher dispatch priorities are rendered earlier than tools with lower priorities. The priority should be in the rangeMIN_PRIORITY...MAX_PRIORITY. The default priority is equal toDEFAULT_PRIORITY.- Returns:
- the dispatch priority
-
getDispatchPriority
protected int getDispatchPriority()Return the dispatch priority for this tool. Tools with higher dispatch priorities receive events earlier than tools with lower priorities. The priority should be in the rangeMIN_PRIORITY...MAX_PRIORITY. The default priority is equal toMAX_PRIORITYminus the render priority.- Returns:
- the dispatch priority
-
setManager
Receives theToolManagerinstance, which theToolimplementation has been registered for. If theToolisderegisteredthis method will be called with null.- Parameters:
manager- theToolManager
-
propagatePropertyChange
-
setEnabled
protected void setEnabled(boolean enabled) Receive notification from the tool manager about the tool's enabled state. In general, tools need not and should not try to implement different behaviour depending on the enabled state, as this is already covered by the ToolManager calling thehandleEditEvent(boolean, EditEvent)andrender(RenderParameters, boolean)in the appropriate state only. However, some tools may need to perform extended actions (for example, for resource management purposes) upon a change of the enabled state.- Parameters:
enabled- controls whether to enable or disable thisTool
-
setActive
protected void setActive(boolean active) Receive notification from the tool manager about the tool's active state.- Parameters:
active- controls whether to activate or deactivate thisTool
-
setCursor
Deprecated.Use setCursor(String) instead. To convert existing calls easily, just add .getCssName() to the method's cursor parameter or use UIStyler.get().cursorStyle().[any method] instead to make use of all currently available css cursors -
setCursor
Set the cursor on the associated view component. Tools should not generally try to change the cursor unless they are currently the exclusive tool. Cursor-feedback while not being the exclusive tool should be provided usinggetActivationFeedback(MouseEditEvent).
Example: setCursor(UIStyler.get().cursorStyle().DEFAULT_CURSOR())- Parameters:
cursor- the css value of the cursor to be set
-
setStatusFeedback
Set the status feedback message published by the tool manager usingToolManager.getStatusFeedback(). Tools should not generally try to change the status message unless they are currently the exclusive tool. Status-feedback while not being the exclusive tool should be provided usinggetActivationFeedback(MouseEditEvent).- Parameters:
feedback- the feedback message to set
-
getManager
Return the current tool manager.- Returns:
- the
ToolManagerornullif this tool is not currently associated with a tool manager.
-