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


Java ImageElement.setAttribute方法代码示例

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


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

示例1: extractLazilyLoadedImage

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
private void extractLazilyLoadedImage(String attr) {
    ImageElement image = TestUtil.createImage();
    image.setAttribute(attr, "image.png");
    mBody.appendChild(image);

    mHead.setInnerHTML("<base href=\"http://example.com/\">");

    EmbedExtractor extractor = new ImageExtractor();
    WebImage result = (WebImage) extractor.extract(image);
    assertNotNull(result);
    assertEquals("<img src=\"http://example.com/image.png\">", result.generateOutput(false));

    List<String> expected = new ArrayList<String>();
    expected.add("http://example.com/image.png");
    assertEquals(expected, result.getUrlList());
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:17,代码来源:EmbedExtractorTest.java

示例2: extractLazilyLoadedFigure

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
private void extractLazilyLoadedFigure(String attr) {
    ImageElement image = TestUtil.createImage();
    image.setAttribute(attr, "image.png");
    Element figure = Document.get().createElement("FIGURE");
    figure.appendChild(image);

    mBody.appendChild(figure);

    mHead.setInnerHTML("<base href=\"http://example.com/\">");

    EmbedExtractor extractor = new ImageExtractor();
    WebFigure result = (WebFigure) extractor.extract(figure);
    assertNotNull(result);
    assertEquals("<figure><img src=\"http://example.com/image.png\"></figure>",
            result.generateOutput(false));

    List<String> expected = new ArrayList<String>();
    expected.add("http://example.com/image.png");
    assertEquals(expected, result.getUrlList());
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:21,代码来源:EmbedExtractorTest.java

示例3: testFigureWithoutCaption

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testFigureWithoutCaption() {
    ImageElement image = TestUtil.createImage();
    image.setSrc("http://wwww.example.com/image.jpeg");
    image.setAttribute("width", "100");
    image.setAttribute("height", "100");
    Element figure = Document.get().createElement("FIGURE");
    figure.appendChild(image);
    mBody.appendChild(figure);

    EmbedExtractor extractor = new ImageExtractor();
    WebImage result = (WebImage) extractor.extract(figure);
    String got = result.generateOutput(false);
    String expected =
        "<figure>" +
            "<img src=\"http://wwww.example.com/image.jpeg\"" +
                " width=\"100\" height=\"100\">" +
        "</figure>";
    assertNotNull(result);
    assertEquals(100, result.getHeight());
    assertEquals(100, result.getWidth());
    assertEquals(expected, got);
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:23,代码来源:EmbedExtractorTest.java

示例4: testFigureWithoutCaptionWithNoscript

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testFigureWithoutCaptionWithNoscript() {
    ImageElement image = TestUtil.createImage();
    image.setSrc("http://wwww.example.com/image.jpeg");
    image.setAttribute("width", "100");
    image.setAttribute("height", "100");
    Element figure = Document.get().createElement("FIGURE");
    figure.appendChild(image);
    Element noscript = Document.get().createElement("NOSCRIPT");
    noscript.setInnerHTML("<span>text</span>");
    figure.appendChild(noscript);
    mBody.appendChild(figure);

    EmbedExtractor extractor = new ImageExtractor();
    WebImage result = (WebImage) extractor.extract(figure);
    String got = result.generateOutput(false);
    String expected =
        "<figure>" +
            "<img src=\"http://wwww.example.com/image.jpeg\"" +
                " width=\"100\" height=\"100\">" +
        "</figure>";
    assertNotNull(result);
    assertEquals(100, result.getHeight());
    assertEquals(100, result.getWidth());
    assertEquals(expected, got);
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:26,代码来源:EmbedExtractorTest.java

示例5: testFigureCaptionTextOnly

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testFigureCaptionTextOnly() {
    ImageElement image = TestUtil.createImage();
    image.setSrc("http://wwww.example.com/image.jpeg");
    image.setAttribute("width", "100");
    image.setAttribute("height", "100");

    Element figure = Document.get().createElement("FIGURE");
    figure.appendChild(image);
    Element figcaption = Document.get().createElement("FIGCAPTION");
    figcaption.setInnerHTML("This is a caption");
    figure.appendChild(figcaption);
    mBody.appendChild(figure);

    EmbedExtractor extractor = new ImageExtractor();
    WebElement result = extractor.extract(figure);
    assertEquals("This is a caption", result.generateOutput(true));
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:18,代码来源:EmbedExtractorTest.java

示例6: testFigureWithCaptionWithoutAnchor

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testFigureWithCaptionWithoutAnchor() {
    ImageElement image = TestUtil.createImage();
    image.setSrc("http://wwww.example.com/image.jpeg");
    image.setAttribute("width", "100");
    image.setAttribute("height", "100");
    Element figure = Document.get().createElement("FIGURE");
    figure.appendChild(image);
    Element figcaption = Document.get().createElement("FIGCAPTION");
    figcaption.setInnerHTML("<div><span>This is a caption</span><a></a></div>");
    figure.appendChild(figcaption);
    mBody.appendChild(figure);

    EmbedExtractor extractor = new ImageExtractor();
    WebImage result = (WebImage) extractor.extract(figure);
    String expected =
        "<figure>" +
            "<img src=\"http://wwww.example.com/image.jpeg\"" +
                " width=\"100\" height=\"100\">" +
            "<figcaption>This is a caption</figcaption>" +
        "</figure>";
    assertNotNull(result);
    assertEquals(100, result.getHeight());
    assertEquals(100, result.getWidth());
    assertEquals(expected, TestUtil.removeAllDirAttributes(
            result.generateOutput(false)));
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:27,代码来源:EmbedExtractorTest.java

示例7: testDivCaption

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testDivCaption() {
    ImageElement image = TestUtil.createImage();
    image.setSrc("http://wwww.example.com/image.jpeg");
    image.setAttribute("width", "100");
    image.setAttribute("height", "100");

    Element figure = Document.get().createElement("FIGURE");
    figure.appendChild(image);
    Element div = Document.get().createElement("DIV");
    div.setInnerHTML("This is a caption");
    figure.appendChild(div);
    mBody.appendChild(figure);
    String expected =
        "<figure>" +
            "<img src=\"http://wwww.example.com/image.jpeg\"" +
                " width=\"100\" height=\"100\">" +
            "<figcaption>\nThis is a caption</figcaption>" +
        "</figure>";
    EmbedExtractor extractor = new ImageExtractor();
    WebElement result = extractor.extract(figure);
    assertEquals(expected, TestUtil.removeAllDirAttributes(
            result.generateOutput(false)));
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:24,代码来源:EmbedExtractorTest.java

示例8: 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

示例9: testImageExtractorWithWidthHeightAttributes

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testImageExtractorWithWidthHeightAttributes() {
    ImageElement image = TestUtil.createImage();
    image.setSrc(IMAGE_BASE64);
    image.setAttribute("width", "32");
    image.setAttribute("height", "32");
    EmbedExtractor extractor = new ImageExtractor();
    WebImage result = (WebImage) extractor.extract(image);
    assertNotNull(result);
    assertEquals(32, result.getWidth());
    assertEquals(32, result.getHeight());
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:12,代码来源:EmbedExtractorTest.java

示例10: testImageExtractorWithWidthAttributeHeightCSS

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testImageExtractorWithWidthAttributeHeightCSS() {
    ImageElement image = TestUtil.createImage();
    image.setSrc(IMAGE_BASE64);
    image.getStyle().setHeight(100, Style.Unit.PX);
    image.setAttribute("width", "144");
    mBody.appendChild(image);
    EmbedExtractor extractor = new ImageExtractor();
    WebImage result = (WebImage) extractor.extract(image);
    assertNotNull(result);
    assertEquals(144, result.getWidth());
    assertEquals(100, result.getHeight());
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:13,代码来源:EmbedExtractorTest.java

示例11: testImageExtractorWithAttributesCSS

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testImageExtractorWithAttributesCSS() {
    ImageElement image = TestUtil.createImage();
    image.setSrc(IMAGE_BASE64);
    image.setAttribute("width", "32");
    image.setAttribute("height", "32");
    image.getStyle().setHeight(48, Style.Unit.PX);
    image.getStyle().setWidth(48, Style.Unit.PX);
    mBody.appendChild(image);
    EmbedExtractor extractor = new ImageExtractor();
    WebImage result = (WebImage) extractor.extract(image);
    assertNotNull(result);
    assertEquals(48, result.getWidth());
    assertEquals(48, result.getHeight());
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:15,代码来源:EmbedExtractorTest.java

示例12: testFigureCaptionWithAnchor

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

    ImageElement image = TestUtil.createImage();
    image.setSrc("http://wwww.example.com/image.jpeg");
    image.setAttribute("width", "100");
    image.setAttribute("height", "100");

    Element figure = Document.get().createElement("FIGURE");
    figure.appendChild(image);
    figure.setAttribute("class", "test");
    figure.setAttribute("attribute", "value");

    Element figcaption = Document.get().createElement("FIGCAPTION");
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.setHref("link_page.html");
    anchor.setInnerHTML("caption<br>link");
    figcaption.appendChild(TestUtil.createText("This is a "));
    figcaption.appendChild(anchor);
    figure.appendChild(figcaption);
    mBody.appendChild(figure);
    String expected =
        "<figure>" +
            "<img src=\"http://wwww.example.com/image.jpeg\"" +
                " width=\"100\" height=\"100\">" +
            "<figcaption>This is a " +
                "<a href=\"http://example.com/link_page.html\">caption<br>link</a>" +
            "</figcaption>" +
        "</figure>";
    EmbedExtractor extractor = new ImageExtractor();
    WebElement result = extractor.extract(figure);
    assertEquals(expected, TestUtil.removeAllDirAttributes(
            result.generateOutput(false)));
    assertEquals("This is a caption\nlink", result.generateOutput(true));
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:36,代码来源:EmbedExtractorTest.java

示例13: extract

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
@Override
public WebImage extract(Element e) {
    if (!relevantTags.contains(e.getTagName())) {
        return null;
    }
    imgSrc = "";

    ImageElement ie = ImageElement.as(DomUtil.getFirstElementByTagNameInc(e, "IMG"));

    if ("FIGURE".equals(e.getTagName())) {
        Element img = DomUtil.getFirstElementByTagName(e, "PICTURE");
        if (img == null) {
            img = DomUtil.getFirstElementByTagName(e, "IMG");
        }
        if (img == null) {
            return null;
        }
        extractImageAttributes(ie);
        Element figcaption;
        Element cap = DomUtil.getFirstElementByTagName(e, "FIGCAPTION");
        if (cap != null) {
            // We look for links because some sites put non-caption
            // elements into <figcaption>. For example: image credit
            // could contain a link. So we get the whole DOM structure within
            // <figcaption> only when it contains links, otherwise we get the innerText.
            NodeList<Element> links = DomUtil.querySelectorAll(cap, "A[HREF]");
            figcaption = links.getLength() > 0 ?
                    cap : createFigcaptionElement(cap);
        } else {
            figcaption = createFigcaptionElement(e);
        }
        return new WebFigure(img, width, height, imgSrc, figcaption);
    }

    if ("SPAN".equals(e.getTagName())) {
        if (!e.getAttribute("class").contains("lazy-image-placeholder")) {
            return null;
        }
        // Image lazy loading on Wikipedia.
        ie = Document.get().createImageElement();
        imgSrc = e.getAttribute("data-src");
        width = JavaScript.parseInt(e.getAttribute("data-width"));
        height = JavaScript.parseInt(e.getAttribute("data-height"));
        ie.setAttribute("srcset", e.getAttribute("data-srcset"));
        return new WebImage(ie, width, height, imgSrc);
    }

    extractImageAttributes(ie);
    return new WebImage(e, width, height, imgSrc);
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:51,代码来源:ImageExtractor.java


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