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, PopupMenuTool, PopupSubMenuTool, SelectPageTool, SetCurrentPageTool, TextSearchTool, TextSelectionTool, TextSelectionTouchTool, TextToSpeechTool, ThumbnailTool, TwoFingerGestureTool, VisibleBoundsTool, WikipediaSearchTool

public abstract class Tool extends Object implements MenuContributor
This abstract class must be sub-classed in order to contribute additional functionality to page-visualization components like the JadicePageView, or the ThumbnailView.
  • Field Details

  • Constructor Details

    • Tool

      public Tool()
  • Method Details

    • ensureDebugId

      public void ensureDebugId(String baseID)
    • render

      protected void render(RenderParameters parameters, boolean isActive)
      Renders the Tool's UI onto the given Graphics2D context using the given RenderControls.

      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 rendered
      isActive - whether the called tool is currently active
    • handleEditEvent

      protected void handleEditEvent(boolean isActive, EditEvent e)
      Handle the given EditEvent. This method dispatches the edit event to the individual handleXYZ()-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 active
      e - the event
    • handleGestureEnd

      protected void handleGestureEnd(GestureEditEvent e)
      Invoked when a multi touch gesture ended.
      Parameters:
      e - the GestureEditEvent
    • handleGestureChange

      protected void handleGestureChange(GestureEditEvent e)
      Invoked when a multi touch gesture changed.
      Parameters:
      e - the GestureEditEvent
    • handleGestureStart

      protected void handleGestureStart(GestureEditEvent e)
      Invoked when a multi touch gesture started.
      Parameters:
      e - the GestureEditEvent
    • handleTouchMove

      protected void handleTouchMove(TouchEditEvent e, boolean isActive)
      Invoked when a touch changed.
      Parameters:
      e - the TouchEditEvent
      isActive - whether this tool is currently active
    • handleTouchStart

      protected void handleTouchStart(TouchEditEvent e, boolean isActive)
      Invoked when a touch started.
      Parameters:
      e - the TouchEditEvent
      isActive - whether this tool is currently active
    • handleTouchEnd

      protected void handleTouchEnd(TouchEditEvent e, boolean isActive)
      Invoked when a touch ended.
      Parameters:
      e - the TouchEditEvent
      isActive - whether this tool is currently active
    • handleMouseClicked

      protected void handleMouseClicked(MouseEditEvent e, boolean isActive)
      Invoked when the mouse button has been clicked (pressed and released) on a component.
      Parameters:
      e - the MouseEditEvent
      isActive - whether this tool is currently active
    • handleMousePressed

      protected void handleMousePressed(MouseEditEvent e, boolean isActive)
      Invoked when a mouse button has been pressed on a component.
      Parameters:
      e - the event
      isActive - whether this tool is currently active
    • handleMouseReleased

      protected void handleMouseReleased(MouseEditEvent e, boolean isActive)
      Invoked when a mouse button has been released on a component.
      Parameters:
      e - the event
      isActive - whether this tool is currently active
    • handleMouseDragged

      protected void handleMouseDragged(MouseEditEvent e, boolean isActive)
      Invoked when a mouse button is pressed on a component and then dragged. MOUSE_DRAGGED events 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, MouseDragEvent events may not be delivered during a native Drag&Drop operation.

      Parameters:
      e - the event
      isActive - whether this tool is currently active
    • handleMouseMoved

      protected void handleMouseMoved(MouseEditEvent e, boolean isActive)
      Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.
      Parameters:
      e - the event
      isActive - whether this tool is currently active
    • handleMouseEntered

      protected void handleMouseEntered(MouseEditEvent e, boolean isActive)
      Invoked when the mouse cursor enters the unobscured part of component's geometry.
      Parameters:
      e - the MouseEditEvent
      isActive - whether this tool is currently active
    • handleMouseExited

      protected void handleMouseExited(MouseEditEvent e, boolean isActive)
      Invoked when the mouse cursor exits the unobscured part of component's geometry.
      Parameters:
      e - the MouseEditEvent
      isActive - whether this tool is currently active
    • handleMouseWheelMoved

      protected void handleMouseWheelMoved(MouseWheelEditEvent e, boolean isActive)
      Invoked when the mouse wheel is rotated.
      Parameters:
      e - the MouseEditEvent
      isActive - whether this tool is currently active
    • handleKeyTyped

      protected void handleKeyTyped(KeyEditEvent e, boolean isActive)
      Invoked when a key has been typed. See the class description for KeyEvent for a definition of a key typed event.
      Parameters:
      e - the MouseEditEvent
      isActive - whether this tool is currently active
    • handleKeyPressed

      protected void handleKeyPressed(KeyEditEvent e, boolean isActive)
      Invoked when a key has been pressed. See the class description for KeyEvent for a definition of a key pressed event.
      Parameters:
      e - the MouseEditEvent
      isActive - whether this tool is currently active
    • handleKeyReleased

      protected void handleKeyReleased(KeyEditEvent e, boolean isActive)
      Invoked when a key has been released. See the class description for KeyEvent for a definition of a key released event.
      Parameters:
      e - the MouseEditEvent
      isActive - whether this tool is currently active
    • getActivationRequest

      protected Tool.ActivationRequest getActivationRequest(EditEvent e)
      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: If the tool returns an Tool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to the ToolActivationPolicy used be the tool manager.
      Parameters:
      e - the MouseEditEvent
      Returns:
      an Tool.ActivationRequest or null if the tool does not seek to be auto-activated at this time.
    • getActivationRequestForMousePressed

      protected Tool.ActivationRequest getActivationRequestForMousePressed(MouseEditEvent e)
      Return the auto-activation request for this this tool in response to the given mouse press. If the tool returns an Tool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to the ToolActivationPolicy used be the tool manager.
      Parameters:
      e - the KeyEditEvent
      Returns:
      an Tool.ActivationRequest or null if the tool does not seek to be auto-activated at this time.
    • getActivationRequestForMouseDragged

      protected Tool.ActivationRequest getActivationRequestForMouseDragged(MouseEditEvent e)
      Return the auto-activation request for this this tool in response to the given mouse drag event. If the tool returns an Tool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to the ToolActivationPolicy used 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 - the KeyEditEvent
      Returns:
      an Tool.ActivationRequest or null if the tool does not seek to be auto-activated at this time.
    • getActivationRequestForKeyPressed

      protected Tool.ActivationRequest getActivationRequestForKeyPressed(KeyEditEvent e)
      Return the auto-activation request for this this tool in response to the given key press. If the tool returns an Tool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to the ToolActivationPolicy used be the tool manager.
      Parameters:
      e - the KeyEditEvent
      Returns:
      an Tool.ActivationRequest or null if the tool does not seek to be auto-activated at this time.
    • getActivationRequestForTouchStart

      protected Tool.ActivationRequest getActivationRequestForTouchStart(TouchEditEvent e)
      Return the auto-activation request for this this tool in response to a touch start. If the tool returns an Tool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to the ToolActivationPolicy used be the tool manager.
      Parameters:
      e - the KeyEditEvent
      Returns:
      an Tool.ActivationRequest or null if the tool does not seek to be auto-activated at this time.
    • getActivationRequestForTouchMove

      protected Tool.ActivationRequest getActivationRequestForTouchMove(TouchEditEvent e)
      Return the auto-activation request for this this tool in response to a touch move. If the tool returns an Tool.ActivationRequest, it becomes eligible for auto-activation. However, the final decision about which tool will actually be activated is up to the ToolActivationPolicy used be the tool manager.
      Parameters:
      e - the KeyEditEvent
      Returns:
      an Tool.ActivationRequest or null if the tool does not seek to be auto-activated at this time.
    • getActivationFeedback

      protected Tool.ActivationRequest getActivationFeedback(MouseEditEvent e)
      Provide feedback for the user about what would happen, if the mouse were pressed at the current location. This method is called while handling MouseMoveEvents. If this method returns null no feedback is provided at all. The activation request returned from this method is the same object that is used during getActivationRequestForKeyPressed(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 using getActivationRequestForMousePressed(MouseEditEvent) or getActivationRequestForMouseDragged(MouseEditEvent).
      Parameters:
      e - the MouseEditEvent
      Returns:
      the Tool.ActivationRequest
    • getActivationFeedback

      protected Tool.ActivationRequest getActivationFeedback(TouchEditEvent e)
      Provide feedback for the user about what would happen, if the finger were moved from the current location. This method is called while handling TouchMoveEvent events. If this method returns null no feedback is provided at all. This method should only return an activation request if it will actually candidate for auto-activation later on using getActivationRequestForTouchStart(TouchEditEvent) or getActivationRequestForTouchMove(TouchEditEvent).
      Parameters:
      e - the TouchEditEvent
      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 range MIN_PRIORITY...MAX_PRIORITY. The default priority is equal to DEFAULT_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 range MIN_PRIORITY...MAX_PRIORITY. The default priority is equal to MAX_PRIORITY minus the render priority.
      Returns:
      the dispatch priority
    • setManager

      protected void setManager(ToolManager manager)
      Receives the ToolManager instance, which the Tool implementation has been registered for. If the Tool is deregistered this method will be called with null.
      Parameters:
      manager - the ToolManager
    • propagatePropertyChange

      protected void propagatePropertyChange(String name, Object oldValue, Object newValue)
    • 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 the handleEditEvent(boolean, EditEvent) and render(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 this Tool
    • 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 this Tool
    • contribute

      public void contribute(ContributionContext context, MenuBuilder menuBuilder)
      Description copied from interface: MenuContributor
      This method is called in order to give the menu contributor a chance to contribute context menu entries via the supplied MenuBuilder.
      Specified by:
      contribute in interface MenuContributor
      Parameters:
      context - the ContributionContext which provides contribution context informations
      menuBuilder - the MenuBuilder to which the tool may contribute entries.
    • setCursor

      @Deprecated protected void setCursor(com.google.gwt.dom.client.Style.Cursor cursor)
      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

      protected void setCursor(String cursor)
      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 using getActivationFeedback(MouseEditEvent).
      Example: setCursor(UIStyler.get().cursorStyle().DEFAULT_CURSOR())
      Parameters:
      cursor - the css value of the cursor to be set
    • setStatusFeedback

      protected void setStatusFeedback(String feedback)
      Set the status feedback message published by the tool manager using ToolManager.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 using getActivationFeedback(MouseEditEvent).
      Parameters:
      feedback - the feedback message to set
    • getManager

      protected ToolManager getManager()
      Return the current tool manager.
      Returns:
      the ToolManager or null if this tool is not currently associated with a tool manager.