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); }
@Override public void setUrlAndVisibleRect(Image image, SafeUri url, int left, int top, int width, int height) { /* * In the event that the clipping rectangle has not changed, we want to * skip all of the work required with a getImpl().adjust, and we do not * want to fire a load event. */ if (!this.url.equals(url) || this.left != left || this.top != top || this.width != width || this.height != height) { this.url = url; this.left = left; this.top = top; this.width = width; this.height = height; impl.adjust(image.getElement(), url, left, top, width, height); /* * The native load event hasn't fired yet, so we don't need to * synthesize an event. If we did synthesize an event, we would get two * load events. */ if (!pendingNativeLoadEvent) { fireSyntheticLoadEvent(image); } } }
public String getUrl() { return uri.asString(); } }
public String getURL() { return url.asString(); }
/** * Compares this string to the specified object. */ @Override public boolean equals(Object obj) { if (!(obj instanceof SafeUri)) { return false; } return uri.equals(((SafeUri) obj).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); }
@Override public QuoteBuilder cite(SafeUri cite) { return cite(cite.asString()); }
@Override public FormBuilder action(SafeUri action) { return action(action.asString()); }
@Override public FrameBuilder longDesc(SafeUri longDesc) { return longDesc(longDesc.asString()); }
@Override public IFrameBuilder src(SafeUri src) { return src(src.asString()); }
/** * Creates an anchor with its html and href (target URL) specified. * * @param html the anchor's html * @param directionEstimator A DirectionEstimator object used for automatic * direction adjustment. For convenience, * {@link #DEFAULT_DIRECTION_ESTIMATOR} can be used. * @param href the url to which it will link */ public Anchor(SafeHtml html, DirectionEstimator directionEstimator, SafeUri href) { this(html.asString(), true, directionEstimator, href.asString()); }
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()); }