Enterprise Information Portal APIs

com.ibm.mm.viewer.annotation
Class CMBAnnotationView

java.lang.Object
  |
  +--com.ibm.mm.viewer.annotation.CMBAnnotationView
All Implemented Interfaces:
CMBAnnotationPropertiesListener

public class CMBAnnotationView
extends java.lang.Object
implements CMBAnnotationPropertiesListener

The View in the MVC architecture. This class takes care of actually drawing the annotations on the JComponent that is set as the view component by calling the setViewComponent( JComponent ) method.

Since:
8.1
See Also:
com.ibm.mm.viewer.annotation.CMBAnnotationSet, com.ibm.mm.viewer.annotation.CMBAnnotationServices

Constructor Summary
CMBAnnotationView()
          Constructor
CMBAnnotationView(CMBAnnotationSet model)
          Constructor
 
Method Summary
 void drawAllAnnotations()
          Draws all the annotations.
 void drawAnnotation(CMBPageAnnotation a)
          Renders the supplied annotation on the screen
 void drawAnnotationInXOR(CMBPageAnnotation a)
          Draws an annotations in XOR mode.
 void drawRectInXOR(java.awt.Rectangle r)
          Draws the specified rectangle in XOR mode
 void eraseAnnotationFromScreen(CMBPageAnnotation a)
          Removes an annotation from the screen
 CMBAnnotationSet getModel()
          Gets the CMBAnnotationSet object .
 java.awt.Frame getOwningFrame()
          The sole purpose of this method is to be able to display an annotation properties dialog box.
 javax.swing.JComponent getViewComponent()
          Returns the view component.
 void handleAnnPropChangedEvent(CMBPageAnnotation a)
          Handles the annotation properties changed event and refreshes the annotation.
 void handleAnnPropWillChangeEvent(CMBPageAnnotation a)
          Handles the event that occurs before the property of an annotation is about to change.
 void paintAll(java.awt.Graphics2D g2, boolean scale)
          Paints all the existing annotations objects.
 void paintAnnotations(java.awt.Graphics2D g2, int pageNum, boolean scale)
           
 void paintThoseInRect(java.awt.Rectangle r, int pageNumber)
          Paints only those annotations whose bounding rectangle intersects with r
 void refreshEntireDrawArea()
          Tells the owner JComponent to repaint itself completely
 void refreshRect(java.awt.Rectangle r)
          Tells the owner JComponent to repaint a certain rectangle of its view.
 void refreshSlightlyBiggerRect(java.awt.Rectangle r)
          Same as refreshRect() but increases the rectangle first.
 void setModel(CMBAnnotationSet model)
          Sets the CMBAnnotationSet object as the model for the view.
 void setViewComponent(javax.swing.JComponent component)
          Sets the view component for the view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CMBAnnotationView

public CMBAnnotationView(CMBAnnotationSet model)
Constructor
Parameters:
mdl - A reference to the CMBAnnotationModel that contains all the annotations to be rendered

CMBAnnotationView

public CMBAnnotationView()
Constructor
Method Detail

setModel

public void setModel(CMBAnnotationSet model)
Sets the CMBAnnotationSet object as the model for the view.
Parameters:
model - The model that contains the list of page annotations.

getModel

public CMBAnnotationSet getModel()
Gets the CMBAnnotationSet object .

setViewComponent

public void setViewComponent(javax.swing.JComponent component)
Sets the view component for the view. This provides the capability of plugging in any JComponent as the view component and the view can handle drawing of the annotations on it.
Parameters:
component - A JComponent object that provides the graphics to draw the annotations on.

getViewComponent

public javax.swing.JComponent getViewComponent()
Returns the view component.
Returns:
JComponent The view component.

paintAll

public void paintAll(java.awt.Graphics2D g2,
                     boolean scale)
Paints all the existing annotations objects. Often times g2 will be clipped to only a certain rectangular region and so most objects that draw() is invoked on will not really be repainted.
Parameters:
g2 - Graphics2D The graphics 2D context to paint on.

paintAnnotations

public void paintAnnotations(java.awt.Graphics2D g2,
                             int pageNum,
                             boolean scale)

paintThoseInRect

public void paintThoseInRect(java.awt.Rectangle r,
                             int pageNumber)
Paints only those annotations whose bounding rectangle intersects with r
Parameters:
r - The rectangle that determines which annotations to draw

drawAllAnnotations

public void drawAllAnnotations()
Draws all the annotations.

drawAnnotation

public void drawAnnotation(CMBPageAnnotation a)
Renders the supplied annotation on the screen
Parameters:
a - The annotation to render.

refreshRect

public void refreshRect(java.awt.Rectangle r)
Tells the owner JComponent to repaint a certain rectangle of its view. Any annotation in this rectangle will also get repainted (if CMBPageAnnotation.dontDraw() was'nt called) due to the paintAll() method.
Parameters:
r - The rectangle to refresh

refreshEntireDrawArea

public void refreshEntireDrawArea()
Tells the owner JComponent to repaint itself completely

refreshSlightlyBiggerRect

public void refreshSlightlyBiggerRect(java.awt.Rectangle r)
Same as refreshRect() but increases the rectangle first. This is useful since if there are handles that are one pixel too big.

eraseAnnotationFromScreen

public void eraseAnnotationFromScreen(CMBPageAnnotation a)
Removes an annotation from the screen
Parameters:
a - The annotation to remove

drawAnnotationInXOR

public void drawAnnotationInXOR(CMBPageAnnotation a)
Draws an annotations in XOR mode. This is useful when dragging or resizing the annotation. Returns the graphics object into paintmode when done
Parameters:
a - CMBPageAnnotation to draw in XOR mode

drawRectInXOR

public void drawRectInXOR(java.awt.Rectangle r)
Draws the specified rectangle in XOR mode
Parameters:
r - The rectangle to draw in XOR mode

getOwningFrame

public java.awt.Frame getOwningFrame()
The sole purpose of this method is to be able to display an annotation properties dialog box.
Returns:
JFrame The parent frame of the view component.

handleAnnPropWillChangeEvent

public void handleAnnPropWillChangeEvent(CMBPageAnnotation a)
Handles the event that occurs before the property of an annotation is about to change. We must erase the annotation BEFORE its property changes. Why? well consider for example the case where the annotation's refresh rect is (0,0,20,20) before the property change, and is (0,0,10,10) after the property change. Now, if we refresh the annotation only AFTER the property changed, we will have refreshed too small of a rectangle. It is important to invoke this if a property that affects the SIZE of the annotation (specifically, makes it smaller) is changed.
Specified by:
handleAnnPropWillChangeEvent in interface CMBAnnotationPropertiesListener
Parameters:
a - The page annotation whose property is about to change.

handleAnnPropChangedEvent

public void handleAnnPropChangedEvent(CMBPageAnnotation a)
Handles the annotation properties changed event and refreshes the annotation.
Specified by:
handleAnnPropChangedEvent in interface CMBAnnotationPropertiesListener
Parameters:
a - The page annotation whose property has changed.

EIP JavaBeans

(c) Copyright International Business Machines Corporation 1996, 2002. IBM Corp. All rights reserved.