org.zkoss.zul.impl
Class LabelImageElement

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlBasedComponent
          extended by org.zkoss.zul.impl.XulElement
              extended by org.zkoss.zul.impl.LabelElement
                  extended by org.zkoss.zul.impl.LabelImageElement
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HtmlBasedComponent, Component, Scope, ComponentCtrl, LabelElement, LabelImageElement, XulElement
Direct Known Subclasses:
Button, Caption, Checkbox, Comboitem, Footer, HeaderElement, Listcell, Listfooter, Menu, Menuitem, Tab, Toolbarbutton, Treecell, Treefooter

public class LabelImageElement
extends LabelElement
implements LabelImageElement

A XUL element with a label (LabelElement.getLabel()) and an image (getImage()).

Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
protected  class LabelImageElement.ExtraCtrl
          A utility class to implement AbstractComponent.getExtraCtrl().
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children
 
Field Summary
 
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclass, RS_NO_DISPLAY, RS_NO_HEIGHT, RS_NO_WIDTH
 
Fields inherited from class org.zkoss.zk.ui.AbstractComponent
_visible
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Constructor Summary
LabelImageElement()
           
 
Method Summary
 java.lang.String getEncodedImageURL()
          Returns the encoded URL for the image (getImage() or getImageContent()), or null if no image.
 java.lang.String getHoverImage()
          Returns the URI of the hover image.
 java.lang.String getImage()
          Returns the image URI.
 Image getImageContent()
          Returns the image content set by setImageContent(Image) or setImageContent(RenderedImage).
 java.lang.String getImgTag()
          Returns the HTML IMG tag for the image part, or null if no image is assigned (isImageAssigned()) Used only for component development, not for application developers.
protected  java.lang.String getImgTag(java.lang.String sclass, boolean enforce)
          Utilities to implement getImgTag().
 java.lang.String getOuterAttrs()
          Returns the exterior attributes for generating the enclosing HTML tag; never return null.
 java.lang.String getSrc()
          Deprecated. As of release 3.5.0, it is redudant since it is the same as getImage()
 boolean isImageAssigned()
          Returns whether the image is available.
protected  java.lang.Object newExtraCtrl()
          Used by AbstractComponent.getExtraCtrl() to create a client control.
 void setHoverImage(java.lang.String src)
          Sets the image URI.
 void setHoverImageContent(Image image)
          Sets the content of the hover image directly.
 void setHoverImageContent(java.awt.image.RenderedImage image)
          Sets the content of the hover image directly with the rendered image.
 void setImage(java.lang.String src)
          Sets the image URI.
 void setImageContent(Image image)
          Sets the content directly.
 void setImageContent(java.awt.image.RenderedImage image)
          Sets the content directly with the rendered image.
 void setSrc(java.lang.String src)
          Deprecated. As of release 3.5.0, it is redudant since it is the same as setImage(java.lang.String)
 
Methods inherited from class org.zkoss.zul.impl.LabelElement
getLabel, setLabel
 
Methods inherited from class org.zkoss.zul.impl.XulElement
getAction, getActionAttrs, getAllOnClickAttrs, getContext, getCtrlKeys, getInnerAttrs, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip
 
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
focus, getAllOnClickAttrs, getDraggable, getDroppable, getHeight, getLeft, getMoldSclass, getRealSclass, getRealStyle, getRealStyleFlags, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZclass, getZindex, getZIndex, redraw, setClass, setDraggable, setDroppable, setFocus, setHeight, setLeft, setMoldSclass, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZclass, setZindex, setZIndex
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addEventHandler, addEventListener, addForward, addForward, addForward, addForward, addMoved, addSharedAnnotationMap, addSharedEventHandlerMap, appendAsapAttr, appendAsapAttr, appendChild, applyProperties, clone, containsVariable, detach, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttributes, getAttributes, getChildren, getCommand, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getExtraCtrl, getFellow, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getMoldURI, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, hasFellow, insertBefore, invalidate, isAsapRequired, isChildable, isInvalidated, isListenerAvailable, isVisible, newChildren, onChildAdded, onChildRemoved, onDrawNewChild, onPageAttached, onPageDetached, onWrongValue, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setComponentDefinition, setId, setMold, setPage, setPageBefore, setParent, setVariable, setVisible, smartUpdate, smartUpdate, smartUpdate, smartUpdateDeferred, smartUpdateValues, toString, unsetVariable
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zkoss.zul.impl.api.LabelElement
getLabel, setLabel
 
