Module org.icepdf.ri.viewer
Class AbstractAnnotationComponent<T extends Annotation>
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- org.icepdf.ri.common.views.annotations.AbstractAnnotationComponent<T>
-
- All Implemented Interfaces:
FocusListener,MouseListener,MouseMotionListener,ImageObserver,MenuContainer,Serializable,EventListener,MouseInputListener,AnnotationComponent,ResizeableComponent
- Direct Known Subclasses:
AbstractButtonComponent,AbstractChoiceComponent,LinkAnnotationComponent,MarkupAnnotationComponent,PopupAnnotationComponent,SignatureComponent,TextWidgetComponent,WidgetAnnotationComponent
public abstract class AbstractAnnotationComponent<T extends Annotation> extends JComponent implements FocusListener, MouseInputListener, AnnotationComponent, ResizeableComponent
AbstractAnnotationComponent contains base functionality for annotation components which are used to display annotation for a given page view. This class controls icon state, focus and basic component states: editable, movable, resizable, selected and show invisible border.- Since:
- 5.0
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
-
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
-
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
-
Field Summary
Fields Modifier and Type Field Description protected Tannotationprotected static floatannotationHighlightAlphaprotected static ColorannotationHighlightColorprotected JPopupMenucontextMenuprotected floatcurrentRotationprotected floatcurrentZoomprotected intcursorprotected DocumentViewControllerdocumentViewControllerprotected intdxprotected intdyprotected PointendOfMousePressprotected booleanisEditableprotected booleanisMousePressedprotected booleanisMovableprotected booleanisResizableprotected booleanisRolloverprotected booleanisSelectedprotected booleanisShowInvisibleBorderprotected booleanisSyntheticprotected static Loggerloggerprotected ResourceBundlemessageBundleprotected PageViewComponentImplpageViewComponentprotected AnnotationStatepreviousAnnotationStateprotected static ResizableBorderresizableBorderstatic intresizeBoxSizeprotected booleanresizedprotected PointstartOfMousePressprotected PointstartPosprotected booleanwasResized-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
Fields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
-
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
-
-
Constructor Summary
Constructors Constructor Description AbstractAnnotationComponent(T annotation, DocumentViewController documentViewController, AbstractPageViewComponent pageViewComponent)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected booleanadditionalActionsHandler(Name additionalActionKey, MouseEvent e)RectangleconvertToPageSpace(Rectangle rect)Convert the shapes that make up the annotation to page space so that they will scale correctly at different zooms.protected ShapeconvertToPageSpace(Shape shape)Convert the shapes that make up the annotation to page space so that they will scale correctly at different zooms.voiddispose()Dispose this component resources.voidfocusGained(FocusEvent e)voidfocusLost(FocusEvent e)TgetAnnotation()Gets wrapped annotation object.DocumentgetDocument()Document that annotation belows too.intgetPageIndex()Page index that annotation component resides on.protected AffineTransformgetPageSpaceTransform()AbstractPageViewComponentgetPageViewComponent()Gets the parent page view that displays this component.protected AffineTransformgetToPageSpaceTransform()protected voidinitiateMouseMoved(MouseEvent e)abstract booleanisActive()booleanisBorderStyle()border has defined style.booleanisEditable()Is the annotation editablebooleanisMovable()Component is movable.booleanisResizable()Component is resizable.booleanisRollover()Component highlight/select border is draw on mouse over.booleanisSelected()Annotation is in a selected state.booleanisShowInvisibleBorder()Component is editable, contents can be updated in uibooleanisSynthetic()protected RectanglelimitAnnotationPosition(int x, int y, int width, int height)voidmouseClicked(MouseEvent e)voidmouseDragged(MouseEvent me)voidmouseEntered(MouseEvent e)voidmouseExited(MouseEvent mouseEvent)voidmouseMoved(MouseEvent me)voidmousePressed(MouseEvent e)voidmouseReleased(MouseEvent mouseEvent)voidpaintComponent(Graphics g)voidrefreshAnnotationRect()Refreshes/transforms the page space bounds back to user space.voidrefreshDirtyBounds()Refreshes the components bounds for the current page transformation.voidremoveMouseListeners()abstract voidresetAppearanceShapes()Rest the annotation appearance stream.protected voidresize()voidsetBounds(int x, int y, int width, int height)voidsetSelected(boolean selected)Sets the selected statevoidsetSynthetic(boolean synthetic)voidvalidate()-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validateTree
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.icepdf.ri.common.views.AnnotationComponent
hasFocus, repaint
-
-
-
-
Field Detail
-
logger
protected static final Logger logger
-
annotationHighlightColor
protected static Color annotationHighlightColor
-
annotationHighlightAlpha
protected static float annotationHighlightAlpha
-
isSynthetic
protected boolean isSynthetic
-
resizeBoxSize
public static final int resizeBoxSize
- See Also:
- Constant Field Values
-
resizableBorder
protected static final ResizableBorder resizableBorder
-
pageViewComponent
protected PageViewComponentImpl pageViewComponent
-
documentViewController
protected DocumentViewController documentViewController
-
currentZoom
protected float currentZoom
-
currentRotation
protected float currentRotation
-
annotation
protected T extends Annotation annotation
-
isMousePressed
protected boolean isMousePressed
-
resized
protected boolean resized
-
wasResized
protected boolean wasResized
-
isEditable
protected boolean isEditable
-
isRollover
protected boolean isRollover
-
isMovable
protected boolean isMovable
-
isResizable
protected boolean isResizable
-
isShowInvisibleBorder
protected boolean isShowInvisibleBorder
-
isSelected
protected boolean isSelected
-
dx
protected int dx
-
dy
protected int dy
-
cursor
protected int cursor
-
startPos
protected Point startPos
-
previousAnnotationState
protected AnnotationState previousAnnotationState
-
startOfMousePress
protected Point startOfMousePress
-
endOfMousePress
protected Point endOfMousePress
-
contextMenu
protected JPopupMenu contextMenu
-
messageBundle
protected ResourceBundle messageBundle
-
-
Constructor Detail
-
AbstractAnnotationComponent
public AbstractAnnotationComponent(T annotation, DocumentViewController documentViewController, AbstractPageViewComponent pageViewComponent)
-
-
Method Detail
-
isActive
public abstract boolean isActive()
- Specified by:
isActivein interfaceAnnotationComponent
-
getDocument
public Document getDocument()
Description copied from interface:AnnotationComponentDocument that annotation belows too.- Specified by:
getDocumentin interfaceAnnotationComponent- Returns:
- document parent.
-
getPageIndex
public int getPageIndex()
Description copied from interface:AnnotationComponentPage index that annotation component resides on.- Specified by:
getPageIndexin interfaceAnnotationComponent- Returns:
- page index of parent page
-
getPageViewComponent
public AbstractPageViewComponent getPageViewComponent()
Description copied from interface:AnnotationComponentGets the parent page view that displays this component.- Specified by:
getPageViewComponentin interfaceAnnotationComponent- Returns:
- parent component.
-
removeMouseListeners
public void removeMouseListeners()
-
getAnnotation
public T getAnnotation()
Description copied from interface:AnnotationComponentGets wrapped annotation object.- Specified by:
getAnnotationin interfaceAnnotationComponent- Returns:
- annotation that this component wraps.
-
focusGained
public void focusGained(FocusEvent e)
- Specified by:
focusGainedin interfaceFocusListener
-
focusLost
public void focusLost(FocusEvent e)
- Specified by:
focusLostin interfaceFocusListener
-
resize
protected void resize()
-
refreshDirtyBounds
public void refreshDirtyBounds()
Refreshes the components bounds for the current page transformation. Bounds are already in user space.- Specified by:
refreshDirtyBoundsin interfaceAnnotationComponent
-
refreshAnnotationRect
public void refreshAnnotationRect()
Refreshes/transforms the page space bounds back to user space. This must be done in order refresh the annotation user space rectangle after UI manipulation, otherwise the annotation will be incorrectly located on the next repaint.- Specified by:
refreshAnnotationRectin interfaceAnnotationComponent
-
paintComponent
public void paintComponent(Graphics g)
- Overrides:
paintComponentin classJComponent
-
resetAppearanceShapes
public abstract void resetAppearanceShapes()
Description copied from interface:AnnotationComponentRest the annotation appearance stream.- Specified by:
resetAppearanceShapesin interfaceAnnotationComponent
-
mouseMoved
public void mouseMoved(MouseEvent me)
- Specified by:
mouseMovedin interfaceMouseMotionListener
-
dispose
public void dispose()
Description copied from interface:AnnotationComponentDispose this component resources.- Specified by:
disposein interfaceAnnotationComponent
-
mouseExited
public void mouseExited(MouseEvent mouseEvent)
- Specified by:
mouseExitedin interfaceMouseListener
-
mouseClicked
public void mouseClicked(MouseEvent e)
- Specified by:
mouseClickedin interfaceMouseListener
-
mouseEntered
public void mouseEntered(MouseEvent e)
- Specified by:
mouseEnteredin interfaceMouseListener
-
mousePressed
public void mousePressed(MouseEvent e)
- Specified by:
mousePressedin interfaceMouseListener
-
additionalActionsHandler
protected boolean additionalActionsHandler(Name additionalActionKey, MouseEvent e)
-
initiateMouseMoved
protected void initiateMouseMoved(MouseEvent e)
-
mouseDragged
public void mouseDragged(MouseEvent me)
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
setBounds
public void setBounds(int x, int y, int width, int height)
-
limitAnnotationPosition
protected Rectangle limitAnnotationPosition(int x, int y, int width, int height)
-
mouseReleased
public void mouseReleased(MouseEvent mouseEvent)
- Specified by:
mouseReleasedin interfaceMouseListener
-
convertToPageSpace
public Rectangle convertToPageSpace(Rectangle rect)
Convert the shapes that make up the annotation to page space so that they will scale correctly at different zooms.- Parameters:
rect- rectangle to convert to page space.- Returns:
- transformed bbox.
-
convertToPageSpace
protected Shape convertToPageSpace(Shape shape)
Convert the shapes that make up the annotation to page space so that they will scale correctly at different zooms.- Parameters:
shape- shape to convert to page space.- Returns:
- transformed bbox.
-
getToPageSpaceTransform
protected AffineTransform getToPageSpaceTransform()
-
getPageSpaceTransform
protected AffineTransform getPageSpaceTransform()
-
isEditable
public boolean isEditable()
Is the annotation editable- Specified by:
isEditablein interfaceAnnotationComponent- Specified by:
isEditablein interfaceResizeableComponent- Returns:
- true if editable, false otherwise.
-
isRollover
public boolean isRollover()
Description copied from interface:AnnotationComponentComponent highlight/select border is draw on mouse over.- Specified by:
isRolloverin interfaceAnnotationComponent- Specified by:
isRolloverin interfaceResizeableComponent- Returns:
- true if is rollover, false otherwise.
-
isBorderStyle
public boolean isBorderStyle()
Description copied from interface:AnnotationComponentborder has defined style.- Specified by:
isBorderStylein interfaceAnnotationComponent- Specified by:
isBorderStylein interfaceResizeableComponent- Returns:
- true if has border style, false otherwise.
-
isSelected
public boolean isSelected()
Description copied from interface:AnnotationComponentAnnotation is in a selected state. Used for drawing a highlighted state.- Specified by:
isSelectedin interfaceAnnotationComponent- Specified by:
isSelectedin interfaceResizeableComponent- Returns:
- is selected
-
setSelected
public void setSelected(boolean selected)
Description copied from interface:AnnotationComponentSets the selected state- Specified by:
setSelectedin interfaceAnnotationComponent- Parameters:
selected- selected state.
-
isMovable
public boolean isMovable()
Description copied from interface:AnnotationComponentComponent is movable.- Specified by:
isMovablein interfaceAnnotationComponent- Specified by:
isMovablein interfaceResizeableComponent- Returns:
- true if movable, false otherwise.
-
isResizable
public boolean isResizable()
Description copied from interface:AnnotationComponentComponent is resizable.- Specified by:
isResizablein interfaceAnnotationComponent- Specified by:
isResizablein interfaceResizeableComponent- Returns:
- true if resizable, false otherwise.
-
isShowInvisibleBorder
public boolean isShowInvisibleBorder()
Description copied from interface:AnnotationComponentComponent is editable, contents can be updated in ui- Specified by:
isShowInvisibleBorderin interfaceAnnotationComponent- Specified by:
isShowInvisibleBorderin interfaceResizeableComponent- Returns:
- true if show invisible border, false otherwise.
-
isSynthetic
public boolean isSynthetic()
- Specified by:
isSyntheticin interfaceAnnotationComponent
-
setSynthetic
public void setSynthetic(boolean synthetic)
- Specified by:
setSyntheticin interfaceAnnotationComponent
-
-