public Object coerceToUi(Object beanProp, org.zkoss.zul.Image imgComp, BindContext ctx) { if (beanProp == null) { return null; } else if (beanProp instanceof org.zkoss.image.Image) { return beanProp; } else if (beanProp instanceof RenderedImage) { RenderedImage awtImg = (RenderedImage) beanProp; try { return Images.encode("a.png", awtImg); } catch (java.io.IOException ex) { throw UiException.Aide.wrap(ex); } } return beanProp; }
/** Sets the content directly with the rendered image. * It actually encodes the rendered image to an PNG image * ({@link org.zkoss.image.Image}) with {@link Images#encode}, * and then invoke {@link #setImageContent(org.zkoss.image.Image)}. * * <p>If you want more control such as different format, quality, * and naming, you can use {@link Images} directly. * * @since 3.0.7 */ public void setImageContent(RenderedImage image) { try { setImageContent(Images.encode("a.png", image)); } catch (java.io.IOException ex) { throw new UiException(ex); } }
/** Sets the content directly with the rendered image. * It actually encodes the rendered image to an PNG image * ({@link org.zkoss.image.Image}) with {@link Images#encode}, * and then invoke {@link #setContent(org.zkoss.image.Image)}. * * <p>If you want more control such as different format, quality, * and naming, you can use {@link Images} directly. * * @since 3.0.7 */ public void setContent(RenderedImage image) { try { setContent(image == null ? (org.zkoss.image.Image) null : Images.encode("a.png", image)); } catch (java.io.IOException ex) { throw new UiException(ex); } }
/** 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. * * <p>It actually encodes the rendered image to an PNG image * ({@link org.zkoss.image.Image}) with {@link Images#encode}, * and then invoke {@link #setHoverContent(org.zkoss.image.Image)}. * * <p>If you want more control such as different format, quality, * and naming, you can use {@link Images} directly. * @since 3.5.0 */ public void setHoverContent(RenderedImage image) { try { setHoverContent(Images.encode("hover.png", image)); } catch (java.io.IOException ex) { throw new UiException(ex); } }
/** 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. * * <p>It actually encodes the rendered image to an PNG image * ({@link org.zkoss.image.Image}) with {@link Images#encode}, * and then invoke {@link #setHoverImageContent(org.zkoss.image.Image)}. * * <p>If you want more control such as different format, quality, * and naming, you can use {@link Images} directly. * @since 3.5.0 */ public void setHoverImageContent(RenderedImage image) { try { setHoverImageContent(Images.encode("hover.png", image)); } catch (java.io.IOException ex) { throw new UiException(ex); } }