org.icepdf.core.views.common
Class AnnotationHandler

java.lang.Object
  extended by org.icepdf.core.views.common.SelectionBoxHandler
      extended by org.icepdf.core.views.common.AnnotationHandler
All Implemented Interfaces:
java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.util.EventListener, javax.swing.event.MouseInputListener

public class AnnotationHandler
extends SelectionBoxHandler
implements javax.swing.event.MouseInputListener

This classes purpose is to manage annotation selected state and the broadcaset of resized and moved for multiple selected components. The other purpose of this class is to handle the drawing of a selection box and handle the creation of new link annotation when the link annotation tool is selected

Since:
4.0

Field Summary
 
Fields inherited from class org.icepdf.core.views.common.SelectionBoxHandler
currentRect, dash1, previousRectDrawn, rectToDraw, selectionBoxColour, stroke
 
Constructor Summary
AnnotationHandler(AbstractPageViewComponent pageViewComponent, DocumentViewModel documentViewModel)
           
 
Method Summary
 AnnotationComponent addAnnotationComponent(Annotation annotation)
          Wraps the specified annotaiton with a new Annotation component and adds it to the PageViewComponent as a child.
 void addSelectedAnnotation(AnnotationComponentImpl annotationComponent)
          Adds an Annotation component to the list of selected.
 void clearSelectedList()
          Clears the slected list of AnnotationComponent, PageViewComponent focus should be called after this method is called to insure deselection of all AnnotationComponents.
 void createNewLinkAnnotation()
          Creates a new link annotation when the link annotation creation tool is selected.
 void initializeAnnotationComponents(java.util.ArrayList<Annotation> annotations)
          Initializes the annotation components given the annotations collections.
 boolean isMultipleSelect()
          Determines if there are more then one selected component.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void moveSelectedAnnotations(int x, int y)
          Moves all selected annotation components by the x,y translation.
 void paintAnnotations(java.awt.Graphics g)
          Paints all annotation content for a given page view.
 void removeAnnotationComponent(AnnotationComponent annotation)
          Removes the specified annotation from the page view.
 void removeSelectedAnnotation(AnnotationComponentImpl annotationComponent)
          Adds an Annotation component to the list of selected.
 void resizeSelectedAnnotations(int width, int height)
          Resizes all selected annotation components by the width and height values.
 void setDocumentViewController(DocumentViewController documentViewController)
          DocumentController callback
 
Methods inherited from class org.icepdf.core.views.common.SelectionBoxHandler
clearRectangle, getCurrentRect, getRectToDraw, paintSelectionBox, resetRectangle, setCurrentRect, setRectToDraw, setSelectionSize, updateDrawableRect, updateSelectionSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationHandler

public AnnotationHandler(AbstractPageViewComponent pageViewComponent,
                         DocumentViewModel documentViewModel)
Method Detail

setDocumentViewController

public void setDocumentViewController(DocumentViewController documentViewController)
DocumentController callback

Parameters:
documentViewController - document controller.

initializeAnnotationComponents

public void initializeAnnotationComponents(java.util.ArrayList<Annotation> annotations)
Initializes the annotation components given the annotations collections.

Parameters:
annotations - annotations to wrap with annotations components.

addAnnotationComponent

public AnnotationComponent addAnnotationComponent(Annotation annotation)
Wraps the specified annotaiton with a new Annotation component and adds it to the PageViewComponent as a child.

Parameters:
annotation - new annotation to add to PageView.

removeAnnotationComponent

public void removeAnnotationComponent(AnnotationComponent annotation)
Removes the specified annotation from the page view. The component is actually set to invisible. We need to keep the component around so that it can be made visible on an undo, as each state var keeps a reference to the component it is

Parameters:
annotation - annotation component to removed.

createNewLinkAnnotation

public void createNewLinkAnnotation()
Creates a new link annotation when the link annotation creation tool is selected. The bounds of the annotation are defined by the current selection box that has none zero bounds. If the two previous conditions are met then the annotation callback is fired and an width a new annotation object which can be updated by the end user using either the api or UI tools.


addSelectedAnnotation

public void addSelectedAnnotation(AnnotationComponentImpl annotationComponent)
Adds an Annotation component to the list of selected. The list of selected annotations is used do batch resize and moved commands.

Parameters:
annotationComponent - component to add to list of selected annotations

removeSelectedAnnotation

public void removeSelectedAnnotation(AnnotationComponentImpl annotationComponent)
Adds an Annotation component to the list of selected. The list of selected annotations is used do batch resize and moved commands.

Parameters:
annotationComponent - remove the specified annotation from the selection list

clearSelectedList

public void clearSelectedList()
Clears the slected list of AnnotationComponent, PageViewComponent focus should be called after this method is called to insure deselection of all AnnotationComponents.


isMultipleSelect

public boolean isMultipleSelect()
Determines if there are more then one selected component. If there is more then one component that steps should be made to do batch move and resize propigation.

Returns:
true if there are more then one AnnotationComponents in a selected state

moveSelectedAnnotations

public void moveSelectedAnnotations(int x,
                                    int y)
Moves all selected annotation components by the x,y translation.

Parameters:
x - x-axis offset to be applied to all selected annotation.
y - y-axis offset to be applied to all selected annotation.

resizeSelectedAnnotations

public void resizeSelectedAnnotations(int width,
                                      int height)
Resizes all selected annotation components by the width and height values.

Parameters:
width - width offset to be applied to all selected annotation.
height - height offset to be applied to all selected annotation.

mouseClicked

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

mousePressed

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

mouseDragged

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

mouseReleased

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

mouseMoved

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

mouseEntered

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

mouseExited

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

paintAnnotations

public void paintAnnotations(java.awt.Graphics g)
Paints all annotation content for a given page view. If any annotation properties are changed then this method must be called to repaint the page annotations.

todo: as a future enhancement it would be great if each Annotation component did its own painting, this would take a little more time to figure out the correct coordinate space.

Parameters:
g - parent PageViewComponent graphics context to paint annotations to.