com.lizardtech.djvubean.toolbar
Class Finder

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by com.lizardtech.djvubean.toolbar.Finder
All Implemented Interfaces:
java.awt.event.ActionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener

public class Finder
extends java.awt.Container
implements java.awt.event.ActionListener, java.beans.PropertyChangeListener

The DjVu toolbar.

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

Nested Class Summary
 
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
static java.lang.Object[] SEARCH_BACK_BUTTON
          Arguments used to create the previous page button.
static java.lang.Object[] SEARCH_DOCUMENT_BACK_BUTTON
          Arguments used to create the first page button.
static java.lang.Object[] SEARCH_DOCUMENT_FWD_BUTTON
          Arguments used to create the last page button.
static java.lang.Object[] SEARCH_FORWARD_BUTTON
          Arguments used to create the next page button.
protected  ToggleButton searchBack
          The search backward button.
protected  ToggleButton searchDocumentBack
          The button to search to the last page.
protected  ToggleButton searchDocumentFwd
          The button to search to the first page.
protected  java.awt.Component searchField
          A text field for the string we are searching for.
protected  ToggleButton searchFwd
          The search forward button.
 
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
Finder(DjVuBean bean)
          Creates a new Finder object.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Called when a button is pressed.
protected  ToggleButton createButton(java.lang.Object[] args)
          Create a normal button using the specified arguments.
 void paint(java.awt.Graphics g)
          Called to paint this container.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Called with a DjVuBean property has changed.
 boolean search(java.lang.String searchText, boolean forward, boolean matchCase, boolean wholeWord, boolean searchDocument)
          Search for text forward or backwards from the last Caret Position from the current page.
 boolean searchDocument(boolean forward)
          Called to do a search on the document.
 boolean searchPage(boolean forward)
          Called to do a search on the current page.
 void setSize(int width, int height)
          Set the size of the Window.
 void setVisible(boolean value)
          Set the visible property of this component.
 void updateTargetWidth(int targetWidth, int width)
          Called when the "TargetWidth" value has been updated.
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, 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, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SEARCH_DOCUMENT_BACK_BUTTON

public static final java.lang.Object[] SEARCH_DOCUMENT_BACK_BUTTON
Arguments used to create the first page button.


SEARCH_DOCUMENT_FWD_BUTTON

public static final java.lang.Object[] SEARCH_DOCUMENT_FWD_BUTTON
Arguments used to create the last page button.


SEARCH_FORWARD_BUTTON

public static final java.lang.Object[] SEARCH_FORWARD_BUTTON
Arguments used to create the next page button.


SEARCH_BACK_BUTTON

public static final java.lang.Object[] SEARCH_BACK_BUTTON
Arguments used to create the previous page button.


searchField

protected java.awt.Component searchField
A text field for the string we are searching for.


searchBack

protected final ToggleButton searchBack
The search backward button.


searchDocumentBack

protected final ToggleButton searchDocumentBack
The button to search to the last page.


searchDocumentFwd

protected final ToggleButton searchDocumentFwd
The button to search to the first page.


searchFwd

protected final ToggleButton searchFwd
The search forward button.

Constructor Detail

Finder

public Finder(DjVuBean bean)
Creates a new Finder object.

Parameters:
bean - the DjVuBean being monitored and controled.
Method Detail

setSize

public void setSize(int width,
                    int height)
Set the size of the Window. This is used to determine how the toolbar should be layed out.

Overrides:
setSize in class java.awt.Component
Parameters:
width - target window width
height - target window height

setVisible

public void setVisible(boolean value)
Set the visible property of this component.

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

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Called when a button is pressed.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - indicating the action performed.

paint

public void paint(java.awt.Graphics g)
Called to paint this container.

Overrides:
paint in class java.awt.Container
Parameters:
g - The graphics device to draw to.

propertyChange

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

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

search

public boolean search(java.lang.String searchText,
                      boolean forward,
                      boolean matchCase,
                      boolean wholeWord,
                      boolean searchDocument)
Search for text forward or backwards from the last Caret Position from the current page.

Parameters:
searchText - text to search for.
forward - true if searching forward, otherwise search backward.
matchCase - true if case sensative.
wholeWord - true if a whole word match is required.
searchDocument - true if a whole document should be searched.
Returns:
True if the text was found.

searchDocument

public boolean searchDocument(boolean forward)
Called to do a search on the document.

Parameters:
forward - true if the search should be forward.
Returns:
the position where the text was found, or -1 if no text was found.

searchPage

public boolean searchPage(boolean forward)
Called to do a search on the current page.

Parameters:
forward - true if the search should be forward.
Returns:
the position where the text was found, or -1 if no text was found.

updateTargetWidth

public void updateTargetWidth(int targetWidth,
                              int width)
Called when the "TargetWidth" value has been updated.

Parameters:
targetWidth - old target width.
width - new target width.

createButton

protected ToggleButton createButton(java.lang.Object[] args)
Create a normal button using the specified arguments. Children classes can change the button properties by overloading this method. For example, if one wanted to replace the LizardTech logo with a Foxtrot Technologies logo one could use the following code:
   class FoxtrotApplet extends com.lizardtech.djview.Applet
   {
     protected ToggleButton createButton(Object[] args)
     {
       if(args == LOGO_BUTTON)
       {
         final Object [] FOXTROTLOGO={
           "Foxtrot Technologies Inc.", 
           "FoxtrotTechnologies",
           "image/foxtrotlogo.djvu",
           new Dimension(24,24) }; 
         return super.createButton(FOXTROTLOGO);
       }
       return super.createButton(args);
     }
   }
 

Parameters:
args - array consisting of tooltip, alt text, and getIcon argument.
Returns:
the newly created button.