Class ViewPlots

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byjava.applet.Applet
                  extended byViewPlots
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ActionListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.event.ItemListener, java.awt.event.KeyListener, java.awt.MenuContainer, java.io.Serializable

public class ViewPlots
extends java.applet.Applet
implements java.awt.event.ActionListener, java.awt.event.ItemListener, java.awt.event.KeyListener

ViewPlots Applet and Application This class will display a list of all image files in the current directory and a list of all the sub-directories in the current directory. It will then allow you to loop through the images, or a sub-set of the images. Giving manual control for forward and back. You also have the option of going to one of the sub- directories and looping through the images there. A coding convention has been followed to establish the scope of a variable. All variables of the form: its represent globally scoped variables available in all methods. All variables of the form: the represent formal arguments of a method. All variables of the form: a[n] represent locally declared variables.

Author:
Daniel J. Adams
See Also:
Serialized Form

Nested Class Summary
(package private)  class ViewPlots.AList
          AList supporting class for ViewPlots This class extends the java.awt.List class to add a few methods that resemble javax.swing.JList methods.
(package private)  class ViewPlots.AnImage
          AnImage supporting class for ViewPlots This class extends the java.awt.Component class to provide a image component.
(package private)  class ViewPlots.DoublePanel
          DoublePanel supporting class for ViewPlots This class extends the java.awt.Panel class to provide a double-buffered Panel.
(package private)  class ViewPlots.Environment
          Environment supporting class for ViewPlots This class handles the retrieving of environment settings for both the applet (passed from html), or from the aplication (command line arguments).
(package private)  class ViewPlots.Timer
          Timer supporting class for ViewPlots This class is a substitue class for the javax.swing.Timer class.
(package private)  class ViewPlots.TimerThread
          TimerThread supporting class for ViewPlots.Timer This class handles the implmentation of the background thread for the image animation.
 
Nested classes inherited from class java.applet.Applet
java.applet.Applet.AccessibleApplet
 
Nested classes inherited from class java.awt.Panel
java.awt.Panel.AccessibleAWTPanel
 
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
private  boolean itsAppletFlag
          Flag to indicate running state as Applet(true) or Application(false)
private  ViewPlots.AList itsDirList
          The widget containing the list of sub-directories of the current dir.
private  ViewPlots.Environment itsEnvironment
          Environment, parameters from the command line or from the HTML file
private  ViewPlots.AList itsFilterList
          The widget containing the list of filters for the current dir.
private  java.util.Vector itsFilters
          The actual filename filters that coorilate with itsFilterList
private static int itsGap
          Represents spacing between widgets, can be 0-MAXINT
private  ViewPlots.AnImage itsImage
          Utilizes the IconImage as component for the image display
private  ViewPlots.AList itsImageList
          The widget containing the list of images in the current dir.
private  int itsIndex
          Index in the image list of the currently displayed image
private  java.awt.Panel itsListPane
          The container that holds the various Lists
private  boolean itsModKey
          Represents the key being held down for multi-select in list
private  java.lang.String itsRootDir
          Root directory, where this was started
private  int[] itsSelectedIndices
          Holder for the sub-set when looping on a subset of images
private  java.lang.String itsSubDir
          Current directory, relative to root directory where this was started
private  ViewPlots.Timer itsTimer
          Trigger for the looping mechanism
private  boolean itsUpdateFlag
          Flag to indicate doing a menu update, ignore slected events during update
 
Fields inherited from class java.applet.Applet
 
Fields inherited from class java.awt.Panel
 
Fields inherited from class java.awt.Container
 
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
ViewPlots()
          Empty constructor Empty contsructor called when executing as an Applet
ViewPlots(boolean theAppletFlag)
          Normal constructor.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent theEvent)
          Responds to Timer events, and Button events This method handles events from both the Buttons, and itsTimer itsTimer events cause itsImage to advance Button events cause the proscribed action to occur.
private static void errorHalt()
          Method called when aborting a run.
private static java.lang.String extractReference(java.lang.String theString)
          Given an HTML formatted line, return only the link referenced file name Return the reference contents of the anchor tag so: Some File returns foobar.txt
 void finalize()
          Method for releasing resources
 boolean findExp(java.lang.String theExp, java.lang.String theString)
          Simplified regular expression finder Allows the meta-characters, '*', and '?'.
