org.icepdf.ri.common.views.annotations
Class AbstractAnnotationComponent

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by org.icepdf.ri.common.views.annotations.AbstractAnnotationComponent
All Implemented Interfaces:
java.awt.event.FocusListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.swing.event.MouseInputListener, AnnotationComponent
Direct Known Subclasses:
MarkupAnnotationComponent, PopupAnnotationComponent, WidgetAnnotationComponent

public abstract class AbstractAnnotationComponent
extends javax.swing.JComponent
implements java.awt.event.FocusListener, javax.swing.event.MouseInputListener, AnnotationComponent

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
javax.swing.JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected  org.icepdf.core.pobjects.annotations.Annotation annotation
           
protected static float annotationHighlightAlpha
           
protected static java.awt.Color annotationHighlightColor
           
protected  float currentRotation
           
protected  float currentZoom
           
protected  int cursor
           
protected  DocumentViewController documentViewController
           
protected  DocumentViewModel documentViewModel
           
protected  java.awt.Point endOfMousePress
           
protected  boolean isEditable
           
protected static boolean isInteractiveAnnotationsEnabled
           
protected  boolean isMousePressed
           
protected  boolean isMovable
           
protected  boolean isResizable
           
protected  boolean isRollover
           
protected  boolean isSelected
           
protected  boolean isShowInvisibleBorder
           
protected static java.util.logging.Logger logger
           
protected  java.util.ResourceBundle messageBundle
           
protected  AbstractPageViewComponent pageViewComponent
           
protected  AnnotationState previousAnnotationState
           
protected static ResizableBorder resizableBorder
           
static int resizeBoxSize
           
protected  boolean resized
           
protected  java.awt.Point startOfMousePress
           
protected  java.awt.Point startPos
           
protected  boolean wasResized
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, 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
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
AbstractAnnotationComponent(org.icepdf.core.pobjects.annotations.Annotation annotation, DocumentViewController documentViewController, AbstractPageViewComponent pageViewComponent, DocumentViewModel documentViewModel)
           
 
Method Summary
protected  boolean additionalActionsHandler(org.icepdf.core.pobjects.Name additionalActionKey, java.awt.event.MouseEvent e)
           
protected  java.awt.Rectangle commonBoundsNormalization(java.awt.geom.GeneralPath shapePath, java.awt.geom.AffineTransform at)
          Normalizes and the given path with the specified transform.
protected  java.awt.Rectangle convertToPageSpace(java.awt.Rectangle rect)
          Convert the shapes that make up the annotation to page space so that they will scale correctly at different zooms.
 void dispose()
           
 void focusGained(java.awt.event.FocusEvent e)
           
 void focusLost(java.awt.event.FocusEvent e)
           
 org.icepdf.core.pobjects.annotations.Annotation getAnnotation()
          Gets wrapped annotation object.
 org.icepdf.core.pobjects.Document getDocument()
           
 int getPageIndex()
           
protected  java.awt.geom.AffineTransform getPageTransform()
           
 AbstractPageViewComponent getPageViewComponent()
           
 PageViewComponent getParentPageView()
           
protected  void initiateMouseMoved(java.awt.event.MouseEvent e)
           
abstract  boolean isActive()
           
 boolean isBorderStyle()
          border has defined style.
 boolean isEditable()
          Is the annotation editable
 boolean isMovable()
          Component is movable.
 boolean isResizable()
          Component is resizable.
 boolean isRollover()
          Component highlight/select border is draw on mouse over.
 boolean isSelected()
           
 boolean isShowInvisibleBorder()
          Component is editable, contents can be updated in ui
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent me)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent mouseEvent)
           
 void mouseMoved(java.awt.event.MouseEvent me)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent mouseEvent)
           
abstract  void paintComponent(java.awt.Graphics g)
           
 void refreshAnnotationRect()
          Refreshes/transforms the page space bounds back to user space.
 void refreshDirtyBounds()
          Refreshes the components bounds for the current page transformation.
 void removeMouseListeners()
           
abstract  void resetAppearanceShapes()
           
protected  void resize()
           
 void setSelected(boolean selected)
           
 void validate()
           
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, 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, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, 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, transferFocusBackward, 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, 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, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, 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, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, 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 java.util.logging.Logger logger

isInteractiveAnnotationsEnabled

protected static boolean isInteractiveAnnotationsEnabled

annotationHighlightColor

protected static java.awt.Color annotationHighlightColor

annotationHighlightAlpha

protected static float annotationHighlightAlpha

resizeBoxSize

public static final int resizeBoxSize
See Also:
Constant Field Values

resizableBorder

protected static ResizableBorder resizableBorder

pageViewComponent

protected AbstractPageViewComponent pageViewComponent

documentViewController

protected DocumentViewController documentViewController

documentViewModel

protected DocumentViewModel documentViewModel

currentZoom

protected float currentZoom

