com.levigo.jadice.swing.annotation
Class AnnotationTool

java.lang.Object
  extended by com.levigo.jadice.swing.tool.Tool
      extended by com.levigo.jadice.swing.internal.tool.AbstractBaseTool
          extended by com.levigo.jadice.swing.annotation.AnnotationTool
All Implemented Interfaces:
MenuContributor

public class AnnotationTool
extends com.levigo.jadice.swing.internal.tool.AbstractBaseTool

A tool used to edit Annotations.


Nested Class Summary
static class AnnotationTool.Mode
           
 
Nested classes/interfaces inherited from class com.levigo.jadice.swing.tool.Tool
Tool.ActivationRequest
 
Field Summary
static ExtResourceBundle BUNDLE
           
 
Fields inherited from class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
activeGesture, currentPage, enableContextToolbar, isActive, lastRenderControls, lastRenderedPageBounds
 
Fields inherited from class com.levigo.jadice.swing.tool.Tool
DEFAULT_PRIORITY, MAX_PRIORITY, MIN_PRIORITY
 
Constructor Summary
AnnotationTool()
           
 
Method Summary
protected  void activateToolbar()
           
protected  void afterHandleEditEvent(boolean isActive, EditEvent e, Object gadget)
           
protected  Object beforeHandleEditEvent(boolean isActive, EditEvent e)
           
protected  void checkForRenderGeometryChange(RenderControls pageRenderControls, Rectangle renderedPageBounds)
           
 void clearSelection()
          Deselect all annotations.
 void contribute(ContributionContext context, MenuBuilder contextMenu)
          This method is called in order to give the menu contributor a chance to contribute context menu entries via the supplied MenuBuilder.
 void deleteSelected()
          Delete all selected annotations.
 void deselect(Annotation a)
          Deselect given annotation object.
 Tool.ActivationRequest getActivationFeedback(MouseEditEvent e)
          Provide feedback for the user about what would happen, if the mouse were pressed at the current location.
protected  com.levigo.jadice.swing.internal.annotation.editors.AnnotationHoverEditor getContextToolbar()
           
 AnnotationFactory getCreateMode()
          Returns the annotation factory used to create the annotation(s) while in create mode.
 Rectangle getCurrentPageRenderBounds()
           
 RenderControls getCurrentPageRenderControls()
           
protected  int getDispatchPriority()
          Return the dispatch priority for this tool.
 Set<DocumentLayer> getEditableAnnotationLayers()
          Return all DocumentLayer that are considered for annotation editing purposes.
 com.levigo.jadice.swing.internal.annotation.editors.SwingAnnotationEditor getEditor()
           
 AnnotationTool.Mode getMode()
          Returns the annotation mode.
 DocumentLayer getNewAnnotationLayer()
          Return the layer onto which newly created annotations are to be placed.
protected  Point getPreferredToolbarLocation()
           
 List<Annotation> getSelection()
          Returns an unmodifiable view of the currently selected annotations.
protected  void handleEditEventPreDispatch(EditEvent e)
           
protected  void handleKeyPressed(KeyEditEvent e, boolean isActive)
          Invoked when a key has been pressed.
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.
static boolean isOverSelectionPoint(MouseEditEvent e, List<Annotation> selection)
           
 boolean isResetAnnotationModeAfterCreation()
          Returns the resetAnnotationModeAfterCreation.
static void paintHandles(com.levigo.jadice.swing.internal.tool.Handle[] handles, RenderParameters parameters)
           
protected  void render(RenderParameters parameters, boolean isActive)
          Renders the Tool's UI onto the given Graphics2D context using the given RenderControls.
 void select(Annotation annotation, Page onPage)
          Selects the given annotation
 void select(Collection<Annotation> annotations, Page page)
          Selects all the annotations within the given collection
protected  void setActive(boolean active)
          Receive notification from the tool manager about the tool's active state.
 void setCreateMode(AnnotationFactory annotationFactory)
          Set the tool's mode to create annotations of the given type (AnnotationTool.Mode.CREATE).
 void setEditMode()
          (Re-)Set the tool's mode to edit existing annotations (AnnotationTool.Mode.EDIT).
