com.photoviewer.client
Class PhotoViewer

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended bythinlet.Thinlet
              extended bycom.photoviewer.client.PhotoViewer
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.lang.Runnable, java.io.Serializable

public class PhotoViewer
extends thinlet.Thinlet

PhotoViewer is the main API for the client. This class performs the client initialization (fetching the directory.zip file), provides access to the Applet instance, provides access to a simple JOptionPane-like popup message dialog, and provides an API for updating the progress meter on the main page, handles all callbacks from the Thinlet GUI widgets (and dispatches those callbacks to the appropriate handler objects). It also provides the implementation and content for the Technical tab as well as access to a utility method for fetching documents via HTTP.

Author:
John De Regnaucourt
See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static java.lang.String AD_INDEX
           
 
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
PhotoViewer(java.applet.Applet applet)
          Default constructor for use with classForName()
 
Method Summary
protected  void addTechRow(java.lang.String key, java.lang.String value)
          Add a row of information key-value pairs to the tech info table
 void characters(java.lang.String text)
          XML Parser callback
protected  void endElement()
          XML Parser callback
 java.lang.Object find(java.lang.String componentName)
          Locate a component by componentName.
 void firstScreenImage()
          Callback method triggered when the Previous Image button is pressed.
 void firstThumbPage()
          Callback method triggered when the Previous Thumb Page button is pressed.
 java.lang.String getCodeBase()
           
 byte[] getContent(java.lang.String uri)
          Load content from Applet, using it's ClassLoader, which will attempt to find it in the codebase, and if it fails, will also try the server from which the Applet was loaded.
 java.awt.Image getIcon(java.lang.String path, boolean preload)
          Override parent class method because it does not work on Microsoft's Java 1.1 VM.
 java.lang.String getJavaVersion()
           
 java.io.InputStream getResource(java.lang.String uri)
          Fetch a resource from the classpath
 int getSelectedThumb()
          Get the index of the "currently selected" thumb, independent of view.
 void gotoURL(java.lang.String url)
          Send the browser to the URL passed in.
 void installParser(ThinletXmlParser parser)
          Install a new parser for processing a new document type.
 void lastScreenImage()
          Callback method triggered when the Next Image button is pressed.
 void lastThumbPage()
          Callback method triggered when the Next Thumb Page button is pressed.
 java.awt.Image loadImageURL(java.lang.String url, long waitTime)
          Load an image from the given URL, and wait for it to complete loading.
 void nextScreenImage()
          Callback method triggered when the Next Image button is pressed.
 void nextThumbPage()
          Callback method triggered when the Next Thumb Page button is pressed.
 void prevScreenImage()
          Callback method triggered when the Previous Image button is pressed.
 void prevThumbPage()
          Callback method triggered when the Previous Thumb Page button is pressed.
 void setSelectedThumb(int i)
          Store the current thumbnail index, independent of the view.
 void showDocument(java.net.URL url)
           
 void sortByCategory()
          Callback method triggered when the sort by Category button is pressed
 void sortByDate()
          Callback method triggered when the Sort by date button is pressed
 void start()
          Initialize the thinlet
protected  void startElement(java.lang.String tag, java.util.Hashtable attributes)
          XML Parser callback
 void tabChanged()
          Callback method triggered when the tabs at the top of the application are selected.
 void thumbClicked(java.lang.String componentName)
          Called when the thumbnails are clicked
 void updateTechInfo()
          Callback method triggered when the Update tech info button is pressed
 void viewFullImage()
          Tell the browser to show the full image for printing, saving.
 
Methods inherited from class thinlet.Thinlet
add, add, add, create, destroy, find, getBoolean, getChoice, getClass, getCount, getDesktop, getDOMAttribute, getDOMCount, getDOMNode, getDOMText, getIcon, getIcon, getInteger, getItem, getItems, getLangResource, getLangResourceDefault, getParent, getPreferredSize, getProperty, getSelectedIndex, getSelectedItem, getSelectedItems, getString, getWidget, handleException, isFocusTraversable, paint, parse, parse, parse, parse, parseDOM, parseXML, processEvent, putProperty, remove, removeAll, repaint, requestFocus, run, setAllI18n, setBoolean, setChoice, setColor, setColors, setFocus, setFont, setFont, setFont, setIcon, setInteger, setKeystroke, setLangResource, setLangResourceDefault, setMethod, setResourceBundle, setString, update
 
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, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setLayout, transferFocusBackward, transferFocusDownCycle, 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, 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, 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, isFontSet, isForegroundSet, isLightweight, isOpaque, 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, setName, setSize, 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

AD_INDEX

