com.lizardtech.djvubean.outline
Class Outline

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by com.lizardtech.djvubean.outline.Outline
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible

public class Outline
extends java.awt.Canvas
implements java.beans.PropertyChangeListener, java.io.Serializable

This class is used for outline navigation. Logically this equivalent to a JTree, but the look and feel is slightly different.

Version:
$Revision: 1.2 $
Author:
Bill C. Riemers
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 DjVuBean djvuBean
          The DjVuComponent used when creating this Outline
 
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
Outline(DjVuBean djvuBean)
          Creates a new Outline object.
 
Method Summary
 void clickLocation(int x, int y)
          Called when the user clicks the mouse on an outline item.
protected  java.util.Vector getActiveVector()
          Called to query the vector of active bookmarks.
 Bookmark getBookmark(int item)
          Get the specified bookmark.
protected  java.awt.Rectangle getCheckboxBounds(int item, Bookmark bookmark, java.lang.Object depthObject)
          Query the bounding rectangle for the specified checkbox.
protected  java.util.Hashtable getDepthMap()
          Query the Hashtable listing the depths of bookmarks.
 int getFontHeight()
          Query the font height used in calculating line spacing.
 int getFontWidth()
          Query the font width used in calculating line indenting.
 java.awt.Dimension getMaximumSize()
          Query the maximum image size allowed.
 java.awt.Dimension getMinimumSize()
          Query the minimum image size allowed.
protected  java.util.Vector getPagenoVector()
          Query the vector of page numbers mapped to bookmarks.
protected  java.util.Hashtable getParentMap()
          Query the Hashtable of bookmark parents.
 java.awt.Dimension getPreferredSize()
          Query the preferred image size allowed.
 int getRow(int y)
          Query the row (item number) of the specified y coordinate.
protected  java.awt.Rectangle getTextBounds(int item, Bookmark bookmark, java.lang.Object depthObject)
          Query the bounding rectangle of the specified row.
 boolean isCheckedItem(int item)
          Query if the specified bookmark is checked.
protected  void mapChildren(Bookmark parent, java.util.Hashtable parentMap, java.util.Vector pagenoVector, java.lang.Number depth)
          Called to create a map the parent of each bookmark.
 void paint(java.awt.Graphics g)
          Called to paint the outline.
 int paintCheckbox(int item, java.awt.Graphics g, Bookmark bookmark)
          Called to recursively paint the check box for the specified item.
 int paintItem(int item, java.awt.Graphics g, Bookmark bookmark)
          Called to recursively paint text and lines for the specified item.
 void propertyChange(java.beans.PropertyChangeEvent e)
          Called with a DjVuBean property has changed.
protected  int setCheckedBookmark(Bookmark bookmark, java.util.Vector activeVector)
          Set the checked value of the specified bookmark.
 void setCheckedItem(int item, boolean checked)
          Set the checked property of the specified bookmark.
protected  void setCheckedItem(int item, boolean checked, java.util.Vector activeVector)
          Check bookmark at the specified row number.
 void setCheckedPage(int pageno)
          Called to check any bookmarks linked to the specified page number.
 void setFirstBookmark(Bookmark bookmark)
          Called to initialize the outline by setting the top level bookmark.
 void setFontHeight(int fontHeight)
          Set the font height used in calculating line spacing.
 void setFontWidth(int fontWidth)
          Set the font width used in calculating line indenting.
 void setVisible(boolean value)
          Called to change the visibility of the outline.
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

djvuBean

public final DjVuBean djvuBean
The DjVuComponent used when creating this Outline

Constructor Detail

Outline

public Outline(DjVuBean djvuBean)
Creates a new Outline object.

Parameters:
djvuBean - the DjVuBean to navigate.
Throws:
java.lang.ArrayIndexOutOfBoundsException - if the document has less than 2 pages.
Method Detail

getBookmark

public Bookmark getBookmark(int item)
Get the specified bookmark.

Parameters:
item - the row number of the bookmark to retrieve.
Returns:
the specified bookmark.

setCheckedItem

public void setCheckedItem(int item,
                           boolean checked)
Set the checked property of the specified bookmark.

Parameters:
item - the row number of the bookmark to check or uncheck.
checked - true if checked.

isCheckedItem

public boolean isCheckedItem(int item)
Query if the specified bookmark is checked.

Parameters:
item - row number of the bookmark to query.
Returns:
true if the specified bookmark is checked.

setCheckedPage

public void setCheckedPage(int pageno)
Called to check any bookmarks linked to the specified page number.

Parameters:
pageno - specifies page number.

setFirstBookmark

public void setFirstBookmark(Bookmark bookmark)
Called to initialize the outline by setting the top level bookmark.

Parameters:
bookmark - top level bookmark.

