Class AnnotationTool

    • Field Detail

      • 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 Detail

      • AnnotationTool

        public AnnotationTool()
    • Method Detail

      • getCurrentShownHandles

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

        public org.jadice.util.base.CompositeMemento captureState()
      • 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
      • 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

        protected <T extends AnnotationWrangler<?> 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.
      • 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)
      • 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.

      • 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
      • 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
      • 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()
      • hideAnnotationTooltip

        public void hideAnnotationTooltip()
        Allows to programmatically hide an annotation tooltip. Calling this method when no tooltip is shown has no effect.
      • 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
      • 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)
      • 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
      • 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