public static final java.lang.String AD_INDEX
See Also:
Constant Field Values
Constructor Detail

PhotoViewer

public PhotoViewer(java.applet.Applet applet)
Default constructor for use with classForName()

Method Detail

start

public void start()
Initialize the thinlet


showDocument

public void showDocument(java.net.URL url)
Parameters:
url - URL to show in the browser

getCodeBase

public java.lang.String getCodeBase()
Returns:
String form of the code base URL gauranteed to end in a slash '/'

tabChanged

public void tabChanged()
Callback method triggered when the tabs at the top of the application are selected.


firstScreenImage

public void firstScreenImage()
Callback method triggered when the Previous Image button is pressed.


prevScreenImage

public void prevScreenImage()
Callback method triggered when the Previous Image button is pressed.


nextScreenImage

public void nextScreenImage()
Callback method triggered when the Next Image button is pressed.


lastScreenImage

public void lastScreenImage()
Callback method triggered when the Next Image button is pressed.


firstThumbPage

public void firstThumbPage()
Callback method triggered when the Previous Thumb Page button is pressed.


prevThumbPage

public void prevThumbPage()
Callback method triggered when the Previous Thumb Page button is pressed.


nextThumbPage

public void nextThumbPage()
Callback method triggered when the Next Thumb Page button is pressed.


lastThumbPage

public void lastThumbPage()
Callback method triggered when the Next Thumb Page button is pressed.


thumbClicked

public void thumbClicked(java.lang.String componentName)
Called when the thumbnails are clicked


sortByDate

public void sortByDate()
Callback method triggered when the Sort by date button is pressed


sortByCategory

public void sortByCategory()
Callback method triggered when the sort by Category button is pressed


updateTechInfo

public void updateTechInfo()
Callback method triggered when the Update tech info button is pressed


getJavaVersion

public java.lang.String getJavaVersion()
Returns:
the current Java VM version as a String

addTechRow

protected void addTechRow(java.lang.String key,
                          java.lang.String value)
Add a row of information key-value pairs to the tech info table

Parameters:
key - String property key
value - String property value

find

public java.lang.Object find(java.lang.String componentName)
Locate a component by componentName. Note that components are cached once requested, so this method can be called repeatedly on a component, without incurring a performance hit.

Parameters:
componentName - String componentName of the component to locate
Returns:
an Object reference of the component, to be used with Thinlet's Bean style accessors.

installParser

public void installParser(ThinletXmlParser parser)
Install a new parser for processing a new document type. This method must be called before calling the parseXML method (implemented on the Thinlet m_parent).

Parameters:
parser - ThinletXmlParser instance to use for the next parseXML() invocation.

startElement

protected void startElement(java.lang.String tag,
                            java.util.Hashtable attributes)
XML Parser callback

Parameters:
tag - String name of element being processed
attributes - Hashtable of attribute key/value pairs for the element being processed.

endElement

protected void endElement()
XML Parser callback


characters

public void characters(java.lang.String text)
XML Parser callback

Parameters:
text - String content that appears between the Start and End element tags

getResource

public java.io.InputStream getResource(java.lang.String uri)
Fetch a resource from the classpath

Parameters:
uri - String describing resource to load.
Returns:
InputStream prepared for reading the resource.

getContent

public byte[] getContent(java.lang.String uri)
Load content from Applet, using it's ClassLoader, which will attempt to find it in the codebase, and if it fails, will also try the server from which the Applet was loaded.

Parameters:
uri - String resource name
Returns:
byte[] of xml directory content.

viewFullImage

public void viewFullImage()
Tell the browser to show the full image for printing, saving.


setSelectedThumb

public void setSelectedThumb(int i)
Store the current thumbnail index, independent of the view.

Parameters:
i - int index of the "current" thumbnail.

getSelectedThumb

public int getSelectedThumb()
Get the index of the "currently selected" thumb, independent of view.

Returns:
int index.

gotoURL

public void gotoURL(java.lang.String url)
Send the browser to the URL passed in.

Parameters:
url -

loadImageURL

public java.awt.Image loadImageURL(java.lang.String url,
                                   long waitTime)
Load an image from the given URL, and wait for it to complete loading.

Parameters:
url - URL of the image.
waitTime - the amount of milliseconds to wait for the image to load.
Returns:
an Image or null.

getIcon

public java.awt.Image getIcon(java.lang.String path,
                              boolean preload)
Override parent class method because it does not work on Microsoft's Java 1.1 VM.

Parameters:
path - is relative to your thinlet instance or the classpath, or an URL
preload - waits for the whole image if true, starts loading (and repaints, and updates the layout) only when required (painted, or size requested) if false
Returns:
the loaded image or null