setFontHeight

public void setFontHeight(int fontHeight)
Set the font height used in calculating line spacing.

Parameters:
fontHeight - to use to calculate line spacing.

getFontHeight

public int getFontHeight()
Query the font height used in calculating line spacing.

Returns:
fontHeight to use to calculate line spacing.

setFontWidth

public void setFontWidth(int fontWidth)
Set the font width used in calculating line indenting.

Parameters:
fontWidth - to use to calculate line indenting.

getFontWidth

public int getFontWidth()
Query the font width used in calculating line indenting.

Returns:
fontWidth to use to calculate line indenting.

getMaximumSize

public java.awt.Dimension getMaximumSize()
Query the maximum image size allowed.

Overrides:
getMaximumSize in class java.awt.Component
Returns:
the maximum image size allowed.

getMinimumSize

public java.awt.Dimension getMinimumSize()
Query the minimum image size allowed.

Overrides:
getMinimumSize in class java.awt.Component
Returns:
the minimum image size allowed.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Query the preferred image size allowed.

Overrides:
getPreferredSize in class java.awt.Component
Returns:
the preferred image size allowed.

getRow

public int getRow(int y)
Query the row (item number) of the specified y coordinate.

Parameters:
y - position along the Y axis.
Returns:
the corresponding row number.

setVisible

public void setVisible(boolean value)
Called to change the visibility of the outline.

Overrides:
setVisible in class java.awt.Component
Parameters:
value - true if visible.

clickLocation

public void clickLocation(int x,
                          int y)
Called when the user clicks the mouse on an outline item. If the check box is checked, the checked value will be toggled. If the name is clicked, the bookmark page will be displayed.

Parameters:
x - position along the X axis clicked.
y - position along the Y axis clicked.

paint

public void paint(java.awt.Graphics g)
Called to paint the outline.

Overrides:
paint in class java.awt.Canvas
Parameters:
g - graphics object to paint.

paintCheckbox

public int paintCheckbox(int item,
                         java.awt.Graphics g,
                         Bookmark bookmark)
Called to recursively paint the check box for the specified item.

Parameters:
item - row number
g - graphics object to paint.
bookmark - to check selected value.
Returns:
the next row number to paint.

paintItem

public int paintItem(int item,
                     java.awt.Graphics g,
                     Bookmark bookmark)
Called to recursively paint text and lines for the specified item.

Parameters:
item - row number
g - graphics object to paint.
bookmark - to check selected value.
Returns:
the next row number to paint.

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent e)
Called with a DjVuBean property has changed.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
e - the PropertyChangeEvent.

getActiveVector

protected java.util.Vector getActiveVector()
Called to query the vector of active bookmarks.

Returns:
active bookmarks.

getCheckboxBounds

protected java.awt.Rectangle getCheckboxBounds(int item,
                                               Bookmark bookmark,
                                               java.lang.Object depthObject)
Query the bounding rectangle for the specified checkbox.

Parameters:
item - row number
bookmark - to check selected value.
depthObject - depth of the bookmark.
Returns:
bounding rectangle.

setCheckedBookmark

protected int setCheckedBookmark(Bookmark bookmark,
                                 java.util.Vector activeVector)
Set the checked value of the specified bookmark.

Parameters:
bookmark - to check.
activeVector - of active bookmarks.
Returns:
the row number of the bookmark.

setCheckedItem

protected void setCheckedItem(int item,
                              boolean checked,
                              java.util.Vector activeVector)
Check bookmark at the specified row number.

Parameters:
item - row number.
checked - true if checked.
activeVector - vector of active bookmarks.

getDepthMap

protected java.util.Hashtable getDepthMap()
Query the Hashtable listing the depths of bookmarks.

Returns:
Hashtable of bookmark depths.

getPagenoVector

protected java.util.Vector getPagenoVector()
Query the vector of page numbers mapped to bookmarks.

Returns:
vector of page numbers.

getParentMap

protected java.util.Hashtable getParentMap()
Query the Hashtable of bookmark parents.

Returns:
Hashtable of bookmark parents.

getTextBounds

protected java.awt.Rectangle getTextBounds(int item,
                                           Bookmark bookmark,
                                           java.lang.Object depthObject)
Query the bounding rectangle of the specified row.

Parameters:
item - row number.
bookmark - for the specified row.
depthObject - indicating depth.
Returns:
bounding rectangle.

mapChildren

protected void mapChildren(Bookmark parent,
                           java.util.Hashtable parentMap,
                           java.util.Vector pagenoVector,
                           java.lang.Number depth)
Called to create a map the parent of each bookmark.

Parameters:
parent - top level bookmark.
parentMap - map to add children to.
pagenoVector - vector of page numbers.
depth - object indicating bookmark depth.