All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----com.elegantchaos.beans.asset.Asset
"User" objects can register an interest in assets, and then request them to load. When an asset is loaded, all registered users get notified, and sent the asset data to use. This potentially allows a number of client objects to share the asset data, avoiding unnecessary duplication of resources.
When user objects are permanently finished with an asset, they can unregister themselves. Assets can be set to automatically unload when all users have unregistered, or they can stay loaded until explicitly requested to unload.
The Asset class provides the capability (as yet unimplemented) for an "asset manager" of some sort which manages the unloading of assets in order to manage application memory effectively. The Asset manager can request that an asset be unloaded. When this happens, all registered users of the asset will receive an assetUnloading(kRequested) event, which gives them the chance to veto the unload (they do this by throwing an exception). The Asset manager will then send an assetUnloading(kFinished) event to indicate that the asset has indeed been unloaded. The Asset manager can also deliver this event without negotiation, in a situation where the asset has unexpectedly become unavailable.
Objects that use listeners are encouraged to fully support assetUnloading requests by not vetoing them unless doing so is absolutely necessary. In any event, assetUnloaded events should be handled so that the object can cope gracefully with it's asset becoming unavailable.
if the asset is already loaded, the calling listener is immedietly sent an assetLoaded(kFinished) event - otherwise the load is requested, and appropriate events are sent to indicate the result
the idea here is to make sure that any user object only receives the load event once, but still inform all objects that need to know as soon as the load occurs.
if the asset is already unloaded, the calling listener is immedietly sent an assetUnloaded(kFinished) event - otherwise the routine first asks all registered listeners whether they mind the asset unloading, and only completes the unload if they all agree
public Asset(java.lang.String url)
public void validateObject() throws java.io.InvalidObjectException
public boolean isCached()
public void setCached(boolean b)
public boolean isPreloaded()
public void setPreloaded(boolean b)
public boolean isLoaded()
public java.lang.String getLocation()
public void setLocation(java.lang.String url)
public java.lang.Object getData()
public boolean isVisual()
public boolean isAudible()
public java.awt.Dimension getSize()
public int getFileSize()
public javax.swing.ImageIcon getPreview()
public void requestLoad(com.elegantchaos.beans.asset.AssetListener al)
if the asset is already loaded, the calling listener is immedietly sent an assetLoaded(kFinished) event - otherwise the load is requested, and appropriate events are sent to indicate the result
the idea here is to make sure that any user object only receives the load event once, but still inform all objects that need to know as soon as the load occurs. As a result, client objects should be prepared to receive the load object before they have requested loading.
public void requestUnload(com.elegantchaos.beans.asset.AssetListener al)
if the asset is already unloaded, the calling listener is immedietly sent an assetUnloaded(kFinished) event - otherwise the routine first asks all registered listeners whether they mind the asset unloading, and only completes the unload if they all agree
public synchronized void addAssetListener(com.elegantchaos.beans.asset.AssetListener al)
public synchronized void removeAssetListener(com.elegantchaos.beans.asset.AssetListener al)
All Packages Class Hierarchy This Package Previous Next Index