protected  void setManager(ToolManager manager)
          Receives the ToolManager instance, which the Tool implementation has been registered for.
 void setNewAnnotationLayer(DocumentLayer newAnnotationLayer)
          Set the layer onto which newly created annotations are to be placed.
 void setResetAnnotationModeAfterCreation(boolean resetAnnotationModeAfterCreation)
          Sets the resetAnnotationModeAfterCreation.
protected  boolean shallHandleEditEvent(boolean isActive, EditEvent e)
           
protected  boolean toolbarShallBeActive()
           
 
Methods inherited from class com.levigo.jadice.swing.internal.tool.AbstractBaseTool
autoscroll, deactivateToolbar, endGesture, getActiveGesture, getCurrentPage, getUndoManager, handleEditEvent, isEnableContextToolbar, serviceGesture, setEnableContextToolbar, startGesture, switchFocus, updateToolbarLocation, updateToolbarVisibility
 
Methods inherited from class com.levigo.jadice.swing.tool.Tool
getActivationRequest, getActivationRequestForKeyPressed, getActivationRequestForMouseDragged, getActivationRequestForMousePressed, getCursor, getManager, getRenderPriority, handleKeyReleased, handleKeyTyped, handleMouseClicked, handleMouseDragged, handleMouseEntered, handleMouseExited, handleMouseWheelMoved, propagatePropertyChange, setCursor, setEnabled, setStatusFeedback
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUNDLE

public static final ExtResourceBundle BUNDLE
Constructor Detail

AnnotationTool

@CallOnEDT
public AnnotationTool()
Method Detail

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
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
isActive - whether this tool is currently active

getActivationFeedback

@CallOnEDT
public 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 MouseEvent.MOUSE_MOVED events. 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

clearSelection

@CallOnEDT
public void clearSelection()
Deselect all annotations.

Throws:
IllegalStateException - if the calling thread is not the Event Dispatch Thread

deselect

@CallOnEDT
public void deselect(Annotation a)
Deselect given annotation object.

Parameters:
a - Annotation to deselect
Throws:
IllegalStateException - if the calling thread is not the Event Dispatch Thread

select

@CallOnEDT
public void select(Annotation annotation,
                             Page onPage)
Selects the given annotation

Parameters:
annotation -
onPage - the page on which the annotation resides
Throws:
IllegalStateException - if the calling thread is not the Event Dispatch Thread

select

@CallOnEDT
public void select(Collection<Annotation> annotations,
                             Page page)
Selects all the annotations within the given collection

Parameters:
annotations -
page - the page on which the annotations reside
Throws:
IllegalStateException - if the calling thread is not the Event Dispatch Thread

shallHandleEditEvent

protected boolean shallHandleEditEvent(boolean isActive,
                                       EditEvent e)
Overrides:
shallHandleEditEvent in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

beforeHandleEditEvent

protected Object beforeHandleEditEvent(boolean isActive,
                                       EditEvent e)
Overrides:
beforeHandleEditEvent in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

afterHandleEditEvent

protected void afterHandleEditEvent(boolean isActive,
                                    EditEvent e,
                                    Object gadget)
Overrides:
afterHandleEditEvent in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

handleEditEventPreDispatch

protected void handleEditEventPreDispatch(EditEvent e)
Overrides:
handleEditEventPreDispatch in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

activateToolbar

protected void activateToolbar()
Overrides:
activateToolbar in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

toolbarShallBeActive

protected boolean toolbarShallBeActive()
Overrides:
toolbarShallBeActive in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

getEditor

@CallOnEDT
public com.levigo.jadice.swing.internal.annotation.editors.SwingAnnotationEditor getEditor()

getContextToolbar

protected com.levigo.jadice.swing.internal.annotation.editors.AnnotationHoverEditor getContextToolbar()
Overrides:
getContextToolbar in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

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
isActive - whether this tool is currently active

isOverSelectionPoint

@CallOnEDT
public static boolean isOverSelectionPoint(MouseEditEvent e,
                                                     List<Annotation> selection)

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
isActive - whether this tool is currently active

getCreateMode

