当前位置: 首页>>代码示例>>Java>>正文


Java ImageElement.getSrc方法代码示例

本文整理汇总了Java中com.google.gwt.dom.client.ImageElement.getSrc方法的典型用法代码示例。如果您正苦于以下问题:Java ImageElement.getSrc方法的具体用法?Java ImageElement.getSrc怎么用?Java ImageElement.getSrc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.dom.client.ImageElement的用法示例。


在下文中一共展示了ImageElement.getSrc方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makeSrcSetAbsolute

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
private static void makeSrcSetAbsolute(Element ie) {
    String srcset = ie.getAttribute("srcset");
    if (srcset.isEmpty()) {
        ie.removeAttribute("srcset");
        return;
    }

    ImageElement holder = Document.get().createImageElement();
    String[] sizes = StringUtil.jsSplit(srcset, ",");
    for(int i = 0; i < sizes.length; i++) {
        String size = StringUtil.jsTrim(sizes[i]);
        if (size.isEmpty()) continue;
        String[] comp = size.split(" ");
        holder.setSrc(comp[0]);
        comp[0] = holder.getSrc();
        sizes[i] = StringUtil.join(comp, " ");
    }
    ie.setAttribute("srcset", StringUtil.join(sizes, ", "));
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:20,代码来源:DomUtil.java

示例2: findImages

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
private void findImages() {
    mImages = new ArrayList<MarkupParser.Image>();

    NodeList<Element> allImages = mRoot.getElementsByTagName("IMG");
    for (int i = 0; i < allImages.getLength(); i++) {
        ImageElement imgElem = ImageElement.as(allImages.getItem(i));

        // As long as the image has a caption, it's relevant regardless of size;
        // otherwise, it's relevant if its size is good.
        String caption = getCaption(imgElem);
        if ((caption != null && !caption.isEmpty()) || isImageRelevantBySize(imgElem)) {
            // Add relevant image to list.
            MarkupParser.Image image = new MarkupParser.Image();
            image.url = imgElem.getSrc();
            image.caption = caption;
            image.width = imgElem.getWidth();
            image.height = imgElem.getHeight();
            mImages.add(image);
        }
    }
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:22,代码来源:IEReadingViewParser.java

示例3: extractImageAttributes

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
private void extractImageAttributes(ImageElement imageElement) {
    // This will get the absolute URL of the image and
    // the displayed image dimension.
    // Try to get lazily-loaded images before falling back to get the src attribute.
    for (String attr : LAZY_IMAGE_ATTRIBUTES) {
        imgSrc = imageElement.getAttribute(attr);
        if (!imgSrc.isEmpty())
            break;
    }
    if (!imgSrc.isEmpty()) {
        // We cannot trust the dimension if the image is not loaded yet.
        // In some cases there are 1x1 placeholder images.
        width = 0;
        height = 0;
    } else {
        imgSrc = imageElement.getSrc();
        // As an ImageElement is manipulated here, it is possible
        // to get the real dimensions.
        width = imageElement.getWidth();
        height = imageElement.getHeight();
    }
    if (LogUtil.isLoggable(LogUtil.DEBUG_LEVEL_VISIBILITY_INFO)) {
        LogUtil.logToConsole("Extracted WebImage: " + imgSrc);
    }
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:26,代码来源:ImageExtractor.java

示例4: updateBgImage

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
private void updateBgImage(ImageElement bgImage){
	canvas.removeStyleName("newbg");
	if(injectedBgCss!=null){
		injectedBgCss.removeFromParent();
	}
	
	if(bgImage!=null){
		int w=(int) (bgImage.getWidth()*currentScale);
		int h=(int) (bgImage.getHeight()*currentScale);
		String css=".newbg{"+"background-image: url(\""+bgImage.getSrc()+"\");background-size:"+w+"px "+h+"px;"+"}";
		injectedBgCss = StyleInjector.injectStylesheet(css);
		
		canvas.addStyleName("newbg");
		
		updateCanvas(false);
	}
}
 
开发者ID:akjava,项目名称:gwthtml5apps,代码行数:18,代码来源:TransparentIt.java

示例5: uploadImage

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
private void uploadImage(final ImageElement element){
	loadedPanel.clear();
	
	loadedImage=new Image(element.getSrc());
	loadedPanel.add(loadedImage);
	
	ImageElementUtils.copytoCanvas(element, sharedCanvas);
	//loadedPanel.add(sharedCanvas);
	
	//add alpha?
	updateBt.setEnabled(true);
	updateMaskBt.setEnabled(true);
	this.selectedElement=element;
	mainTab.selectTab(0);
	
	//can't drop convert anymore somewhere need wait loading.
	//mainTab.selectTab(3);
	//temporaly doing.,how to drop convert?
	//doInPaint(element,maskImageElement);
	
}
 
开发者ID:akjava,项目名称:gwthtml5apps,代码行数:22,代码来源:Inpaint.java

示例6: cloneAndProcessNode

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
private void cloneAndProcessNode() {
    Element cloned = Element.as(imgElement.cloneNode(true));
    ImageElement ie = ImageElement.as(
            DomUtil.getFirstElementByTagNameInc(cloned, "IMG"));
    if (!srcUrl.isEmpty()) {
        ie.setSrc(srcUrl);
        srcUrl = ie.getSrc();
    }
    // If computed width or height is zero, do not override them
    // to keep them visible.
    if (width > 0 && height > 0) {
        ie.setWidth(width);
        ie.setHeight(height);
    }
    DomUtil.stripImageElement(ie);

    NodeList<Element> srcs = cloned.getElementsByTagName("SOURCE");
    for (int i = 0; i < srcs.getLength(); i++) {
        Element src = srcs.getItem(i);
        for (String attr : LAZY_SRCSET_ATTRIBUTES) {
            String srcset = src.getAttribute(attr);
            if (!srcset.isEmpty()) {
                src.setAttribute("srcset", srcset);
                break;
            }
        }
    }

    DomUtil.makeAllSrcAttributesAbsolute(cloned);
    DomUtil.makeAllSrcSetAbsolute(cloned);

    clonedImg = cloned;
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:34,代码来源:WebImage.java

示例7: testGetSrcList

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testGetSrcList() {
    mHead.setInnerHTML("<base href=\"http://example.com/\">");

    ImageElement img = Document.get().createImageElement();
    img.setSrc("image");
    img.setAttribute("srcset",
            "image200 200w, image400 400w");
    WebImage wi = new WebImage(img, 1, 1, img.getSrc());
    List<String> urls = wi.getUrlList();
    assertEquals(3, urls.size());
    assertEquals("http://example.com/image", urls.get(0));
    assertEquals("http://example.com/image200", urls.get(1));
    assertEquals("http://example.com/image400", urls.get(2));
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:15,代码来源:WebImageTest.java


注:本文中的com.google.gwt.dom.client.ImageElement.getSrc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。