com.lizardtech.djvubean.toolbar
Class Toolbar

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

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

The DjVu toolbar.

Version:
$Revision: 1.11 $
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[] ACTUAL_SIZE_BUTTON
          Arguments used to create the actual size button.
protected  ToggleButton actualSize
          The mode button to zoom to actual size (100 dpi)
static java.awt.Color BLACK
          the color black
static java.lang.Object[] FIRST_PAGE_BUTTON
          Arguments used to create the first page button.
protected  ToggleButton firstPage
          The button to go to the first page.
static java.lang.Object[] FIT_PAGE_BUTTON
          Arguments used to create the fit page button.
static java.lang.Object[] FIT_WIDTH_BUTTON
          Arguments used to create the fit width button.
protected  ToggleButton fitPage
          The mode button to fit page.
protected  ToggleButton fitWidth
          The mode button to fit width.
static java.lang.Object[] LAST_PAGE_BUTTON
          Arguments used to create the last page button.
protected  ToggleButton lastPage
          The button to go to the last page.
static java.awt.Color LIGHT_GRAY
          the color gray
protected  ToggleButton logo
          The LizardTech logo button.
static java.lang.Object[] LOGO_BUTTON
          Arguments used to create the logo button.
protected  ToggleButton logo2
          The LizardTech logo button.
protected  java.awt.Panel modeButtonPanel
          The panel with mode buttons.
static java.lang.Object[] NEXT_PAGE_BUTTON
          Arguments used to create the next page button.
protected  ToggleButton nextPage
          The next page button.
static java.lang.Object[] PAGE_SELECT
          Arguments used to create the page selection combobox.
protected  java.awt.Panel pagePanel
          The panel with page navigation buttons.
protected  java.awt.Container pageSelect
          The combobox for selecting the current page.
protected  java.awt.event.ActionListener pageSelectEditorActionListener
          Used for typing in a page number.
static java.lang.Object[] PAN_MODE_BUTTON
          Arguments used to create the pan mode button.
protected  ToggleButton panMode
          The mode button to pan the document.
static java.lang.Object[] PREVIOUS_PAGE_BUTTON
          Arguments used to create the previous page button.
protected  ToggleButton prevPage
          The previous page button.
static java.lang.Object[] SEARCH_BACK_BUTTON
          Arguments used to create the previous page button.
static java.lang.Object[] SEARCH_BUTTON
          Arguments used to create the pan mode 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.
static java.lang.String SEARCH_NOT_SELECTED_STRING
          card name for navigation buttons
static java.lang.String SEARCH_SELECTED_STRING
          card name for search mode buttons
protected  ToggleButton searchMode
          The search button to search the document.
static java.lang.Object[] SEPARATOR_BUTTON
          Arguments used to create the logo button.
static java.lang.Object[] TEXT_MODE_BUTTON
          Arguments used to create the pan mode button.
protected  ToggleButton textMode
          The mode button to display hiddent text.
static java.lang.Object[] ZOOM_MODE_BUTTON
          Arguments used to create the pan mode button.
static java.lang.Object[] ZOOM_SELECT
          Arguments used to create the zoom selection combobox.
protected  ToggleButton zoomIn
          The zoom in button.
static java.lang.Object[] ZOOMIN_BUTTON
          Arguments used to create the zoom in button.
protected  ToggleButton zoomMode
          The mode button to pan the document.
protected  ToggleButton zoomOut
          The zoom out button.
static java.lang.Object[] ZOOMOUT_BUTTON
          Arguments used to create the zoom out button.
protected  java.awt.Panel zoomPagePanel
          The panel with zoom and page panels.
protected  java.awt.Panel zoomPanel
          The panel with zoom buttons.
protected  java.awt.Container zoomSelect
          The combobox for zooming.
 
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
Toolbar(DjVuBean bean)
          Creates a new Toolbar 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.
static ToggleButton createButton(java.util.Vector buttonList, java.lang.Object[] args)
          Called to create a new ToggleButton.
protected  java.awt.Container createComboBox(java.lang.Object[] args)
          Creates an editable combobox.
protected  ToggleButton createToggleButton(java.lang.Object[] args)
          Create a logo button using the specified arguments.
protected  void editorActionListener(java.awt.Container select, java.lang.String appendString)
          Create an editor class which simply sends the edited value with the specified string appended.
 void itemStateChanged(java.awt.event.ItemEvent event)
          Called when an item state changes.
 void paint(java.awt.Graphics g)
          Called to paint this container.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Called when a DjVuBean property is changed.
 void setSize(int width, int height)
          Set the target size of the Window.
protected  void setZoomEnabled(boolean value)
          Called to enable or disable the zoom buttons.
 void updateTargetWidth(int targetWidth, int width)
          Called to update the target width of the toolbar.
 
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, setVisible, 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

FIRST_PAGE_BUTTON

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


SEARCH_DOCUMENT_BACK_BUTTON

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


LAST_PAGE_BUTTON

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


SEARCH_DOCUMENT_FWD_BUTTON

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


LOGO_BUTTON

public static final java.lang.Object[] LOGO_BUTTON
Arguments used to create the logo button.


SEPARATOR_BUTTON

public static final java.lang.Object[] SEPARATOR_BUTTON
Arguments used to create the logo button.


NEXT_PAGE_BUTTON

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


SEARCH_FORWARD_BUTTON

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


PREVIOUS_PAGE_BUTTON

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


SEARCH_BACK_BUTTON

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


ZOOMIN_BUTTON

public static final java.lang.Object[] ZOOMIN_BUTTON
Arguments used to create the zoom in button.


