Class AbstractImagePrototype
Image object. An image
prototype can be thought of as an abstract image factory with additional
capabilities.
The applyTo(Image) method provides an efficient way to replace the
contents of an existing Image. This is useful in cases where an
image changes its appearance based on a user's action. Instead of creating
two Image objects then alternately hiding/showing them, one can
use the applyTo(Image) method of two
AbstractImagePrototype objects to transform a single
Image object between two (or more) visual representations. The
use of AbstractImagePrototypes results in an cleaner and more
efficient implementation.
This class also provide methods for working with raw elements, using
createElement() and applyTo(ImagePrototypeElement).
This class is also a useful way to encapsulate complex HTML that represents
an image without actually instantiating Image objects. When
constructing large HTML fragments, especially those that contain many images,
getHTML() can be much more efficient.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis corresponds to the top Element of the DOM structure created bycreateElement(). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidapplyTo(AbstractImagePrototype.ImagePrototypeElement imageElement) Transforms an existingAbstractImagePrototype.ImagePrototypeElementinto the image represented by this prototype.abstract voidTransforms an existingImageinto the image represented by this prototype.static AbstractImagePrototypecreate(ImageResource resource) Create an AbstractImagePrototype backed by a ClientBundle ImageResource.Creates a newElementbased on the image represented by this prototype.abstract ImageCreates a newImageinstance based on the image represented by this prototype.getHTML()Gets an HTML fragment that displays the image represented by this prototype.Gets an HTML fragment that displays the image represented by this prototype.
-
Constructor Details
-
AbstractImagePrototype
public AbstractImagePrototype()
-
-
Method Details
-
create
Create an AbstractImagePrototype backed by a ClientBundle ImageResource. This method provides an API compatibility mapping for the new ImageResource API.- Parameters:
resource- an ImageResource produced by a ClientBundle- Returns:
- an AbstractImagePrototype that displays the contents of the ImageResource
-
applyTo
Transforms an existingImageinto the image represented by this prototype.- Parameters:
image- the instance to be transformed to match this prototype
-
applyTo
Transforms an existingAbstractImagePrototype.ImagePrototypeElementinto the image represented by this prototype.- Parameters:
imageElement- anImagePrototypeElementcreated bycreateElement()
-
createElement
Creates a newElementbased on the image represented by this prototype. The DOM structure may not necessarily a simple<img>element. It may be a more complex structure that should be treated opaquely.- Returns:
- the
ImagePrototypeElementcorresponding to the image represented by this prototype
-
createImage
Creates a newImageinstance based on the image represented by this prototype.- Returns:
- a new
Imagebased on this prototype
-
getHTML
Gets an HTML fragment that displays the image represented by this prototype. The HTML returned is not necessarily a simple<img>element. It may be a more complex structure that should be treated opaquely.The default implementation calls
getSafeHtml().- Returns:
- the HTML representation of this prototype
-
getSafeHtml
Gets an HTML fragment that displays the image represented by this prototype. The HTML returned is not necessarily a simple<img>element. It may be a more complex structure that should be treated opaquely.The default implementation throws an
UnsupportedOperationException.- Returns:
- the HTML representation of this prototype
-