private  java.util.Vector getAllImages()
          Get a set of images in subdirectories for an Image display Gather a list of all images in all sub-directories of the current directory.
private  java.util.Vector getMenu(boolean theDirFlag)
          Get a set of items for a List display Gather a list of all sub-directories (o1n theDirFlag->true) or all images (theDirFlag->false) in the current directory.
private  java.util.Vector getRecursiveMenu()
          Get a set of items for a List display Gather a list of all all images (theDirFlag->false) in all sub-directories.
 void init()
          Method called as an Applet, prior to display.
private  boolean isDir(java.lang.String theFileName)
          Given a file name, return if it looks like a directory Return true if the String looks like a directory String
private static boolean isImage(java.lang.String theFileName)
          Given a file name, return if it looks like an image Class method return true if String looks like an image file
 void itemStateChanged(java.awt.event.ItemEvent theEvent)
          Respond to select events in the lists.
 void keyPressed(java.awt.event.KeyEvent theEvent)
          KeyListener method, detect a key press
 void keyReleased(java.awt.event.KeyEvent theEvent)
          KeyListener method, detect a key release
 void keyTyped(java.awt.event.KeyEvent theEvent)
          Placeholder method for KeyListener
static void main(java.lang.String[] theArgs)
          Application entry point This method allows the applet to be run as an application.
private  java.awt.Container makeContentPane()
          Build the contents of the Applet This method builds and initializes all of the widgets for the display.
private  void showImage()
          Displays the image Displays the image in itsImageList pointed to by itsIndex.
 
Methods inherited from class java.applet.Applet
destroy, getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, 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, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, 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, isFocusTraversable, 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, 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, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

itsGap

private static final int itsGap
Represents spacing between widgets, can be 0-MAXINT

See Also:
Constant Field Values

itsModKey

private boolean itsModKey
Represents the key being held down for multi-select in list


itsImage

private ViewPlots.AnImage itsImage
Utilizes the IconImage as component for the image display


itsTimer

private ViewPlots.Timer itsTimer
Trigger for the looping mechanism


itsIndex

private int itsIndex
Index in the image list of the currently displayed image


itsAppletFlag

private boolean itsAppletFlag
Flag to indicate running state as Applet(true) or Application(false)


itsDirList

private ViewPlots.AList itsDirList
The widget containing the list of sub-directories of the current dir.


itsImageList

private ViewPlots.AList itsImageList
The widget containing the list of images in the current dir.


itsFilterList

private ViewPlots.AList itsFilterList
The widget containing the list of filters for the current dir.


itsFilters

private java.util.Vector itsFilters
The actual filename filters that coorilate with itsFilterList


itsListPane

private java.awt.Panel itsListPane
The container that holds the various Lists


itsSelectedIndices

private int[] itsSelectedIndices
Holder for the sub-set when looping on a subset of images


itsUpdateFlag

private boolean itsUpdateFlag
Flag to indicate doing a menu update, ignore slected events during update


itsSubDir

private java.lang.String itsSubDir
Current directory, relative to root directory where this was started


itsRootDir

private java.lang.String itsRootDir
Root directory, where this was started


itsEnvironment

private ViewPlots.Environment itsEnvironment
Environment, parameters from the command line or from the HTML file

Constructor Detail

ViewPlots

public ViewPlots()
Empty constructor Empty contsructor called when executing as an Applet


ViewPlots

public ViewPlots(boolean theAppletFlag)
Normal constructor. Normal constructor, called directly by main() to indicate that we are not running as an Applet and need to make sure we use filesystem, nor URL resources. Also called by the applet constructor with true to insure that we are running in a browser.

Parameters:
theAppletFlag - true if running as an applet, false if an application
Method Detail

main

public static void main(java.lang.String[] theArgs)
Application entry point This method allows the applet to be run as an application. It sets up the necessary components for a single display window that acts like the applet portion of a browser window. When this class is run as an application, the main window is closed to end it.

Parameters:
theArgs - Arguments passed in on the command line. A single argument is used to determine the root directory, default is '.' with no argument.

errorHalt

