1 16 package com.google.gwt.user.client.ui.impl; 17 18 import com.google.gwt.user.client.DOM; 19 import com.google.gwt.user.client.Element; 20 21 28 public class ClippedImageImpl { 29 30 public void adjust(Element img, String url, int left, int top, int width, 31 int height) { 32 String style = "url(" + url + ") no-repeat " + (-left + "px ") 33 + (-top + "px"); 34 DOM.setStyleAttribute(img, "background", style); 35 DOM.setStyleAttribute(img, "width", width + "px"); 36 DOM.setStyleAttribute(img, "height", height + "px"); 37 } 38 39 public Element createStructure(String url, int left, int top, int width, 40 int height) { 41 Element tmp = DOM.createSpan(); 42 DOM.setInnerHTML(tmp, getHTML(url, left, top, width, height)); 43 return DOM.getFirstChild(tmp); 44 } 45 46 public String getHTML(String url, int left, int top, int width, int height) { 47 String style = "width: " + width + "px; height: " + height 48 + "px; background: url(" + url + ") no-repeat " + (-left + "px ") 49 + (-top + "px"); 50 51 String clippedImgHtml = "<img SRC='clear.cache.gif' style='" 52 + style + "' border='0'>"; 53 54 return clippedImgHtml; 55 } 56 } 57 | Popular Tags |