Package org.zkoss.zul

Class Image

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, org.zkoss.zk.ui.Component, org.zkoss.zk.ui.ext.Scope, org.zkoss.zk.ui.sys.ComponentCtrl
    Direct Known Subclasses:
    Captcha, Imagemap

    public class Image
    extends XulElement
    An image.

    [Since 6.0.0]

    To turn on the preload image function for this component, you have to specify the component's attribute map with key "org.zkoss.zul.image.preload" to true. That is, for example, if in a zul file, you shall specify <custom-attributes> of the component like this:

     <image ...>
         <custom-attributes org.zkoss.zul.image.preload='true'/>
     </image>
     
    Or specify it onto the root component. For example,
     <window ...>
         <custom-attributes org.zkoss.zul.image.preload="true"/>
         <image .../>
     </window>
     
    [Since 6.5.2]

    Preload image function is also configurable from zk.xml by setting library properties. For example,

     <library-property/>
         <name>org.zkoss.zul.image.preload</name/>
         <value>true</value/>
     </library-property/>
     

    See also how to fix the alpha transparency problem of PNG files found in IE6?

    Author:
    tomyeh
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      protected class  Image.ExtraCtrl
      A utility class to implement HtmlBasedComponent.getExtraCtrl().
      • Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent

        org.zkoss.zk.ui.AbstractComponent.Children, org.zkoss.zk.ui.AbstractComponent.ForwardInfo, org.zkoss.zk.ui.AbstractComponent.TargetInfo
    • Field Summary

      • Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent

        _zclass
      • Fields inherited from interface org.zkoss.zk.ui.Component

        APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
      • Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl

        AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
    • Constructor Summary

      Constructors 
      Constructor Description
      Image()  
      Image​(java.lang.String src)  
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      java.lang.String getAlign()
      Deprecated.
      as of release 6.0.0, use CSS instead.
      java.lang.String getBorder()
      Deprecated.
      As of release 5.0.5, use CSS instead.
      org.zkoss.image.Image getContent()
      Returns the content set by setContent(org.zkoss.image.Image).
      java.lang.Object getExtraCtrl()  
      java.lang.String getHover()
      Returns the URI of the hover image.
      java.lang.String getHspace()
      Deprecated.
      as of release 6.0.0, use CSS instead.
      java.lang.String getSrc()
      Returns the source URI of the image.
      java.lang.String getVspace()
      Deprecated.
      as of release 6.0.0, use CSS instead.
      protected boolean isChildable()
      Default: not childable.
      protected void renderProperties​(org.zkoss.zk.ui.sys.ContentRenderer renderer)  
      void setAlign​(java.lang.String align)
      Deprecated.
      as of release 6.0.0, use CSS instead.
      void setBorder​(java.lang.String border)
      Deprecated.
      As of release 5.0.5, use CSS instead.
      void setContent​(java.awt.image.RenderedImage image)
      Sets the content directly with the rendered image.
      void setContent​(org.zkoss.image.Image image)
      Sets the content directly.
      void setHover​(java.lang.String src)
      Sets the image URI.
      void setHoverContent​(java.awt.image.RenderedImage image)
      Sets the content of the hover image directly with the rendered image.
      void setHoverContent​(org.zkoss.image.Image image)
      Sets the content of the hover image directly.
      void setHspace​(java.lang.String hspace)
      Deprecated.
      as of release 6.0.0, use CSS instead.
      void setSrc​(java.lang.String src)
      Sets the source URI of the image.
      void setVspace​(java.lang.String vspace)
      Deprecated.
      as of release 6.0.0, use CSS instead.
      • Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent

        addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, removeSclass, removeSclass, service, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
      • Methods inherited from class org.zkoss.zk.ui.AbstractComponent

        addAnnotation, addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, invalidate, invalidatePartial, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl

        invalidatePartial
    • Constructor Detail

      • Image

        public Image()
      • Image

        public Image​(java.lang.String src)
    • Method Detail

      • getAlign

        public java.lang.String getAlign()
        Deprecated.
        as of release 6.0.0, use CSS instead.
        Returns the alignment.

        Default: null (use browser default).

      • setAlign

        public void setAlign​(java.lang.String align)
        Deprecated.
        as of release 6.0.0, use CSS instead.
        Sets the alignment: one of top, texttop, middle, absmiddle, bottom, absbottom, baseline, left, right and center.
      • getBorder

        public java.lang.String getBorder()
        Deprecated.
        As of release 5.0.5, use CSS instead.
      • setBorder

        public void setBorder​(java.lang.String border)
        Deprecated.
        As of release 5.0.5, use CSS instead.
      • getHspace

        public java.lang.String getHspace()
        Deprecated.
        as of release 6.0.0, use CSS instead.
        Returns number of pixels of extra space to the left and right side of the image.

        Default: null (use browser default).

      • setHspace

        public void setHspace​(java.lang.String hspace)
        Deprecated.
        as of release 6.0.0, use CSS instead.
        Sets number of pixels of extra space to the left and right side of the image.
      • getVspace

        public java.lang.String getVspace()
        Deprecated.
        as of release 6.0.0, use CSS instead.
        Returns number of pixels of extra space to the top and bottom side of the image.

        Default: null (use browser default).

      • setVspace

        public void setVspace​(java.lang.String vspace)
        Deprecated.
        as of release 6.0.0, use CSS instead.
        Sets number of pixels of extra space to the top and bottom side of the image.
      • getSrc

        public java.lang.String getSrc()
        Returns the source URI of the image.

        Default: null.

      • setContent

        public void setContent​(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 setContent(org.zkoss.image.Image).

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

        Since:
        3.0.7
      • getHover

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

        Default: null.

        Since:
        3.5.0
      • setHoverContent

        public void setHoverContent​(org.zkoss.image.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 setHover(null). In other words, the last invocation of setHoverContent(org.zkoss.image.Image) overrides the previous setHover(java.lang.String), if any.

        Parameters:
        image - the image to display.
        Since:
        3.5.0
        See Also:
        setHover(java.lang.String)
      • setHoverContent

        public void setHoverContent​(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 setHoverContent(org.zkoss.image.Image).

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

        Since:
        3.5.0
      • renderProperties

        protected void renderProperties​(org.zkoss.zk.ui.sys.ContentRenderer renderer)
                                 throws java.io.IOException
        Overrides:
        renderProperties in class XulElement
        Throws:
        java.io.IOException
      • isChildable

        protected boolean isChildable()
        Default: not childable.
        Overrides:
        isChildable in class org.zkoss.zk.ui.AbstractComponent
      • getExtraCtrl

        public java.lang.Object getExtraCtrl()
        Specified by:
        getExtraCtrl in interface org.zkoss.zk.ui.sys.ComponentCtrl
        Overrides:
        getExtraCtrl in class org.zkoss.zk.ui.HtmlBasedComponent