|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.wicket.request.resource.AbstractResource org.apache.wicket.request.resource.DynamicImageResource org.apache.wicket.markup.html.image.resource.RenderedDynamicImageResource
public abstract class RenderedDynamicImageResource
A DynamicImageResource subclass that allows easy rendering of regeneratable (unbuffered) dynamic images. A RenderedDynamicImageResource implements the abstract method render(Graphics2D) to create/re-create a given image on-the-fly. When a RenderedDynamicImageResource is serialized, the image state is transient, which means it will disappear when the resource is sent over the wire and then will be recreated when required.
The format of the image (and therefore the resource's extension) can be specified with setFormat(String). The default format is "PNG" because JPEG is lossy and makes generated images look bad and GIF has patent issues.
DefaultButtonImageResource
,
DefaultButtonImageResourceFactory
,
Serialized FormNested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.wicket.request.resource.AbstractResource |
---|
AbstractResource.ResourceResponse, AbstractResource.WriteCallback |
Nested classes/interfaces inherited from interface org.apache.wicket.request.resource.IResource |
---|
IResource.Attributes |
Field Summary |
---|
Fields inherited from class org.apache.wicket.request.resource.AbstractResource |
---|
INTERNAL_HEADERS |
Constructor Summary | |
---|---|
RenderedDynamicImageResource(int width,
int height)
Constructor. |
|
RenderedDynamicImageResource(int width,
int height,
String format)
Constructor. |
Method Summary | |
---|---|
int |
getHeight()
|
protected byte[] |
getImageData(IResource.Attributes attributes)
Get image data for our dynamic image resource. |
int |
getType()
|
int |
getWidth()
|
void |
invalidate()
Causes the image to be redrawn the next time its requested. |
protected abstract boolean |
render(Graphics2D graphics,
IResource.Attributes attributes)
Override this method to provide your rendering code. |
protected byte[] |
render(IResource.Attributes attributes)
Renders this image |
void |
setHeight(int height)
|
void |
setType(int type)
|
void |
setWidth(int width)
|
Methods inherited from class org.apache.wicket.request.resource.DynamicImageResource |
---|
configureResponse, getFormat, newResourceResponse, setFormat, setLastModifiedTime, toImageData |
Methods inherited from class org.apache.wicket.request.resource.AbstractResource |
---|
configureCache, flushResponseAfterHeaders, getCachingStrategy, respond, setResponseHeaders |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RenderedDynamicImageResource(int width, int height)
width
- Width of imageheight
- Height of imagepublic RenderedDynamicImageResource(int width, int height, String format)
width
- Width of imageheight
- Height of imageformat
- The format of the image (jpg, png or gif)Method Detail |
---|
public int getHeight()
public int getType()
public int getWidth()
public void invalidate()
public void setHeight(int height)
height
- The height to set.public void setType(int type)
type
- The type to set (one of BufferedImage.TYPE_*).public void setWidth(int width)
width
- The width to set.protected byte[] getImageData(IResource.Attributes attributes)
DynamicImageResource
DynamicImageResource.setLastModifiedTime(Time)
when it does so. This
ensures that image caching works correctly.
getImageData
in class DynamicImageResource
attributes
- the context bringing the request, response and the parameters
null
means there is no image and 404
(Not found) response will be return.protected byte[] render(IResource.Attributes attributes)
attributes
- the current request attributes
protected abstract boolean render(Graphics2D graphics, IResource.Attributes attributes)
graphics
- The graphics context to render on.attributes
- the current request attributes
true
if the image was rendered. false
if the image size was changed
by the rendering implementation and the image should be re-rendered at the new size.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |