private void updateImageElementFromImageResource(Element imageSpan, ImageResource res, int spacing) { SafeUri url = res.getSafeUri(); int width = res.getWidth(); int height = res.getHeight(); int paddingRight = width + spacing; String style = "url(\"" + url.asString() + "\") no-repeat scroll left center"; imageSpan.getStyle().setProperty("background", style); imageSpan.getStyle().setPropertyPx("width", width); imageSpan.getStyle().setPropertyPx("height", height); imageSpan.getStyle().setPropertyPx("paddingRight", paddingRight); }
public String getUrl() { return uri.asString(); } }
/** * Causes the browser to pre-fetch the image at a given URL. * * @param url the URL of the image to be prefetched */ public static void prefetch(SafeUri url) { prefetch(url.asString()); }
/** * Gets the URL of the image. The URL that is returned is not necessarily the * URL that was passed in by the user. It may have been transformed to an * absolute URL. * * @return the image URL */ public String getUrl() { return state.getUrl(this).asString(); }
/** * Sets the background-image CSS property. * * @param uri the URI of the background image * @return a {@link SafeStyles} instance * @see #forTrustedBackgroundImage(String) */ public static SafeStyles forBackgroundImage(SafeUri uri) { return fromTrustedNameAndValue("background-image", "url(\"" + uri.asString() + "\")"); }
/** * Creates an anchor with its html and href (target URL) specified. * * @param html the anchor's html * @param href the url to which it will link */ public Anchor(SafeHtml html, SafeUri href) { this(html.asString(), true, href.asString()); }
/** * Creates an anchor with its html and href (target URL) specified. * * @param html the anchor's html * @param dir the html's direction * @param href the url to which it will link */ public Anchor(SafeHtml html, Direction dir, SafeUri href) { this(html.asString(), true, dir, href.asString()); }
@Override public AnchorBuilder href(SafeUri href) { return href(href.asString()); }
/** * Creates a source anchor (link to URI). * * That is, an anchor with an href attribute specifying the destination URI. * * @param html the anchor's html * @param href the url to which it will link * @param target the target frame (e.g. "_blank" to open the link in a new * window) */ public Anchor(SafeHtml html, SafeUri href, String target) { this(html.asString(), true, href.asString(), target); }
int paddingRight = width + 8; String background = "url(\"" + uri.asString() + "\") no-repeat " + (-left + "px ") + (-top + "px");
/** * A URI designating a document that describes the reason for the change. * * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/">W3C HTML Specification</a> */ public final native void setCite(@IsSafeUri String cite) /*-{ this.cite = cite; }-*/;
@Override public void setUrl(Image image, SafeUri url) { image.clearUnhandledEvent(); getImageElement(image).setSrc(url.asString()); }
@Override public StylesBuilder backgroundImage(SafeUri uri) { delegate.assertCanAddStyleProperty().setBackgroundImage(uri.asString()); return this; }
/** * A URI designating a source document or message. * * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/text.html#adef-cite-Q">W3C HTML Specification</a> */ public final native void setCite(@IsSafeUri String cite) /*-{ this.cite = cite; }-*/; }
/** * Server-side form handler. * * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#adef-action">W3C HTML Specification</a> */ public final native void setAction(@IsSafeUri String action) /*-{ this.action = action; }-*/;
/** * URI designating a long description of this image or frame. * * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-longdesc-FRAME">W3C HTML Specification</a> */ public final native void setLongDesc(@IsSafeUri String longDesc) /*-{ this.longDesc = longDesc; }-*/;
@Override @SuppressIsTrustedResourceUriCastCheck public FrameBuilder src(@IsTrustedResourceUri SafeUri src) { return src(src.asString()); }
/** * A URI specifying the location of the object's data. * * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/struct/objects.html#adef-data">W3C HTML Specification</a> */ public final native void setData(@IsTrustedResourceUri String data) /*-{ this.data = data; }-*/;
/** * A URI designating the initial frame contents. * * @see <a href="http://www.w3.org/TR/1999/REC-html401-19991224/present/frames.html#adef-src-FRAME">W3C HTML Specification</a> */ public final native void setSrc(@IsTrustedResourceUri String src) /*-{ this.src = src; }-*/; }
public void adjust(Element img, SafeUri url, int left, int top, int width, int height) { String style = "url(\"" + url.asString() + "\") no-repeat " + (-left + "px ") + (-top + "px"); img.getStyle().setProperty("background", style); img.getStyle().setPropertyPx("width", width); img.getStyle().setPropertyPx("height", height); }