|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sourceforge.pavlov.randommedia.AbstractRandomMediaFactory
public abstract class AbstractRandomMediaFactory
This is a base class for random media factories. A random media factory is supplied with a directory tree or JAR file or mixture of the two, and randomly supplies a media object (i.e. an image, a sound) from the files. Implementations often will require caching/preloading.
Constructor Summary | |
---|---|
AbstractRandomMediaFactory()
Creates a new AbstractRandomMediaFactory instance. |
|
AbstractRandomMediaFactory(String rootDir)
Creates a new AbstractRandomMediaFactory instance. |
Method Summary | |
---|---|
void |
actionPerformed(ActionEvent e)
Toggles the enabled state of a RandomMediaDirectory named by the ActionEvent's ActionCommand. |
void |
addMediaRootChangedListener(MediaRootChangedListener who)
Adds an object that wants to be notified when the media directory structure has changed. |
abstract void |
clearCache()
Clears any caching mechanism. |
void |
clearDirectories()
Removes all directories and clears any cache. |
void |
disableDirectory(String dirName)
Disables the named RandomMediaDirectory. |
void |
enableDirectory(RandomMediaDirectory directory)
This enables, i.e. |
void |
enableDirectory(String dirName)
Enables the named RandomMediaDirectory. |
protected abstract ZipCapableFileFilter |
getFileFilter()
Describe getFileFilter method here. |
int |
getNumberOfDisabledItems()
Returns a count of items in disabled directories. |
int |
getNumberOfEnabledItems()
Returns a count of items in enabled directories. |
int |
getNumberOfTotalItems()
Returns a count of items in enabled and disabled directories. |
URL |
getRandomURL()
Returns a random URL from one of the enabled directories. |
String |
getRootDirectory()
getRootDirectory returns a String representation of this
factory's root directory. |
String[] |
getSubDirectoryNames()
Returns a string array of subdirectory names. |
boolean |
isDirectoryEnabled(String dirName)
Returns whether the named directory is enabled or not. |
protected void |
notifyListeners()
Lets all the MediaRootChangedListeners know that the MediaRoot has changed. |
void |
refresh()
Synch the in-memory representation up with the filesystem representation. |
void |
setRootDirectory(File directory)
Sets the root directory for this media factory, clears the cache as per clearCache() and refreshes its state with refresh(). |
void |
setRootDirectory(String dir)
|
void |
toggleEnabled(String dirName)
Toggles the enabled state of the named RandomMediaDirectory. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AbstractRandomMediaFactory()
AbstractRandomMediaFactory
instance.
Uses the directory "resources/images" as its root directory.
public AbstractRandomMediaFactory(String rootDir)
AbstractRandomMediaFactory
instance.
rootDir
- a String
valueMethod Detail |
---|
protected abstract ZipCapableFileFilter getFileFilter()
getFileFilter
method here.
ZipCapableFileFilter
valuepublic abstract void clearCache()
public String getRootDirectory()
getRootDirectory
returns a String representation of this
factory's root directory.
String
valuepublic void setRootDirectory(String dir)
public void setRootDirectory(File directory)
directory
- a File
valueprotected void notifyListeners()
public void addMediaRootChangedListener(MediaRootChangedListener who)
who
- a MediaRootChangedListener
valuepublic void refresh()
public void enableDirectory(RandomMediaDirectory directory)
directory
- a RandomMediaDirectory
valuepublic void enableDirectory(String dirName)
dirName
- a String
valuepublic void disableDirectory(String dirName)
dirName
- a String
valuepublic void clearDirectories()
public void toggleEnabled(String dirName)
public boolean isDirectoryEnabled(String dirName)
dirName
- a String
value
boolean
valuepublic int getNumberOfEnabledItems()
int
valuepublic int getNumberOfTotalItems()
int
valuepublic int getNumberOfDisabledItems()
int
valuepublic URL getRandomURL()
getRandomURL
in interface RandomURLProvider
URL
valuepublic String[] getSubDirectoryNames()
String[]
valuepublic void actionPerformed(ActionEvent e)
actionPerformed
in interface ActionListener
e
- an ActionEvent
value
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |