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 StringThis 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.CompositeMementovoidUnselects all currently selected annotations.voidcontribute(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.voidDeletes the selected annotations.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.intThe duration in milliseconds in which a new Annotation will not be deselected after its creation.Deprecated.For testing onlyprotected intReturn the dispatch priority for this tool.protected MultiWranglerprotected Tool.ActivationRequestReturns 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 voidhandleEditEvent(boolean isActive, EditEvent e) Handle the givenEditEvent.protected voidhandleKeyPressed(KeyEditEvent e, boolean isActive) Invoked when a key has been pressed.protected voidhandleMouseClicked(MouseEditEvent e, boolean isActive) All the handleMouse... and handleKey... methods are only called in annotation edit mode.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 voidhandleTouchMove(TouchEditEvent e, boolean isActive) Invoked when a touch changed.protected voidhandleTouchStart(TouchEditEvent e, boolean isActive) Invoked when a touch started.voidAllows to programmatically hide an annotation tooltip.booleanChecks if the permissions of all selected annotations grant the deletion.protected booleanbooleanSpecifies whether the AnnotationToolbar shall be visible immediately after creating an annotation.booleanReturns the current selection mode.voidmoveSelectionTo(double x, double y) voidmoveSelectionTo(double x, double y, boolean createUndoMemento) voidonKeyDown(com.google.gwt.event.dom.client.KeyDownEvent e) protected voidrender(RenderParameters parameters, boolean isActive) Renders the Tool's UI onto the givenGraphics2Dcontext using the givenRenderControls.protected voidrenderAndAddHandle(com.levigo.jadice.web.client.util.internal.graphics.JadiceGraphics graphics, Handle h) protected voidrenderBounds(AnnotationSelection selection, com.levigo.jadice.web.client.util.internal.graphics.JadiceGraphics graphics) Renders the bounds of the currently selected annotation(s).voidvoidselectAnnotations(Page page, boolean showAnnoToolbar, ShapeBasedAnnotation... annotations) Selects the given annotation(s) for the given page.voidselectAnnotations(Page page, ShapeBasedAnnotation... annotations) Selects the given annotation(s) for the given page.protected voidsetActive(boolean active) Receive notification from the tool manager about the tool's active state.voidsetCreateMode(AnnotationProfile profile, AnnotationFactory factory) Sets the Creation Mode.voidsetCreationTimeSlot(int creationTimeSlot) Sets the duration in milliseconds in which a new Annotation will not be deselected after its creation.voidSets the cursor style selector to be usedvoidsetEditorHost(AbstractBar host) This is used to set a non-pop-up toolbar holding the editing tools.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.voidsetMultiAnnoMode(boolean multiAnnoMode) voidsetOpenToolbarOnCreation(boolean openToolbarOnCreation) Specifies whether the AnnotationToolbar shall be visible immediately after creating an annotation.voidsetSingleSelectionMode(boolean singleSelectionMode) Sets the current selection mode.voidsetToolbar(AbstractBar toolbar) Deprecated.UsesetEditorHost(AbstractBar)insteadvoidsetTooltipGenerator(AnnotationTooltipGenerator tooltipGenerator) Sets theAnnotationTooltipGeneratorwhich shall be used to create a tooltip for a hovered annotation.voidsetWranglerFinder(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.Handlerto theToolManagerand 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 unmodifiableListof 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:
ensureDebugIdin classTool
-
setActive
protected void setActive(boolean active) Description copied from class:ToolReceive notification from the tool manager about the tool's active state. -
setEnabled
protected void setEnabled(boolean enabled) Description copied from class:ToolReceive 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:
setEnabledin classTool- Parameters:
enabled- controls whether to enable or disable thisTool
-
getDispatchPriority
protected int getDispatchPriority()Description copied from class:ToolReturn 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_PRIORITYminus the render priority.- Overrides:
getDispatchPriorityin 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:ToolReceives theToolManagerinstance, which theToolimplementation has been registered for. If theToolisderegisteredthis method will be called with null.- Overrides:
setManagerin classTool- Parameters:
manager- theToolManager
-
getMultiWrangler
-
render
Description copied from class:ToolRenders 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.
-
renderAndAddHandle
protected void renderAndAddHandle(com.levigo.jadice.web.client.util.internal.graphics.JadiceGraphics graphics, Handle h) -
getActivationFeedback
Description copied from class:ToolProvide 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 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:
getActivationFeedbackin classTool- Parameters:
e- theMouseEditEvent- Returns:
- the
Tool.ActivationRequest
-
getPointedEditEventActivationFeedback
-
getActivationFeedback
Description copied from class:ToolProvide 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 usingTool.getActivationRequestForTouchStart(TouchEditEvent)orTool.getActivationRequestForTouchMove(TouchEditEvent).- Overrides:
getActivationFeedbackin classTool- Parameters:
e- theTouchEditEvent- Returns:
- the
Tool.ActivationRequest
-
handleTouchStart
Description copied from class:ToolInvoked when a touch started.- Overrides:
handleTouchStartin classTool- Parameters:
e- theTouchEditEventisActive- whether this tool is currently active
-
handleTouchMove
Description copied from class:ToolInvoked when a touch changed.- Overrides:
handleTouchMovein classTool- Parameters:
e- theTouchEditEventisActive- 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:ToolHandle 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:
handleEditEventin 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 theAnnotationTooltipGeneratorwhich shall be used to create a tooltip for a hovered annotation.- Parameters:
tooltipGenerator- TheAnnotationTooltipGeneratorgenerating the tooltip
-
getCurrentPage
-
setMultiAnnoMode
public void setMultiAnnoMode(boolean multiAnnoMode) -
handleMouseClicked
All the handleMouse... and handleKey... methods are only called in annotation edit mode.- Overrides:
handleMouseClickedin classTool- Parameters:
e- theMouseEditEventisActive- whether this tool is currently active
-
handleMouseExited
Description copied from class:ToolInvoked when the mouse cursor exits the unobscured part of component's geometry.- Overrides:
handleMouseExitedin classTool- Parameters:
e- theMouseEditEventisActive- whether this tool is currently active
-
handleMouseEntered
Description copied from class:ToolInvoked when the mouse cursor enters the unobscured part of component's geometry.- Overrides:
handleMouseEnteredin classTool- Parameters:
e- theMouseEditEventisActive- whether this tool is currently active
-
handleMouseMoved
Description copied from class:ToolInvoked when the mouse cursor has been moved onto a component but no buttons have been pushed.- Overrides:
handleMouseMovedin classTool- Parameters:
e- the eventisActive- whether this tool is currently active
-
handleMouseDragged
Description copied from class:ToolInvoked 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.- Overrides:
handleMouseDraggedin classTool- Parameters:
e- the eventisActive- whether this tool is currently active
-
handleMousePressed
Description copied from class:ToolInvoked when a mouse button has been pressed on a component.- Overrides:
handleMousePressedin 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:ToolInvoked when a key has been pressed. See the class description forKeyEventfor a definition of a key pressed event.- Overrides:
handleKeyPressedin classTool- Parameters:
e- theMouseEditEventisActive- whether this tool is currently active
-
handleMouseReleased
Description copied from class:ToolInvoked when a mouse button has been released on a component.- Overrides:
handleMouseReleasedin 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
-