|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.PropertyContainer
util.PropertyResources
util.PropertyBundles
jview.ImageCache
public class ImageCache
A class to monitor an URL for a sequence of images. Two important times have
to be distinguished: The main web-site refresh interval, i.e. the time
at which the content of the URL is updated to show a new image, and
the recording interval of the cache, which is at least as long as the
web update interval. If you have a website that delivers an hourly update
of an image, but you are only interested in the daily changes, leave the
#KEY_WEBUPDATE interval at 3600 000ms, and set the
#KEY_CACHEUPDATE to 86400 000ms.
Subclasses may load specific images and allow some image-manipulation.
Clouds| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class util.PropertyResources |
|---|
PropertyResources.URLResource |
| Field Summary | |
|---|---|
private SortedMap<Date,BufferedImage> |
cache
The mapping of retrieval dates to images. |
private static int |
DEFCACHESIZE
Defaults to zero meaning unlimited cache size. |
static String |
KEY_CACHEREFRESH
Forced to be at least the web refresh interval, determines image seq. |
static String |
KEY_CACHESIZE
The maximum cache size. |
static String |
KEY_IMAGEURL
URL to read the cloud image from. |
static String |
KEY_WEBREFRESH
The web refresh interval, the time the URL is updated. |
private Date |
last
The date of the last successful invokation. |
| Fields inherited from class util.PropertyBundles |
|---|
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES |
| Fields inherited from class util.PropertyResources |
|---|
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset |
| Fields inherited from class util.PropertyContainer |
|---|
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR |
| Fields inherited from interface util.ResourceSupplying |
|---|
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME |
| Fields inherited from interface util.PropertySupplying |
|---|
CONFIG, KEY_CLASS |
| Constructor Summary | |
|---|---|
ImageCache(Map<String,String> prop)
Defaults only the cache size. |
|
| Method Summary | |
|---|---|
protected BufferedImage |
downloadImage(URL address,
Date called)
The default implementation simply downloads the image and adjusts the time stamp of the image retrieveal to additionally reflect the time it took for downloading. |
protected List<URL> |
getDownloadURL()
In the default implementation we simply return the URL given by the KEY_IMAGEURL. |
Date |
getLastDate()
Returns the last date in the cache. |
BufferedImage |
getLastImage()
Returns the last buffered image in the cache. |
long |
getRefreshInterval()
The refresh interval is our cache intervall, not the web refresh. |
void |
init()
We throw an illegal argument if no download url has been given. |
boolean |
isFixedRate()
We act like a cron, thus return true; |
boolean |
isRefreshNeeded()
We return true if we request a new image. |
void |
refresh()
On refresh, we download the image from the net and store it in the cache if successful. |
| Methods inherited from class util.PropertyBundles |
|---|
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource |
| Methods inherited from class util.PropertyResources |
|---|
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet |
| Methods inherited from class util.PropertyContainer |
|---|
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface util.ResourceSupplying |
|---|
getResource, getResourceAsStream, getResources |
| Methods inherited from interface util.PropertySupplying |
|---|
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties |
| Field Detail |
|---|
public static final String KEY_IMAGEURL
public static final String KEY_WEBREFRESH
public static final String KEY_CACHEREFRESH
public static final String KEY_CACHESIZE
private static final int DEFCACHESIZE
private SortedMap<Date,BufferedImage> cache
private Date last
| Constructor Detail |
|---|
public ImageCache(Map<String,String> prop)
| Method Detail |
|---|
public void init()
init in interface Initializableinit in class PropertyResourcespublic void refresh()
refresh in interface Refreshingpublic boolean isRefreshNeeded()
isRefreshNeeded in interface ConditionalRefreshingpublic long getRefreshInterval()
getRefreshInterval in interface Refreshingpublic boolean isFixedRate()
isFixedRate in interface RefreshingTimerpublic BufferedImage getLastImage()
getLastDate() consider synchronizing in multithreaded
environments.
public Date getLastDate()
protected List<URL> getDownloadURL()
KEY_IMAGEURL.
protected BufferedImage downloadImage(URL address,
Date called)
throws IOException
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||