@CallOnEDT
public AnnotationFactory getCreateMode()
Returns the annotation factory used to create the annotation(s) while in create mode.

Returns:
AnnotationFactory the factory used to create the annotations

getMode

@CallOnEDT
public AnnotationTool.Mode getMode()
Returns the annotation mode.

Returns:
the mode

setEditMode

@CallOnEDT
public void setEditMode()
(Re-)Set the tool's mode to edit existing annotations (AnnotationTool.Mode.EDIT).


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 com.levigo.jadice.swing.internal.tool.AbstractBaseTool

setCreateMode

@CallOnEDT
public void setCreateMode(AnnotationFactory annotationFactory)
Set the tool's mode to create annotations of the given type (AnnotationTool.Mode.CREATE).

Parameters:
annotationFactory -
Throws:
IllegalStateException - if the calling thread is not the Event Dispatch Thread

isResetAnnotationModeAfterCreation

@CallOnEDT
public boolean isResetAnnotationModeAfterCreation()
Returns the resetAnnotationModeAfterCreation.

Returns:
boolean
Throws:
IllegalStateException - if the calling thread is not the Event Dispatch Thread

setResetAnnotationModeAfterCreation

@CallOnEDT
public void setResetAnnotationModeAfterCreation(boolean resetAnnotationModeAfterCreation)
Sets the resetAnnotationModeAfterCreation.

Parameters:
resetAnnotationModeAfterCreation - The resetAnnotationModeAfterCreation to set
Throws:
IllegalStateException - if the calling thread is not the Event Dispatch Thread

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

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 com.levigo.jadice.swing.internal.tool.AbstractBaseTool
Parameters:
parameters - the view component which is currently being rendered
isActive - whether the called tool is currently active

checkForRenderGeometryChange

protected void checkForRenderGeometryChange(RenderControls pageRenderControls,
                                            Rectangle renderedPageBounds)
Overrides:
checkForRenderGeometryChange in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

paintHandles

@CallOnEDT
public static void paintHandles(com.levigo.jadice.swing.internal.tool.Handle[] handles,
                                          RenderParameters parameters)
Parameters:
handles -
parameters - the render parameters

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

getSelection

@CallOnEDT
public List<Annotation> getSelection()
Returns an unmodifiable view of the currently selected annotations. Note that this view is backed by the live collection of selected annotations which might change over time. These changes will at some point in time be reflected by the returned view.

Returns:
a view of selected annotations

deleteSelected

@CallOnEDT
public void deleteSelected()
Delete all selected annotations.

Throws:
IllegalStateException - if the calling thread is not the Event Dispatch Thread

contribute

@CallOnEDT
public void contribute(ContributionContext context,
                                 MenuBuilder contextMenu)
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
contextMenu - the MenuBuilder to which the tool may contribute entries.

getPreferredToolbarLocation

protected Point getPreferredToolbarLocation()
Overrides:
getPreferredToolbarLocation in class com.levigo.jadice.swing.internal.tool.AbstractBaseTool

getCurrentPageRenderBounds

@CallOnEDT
public Rectangle getCurrentPageRenderBounds()

getCurrentPageRenderControls

@CallOnEDT
public RenderControls getCurrentPageRenderControls()

getEditableAnnotationLayers

@CallOnEDT
public Set<DocumentLayer> getEditableAnnotationLayers()
Return all DocumentLayer that are considered for annotation editing purposes. By default only the DocumentLayer.ANNOTATIONS is considered. The list is live and can be edited to add or remove layers to be considered.

Returns:
the list of document layers

getNewAnnotationLayer

@CallOnEDT
public DocumentLayer getNewAnnotationLayer()
Return the layer onto which newly created annotations are to be placed. By default new annotations are created on the DocumentLayer.ANNOTATIONS.

Returns:
the document layer for new annotations

setNewAnnotationLayer

@CallOnEDT
public void setNewAnnotationLayer(DocumentLayer newAnnotationLayer)
Set the layer onto which newly created annotations are to be placed. By default new annotations are created on the DocumentLayer.ANNOTATIONS.

Parameters:
newAnnotationLayer - the document layer for new annotations


Copyright © 1995-2020 levigo holding gmbh. All Rights Reserved.