ZOOMOUT_BUTTON

public static final java.lang.Object[] ZOOMOUT_BUTTON
Arguments used to create the zoom out button.


PAGE_SELECT

public static final java.lang.Object[] PAGE_SELECT
Arguments used to create the page selection combobox.


ZOOM_SELECT

public static final java.lang.Object[] ZOOM_SELECT
Arguments used to create the zoom selection combobox.


ACTUAL_SIZE_BUTTON

public static final java.lang.Object[] ACTUAL_SIZE_BUTTON
Arguments used to create the actual size button.


FIT_PAGE_BUTTON

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


FIT_WIDTH_BUTTON

public static final java.lang.Object[] FIT_WIDTH_BUTTON
Arguments used to create the fit width button.


SEARCH_BUTTON

public static final java.lang.Object[] SEARCH_BUTTON
Arguments used to create the pan mode button.


PAN_MODE_BUTTON

public static final java.lang.Object[] PAN_MODE_BUTTON
Arguments used to create the pan mode button.


ZOOM_MODE_BUTTON

public static final java.lang.Object[] ZOOM_MODE_BUTTON
Arguments used to create the pan mode button.


TEXT_MODE_BUTTON

public static final java.lang.Object[] TEXT_MODE_BUTTON
Arguments used to create the pan mode button.


SEARCH_SELECTED_STRING

public static final java.lang.String SEARCH_SELECTED_STRING
card name for search mode buttons

See Also:
Constant Field Values

SEARCH_NOT_SELECTED_STRING

public static final java.lang.String SEARCH_NOT_SELECTED_STRING
card name for navigation buttons

See Also:
Constant Field Values

BLACK

public static final java.awt.Color BLACK
the color black


LIGHT_GRAY

public static final java.awt.Color LIGHT_GRAY
the color gray


pageSelect

protected final java.awt.Container pageSelect
The combobox for selecting the current page.


zoomSelect

protected final java.awt.Container zoomSelect
The combobox for zooming.


modeButtonPanel

protected final java.awt.Panel modeButtonPanel
The panel with mode buttons.


pagePanel

protected final java.awt.Panel pagePanel
The panel with page navigation buttons.


zoomPagePanel

protected final java.awt.Panel zoomPagePanel
The panel with zoom and page panels.


zoomPanel

protected final java.awt.Panel zoomPanel
The panel with zoom buttons.


actualSize

protected final ToggleButton actualSize
The mode button to zoom to actual size (100 dpi)


firstPage

protected final ToggleButton firstPage
The button to go to the first page.


fitPage

protected final ToggleButton fitPage
The mode button to fit page.


fitWidth

protected final ToggleButton fitWidth
The mode button to fit width.


lastPage

protected final ToggleButton lastPage
The button to go to the last page.


logo

protected final ToggleButton logo
The LizardTech logo button.


logo2

protected final ToggleButton logo2
The LizardTech logo button.


nextPage

protected final ToggleButton nextPage
The next page button.


panMode

protected final ToggleButton panMode
The mode button to pan the document.


prevPage

protected final ToggleButton prevPage
The previous page button.


searchMode

protected final ToggleButton searchMode
The search button to search the document.


textMode

protected final ToggleButton textMode
The mode button to display hiddent text.


zoomIn

protected final ToggleButton zoomIn
The zoom in button.


zoomMode

protected final ToggleButton zoomMode
The mode button to pan the document.


zoomOut

protected final ToggleButton zoomOut
The zoom out button.


pageSelectEditorActionListener

protected java.awt.event.ActionListener pageSelectEditorActionListener
Used for typing in a page number.

Constructor Detail

Toolbar

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

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

setSize

public void setSize(int width,
                    int height)
Set the target 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

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.

createButton

public static ToggleButton createButton(java.util.Vector buttonList,
                                        java.lang.Object[] args)
Called to create a new ToggleButton.

Parameters:
buttonList - Vector of buttons to append this item to
args - the arguments used to create this button
Returns:
the newly created button

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent event)
Called when an item state changes.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
event - indicating the changed item.

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 when a DjVuBean property is changed.

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

updateTargetWidth

public void updateTargetWidth(int targetWidth,
                              int width)
Called to update the target width of the toolbar.

Parameters:
targetWidth - The target width for the toolbar. (-1 if unknown)
width - The target width of the parent container.

setZoomEnabled

protected void setZoomEnabled(boolean value)
Called to enable or disable the zoom buttons.

Parameters:
value - true if zoom buttons should be enabled.

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.

createComboBox

protected java.awt.Container createComboBox(java.lang.Object[] args)
Creates an editable combobox.

Parameters:
args - used to create the combobox.
Returns:
the newly created combobox.

createToggleButton

protected ToggleButton createToggleButton(java.lang.Object[] args)
Create a logo button using the specified arguments. Children classes can change the button properties by overloading this class. For example, if one wanted to replace the text used for Pan mode, one could use the following code:
   class MyApplet extends com.lizardtech.djview.Applet
   {
     protected ToggleButton createToggleButton(Object[] args)
     {
       if(args == PAN_MODE_BUTTON)
       {
         final Object [] button={
           "Mouse Scroll",
           "MouseScroll",
           PAN_MODE_BUTTON[2],
           PAN_MODE_BUTTON[3]}; 
         return super.createToggleButton(button);
       }
       return super.createToggleButton(args);
     }
   }
 

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

editorActionListener

protected void editorActionListener(java.awt.Container select,
                                    java.lang.String appendString)
Create an editor class which simply sends the edited value with the specified string appended.

Parameters:
select - the combobox being edited.
appendString - String to append.