currentRotation

protected float currentRotation

annotation

protected org.icepdf.core.pobjects.annotations.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

cursor

protected int cursor

startPos

protected java.awt.Point startPos

previousAnnotationState

protected AnnotationState previousAnnotationState

startOfMousePress

protected java.awt.Point startOfMousePress

endOfMousePress

protected java.awt.Point endOfMousePress

messageBundle

protected java.util.ResourceBundle messageBundle
Constructor Detail

AbstractAnnotationComponent

public AbstractAnnotationComponent(org.icepdf.core.pobjects.annotations.Annotation annotation,
                                   DocumentViewController documentViewController,
                                   AbstractPageViewComponent pageViewComponent,
                                   DocumentViewModel documentViewModel)
Method Detail

isActive

public abstract boolean isActive()

getDocument

public org.icepdf.core.pobjects.Document getDocument()
Specified by:
getDocument in interface AnnotationComponent

getPageIndex

public int getPageIndex()
Specified by:
getPageIndex in interface AnnotationComponent

getParentPageView

public PageViewComponent getParentPageView()
Specified by:
getParentPageView in interface AnnotationComponent

getPageViewComponent

public AbstractPageViewComponent getPageViewComponent()
Specified by:
getPageViewComponent in interface AnnotationComponent

removeMouseListeners

public void removeMouseListeners()

getAnnotation

public org.icepdf.core.pobjects.annotations.Annotation getAnnotation()
Description copied from interface: AnnotationComponent
Gets wrapped annotation object.

Specified by:
getAnnotation in interface AnnotationComponent
Returns:
annotation that this component wraps.

focusGained

public void focusGained(java.awt.event.FocusEvent e)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Specified by:
focusLost in interface java.awt.event.FocusListener

resize

protected void resize()

refreshDirtyBounds

public void refreshDirtyBounds()
Refreshes the components bounds for the current page transformation. Bounds have are already in user space.

Specified by:
refreshDirtyBounds in interface AnnotationComponent

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:
refreshAnnotationRect in interface AnnotationComponent

commonBoundsNormalization

protected java.awt.Rectangle commonBoundsNormalization(java.awt.geom.GeneralPath shapePath,
                                                       java.awt.geom.AffineTransform at)
Normalizes and the given path with the specified transform. The method also rounds the Rectangle2D bounds values when creating a new rectangle instead of truncating the values.

Parameters:
shapePath - path to apply transform to
at - transform to apply to shapePath
Returns:
bound value of the shape path.

validate

public void validate()
Overrides:
validate in class java.awt.Container

paintComponent

public abstract void paintComponent(java.awt.Graphics g)
Overrides:
paintComponent in class javax.swing.JComponent

resetAppearanceShapes

public abstract void resetAppearanceShapes()
Specified by:
resetAppearanceShapes in interface AnnotationComponent

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent me)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

dispose

public void dispose()
Specified by:
dispose in interface AnnotationComponent

mouseExited

public void mouseExited(java.awt.event.MouseEvent mouseEvent)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

additionalActionsHandler

protected boolean additionalActionsHandler(org.icepdf.core.pobjects.Name additionalActionKey,
                                           java.awt.event.MouseEvent e)

initiateMouseMoved

protected void initiateMouseMoved(java.awt.event.MouseEvent e)

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent me)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent mouseEvent)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

convertToPageSpace

protected java.awt.Rectangle convertToPageSpace(java.awt.Rectangle rect)
Convert the shapes that make up the annotation to page space so that they will scale correctly at different zooms.

Returns:
transformed bbox.

getPageTransform

protected java.awt.geom.AffineTransform getPageTransform()

isEditable

public boolean isEditable()
Is the annotation editable

Specified by:
isEditable in interface AnnotationComponent
Returns:
true if editable, false otherwise.

isRollover

public boolean isRollover()
Description copied from interface: AnnotationComponent
Component highlight/select border is draw on mouse over.

Specified by:
isRollover in interface AnnotationComponent

isBorderStyle

public boolean isBorderStyle()
Description copied from interface: AnnotationComponent
border has defined style.

Specified by:
isBorderStyle in interface AnnotationComponent
Returns:

isSelected

public boolean isSelected()
Specified by:
isSelected in interface AnnotationComponent

setSelected

public void setSelected(boolean selected)
Specified by:
setSelected in interface AnnotationComponent

isMovable

public boolean isMovable()
Description copied from interface: AnnotationComponent
Component is movable.

Specified by:
isMovable in interface AnnotationComponent

isResizable

public boolean isResizable()
Description copied from interface: AnnotationComponent
Component is resizable.

Specified by:
isResizable in interface AnnotationComponent

isShowInvisibleBorder

public boolean isShowInvisibleBorder()
Description copied from interface: AnnotationComponent
Component is editable, contents can be updated in ui

Specified by:
isShowInvisibleBorder in interface AnnotationComponent