Class AnnotationTool
- All Implemented Interfaces:
MenuContributor
-
Nested Class Summary
Nested classes/interfaces inherited from class com.levigo.jadice.web.client.tool.Tool
Tool.ActivationRequest
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
This property key can be used to receive changes in the current selection of annotations.Fields inherited from class com.levigo.jadice.web.client.tool.Tool
DEFAULT_PRIORITY, MAX_PRIORITY, MIN_PRIORITY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.jadice.util.base.CompositeMemento
void
Unselects all currently selected annotations.void
contribute
(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
.void
Deletes the selected annotations.void
ensureDebugId
(String baseID) protected Tool.ActivationRequest
Provide feedback for the user about what would happen, if the mouse were pressed at the current location.protected Tool.ActivationRequest
Provide feedback for the user about what would happen, if the finger were moved from the current location.int
The duration in milliseconds in which a new Annotation will not be deselected after its creation.Deprecated.For testing onlyprotected int
Return the dispatch priority for this tool.protected MultiWrangler
protected Tool.ActivationRequest
Returns the currently selected annotations.Returns the registeredAnnotationTooltipGenerator
.Wrangler
<?> getWrangler
(Annotation a, EditEvent e) protected <T extends Annotation>
Wrangler<?> getWrangler
(T a, String typeName) Returns the AnnotationWrangler.protected void
handleEditEvent
(boolean isActive, EditEvent e) Handle the givenEditEvent
.protected void
handleKeyPressed
(KeyEditEvent e, boolean isActive) Invoked when a key has been pressed.protected void
handleMouseClicked
(MouseEditEvent e, boolean isActive) All the handleMouse... and handleKey... methods are only called in annotation edit mode.protected void
handleMouseDragged
(MouseEditEvent e, boolean isActive) Invoked when a mouse button is pressed on a component and then dragged.protected void
handleMouseEntered
(MouseEditEvent e, boolean isActive) Invoked when the mouse cursor enters the unobscured part of component's geometry.protected void
handleMouseExited
(MouseEditEvent e, boolean isActive) Invoked when the mouse cursor exits the unobscured part of component's geometry.protected void
handleMouseMoved
(MouseEditEvent e, boolean isActive) Invoked when the mouse cursor has been moved onto a component but no buttons have been pushed.protected void
handleMousePressed
(MouseEditEvent e, boolean isActive) Invoked when a mouse button has been pressed on a component.protected void
handleMouseReleased
(MouseEditEvent e, boolean isActive) Invoked when a mouse button has been released on a component.protected void
handleTouchMove
(TouchEditEvent e, boolean isActive) Invoked when a touch changed.protected void
handleTouchStart
(TouchEditEvent e, boolean isActive) Invoked when a touch started.void
Allows to programmatically hide an annotation tooltip.boolean
Checks if the permissions of all selected annotations grant the deletion.protected boolean
boolean
Specifies whether the AnnotationToolbar shall be visible immediately after creating an annotation.boolean
Returns the current selection mode.void
moveSelectionTo
(double x, double y) void
moveSelectionTo
(double x, double y, boolean createUndoMemento) void
onKeyDown
(com.google.gwt.event.dom.client.KeyDownEvent e) protected void
render
(RenderParameters parameters, boolean isActive) Renders the Tool's UI onto the givenGraphics2D
context using the givenRenderControls
.protected void
renderAndAddHandle
(com.levigo.jadice.web.client.util.internal.graphics.JadiceGraphics graphics, Handle h) protected void
renderBounds
(AnnotationSelection selection, com.levigo.jadice.web.client.util.internal.graphics.JadiceGraphics graphics) Renders the bounds of the currently selected annotation(s).void
void
selectAnnotations
(Page page, boolean showAnnoToolbar, ShapeBasedAnnotation... annotations) Selects the given annotation(s) for the given page.void
selectAnnotations
(Page page, ShapeBasedAnnotation... annotations) Selects the given annotation(s) for the given page.protected void
setActive
(boolean active) Receive notification from the tool manager about the tool's active state.void
setCreateMode
(AnnotationProfile profile, AnnotationFactory factory) Sets the Creation Mode.void
setCreationTimeSlot
(int creationTimeSlot) Sets the duration in milliseconds in which a new Annotation will not be deselected after its creation.void
Sets the cursor style selector to be usedvoid
setEditorHost
(AbstractBar host) This is used to set a non-pop-up toolbar holding the editing tools.protected void
setEnabled
(boolean enabled) Receive notification from the tool manager about the tool's enabled state.protected void
setManager
(ToolManager manager) Receives theToolManager
instance, which theTool
implementation has been registered for.void
setMultiAnnoMode
(boolean multiAnnoMode) void
setOpenToolbarOnCreation
(boolean openToolbarOnCreation) Specifies whether the AnnotationToolbar shall be visible immediately after creating an annotation.void
setSingleSelectionMode
(boolean singleSelectionMode) Sets the current selection mode.void
setToolbar
(AbstractBar toolbar) Deprecated.UsesetEditorHost(AbstractBar)
insteadvoid
setTooltipGenerator
(AnnotationTooltipGenerator tooltipGenerator) Sets theAnnotationTooltipGenerator
which shall be used to create a tooltip for a hovered annotation.void
setWranglerFinder
(WranglerFinder wranglerFinder) Methods inherited from class com.levigo.jadice.web.client.tool.Tool
getActivationRequest, getActivationRequestForKeyPressed, getActivationRequestForMouseDragged, getActivationRequestForMousePressed, getActivationRequestForTouchMove, getActivationRequestForTouchStart, getManager, getRenderPriority, handleGestureChange, handleGestureEnd, handleGestureStart, handleKeyReleased, handleKeyTyped, handleMouseWheelMoved, handlePointerDown, handlePointerMove, handlePointerUp, handleTouchEnd, propagatePropertyChange, setCursor, setCursor, setStatusFeedback
-
Field Details
-
PROPERTY_KEY_ANNOTATION_SELECTION
This property key can be used to receive changes in the current selection of annotations.Add a
ToolChangedEvent.Handler
to theToolManager
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 unmodifiableList
of currently selected annotations); the old value represents the previous selection (also as unmodifiableList
).
-
-
Constructor Details
-
AnnotationTool
public AnnotationTool()
-
-
Method Details
-
getCurrentShownHandles
Deprecated.For testing only -
captureState
public org.jadice.util.base.CompositeMemento captureState() -
ensureDebugId
- Overrides:
ensureDebugId
in classTool
-
setActive
protected void setActive(boolean active) Description copied from class:Tool
Receive notification from the tool manager about the tool's active state. -
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 theTool.handleEditEvent(boolean, EditEvent)
andTool.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 classTool
- Parameters:
enabled
- controls whether to enable or disable thisTool
-
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 rangeTool.MIN_PRIORITY
...Tool.MAX_PRIORITY
. The default priority is equal toTool.MAX_PRIORITY
minus the render priority.- Overrides:
getDispatchPriority
in classTool
- Returns:
- the dispatch priority
-
isMultiplyer
-
setWranglerFinder
-
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
-
getWrangler
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
Description copied from class:Tool
Receives theToolManager
instance, which theTool
implementation has been registered for. If theTool
isderegistered
this method will be called with null.- Overrides:
setManager
in classTool
- Parameters:
manager
- theToolManager
-
getMultiWrangler
-
render
Description copied from class:Tool
Renders the Tool's UI onto the givenGraphics2D
context 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.
-
renderAndAddHandle
protected void renderAndAddHandle(com.levigo.jadice.web.client.util.internal.graphics.JadiceGraphics graphics, Handle h) -
getActivationFeedback
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 handlingMouseMoveEvent
s. If this method returnsnull
no feedback is provided at all. The activation request returned from this method is the same object that is used duringTool.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 usingTool.getActivationRequestForMousePressed(MouseEditEvent)
orTool.getActivationRequestForMouseDragged(MouseEditEvent)
.- Overrides:
getActivationFeedback
in classTool
- Parameters:
e
- theMouseEditEvent
- Returns:
- the
Tool.ActivationRequest
-
getPointedEditEventActivationFeedback
-
getActivationFeedback
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 handlingTouchMoveEvent
events. If this method returnsnull
no feedback is provided at all. This method should only return an activation request if it will actually candidate for auto-activation later on usingTool.getActivationRequestForTouchStart(TouchEditEvent)
orTool.getActivationRequestForTouchMove(TouchEditEvent)
.- Overrides:
getActivationFeedback
in classTool
- Parameters:
e
- theTouchEditEvent
- Returns:
- the
Tool.ActivationRequest
-
handleTouchStart
Description copied from class:Tool
Invoked when a touch started.- Overrides:
handleTouchStart
in classTool
- Parameters:
e
- theTouchEditEvent
isActive
- whether this tool is currently active
-
handleTouchMove
Description copied from class:Tool
Invoked when a touch changed.- Overrides:
handleTouchMove
in classTool
- Parameters:
e
- theTouchEditEvent
isActive
- whether this tool is currently active
-
setCreateMode
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
-
handleEditEvent
Description copied from class:Tool
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.- Overrides:
handleEditEvent
in classTool
- Parameters:
isActive
- whether this tool is currently activee
- 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.UsesetEditorHost(AbstractBar)
instead- Parameters:
toolbar
- the editor host
-
setEditorHost
This is used to set a non-pop-up toolbar holding the editing tools.- Parameters:
host
- the editor host
-
selectAnnotations
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, useselectAnnotations(Page, boolean, ShapeBasedAnnotation...)
.- Parameters:
page
- the page containing the annotationsannotations
- 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 pageshowAnnoToolbar
- true: show the annotation toolbar; false: just select annotation and do not show the AnnotationToolbarannotations
- the annotations to select- See Also:
-
clearAnnotationSelection
public void clearAnnotationSelection()Unselects all currently selected annotations.- See Also:
-
getSelectedAnnotations
Returns the currently selected annotations. The list is read only - to modify the selection, useselectAnnotations(Page, ShapeBasedAnnotation...)
orselectAnnotations(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
Returns the registeredAnnotationTooltipGenerator
.- Returns:
- the tooltip generator or null, if not set
- See Also:
-
setTooltipGenerator
Sets theAnnotationTooltipGenerator
which shall be used to create a tooltip for a hovered annotation.- Parameters:
tooltipGenerator
- TheAnnotationTooltipGenerator
generating the tooltip
-
getCurrentPage
-
setMultiAnnoMode
public void setMultiAnnoMode(boolean multiAnnoMode) -
handleMouseClicked
All the handleMouse... and handleKey... methods are only called in annotation edit mode.- Overrides:
handleMouseClicked
in classTool
- Parameters:
e
- theMouseEditEvent
isActive
- whether this tool is currently active
-
handleMouseExited
Description copied from class:Tool
Invoked when the mouse cursor exits the unobscured part of component's geometry.- Overrides:
handleMouseExited
in classTool
- Parameters:
e
- theMouseEditEvent
isActive
- whether this tool is currently active
-
handleMouseEntered
Description copied from class:Tool
Invoked when the mouse cursor enters the unobscured part of component's geometry.- Overrides:
handleMouseEntered
in classTool
- Parameters:
e
- theMouseEditEvent
isActive
- whether this tool is currently active
-
handleMouseMoved
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 classTool
- Parameters:
e
- the eventisActive
- whether this tool is currently active
-
handleMouseDragged
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 classTool
- Parameters:
e
- the eventisActive
- whether this tool is currently active
-
handleMousePressed
Description copied from class:Tool
Invoked when a mouse button has been pressed on a component.- Overrides:
handleMousePressed
in classTool
- Parameters:
e
- the eventisActive
- 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
Description copied from class:Tool
Invoked when a key has been pressed. See the class description forKeyEvent
for a definition of a key pressed event.- Overrides:
handleKeyPressed
in classTool
- Parameters:
e
- theMouseEditEvent
isActive
- whether this tool is currently active
-
handleMouseReleased
Description copied from class:Tool
Invoked when a mouse button has been released on a component.- Overrides:
handleMouseReleased
in classTool
- Parameters:
e
- the eventisActive
- 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
- Returns:
- the current cursor style selector
-
setCursorStyleSelector
Sets the cursor style selector to be used- Parameters:
cstse
- the new cursor style selector to be used
-
getAnnotationSelection
-