ach
Class CatalogPanel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjava.awt.Panel
              extended byach.CatalogPanel
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ComponentListener, java.util.EventListener, java.awt.image.ImageObserver, ImgProdObserver, java.awt.event.KeyListener, java.awt.MenuContainer, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.lang.Runnable, java.io.Serializable

public class CatalogPanel
extends java.awt.Panel
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.ComponentListener, java.awt.event.KeyListener, ImgProdObserver, java.awt.image.ImageObserver, java.lang.Runnable

CatalogPanel.java
Copyright (C) 2001-2010 H. Hackbarth, All Rights Reserved
Panel to display a given list of images as thumbnails with optional information. Thumbnails can be selected (also multiple selections) by clicking or Ctrl-A (selects all). A double click schedules an event of type KEY_PRESS with "Enter"-Key to it's parent component. Selected images can then be retrieved through method getSelected(). Loading of thumbnail images is carried out asynchronously. When loading is finished, the component schedules an event with ID 99993 to it's parent component. The updated image list (String array) is handed over as event arg. This component drills also down into multipage images if in the constructor the asynchronous flag is set to false. Multipage images will be suffixed with the page number in brackets ('[' and ']'). If a thumbnail directory is specified, rendered thumbnails are stored and will be read the next time for faster display from that directory. For examples how to use this class please refer to ImagePanel.java. replacements.

THE AUTHOR MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. THE AUTHOR SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.

See Also:
Serialized Form

Nested Class Summary
 
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
 
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
CatalogPanel(boolean addDescriptions, java.lang.String thumbnailSubdir, boolean asynchronous)
          Constructor for catalog panel containing images as thumbnails.
 
Method Summary
 java.awt.Component add(java.awt.Component c)
          Add any kind of component to the catalog
 void addImage(java.lang.String name, java.awt.Dimension bounds, int scaleHint)
          Add an image to the catalog panel.
 void addImageList(java.lang.String[] nameList, java.awt.Dimension bounds, int scaleHint)
          Adds a list of images (filenames or URLs) to the catalog
 void clearCatalog()
          clear all thumbnails from catalog
 void componentHidden(java.awt.event.ComponentEvent e)
          event handler for component events
 void componentMoved(java.awt.event.ComponentEvent e)
          event handler for component events
 void componentResized(java.awt.event.ComponentEvent e)
          event handler for component events
 void componentShown(java.awt.event.ComponentEvent e)
          event handler for component events
 java.awt.Dimension getMinimumSize()
          Get minimum size of component
 java.awt.Dimension getPreferredSize()
          Get preferred size of component
 java.lang.String[] getSelected()
          Get a list of all currently selected thumbnail images as a string array.
 boolean handleEvent(java.awt.Event evt)
          Event handler for JDK 1.0 events
 void imageProducerUpdate(java.awt.image.ImageProducer imgSrc, java.lang.String errorMsg, ImageInfo imgInfo)
          As this component implements the ImgProdObserver interface, this is the method which will be called back, when asynchronous loading of an imageproducer through an ImageInfo thread is finished.
 boolean imageUpdate(java.awt.Image img, int flags, int x, int y, int w, int h)
          As this component implements the ImageObserver interface, this is the method which is called back when rendering of an image communicates a new state.
 boolean isSelected(java.awt.Component c)
          Return selection state of a given component
 void keyPressed(java.awt.event.KeyEvent e)
          event handler for key events
 void keyReleased(java.awt.event.KeyEvent e)
          event handler for key events
 void keyTyped(java.awt.event.KeyEvent e)
          event handler for key events
 java.awt.Dimension minimumSize()
          Get minimum size of component
 void mouseClicked(java.awt.event.MouseEvent e)
          event handler for mouse events
 void mouseDragged(java.awt.event.MouseEvent e)
          event handler for mouse motion events
 void mouseEntered(java.awt.event.MouseEvent e)
          event handler for mouse events
 void mouseExited(java.awt.event.MouseEvent e)
          event handler for mouse events
 void mouseMoved(java.awt.event.MouseEvent e)
          event handler for mouse motion events
 void mousePressed(java.awt.event.MouseEvent e)
          event handler for mouse events
 void mouseReleased(java.awt.event.MouseEvent e)
          event handler for mouse events
 java.awt.Dimension preferredSize()
          Get preferred size of component
 void removeSelected()
          remove selected components from catalog
 void resize(java.awt.Dimension d)
          resize component to given dimension
 void resize(int width, int height)
          resize component to given dimension
 void run()
          Runs thumbnail rendering as seperate thread (use start() method to run it).
 void scheduleParentEvent(java.awt.Event e)
           
 void setSelected(java.awt.Component c, boolean state)
          Select or deselect a given component
 void setSelected(int index, boolean state)
          Select or deselect a given component
 void setSelectedAll(boolean state)
          Set selection state of all components
 void setSelectedRange(int fromIndex, int toIndex, boolean state)
          Set the selection state of a range of components
 void setSize(java.awt.Dimension d)
          resize component to given dimension
 void setSize(int width, int height)
          resize component to given dimension
 void stopLoading()
          Stop loading / rendering of further images
 void toggleSelected(java.awt.Component c)
          Toggle the selection stat of a given component
 void toggleSelected(int index)
          Toggle the selection stat of a given component
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
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, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, paint, paintComponents, paramString, 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, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, hasFocus, hide, 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, 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

CatalogPanel

public CatalogPanel(boolean addDescriptions,
                    java.lang.String thumbnailSubdir,
                    boolean asynchronous)
Constructor for catalog panel containing images as thumbnails. Multipage TIFFs will only be drilled down if asynchronous flag set to false. If parameter for thumbnail directory is null, no thumbnails are stored. Otherwise Thumbnails are stored for faster access in the future (requires write access to local file system).