Methods inherited from interface org.zkoss.zul.impl.api.XulElement
getAction, getContext, getCtrlKeys, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip
 
Methods inherited from interface org.zkoss.zk.ui.api.HtmlBasedComponent
focus, getHeight, getLeft, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZclass, getZindex, getZIndex, setDraggable, setDroppable, setFocus, setHeight, setLeft, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZclass, setZindex, setZIndex
 
Methods inherited from interface org.zkoss.zk.ui.Component
addEventListener, addForward, addForward, addForward, addForward, appendChild, applyProperties, clone, containsVariable, detach, getAttribute, getAttribute, getAttributes, getAttributes, getChildren, getDefinition, getDesktop, getFellow, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, insertBefore, invalidate, isChildable, isInvalidated, isListenerAvailable, isVisible, redraw, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, setAttribute, setAttribute, setId, setMold, setPage, setPageBefore, setParent, setVariable, setVisible, unsetVariable
 

Constructor Detail

LabelImageElement

public LabelImageElement()
Method Detail

getImage

public java.lang.String getImage()
Returns the image URI.

Default: null.

Specified by:
getImage in interface LabelImageElement

setImage

public void setImage(java.lang.String src)
Sets the image URI.

Calling this method implies setImageContent(null). In other words, the last invocation of setImage(java.lang.String) overrides the previous setImageContent(org.zkoss.image.Image), if any.

If src is changed, the component's inner is invalidate. Thus, you want to smart-update, you have to override this method.

Specified by:
setImage in interface LabelImageElement
See Also:
setImageContent(Image), setImageContent(RenderedImage)

getSrc

public java.lang.String getSrc()
Deprecated. As of release 3.5.0, it is redudant since it is the same as getImage()


setSrc

public void setSrc(java.lang.String src)
Deprecated. As of release 3.5.0, it is redudant since it is the same as setImage(java.lang.String)


setImageContent

public void setImageContent(Image image)
Sets the content directly.

Default: null.

Calling this method implies setImage(null). In other words, the last invocation of setImageContent(org.zkoss.image.Image) overrides the previous setImage(java.lang.String), if any.

Specified by:
setImageContent in interface LabelImageElement
Parameters:
image - the image to display.
See Also:
setImage(java.lang.String)

setImageContent

public void setImageContent(java.awt.image.RenderedImage image)
Sets the content directly with the rendered image. It actually encodes the rendered image to an PNG image (Image) with Images.encode(java.lang.String, java.awt.image.RenderedImage, float, boolean), and then invoke setImageContent(org.zkoss.image.Image).

If you want more control such as different format, quality, and naming, you can use Images directly.

Specified by:
setImageContent in interface LabelImageElement
Since:
3.0.7

getImageContent

public Image getImageContent()
Returns the image content set by setImageContent(Image) or setImageContent(RenderedImage).

Note: it won't load the content specified by setImage(java.lang.String). Actually, it returns null if setImage(java.lang.String) was called.

Specified by:
getImageContent in interface LabelImageElement

getHoverImage

public java.lang.String getHoverImage()
Returns the URI of the hover image. The hover image is used when the mouse is moving over this component.

Default: null.

Specified by:
getHoverImage in interface LabelImageElement
Since:
3.5.0

setHoverImage

public void setHoverImage(java.lang.String src)
Sets the image URI. The hover image is used when the mouse is moving over this component.

Calling this method implies setHoverImageContent(null). In other words, the last invocation of setHoverImage(java.lang.String) overrides the previous setHoverImageContent(org.zkoss.image.Image), if any.

Specified by:
setHoverImage in interface LabelImageElement
Since:
3.5.0

setHoverImageContent

public void setHoverImageContent(Image image)
Sets the content of the hover image directly. The hover image is used when the mouse is moving over this component.

Default: null.

Calling this method implies setHoverImage(null). In other words, the last invocation of setHoverImageContent(org.zkoss.image.Image) overrides the previous setHoverImage(java.lang.String), if any.

