|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
org.rakeshv.gui.SlideShow
public class SlideShow
Modified version of SlideShow presented in
Java Thread Programming by Paul Hyde published by
SAMS.
Load all the images found under the specified directory
tree and display using a BufferedImage object.
The images are loaded one at a time using File to
traverse the specified directory. Each image will
be displayed for approximately delayInterval
milliseconds. The default value is 100ms for
delayInterval. This value can be
specified by implementing applications. Implementing
applications can also specify that only images in the specified
directory be displayed, without traversing
sub-directories.
Copyright 2002, Rakesh Vidyadharan
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
javax.swing.JComponent.AccessibleJComponent |
| 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 boolean |
CONTINUE_PLAYBACK
Flag that should be used to re-activate the play-back of images. |
private int |
delayInterval
The variable that controls the delay between successive image loading. |
private java.awt.image.BufferedImage |
image
The current image object that is being displayed. |
private java.lang.Thread |
internalThread
The Thread that is used to load the images one at
a time. |
static boolean |
SPECIFIED_DIRECTORY_ONLY
Flag that indicates that the specified directory
should not be traversed recursively, and only image
files found under the specified directory be played. |
static boolean |
STOP_PLAYBACK
Flag that should be used to stop the play-back of the images. |
private boolean |
stopRequested
A flag that is used to indicate whether the user requested the loading of images to stop. |
static boolean |
TRAVERSE_SUBDIRECTORIES
Flag that indicates that the specified directory
should be traversed recursively, and all image
files found played. |
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| 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 | |
|---|---|
SlideShow(java.io.File directory)
Create a new JComponent that will load all the
image files under the directory. |
|
SlideShow(java.io.File directory,
boolean traverseDirectory)
Create a new JComponent. |
|
| Method Summary | |
|---|---|
int |
getDelayInterval()
Return the current value for delayInterval. |
boolean |
getStopRequested()
Get the current value of the stopRequested
flag. |
void |
paint(java.awt.Graphics g)
Draws the current image onto this
component. |
void |
setDelayInterval(int interval)
Set the desired delayInterval. |
void |
setStopRequested(boolean flag)
Set the stopRequested flag to the specified
value. |
| Methods inherited from class javax.swing.JComponent |
|---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI |
| Methods inherited from class java.awt.Container |
|---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, 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, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, 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 |
|---|
public static final boolean TRAVERSE_SUBDIRECTORIES
directory
should be traversed recursively, and all image
files found played.
public static final boolean SPECIFIED_DIRECTORY_ONLY
directory
should not be traversed recursively, and only image
files found under the specified directory be played.
public static final boolean CONTINUE_PLAYBACK
public static final boolean STOP_PLAYBACK
private int delayInterval
milliseconds.
The default value is set to 500ms.
private java.awt.image.BufferedImage image
private java.lang.Thread internalThread
Thread that is used to load the images one at
a time.
private volatile boolean stopRequested
false, so that images will be loaded until the
user sends a stop request. Since this value will
be changed in another thread, this field
is made volatile to ensure that the
internalThread picks up the latest value.
| Constructor Detail |
|---|
public SlideShow(java.io.File directory)
JComponent that will load all the
image files under the directory. This component
may be embedded in any Swing container that
wishes to display a slide show of images. This constructor
just invokes SlideShow( File, boolean ) with
TRAVERSE_SUBDIRECTORIES.
directory - - The directory tree from which the images
are to be played.
public SlideShow(java.io.File directory,
boolean traverseDirectory)
JComponent. Depending
upon the boolean value passed in
sub-directories will be traversed.
directory - - The directory tree from which the images
are to be played.traverseDirectory - - Flag that indicates whether
image files under sub-directories should be played. Use
TRAVERSE_SUBDIRECTORIES or
SPECIFIED_DIRECTORY_ONLY
to specify preference.| Method Detail |
|---|
public void paint(java.awt.Graphics g)
image onto this
component.
paint in class javax.swing.JComponentpublic final int getDelayInterval()
delayInterval.
public final void setDelayInterval(int interval)
delayInterval.
interval - - The desired interval to set.public final boolean getStopRequested()
stopRequested
flag.
stopRequestedpublic final void setStopRequested(boolean flag)
stopRequested flag to the specified
value. After setting the specified flag, send an
interrupt to the internalThread. It is recommended that you use the
CONTINUE_PLAYBACK or
STOP_PLAYBACK flags to set the value.
flag - - The value to set.
|
Rakesh API | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||