private static void errorHalt()
Method called when aborting a run. For consistancy, this is a method that displays the usage information for running this as an application.


init

public void init()
Method called as an Applet, prior to display. Required method for all Applets to do setups prior to the display of the Applet. This init sets the Applets content pane to a newly constructed pane.


showImage

private void showImage()
Displays the image Displays the image in itsImageList pointed to by itsIndex. Checking is done prior to display, to insure that itsIndex is within bounds of itsImageList or itsSelectedIndices, wrapping over as required. Side Effect: itsImage may be changed to either the first legal element if itsIndex overflows the limits, or to the last legal element if itsIndex underflows the limits.


actionPerformed

public void actionPerformed(java.awt.event.ActionEvent theEvent)
Responds to Timer events, and Button events This method handles events from both the Buttons, and itsTimer itsTimer events cause itsImage to advance Button events cause the proscribed action to occur. Side Effects: itsImage is adjusted on itsTimer ticks, Forward button press, and Backward button press. On View button press itsSubDir is reset, and both menus updated.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
theEvent - Action event from itsTimer or a JButton

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent theEvent)
Respond to select events in the lists. Allow the list selection events to occur. This can cause a new Image to be displayed, or a new set of contraints on the images. Side Effects: On selecting a new sub directory, the lists are regenerated.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
theEvent - List Selection event from one of the lists.

makeContentPane

private java.awt.Container makeContentPane()
Build the contents of the Applet This method builds and initializes all of the widgets for the display. It is called once at initialization of the applet.

Returns:
Container (DoublePanel) for root content pane.

getMenu

private java.util.Vector getMenu(boolean theDirFlag)
Get a set of items for a List display Gather a list of all sub-directories (o1n theDirFlag->true) or all images (theDirFlag->false) in the current directory.

Parameters:
theDirFlag - Flag to indicate if collecting directories
Returns:
Vector List of menu items for indicated menu.

getAllImages

private java.util.Vector getAllImages()
Get a set of images in subdirectories for an Image display Gather a list of all images in all sub-directories of the current directory.

Returns:
Vector List of menu items for indicated menu.

getRecursiveMenu

private java.util.Vector getRecursiveMenu()
Get a set of items for a List display Gather a list of all all images (theDirFlag->false) in all sub-directories.

Returns:
Vector List of menu items for indicated menu.

isImage

private static boolean isImage(java.lang.String theFileName)
Given a file name, return if it looks like an image Class method return true if String looks like an image file

Parameters:
theFileName - String to test for Image pattern
Returns:
true if theFileName matches the Image pattern

isDir

private boolean isDir(java.lang.String theFileName)
Given a file name, return if it looks like a directory Return true if the String looks like a directory String

Parameters:
theFileName - String to test for directory pattern
Returns:
true if theFileName matches the directory pattern

extractReference

private static java.lang.String extractReference(java.lang.String theString)
Given an HTML formatted line, return only the link referenced file name Return the reference contents of the anchor tag so: Some File returns foobar.txt

Parameters:
theString - String to search for reference
Returns:
null, or the reference without HTML tag info.

findExp

public boolean findExp(java.lang.String theExp,
                       java.lang.String theString)
Simplified regular expression finder Allows the meta-characters, '*', and '?'. These will work as wildcards in search strings for file/directory names.

Parameters:
theExp - String containing meta-characters for match
theString - String to search for match

keyPressed

public void keyPressed(java.awt.event.KeyEvent theEvent)
KeyListener method, detect a key press

Specified by:
keyPressed in interface java.awt.event.KeyListener
Parameters:
theEvent - KeyEvent of key pressed

keyReleased

public void keyReleased(java.awt.event.KeyEvent theEvent)
KeyListener method, detect a key release

Specified by:
keyReleased in interface java.awt.event.KeyListener
Parameters:
theEvent - KeyEvent of key released

keyTyped

public void keyTyped(java.awt.event.KeyEvent theEvent)
Placeholder method for KeyListener

Specified by:
keyTyped in interface java.awt.event.KeyListener
Parameters:
theEvent - KeyEvent of key typed

finalize

public void finalize()
              throws java.lang.Throwable
Method for releasing resources

Throws:
java.lang.Throwable