Parameters:
addDescriptions - flag if descriptions should be displayed on thumbnails
thumbnailSubdir - directory where to store thumbnail images for faster execution next time
asynchronous - flag if images should be loaded asynchronously
Method Detail

resize

public void resize(java.awt.Dimension d)
resize component to given dimension

Parameters:
d - dimension of component

resize

public void resize(int width,
                   int height)
resize component to given dimension

Parameters:
width - component width
height - component height

setSize

public void setSize(java.awt.Dimension d)
resize component to given dimension

Parameters:
d - dimension of component

setSize

public void setSize(int width,
                    int height)
resize component to given dimension

Parameters:
width - component width
height - component height

getMinimumSize

public java.awt.Dimension getMinimumSize()
Get minimum size of component

Returns:
Dimension with minimum size.

minimumSize

public java.awt.Dimension minimumSize()
Get minimum size of component

Returns:
Dimension with minimum size.

preferredSize

public java.awt.Dimension preferredSize()
Get preferred size of component

Returns:
Dimension with preferred size.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Get preferred size of component

Returns:
Dimension with preferred size.

add

public java.awt.Component add(java.awt.Component c)
Add any kind of component to the catalog

Parameters:
c - component to be added
Returns:
Component

imageProducerUpdate

public void imageProducerUpdate(java.awt.image.ImageProducer imgSrc,
                                java.lang.String errorMsg,
                                ImageInfo imgInfo)
As this component implements the ImgProdObserver interface, this is the method which will be called back, when asynchronous loading of an imageproducer through an ImageInfo thread is finished.

Specified by:
imageProducerUpdate in interface ImgProdObserver
Parameters:
imgSrc - ImageProducer for the requested image
errorMsg - String containing an error message if any error occured during loading
imgInfo - an ImageInfo instance that carried out the asynchronous loading
See Also:
ImageInfo

imageUpdate

public boolean imageUpdate(java.awt.Image img,
                           int flags,
                           int x,
                           int y,
                           int w,
                           int h)
As this component implements the ImageObserver interface, this is the method which is called back when rendering of an image communicates a new state.

Specified by:
imageUpdate in interface java.awt.image.ImageObserver
Parameters:
img -
flags -
x -
y -
w -
h -
Returns:

addImage

public void addImage(java.lang.String name,
                     java.awt.Dimension bounds,
                     int scaleHint)
Add an image to the catalog panel.

Parameters:
name - Filename or URL for the image
bounds - Dimension of the thumbnail images
scaleHint - controls the scaling method (see java.awt.Image, e.g SCALE_FAST, SCALE_SMOOTH etc.)

addImageList

public void addImageList(java.lang.String[] nameList,
                         java.awt.Dimension bounds,
                         int scaleHint)
Adds a list of images (filenames or URLs) to the catalog

Parameters:
nameList - String array containing the image list to be added.
bounds - Dimension of the thumbnail images
scaleHint - controls the scaling method (see java.awt.Image, e.g SCALE_FAST, SCALE_SMOOTH etc.)

run

public void run()
Runs thumbnail rendering as seperate thread (use start() method to run it).

Specified by:
run in interface java.lang.Runnable

stopLoading

public void stopLoading()
Stop loading / rendering of further images


clearCatalog

public void clearCatalog()
clear all thumbnails from catalog


scheduleParentEvent

public void scheduleParentEvent(java.awt.Event e)

getSelected

public java.lang.String[] getSelected()
Get a list of all currently selected thumbnail images as a string array.

Returns:
String array containing either filenames or URLs of original images.

setSelected

public void setSelected(java.awt.Component c,
                        boolean state)
Select or deselect a given component

Parameters:
c - Component to be selected/deselected
state - true selects component, false deselcts it

setSelected

public void setSelected(int index,
                        boolean state)
Select or deselect a given component

Parameters:
index - Index of component to be selected/deselected
state - true selects component, false deselcts it

isSelected

public boolean isSelected(java.awt.Component c)
Return selection state of a given component

Parameters:
c - Compoenent to read state from
Returns:
true for selected, false for deselectd

toggleSelected

public void toggleSelected(java.awt.Component c)
Toggle the selection stat of a given component

Parameters:
c - Component to toggle state of

toggleSelected

public void toggleSelected(int index)
Toggle the selection stat of a given component

Parameters:
index - Index of component to toggle state of

setSelectedRange

public void setSelectedRange(int fromIndex,
                             int toIndex,
                             boolean state)
Set the selection state of a range of components

Parameters:
fromIndex - Starting index
toIndex - Ending index
state - true for selected, false for deselected

setSelectedAll

public void setSelectedAll(boolean state)
Set selection state of all components

Parameters:
state - true for selected, false for deselected

removeSelected

public void removeSelected()
remove selected components from catalog


handleEvent

public boolean handleEvent(java.awt.Event evt)
Event handler for JDK 1.0 events

Parameters:
evt - Event to be processed (see java.awt.Event)
Returns:
true if event was handled, else result of super.handleEvent()

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
event handler for mouse events

Specified by:
mouseClicked in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
event handler for mouse events

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
event handler for mouse events

Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
event handler for mouse events

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
event handler for mouse events

Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
event handler for mouse motion events

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
event handler for mouse motion events

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
event handler for component events

Specified by:
componentResized in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
event handler for component events

Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
event handler for component events

Specified by:
componentShown in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
event handler for component events

Specified by:
componentHidden in interface java.awt.event.ComponentListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
event handler for key events

Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
event handler for key events

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
event handler for key events

Specified by:
keyReleased in interface java.awt.event.KeyListener