Specified by:
setHoverImageContent in interface LabelImageElement
Parameters:
image - the image to display.
Since:
3.5.0

setHoverImageContent

public void setHoverImageContent(java.awt.image.RenderedImage image)
Sets the content of the hover image directly with the rendered image. The hover image is used when the mouse is moving over this component.

It actually encodes the rendered image to an PNG image (Image) with Images.encode(java.lang.String, java.awt.image.RenderedImage, float, boolean), and then invoke setHoverImageContent(org.zkoss.image.Image).

If you want more control such as different format, quality, and naming, you can use Images directly.

Specified by:
setHoverImageContent in interface LabelImageElement
Since:
3.5.0

isImageAssigned

public boolean isImageAssigned()
Returns whether the image is available. In other words, it return true if setImage(java.lang.String) or setImageContent(org.zkoss.image.Image) is called with non-null.


getImgTag

public java.lang.String getImgTag()
Returns the HTML IMG tag for the image part, or null if no image is assigned (isImageAssigned())

Used only for component development, not for application developers.

Note: the component template shall use this method to generate the HTML tag, instead of using getImage().


getImgTag

protected java.lang.String getImgTag(java.lang.String sclass,
                                     boolean enforce)
Utilities to implement getImgTag(). By default, getImgTag() is the same as getImageTag(null, false).

Used only for component developements; not by app developers.

Parameters:
sclass - the style class of the generated image.
enforce - whether to generate an empty pixel if no image is assigned. By default, null is returned. However, if you prefer to generate an image tag with an empty pixel, you can specify true here.
Since:
3.5.0

getEncodedImageURL

public java.lang.String getEncodedImageURL()
Returns the encoded URL for the image (getImage() or getImageContent()), or null if no image.

Used only for component developements; not by app developers.

Note: this method can be invoked only if execution is not null.

Since:
3.5.0

getOuterAttrs

public java.lang.String getOuterAttrs()
Description copied from class: HtmlBasedComponent
Returns the exterior attributes for generating the enclosing HTML tag; never return null.

Used only by component developers.

Default: Generates the tooltip text, style, sclass, draggable and droppable attribute if necessary. In other words, the corresponding attribute is generated if HtmlBasedComponent.getTooltiptext(), HtmlBasedComponent.getRealStyle(), HtmlBasedComponent.getSclass(), HtmlBasedComponent.getDraggable(), HtmlBasedComponent.getDroppable() are defined.

You have to call both HtmlBasedComponent.getOuterAttrs() and HtmlBasedComponent.getInnerAttrs() to generate complete attributes.

For simple components that all attributes are put on the outest HTML element, all you need is as follows.

<xx id="${self.uuid}"${self.outerAttrs}${self.innerAttrs}>

If you want to put attributes in a nested HTML element, you shall use the following pattern. Notice: if HtmlBasedComponent.getInnerAttrs() in a different tag, the tag must be named with "${self.uuid}!real".

<xx id="${self.uuid}"${self.outerAttrs}>
 <yy id="${self.uuid}!real"${self.innerAttrs}>...

Note: This class handles non-deferrable event listeners automatically. However, you have to invoke AbstractComponent.appendAsapAttr(java.lang.StringBuffer, java.lang.String) for each event the component handles in HtmlBasedComponent.getOuterAttrs() as follows.


        appendAsapAttr(sb, Events.ON_OPEN);
  appendAsapAttr(sb, Events.ON_CHANGE);

Theorectically, you could put any attributes in either HtmlBasedComponent.getInnerAttrs() or HtmlBasedComponent.getOuterAttrs(). However, zkau.js assumes all attributes are put at the outer one. If you want something different, you have to provide your own setAttr (refer to how checkbox is implemented).

Overrides:
getOuterAttrs in class XulElement

newExtraCtrl

protected java.lang.Object newExtraCtrl()
Description copied from class: HtmlBasedComponent
Used by AbstractComponent.getExtraCtrl() to create a client control. It is used only by component developers.

Defaut: creates an instance of HtmlBasedComponent.ExtraCtrl.

Overrides:
newExtraCtrl in class HtmlBasedComponent


Copyright © 2005-2009 Potix Corporation. All Rights Reserved.