com.lizardtech.djvubean
Class DjVuViewport

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by com.lizardtech.djvubean.DjVuBean
                  extended by com.lizardtech.djvubean.DjVuViewport
All Implemented Interfaces:
DjVuInterface, java.awt.event.AdjustmentListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.beans.PropertyChangeListener, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible

public class DjVuViewport
extends DjVuBean
implements java.awt.event.AdjustmentListener

This extension to DjVuBean allows a DjVuPage to be viewed without the need for a ScrollPane or JScrollPane. The main this class should be used is to avoid the annoying flicker caused by ScrollPane repainting the screen when JScrollPane is not available. This panel will not render the scrollbars. Instead the scrollbars should be rendered in a parent component.

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

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
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
 
Fields inherited from class com.lizardtech.djvubean.DjVuBean
FIRST_PAGE, FIT_PAGE, FIT_WIDTH, getImageThread, image, LAST_MODE, LAST_PAGE, MATCH_CASE_MASK, mlistener, NAVIGATE_LIST, NEXT_PAGE, PAN_MODE, PREV_PAGE, properties, SEARCH_BACKWARD_MASK, TEXT_MODE, WHOLE_DOCUMENT_MASK, WHOLE_WORD_MASK, zoom, ZOOM_BUTTON_LIST, ZOOM_FIT_PAGE, ZOOM_FIT_WIDTH, ZOOM_IN, ZOOM_MODE, ZOOM_ONE_TO_ONE, ZOOM_OUT, ZOOM_SPECIAL_LIST, ZOOM_STANDARD_LIST, ZOOM_STRETCH, ZOOM100, ZOOM150, ZOOM25, ZOOM300, ZOOM50, ZOOM75
 
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
DjVuViewport()
          Creates a new DjVuViewport object.
 
Method Summary
 void adjustmentValueChanged(java.awt.event.AdjustmentEvent event)
          Called to process scrollbar events.
 java.awt.Dimension getMaximumSize()
          Query the maximum panel size.
 java.awt.Dimension getMinimumSize()
          Query the minimum panel size.
 java.awt.Dimension getPreferredSize()
          Query the preferred panel size.
 java.awt.Scrollbar getScrollbar(int orientation)
          Query the a scrollbar component.
 java.awt.Point getScrollPosition()
          Query the current scroll position.
 java.awt.Dimension getViewportSize()
          Query the size of this panel.
 void paint(java.awt.Graphics g)
          Called to redraw the panel.
 void paintComponent(java.awt.Graphics g)
          Called to draw the panel.
protected  void processEvent(java.awt.AWTEvent event)
          Called to process events.
 void run()
           
 void setImageSize(int width, int height)
          Adjust the image scale.
 void setScrollbar(int orientation, java.awt.Scrollbar scrollbar)
          Set either the horizontal or vertical scrollbar.
 void setScrollPosition(int x, int y)
          Set the scroll position.
 void setSize(int width, int height)
          Set the size of this panel.
 void setURL(java.net.URL url)
          Called to set the URL to browse, and reset the scrollbars.
 void setViewportSize(int width, int height)
          Set the size of this panel.
 
Methods inherited from class com.lizardtech.djvubean.DjVuBean
addPropertyChangeListener, createAddOn, getCaretPosition, getDjVuOptions, getDocument, getDPI, getImage, getImageWait, getLastMode, getMaximumPanelSize, getMinimumPanelSize, getMode, getOutline, getPage, getPageCount, getPreferredPanelSize, getProperties, getSearchMask, getSearchText, getSelect, getStatus, getTargetWidth, getText, getTextArea, getTextCodec, getTextSearchObject, getToolbar, getURL, getXScale, getYScale, getZoom, imageUpdate, invokeMethod, invokeParentsMethod, isDecoding, isOpaque, propertyChange, recursiveRevalidate, removePropertyChangeListener, repaintImageCoordinates, scaleScrollPosition, setBackground, setCaretPosition, setDjVuOptions, setImage, setImageSize, setMode, setMode, setPage, setPageString, setPanelSize, setPanelSize, setProperties, setPropertyName, setScrollPosition, setSearchMask, setSearchText, setSelect, setSelectionList, setSize, setStatus, setSubmit, setTargetWidth, setViewportSize, setZoom, stringToBoolean, update, validate, zoomSelect
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, 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, 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, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, 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, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DjVuViewport

public DjVuViewport()
Creates a new DjVuViewport object.

Method Detail

setImageSize

public void setImageSize(int width,
                         int height)
Adjust the image scale.

Overrides:
setImageSize in class DjVuBean
Parameters:
width - to scale the image to.
height - to scale the image to.

getMaximumSize

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

Overrides:
getMaximumSize in class DjVuBean
Returns:
maximum panel size.

getMinimumSize

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

Overrides:
getMinimumSize in class DjVuBean
Returns:
minimum panel size.

getPreferredSize

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

Overrides:
getPreferredSize in class DjVuBean
Returns:
preferred panel size.

setScrollPosition

public void setScrollPosition(int x,
                              int y)
Set the scroll position.

Overrides:
setScrollPosition in class DjVuBean
Parameters:
x - coordinate of upper left corner.
y - coordinate of upper left corner.

getScrollPosition

public java.awt.Point getScrollPosition()
Query the current scroll position.

Overrides:
getScrollPosition in class DjVuBean
Returns:
location of upper left corner.

setScrollbar

public void setScrollbar(int orientation,
                         java.awt.Scrollbar scrollbar)
Set either the horizontal or vertical scrollbar.

Parameters:
orientation - either Scrollbar.HORIZONTAL or Scrollbar.VERTICAL
scrollbar - component.

getScrollbar

public java.awt.Scrollbar getScrollbar(int orientation)
Query the a scrollbar component.

Parameters:
orientation - either Scrollbar.HORIZONTAL or Scrollbar.VERTICAL
Returns:
scrollbar component.

setSize

public void setSize(int width,
                    int height)
Set the size of this panel.

Overrides:
setSize in class DjVuBean
Parameters:
width - of this panel.
height - of this panel.

setURL

public void setURL(java.net.URL url)
            throws java.io.IOException
Called to set the URL to browse, and reset the scrollbars.

Overrides:
setURL in class DjVuBean
Parameters:
url - indicates document to view.
Throws:
java.io.IOException - if an error occures

setViewportSize

public void setViewportSize(int width,
                            int height)
Set the size of this panel.

Overrides:
setViewportSize in class DjVuBean
Parameters:
width - of this panel.
height - of this panel.

getViewportSize

public java.awt.Dimension getViewportSize()
Query the size of this panel.

Overrides:
getViewportSize in class DjVuBean
Returns:
the panel size.

adjustmentValueChanged

public void adjustmentValueChanged(java.awt.event.AdjustmentEvent event)
Called to process scrollbar events.

Specified by:
adjustmentValueChanged in interface java.awt.event.AdjustmentListener
Parameters:
event - to process.

paint

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

Overrides:
paint in class DjVuBean
Parameters:
g - Graphics device to draw the panel to.

paintComponent

public void paintComponent(java.awt.Graphics g)
Called to draw the panel.

Overrides:
paintComponent in class DjVuBean
Parameters:
g - Graphics device to draw the panel to.

processEvent

protected void processEvent(java.awt.AWTEvent event)
Called to process events. Mouse events will be rewritten to indicate the position in the document clicked, instead of the position of the panel.

Overrides:
processEvent in class java.awt.Container
Parameters:
event - to process.

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class DjVuBean