Class AnnotationTool

java.lang.Object
com.levigo.jadice.web.client.tool.Tool
com.levigo.jadice.web.client.tools.AnnotationTool
All Implemented Interfaces:
MenuContributor

public class AnnotationTool extends Tool
  • Field Details

    • PROPERTY_KEY_ANNOTATION_SELECTION

      public static final String PROPERTY_KEY_ANNOTATION_SELECTION
      This property key can be used to receive changes in the current selection of annotations.

      Add a ToolChangedEvent.Handler to the ToolManager and get notified about selection changes. Check for evt.getDescription().equals(PROPERTY_KEY_ANNOTATION_SELECTION).

      In the ToolChangedEvent, the new value holds the current selection (an unmodifiable List of currently selected annotations); the old value represents the previous selection (also as unmodifiable List).

  • Constructor Details

    • AnnotationTool

      public AnnotationTool()
  • Method Details

    • getCurrentShownHandles

      @Deprecated public Set<Handle> getCurrentShownHandles()
      Deprecated.
      For testing only
    • captureState

      public org.jadice.util.base.CompositeMemento captureState()
    • ensureDebugId

      public void ensureDebugId(String baseID)
      Overrides:
      ensureDebugId in class Tool
    • setActive

      protected void setActive(boolean active)
      Description copied from class: Tool
      Receive notification from the tool manager about the tool's active state.
      Overrides:
      setActive in class Tool
      Parameters:
      active - controls whether to activate or deactivate this Tool
    • setEnabled

      protected void setEnabled(boolean enabled)
      Description copied from class: Tool
      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 Tool.handleEditEvent(boolean, EditEvent) and Tool.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.
      Overrides:
      setEnabled in class Tool
      Parameters:
      enabled - controls whether to enable or disable this Tool
    • getDispatchPriority

      protected int getDispatchPriority()
      Description copied from class: Tool
      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 Tool.MIN_PRIORITY...Tool.MAX_PRIORITY. The default priority is equal to Tool.MAX_PRIORITY minus the render priority.
      Overrides:
      getDispatchPriority in class Tool
      Returns:
      the dispatch priority
    • isMultiplyer

      protected boolean isMultiplyer(PointedEditEvent e)
    • setWranglerFinder

      public void setWranglerFinder(WranglerFinder wranglerFinder)
    • setOpenToolbarOnCreation

      public void setOpenToolbarOnCreation(boolean openToolbarOnCreation)
      Specifies whether the AnnotationToolbar shall be visible immediately after creating an annotation.
      Parameters:
      openToolbarOnCreation - true to enforce a visible toolbar
    • isOpenToolbarOnCreation

      public boolean isOpenToolbarOnCreation()
      Specifies whether the AnnotationToolbar shall be visible immediately after creating an annotation.
      Returns:
      true if toolbar will be shown, false otherwise. Default: false.
    • getCreationTimeSlot

      public int getCreationTimeSlot()
      The duration in milliseconds in which a new Annotation will not be deselected after its creation. Default is 50 milliseconds.
      Returns:
      the duration in milliseconds in which a new Annotation will not be deselected after its creation
    • setCreationTimeSlot

      public void setCreationTimeSlot(int creationTimeSlot)
      Sets the duration in milliseconds in which a new Annotation will not be deselected after its creation. Default is 50 milliseconds.
      Parameters:
      creationTimeSlot - the duration in milliseconds
    • getWrangler

      public Wrangler<?> getWrangler(Annotation a, EditEvent e)
    • getWrangler

      protected <T extends Annotation> Wrangler<?> getWrangler(T a, String typeName)
      Returns the AnnotationWrangler.
      Type Parameters:
      T - A type extending Annotation.
      Parameters:
      a - The annotation.
      typeName - Type name of annotation template type, or null if unused.
      Returns:
      Specific wrangler for the given annotation.
    • setManager

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

      protected MultiWrangler getMultiWrangler()
    • render

      protected void render(RenderParameters parameters, boolean isActive)
      Description copied from class: Tool
      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.

      Overrides:
      render in class Tool
      Parameters:
      parameters - the view component which is currently being rendered
      isActive - whether the called tool is currently active
    • renderAndAddHandle

      protected void renderAndAddHandle(com.levigo.jadice.web.client.util.internal.graphics.JadiceGraphics graphics, Handle h)
    • getActivationFeedback

      protected Tool.ActivationRequest getActivationFeedback(MouseEditEvent e)
      Description copied from class: Tool
      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 Tool.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 Tool.getActivationRequestForMousePressed(MouseEditEvent) or Tool.getActivationRequestForMouseDragged(MouseEditEvent).
      Overrides:
      getActivationFeedback in class Tool
      Parameters:
      e - the MouseEditEvent
      Returns:
      the Tool.ActivationRequest
    • getPointedEditEventActivationFeedback

      protected Tool.ActivationRequest getPointedEditEventActivationFeedback(PointedEditEvent e)
    • getActivationFeedback

      protected Tool.ActivationRequest getActivationFeedback(TouchEditEvent e)
      Description copied from class: Tool
      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 Tool.getActivationRequestForTouchStart(TouchEditEvent) or Tool.getActivationRequestForTouchMove(TouchEditEvent).
      Overrides:
      getActivationFeedback in class Tool
      Parameters:
      e - the TouchEditEvent
      Returns:
      the Tool.ActivationRequest
    • handleTouchStart

      protected void handleTouchStart(TouchEditEvent e, boolean isActive)
      Description copied from class: Tool
      Invoked when a touch started.
      Overrides:
      handleTouchStart in class Tool
      Parameters:
      e - the TouchEditEvent
      isActive - whether this tool is currently active
    • handleTouchMove

      protected void handleTouchMove(TouchEditEvent e, boolean isActive)
      Description copied from class: Tool
      Invoked when a touch changed.
      Overrides:
      handleTouchMove in class Tool
      Parameters:
      e - the TouchEditEvent
      isActive - whether this tool is currently active
    • setCreateMode

      public void setCreateMode(AnnotationProfile profile, AnnotationFactory factory)
      Sets the Creation Mode.
      Parameters:
      profile - The annotation profile providing additional annotation specific config.
      factory - The factory to be used when creating instances, or null to deactivate this tool.
    • isDeleteSelectedAnnotationsAllowed

      public boolean isDeleteSelectedAnnotationsAllowed()
      Checks if the permissions of all selected annotations grant the deletion.
      Returns:
      true, if the selected permissions are allowed to be deleted, false, else
    • deleteSelectedAnnotations

      public void deleteSelectedAnnotations()
      Deletes the selected annotations.

      Verifies if the deletion is allowed.

    • getCreate

      public AnnotationFactory getCreate()
    • handleEditEvent

      protected void handleEditEvent(boolean isActive, EditEvent e)
      Description copied from class: Tool
      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.
      Overrides:
      handleEditEvent in class Tool
      Parameters:
      isActive - whether this tool is currently active
      e - the event
    • renderBounds

      protected void renderBounds(AnnotationSelection selection, com.levigo.jadice.web.client.util.internal.graphics.JadiceGraphics graphics)
      Renders the bounds of the currently selected annotation(s).
      Parameters:
      selection - Holds the currently selected annotation(s).
      graphics - The helper class used for graphical operations
    • setToolbar

      @Deprecated public void setToolbar(AbstractBar toolbar)
      Deprecated.
      Parameters:
      toolbar - the editor host
    • setEditorHost

      public void setEditorHost(AbstractBar host)
      This is used to set a non-pop-up toolbar holding the editing tools.
      Parameters:
      host - the editor host
    • selectAnnotations

      public void selectAnnotations(Page page, ShapeBasedAnnotation... annotations)
      Selects the given annotation(s) for the given page. If the given annotations are null (no annotation passed), the selection will be cleared.

      Note
      This method will just select the annotations. The AnnotationToolbar will not be visible. If the toolbar is desired to be visible, use selectAnnotations(Page, boolean, ShapeBasedAnnotation...).

      Parameters:
      page - the page containing the annotations
      annotations - the annotations to select
      See Also:
    • resetEditorFocusability

      public void resetEditorFocusability()
    • selectAnnotations

      public void selectAnnotations(Page page, boolean showAnnoToolbar, ShapeBasedAnnotation... annotations)
      Selects the given annotation(s) for the given page. If the given annotations are null (no annotation passed), the selection will be cleared.
      Parameters:
      page - the page
      showAnnoToolbar - true: show the annotation toolbar; false: just select annotation and do not show the AnnotationToolbar
      annotations - the annotations to select
      See Also:
    • clearAnnotationSelection

      public void clearAnnotationSelection()
      Unselects all currently selected annotations.
      See Also:
    • getSelectedAnnotations

      public List<ShapeBasedAnnotation> getSelectedAnnotations()
      Returns the currently selected annotations. The list is read only - to modify the selection, use selectAnnotations(Page, ShapeBasedAnnotation...) or selectAnnotations(Page, boolean, ShapeBasedAnnotation...).
      Returns:
      the list of currently selected annotations
    • hideAnnotationTooltip

      public void hideAnnotationTooltip()
      Allows to programmatically hide an annotation tooltip. Calling this method when no tooltip is shown has no effect.
    • getTooltipGenerator

      public AnnotationTooltipGenerator getTooltipGenerator()
      Returns the registered AnnotationTooltipGenerator.
      Returns:
      the tooltip generator or null, if not set
      See Also:
    • setTooltipGenerator

      public void setTooltipGenerator(AnnotationTooltipGenerator tooltipGenerator)
      Sets the AnnotationTooltipGenerator which shall be used to create a tooltip for a hovered annotation.
      Parameters:
      tooltipGenerator - The AnnotationTooltipGenerator generating the tooltip
    • getCurrentPage

      public Page getCurrentPage()
    • setMultiAnnoMode

      public void setMultiAnnoMode(boolean multiAnnoMode)
    • handleMouseClicked

      protected void handleMouseClicked(MouseEditEvent e, boolean isActive)
      All the handleMouse... and handleKey... methods are only called in annotation edit mode.
      Overrides:
      handleMouseClicked in class Tool
      Parameters:
      e - the MouseEditEvent
      isActive - whether this tool is currently active
    • handleMouseExited

      protected void handleMouseExited(MouseEditEvent e, boolean isActive)
      Description copied from class: Tool
      Invoked when the mouse cursor exits the unobscured part of component's geometry.
      Overrides:
      handleMouseExited in class Tool
      Parameters:
      e - the MouseEditEvent
      isActive - whether this tool is currently active
    • handleMouseEntered

      protected void handleMouseEntered(MouseEditEvent e, boolean isActive)
      Description copied from class: Tool
      Invoked when the mouse cursor enters the unobscured part of component's geometry.
      Overrides:
      handleMouseEntered in class Tool
      Parameters:
      e - the MouseEditEvent
      isActive - whether this tool is currently active
    • handleMouseMoved

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

      protected void handleMouseDragged(MouseEditEvent e, boolean isActive)
      Description copied from class: Tool
      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.

      Overrides:
      handleMouseDragged in class Tool
      Parameters:
      e - the event
      isActive - whether this tool is currently active
    • handleMousePressed

      protected void handleMousePressed(MouseEditEvent e, boolean isActive)
      Description copied from class: Tool
      Invoked when a mouse button has been pressed on a component.
      Overrides:
      handleMousePressed in class Tool
      Parameters:
      e - the event
      isActive - whether this tool is currently active
    • moveSelectionTo

      public void moveSelectionTo(double x, double y, boolean createUndoMemento)
    • moveSelectionTo

      public void moveSelectionTo(double x, double y)
    • onKeyDown

      public void onKeyDown(com.google.gwt.event.dom.client.KeyDownEvent e)
    • handleKeyPressed

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

      protected void handleMouseReleased(MouseEditEvent e, boolean isActive)
      Description copied from class: Tool
      Invoked when a mouse button has been released on a component.
      Overrides:
      handleMouseReleased in class Tool
      Parameters:
      e - the event
      isActive - whether this tool is currently active
    • 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
      Overrides:
      contribute in class Tool
      Parameters:
      context - the ContributionContext which provides contribution context informations
      menuBuilder - the MenuBuilder to which the tool may contribute entries.
    • isSingleSelectionMode

      public boolean isSingleSelectionMode()
      Returns the current selection mode. Defaults to false.
      Returns:
      true if only one annotation can be selected at a given point in time, false else
    • setSingleSelectionMode

      public void setSingleSelectionMode(boolean singleSelectionMode)
      Sets the current selection mode.
      Parameters:
      singleSelectionMode - true if only one annotation shall be selectable at a given point in time. False if multiple annotations shall be selectable at a given point in time.
    • getCursorStyleSelector

      public CursorStyleSelector getCursorStyleSelector()
      Returns:
      the current cursor style selector
    • setCursorStyleSelector

      public void setCursorStyleSelector(CursorStyleSelector cstse)
      Sets the cursor style selector to be used
      Parameters:
      cstse - the new cursor style selector to be used
    • getAnnotationSelection

      public AnnotationSelection getAnnotationSelection()