Class TextAnnotationWrangler
java.lang.Object
com.levigo.jadice.annotation.AnnotationWrangler
com.levigo.jadice.web.client.internal.annotation.Wrangler<TextAnnotation>
com.levigo.jadice.web.client.internal.annotation.wrangler.DefaultWrangler<TextAnnotation>
com.levigo.jadice.web.client.internal.annotation.wrangler.TextAnnotationWrangler
- Direct Known Subclasses:
CalloutAnnotationWrangler
,IconifiedTextAnnotationWrangler
,StampAnnotationWrangler
Manages the creation of text annotations.
This class is referenced in annotation profiles by its full classname. It supports parameterization via annotation profiles.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Possible values for the initial cursor position in the TextEditor.static enum
Possible values for the behavior of the TextEditor when an outside click occursstatic enum
static enum
How to behave on rotated Pagesstatic class
static enum
Possible values for initial text selection in the TextEditor.Nested classes/interfaces inherited from class com.levigo.jadice.web.client.internal.annotation.wrangler.DefaultWrangler
DefaultWrangler.CreationMode
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected TextAnnotationWrangler.CursorPosition
Profile-injected parameter that defines the initial cursor position in the TextEditor.Profile injected parameter that defines the behavior of the TextEditor on an outside click.protected int
Profile-injected parameter.protected int
Profile-injected parameter.protected boolean
Profile-injected parameter.protected TextAnnotationWrangler.ExpandHeight
Profile injected parameter that defines the behavior of the annotation according to the text lengthProfile-injected parameter that defines the initial behavior for rotated Pagesprotected Boolean
protected TextAnnotationWrangler.TextSelection
Profile-injected parameter that defines the initial text selection behavior in the TextEditor.Fields inherited from class com.levigo.jadice.web.client.internal.annotation.wrangler.DefaultWrangler
boundsType, createAnno, createEnd, createStart, EMPTY_HANDLE_LIST, MINIMUM_HEIGHT, MINIMUM_WIDTH, minimumHeight, minimumWidth, selectionInspector
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterCreate
(EditEvent editEvent, TextAnnotation selected, Object... params) Opens the text editor directly after creating a text based annotation.protected Rectangle
calculateEditorBounds
(PageView pageView, Page page, TextAnnotation selected) Calculates the editor bounds which should be the same size and position as the text annotation.void
contribute
(ContributionContext cc, MenuBuilder builder, List<? extends Annotation> selected) Contributes an icon to open the text editor popup.protected TextEditor
createTextEditor
(int editorMinWidth, int editorMinHeight, TextAnnotation selected, double pageHeight) Creates a text editor.int
Returns the minimum text editor height.int
Returns the minimum text editor width.getHandles
(PageView pageView, Page page, TextAnnotation annotation) Creates handles for a specific annotation.protected EffectIcon
getIcon
(List<? extends Annotation> selected, Document doc) protected ToggleIconFont
getIconFont
(List<? extends Annotation> selected, Document doc) protected float
getMultiplier
(PageView pageView, Page page) This method calculates the multiplier for the correct translation of units for a correct presentation and positioning of the editor.void
handleEditEvent
(EditEvent e, TextAnnotation selected, AnnotationEditor editor) Called whenever a text annotation is edited.boolean
Indicates whether this wrangler executes an action after annotation creation.boolean
isSelectionPoint
(Annotation annotation, Point2D mousePoint, int tolerance, boolean b, int lineWidthFactor) boolean
Returns if the handle to rotate the annotation is displayed.protected void
openTextEditor
(TextAnnotation selected, Page page, RenderControls controls, PageView pageView, int editorMinWidth, int editorMinHeight) Opens the text editor in a new popup.boolean
This can be overriden by any subclass to disable the initial resizing when an annotation is added with a single click.void
setCursorPosition
(TextAnnotationWrangler.CursorPosition cursorPosition) void
setEditorBehaviorOnOutsideClick
(TextAnnotationWrangler.EditorBehaviorOnOutsideClick behaviorOnOutsideClick) void
setEditorHeight
(int editorHeight) Used to inject the value defined in the annotation profile.void
setEditorWidth
(int width) Used to inject the value defined in the annotation profile.void
setExecuteActionAfterCreation
(boolean executeActionAfterCreation) Used to inject the value defined in the annotation profile.void
setExpandHeight
(TextAnnotationWrangler.ExpandHeight expandHeight) Used to inject the value defined in the annotation profile.void
setForceAnnotationUpright
(TextAnnotationWrangler.ForceAnnotationUpright forceAnnotationUpright) void
setShowRotationHandle
(boolean showRotationHandle) Used to inject the value defined in the annotation profile.void
setTextSelection
(TextAnnotationWrangler.TextSelection textSelection) protected void
updateCreated
(EditEvent editEvent, TextAnnotation createAnno, Point2D createStart, Point2D createEnd) Methods inherited from class com.levigo.jadice.web.client.internal.annotation.wrangler.DefaultWrangler
calcMinWidth, getCreationMode, getCursor, getMinimumHeight, getMinimumWidth, handleCreateEditEvent, isSelectionTouchPoint, setCreationMode, setMinimumHeight, setMinimumWidth
-
Field Details
-
executeActionAfterCreation
protected boolean executeActionAfterCreationProfile-injected parameter. Instructs this wrangler implementation to open the text editor automatically after creating a text annotation.Defaults to false.
-
showRotationHandle
-
editorWidth
protected int editorWidthProfile-injected parameter. Instructs this wrangler implementation to open the text editor with the minimum width defined in the annotation profile.Defaults to 50 px.
-
editorHeight
protected int editorHeightProfile-injected parameter. Instructs this wrangler implementation to open the text editor with the minimum width defined in the annotation profile.Defaults to 50 px.
-
textSelection
Profile-injected parameter that defines the initial text selection behavior in the TextEditor. -
cursorPosition
Profile-injected parameter that defines the initial cursor position in the TextEditor. -
forceAnnotationUpright
Profile-injected parameter that defines the initial behavior for rotated Pages -
editorBehaviorOnOutsideClick
Profile injected parameter that defines the behavior of the TextEditor on an outside click. -
expandHeight
Profile injected parameter that defines the behavior of the annotation according to the text length
-
-
Constructor Details
-
TextAnnotationWrangler
public TextAnnotationWrangler()
-
-
Method Details
-
setExpandHeight
Used to inject the value defined in the annotation profile.- Parameters:
expandHeight
- The value defined in the annotation profile.
-
setExecuteActionAfterCreation
public void setExecuteActionAfterCreation(boolean executeActionAfterCreation) Used to inject the value defined in the annotation profile.- Parameters:
executeActionAfterCreation
- The value defined in the annotation profile.
-
setEditorWidth
public void setEditorWidth(int width) Used to inject the value defined in the annotation profile.- Parameters:
width
- The value defined in the annotation profile.
-
setEditorHeight
public void setEditorHeight(int editorHeight) Used to inject the value defined in the annotation profile.- Parameters:
editorHeight
- The value defined in the annotation profile.
-
isExecuteActionAfterCreation
public boolean isExecuteActionAfterCreation()Indicates whether this wrangler executes an action after annotation creation.- Returns:
- True, if
afterCreate(EditEvent, TextAnnotation, Object...)
will be called after each annotation creation. False, else.
-
getEditorWidth
public int getEditorWidth()Returns the minimum text editor width.- Returns:
- The minimum text editor width in px.
-
getEditorHeight
public int getEditorHeight()Returns the minimum text editor height.- Returns:
- The minimum text editor height in px.
-
isShowRotationHandle
public boolean isShowRotationHandle()Returns if the handle to rotate the annotation is displayed.- Returns:
- If the rotation handle is shown.
-
setShowRotationHandle
public void setShowRotationHandle(boolean showRotationHandle) Used to inject the value defined in the annotation profile.- Parameters:
showRotationHandle
- The value defined in the annotation profile.
-
getHandles
Description copied from class:Wrangler
Creates handles for a specific annotation.- Overrides:
getHandles
in classDefaultWrangler<TextAnnotation>
- Parameters:
pageView
- PageView the annotation is shown on (for example for repaint calls)page
- The page that contains the annotationannotation
- The annotation the wrangler should create handles for- Returns:
- Handles that can be used to edit the annotation
-
isSelectionPoint
public boolean isSelectionPoint(Annotation annotation, Point2D mousePoint, int tolerance, boolean b, int lineWidthFactor) - Overrides:
isSelectionPoint
in classDefaultWrangler<TextAnnotation>
-
handleEditEvent
Called whenever a text annotation is edited.Opens the text editor when a selected annotation is double clicked and appropriate permissions are existing.
- Overrides:
handleEditEvent
in classDefaultWrangler<TextAnnotation>
- Parameters:
e
- The event that triggered the editingselected
- The annotation to be editededitor
- The annotation editor that provides all editing options for the annotation
-
createTextEditor
protected TextEditor createTextEditor(int editorMinWidth, int editorMinHeight, TextAnnotation selected, double pageHeight) Creates a text editor. The editor for normal text annotations does not have a minimum size.- Parameters:
pageHeight
-- Returns:
- a new text editor instance.
-
updateCreated
protected void updateCreated(EditEvent editEvent, TextAnnotation createAnno, Point2D createStart, Point2D createEnd) - Overrides:
updateCreated
in classDefaultWrangler<TextAnnotation>
-
afterCreate
Opens the text editor directly after creating a text based annotation.Places the text editor popup at the upper left corner of the created annotation.
- Overrides:
afterCreate
in classDefaultWrangler<TextAnnotation>
- Parameters:
editEvent
- the last mouse event that is related to the creation.selected
- the created annotation.params
- an array containing the coordinates of the upper left corner of the annotation. The text editor is placed there.
-
getIcon
- Returns:
- the icon used for the
AnnotationEditor
-
getIconFont
- Returns:
- the icon used for the
AnnotationEditor
-
getTextSelection
-
setTextSelection
-
getCursorPosition
-
setCursorPosition
-
getForceAnnotationUpright
-
setForceAnnotationUpright
public void setForceAnnotationUpright(TextAnnotationWrangler.ForceAnnotationUpright forceAnnotationUpright) -
setEditorBehaviorOnOutsideClick
public void setEditorBehaviorOnOutsideClick(TextAnnotationWrangler.EditorBehaviorOnOutsideClick behaviorOnOutsideClick) -
getEditorBehaviorOnOutsideClick
-
calculateEditorBounds
Calculates the editor bounds which should be the same size and position as the text annotation. After that the position will be slightly adapted according to the line width of the annotation.- Parameters:
pageView
- thePageView
containing theAnnotation
page
- the page containing theAnnotation
selected
- the selectedAnnotation
- Returns:
- the calculated editor bounds
-
getMultiplier
This method calculates the multiplier for the correct translation of units for a correct presentation and positioning of the editor.- Parameters:
pageView
- thePageView
containing theAnnotation
page
- thePage
containing theAnnotation
- Returns:
- returns the multiplier for correct unit translation
-
scaleByEditorWidth
public boolean scaleByEditorWidth()This can be overriden by any subclass to disable the initial resizing when an annotation is added with a single click.
-