|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.apache.wicket.Component
org.apache.wicket.markup.html.WebComponent
org.apache.wicket.markup.html.image.Image
net.databinder.components.RenderedLabel
public class RenderedLabel
Renders its model text into a PNG, using any typeface available to the JVM. The size of the image is determined by the model text and the characteristics of font selected. The default font is 14pt sans, plain black on a white background. The background may be set to null for alpha transparency, which will appear gray in outdated browsers. The image's alt attribute will be set to the model text, and width and height attributes will be set appropriately.
If told to use a shared image resource, RenderedLabel will add its image to the application's shared resources and reference it from a permanent, unique, browser-chacheable URL. Note that if users might request a shared resource before a page containing it has rendered (after a context reload, for example) you should load that resource using loadSharedResources() as the application is starting up.
This class is inspired by, and draws code from, Wicket's DefaultButtonImageResource.
SharedResources,
Serialized Form| Nested Class Summary | |
|---|---|
static class |
RenderedLabel.RenderedTextImageResource
Inner class that renders the model text into an image resource. |
| Nested classes/interfaces inherited from class org.apache.wicket.Component |
|---|
org.apache.wicket.Component.ComponentModelChange, org.apache.wicket.Component.EnabledChange, org.apache.wicket.Component.IVisitor, org.apache.wicket.Component.VisibilityChange |
| Field Summary |
|---|
| Fields inherited from class org.apache.wicket.Component |
|---|
ENABLE, FLAG_RESERVED1, FLAG_RESERVED2, FLAG_RESERVED3, FLAG_RESERVED4, FLAG_RESERVED5, FLAG_RESERVED6, FLAG_RESERVED7, FLAG_RESERVED8, PATH_SEPARATOR, RENDER |
| Fields inherited from interface org.apache.wicket.IResourceListener |
|---|
INTERFACE |
| Constructor Summary | |
|---|---|
RenderedLabel(java.lang.String id)
Constructor to be used if model is derived from a compound property model. |
|
RenderedLabel(java.lang.String id,
boolean shareResource)
Constructor for compound property model and shared resource pool. |
|
RenderedLabel(java.lang.String id,
org.apache.wicket.model.IModel model)
Constructor with explicit model. |
|
RenderedLabel(java.lang.String id,
org.apache.wicket.model.IModel model,
boolean shareResource)
Constructor with explicit model. |
|
| Method Summary | |
|---|---|
static java.awt.Font |
fontForResource(org.apache.wicket.Resource fontRes)
Utility method for creating Font objects from resources. |
java.awt.Color |
getBackgroundColor()
|
java.awt.Color |
getColor()
|
java.awt.Font |
getFont()
|
protected int |
getLabelHash()
|
protected static int |
getLabelHash(java.lang.String text,
java.awt.Font font,
java.awt.Color color,
java.awt.Color backgroundColor,
java.lang.Integer maxWidth)
|
java.lang.Integer |
getMaxWidth()
|
protected void |
init()
Perform generic initialization. |
protected org.apache.wicket.model.IModel |
initModel()
Restores compound model resolution that is disabled in the Image superclass. |
boolean |
isAntiAliased()
|
boolean |
isVisible()
|
protected static void |
loadSharedResources(RenderedLabel.RenderedTextImageResource res,
java.lang.String text,
java.awt.Font font,
java.awt.Color color,
java.awt.Color backgroundColor,
java.lang.Integer maxWidth)
Utility method to load a specific instance of a the rendering shared resource. |
static void |
loadSharedResources(java.lang.String text,
java.awt.Font font,
java.awt.Color color,
java.awt.Color backgroundColor,
java.lang.Integer maxWidth)
Load shared resource into pool so it will be available even before a page using the rendered label is first rendered. |
protected RenderedLabel.RenderedTextImageResource |
newRenderedTextImageResource(boolean isShared)
Create a new image resource to render this label. |
protected void |
onBeforeRender()
|
protected void |
onComponentTag(org.apache.wicket.markup.ComponentTag tag)
Adds image-specific attributes including width, height, and alternate text. |
RenderedLabel |
setAntiAlias(boolean antiAlias)
|
RenderedLabel |
setBackgroundColor(java.awt.Color backgroundColor)
Specify a background color to match the page. |
RenderedLabel |
setColor(java.awt.Color color)
|
RenderedLabel |
setFont(java.awt.Font font)
|
RenderedLabel |
setMaxWidth(java.lang.Integer maxWidth)
Specify a maximum pixel width, causing longer renderings to wrap. |
| Methods inherited from class org.apache.wicket.markup.html.image.Image |
|---|
getImageResource, getImageResourceReference, getStatelessHint, onComponentTagBody, onResourceRequested, setImageResource, setImageResourceReference, setImageResourceReference, setModel |
| Methods inherited from class org.apache.wicket.markup.html.WebComponent |
|---|
onRender |
| Methods inherited from class org.apache.wicket.Component |
|---|
add, addStateChange, afterRender, beforeRender, callOnBeforeRenderIfNotVisible, checkComponentTag, checkComponentTagAttribute, checkHierarchyChange, continueToOriginalDestination, debug, detach, detachBehaviors, detachModel, detachModels, determineVisibility, error, exceptionMessage, fatal, findMarkupStream, findPage, findParent, findParentWithAssociatedMarkup, getApplication, getBehaviors, getBehaviors, getClassRelativePath, getComponentBorder, getConverter, getConverter, getEscapeModelStrings, getFeedbackMessage, getFlag, getFlag, getId, getInnermostModel, getInnermostModel, getLocale, getLocalizer, getMarkupAttributes, getMarkupId, getMarkupId, getMetaData, getModel, getModelComparator, getModelObject, getModelObjectAsString, getModelObjectAsString, getOutputMarkupId, getOutputMarkupPlaceholderTag, getPage, getPageFactory, getPageRelativePath, getParent, getPath, getRenderBodyOnly, getRequest, getRequestCycle, getResponse, getSession, getSizeInBytes, getString, getString, getString, getStyle, getVariation, hasBeenRendered, hasErrorMessage, hasFeedbackMessage, info, internalAttach, internalDetach, internalOnAttach, internalOnDetach, internalOnModelChanged, isActionAuthorized, isAncestorOf, isAttached, isBehaviorAccepted, isEnableAllowed, isEnabled, isIgnoreAttributeModifier, isRenderAllowed, isStateless, isVersioned, isVisibilityAllowed, isVisibleInHierarchy, locateMarkupStream, markAttached, markRendering, modelChanged, modelChanging, newPage, newPage, onAfterRender, onAttach, onBeginRequest, onDetach, onEndRequest, onModelChanged, onModelChanging, prepareForRender, redirectToInterceptPage, remove, remove, render, render, renderComponent, renderComponent, renderComponentTag, rendered, renderHead, replaceComponentTagBody, replaceWith, sameInnermostModel, sameInnermostModel, setAuto, setComponentBorder, setEnabled, setEscapeModelStrings, setFlag, setFlag, setIgnoreAttributeModifier, setMarkupId, setMarkupStream, setMetaData, setModelObject, setOutputMarkupId, setOutputMarkupPlaceholderTag, setRedirect, setRenderBodyOnly, setResponsePage, setResponsePage, setResponsePage, setVersioned, setVisibilityAllowed, setVisible, toString, toString, urlFor, urlFor, urlFor, urlFor, urlFor, urlFor, visitParents, warn, wrap |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public RenderedLabel(java.lang.String id)
id - Wicket id
public RenderedLabel(java.lang.String id,
boolean shareResource)
id - Wicket idshareResource - true to add to shared resource pool
public RenderedLabel(java.lang.String id,
org.apache.wicket.model.IModel model)
id - Wicket idmodel - model for
public RenderedLabel(java.lang.String id,
org.apache.wicket.model.IModel model,
boolean shareResource)
id - Wicket idmodel - model forshareResource - true to add to shared resource pool| Method Detail |
|---|
protected void init()
protected void onBeforeRender()
onBeforeRender in class org.apache.wicket.Componentpublic boolean isVisible()
isVisible in class org.apache.wicket.Componentprotected void onComponentTag(org.apache.wicket.markup.ComponentTag tag)
onComponentTag in class org.apache.wicket.markup.html.image.Imageprotected int getLabelHash()
protected static int getLabelHash(java.lang.String text,
java.awt.Font font,
java.awt.Color color,
java.awt.Color backgroundColor,
java.lang.Integer maxWidth)
protected org.apache.wicket.model.IModel initModel()
initModel in class org.apache.wicket.markup.html.image.Image
public static void loadSharedResources(java.lang.String text,
java.awt.Font font,
java.awt.Color color,
java.awt.Color backgroundColor,
java.lang.Integer maxWidth)
text - font - uses default if nullcolor - uses default if nullbackgroundColor - uses default if nullmaxWidth -
protected static void loadSharedResources(RenderedLabel.RenderedTextImageResource res,
java.lang.String text,
java.awt.Font font,
java.awt.Color color,
java.awt.Color backgroundColor,
java.lang.Integer maxWidth)
protected RenderedLabel.RenderedTextImageResource newRenderedTextImageResource(boolean isShared)
isShared - is a shared, cacheable resource
public java.awt.Color getBackgroundColor()
public RenderedLabel setBackgroundColor(java.awt.Color backgroundColor)
backgroundColor - color or null for transparent
public java.awt.Color getColor()
public RenderedLabel setColor(java.awt.Color color)
color - Color to print textpublic java.awt.Font getFont()
public RenderedLabel setFont(java.awt.Font font)
public java.lang.Integer getMaxWidth()
public RenderedLabel setMaxWidth(java.lang.Integer maxWidth)
maxWidth - maximum width in pixels
public static java.awt.Font fontForResource(org.apache.wicket.Resource fontRes)
fontRes - Resource containing a TrueType font descriptor.
public boolean isAntiAliased()
public RenderedLabel setAntiAlias(boolean antiAlias)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||