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


Java ImageElement.setSrc方法代码示例

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


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

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

示例2: createTexture

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
private WebGLTexture createTexture(String url) {
  // Create the texture object.
  final WebGLTexture tex = gl.createTexture();

  // Load the image.
  final ImageElement img = createImage();
  img.setSrc(url);
  hookOnLoad(img, new EventHandler() {
    @Override
    public void onEvent(NativeEvent e) {
      // Load image data into the texture object once it's loaded.
      gl.bindTexture(TEXTURE_2D, tex);
      gl.texImage2D(TEXTURE_2D, 0, RGBA, RGBA, UNSIGNED_BYTE, img);
      gl.texParameteri(TEXTURE_2D, TEXTURE_MAG_FILTER, LINEAR);
      gl.texParameteri(TEXTURE_2D, TEXTURE_MIN_FILTER, LINEAR);
      gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_S, CLAMP_TO_EDGE);
      gl.texParameteri(TEXTURE_2D, TEXTURE_WRAP_T, CLAMP_TO_EDGE);
      gl.bindTexture(TEXTURE_2D, null);
    }
  });

  return tex;
}
 
开发者ID:playn,项目名称:playn,代码行数:24,代码来源:WebGLDemo.java

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

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

示例5: testCaptionedDominantImageWithSmallestAR

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testCaptionedDominantImageWithSmallestAR() {
    Element root = TestUtil.createDiv(0);
    String expectedCaption = "Captioned Dominant Image with Smallest AR";
    Element figure = createFigureWithCaption(expectedCaption);
    ImageElement img = TestUtil.createImage();
    String expectedUrl = "http://example.com/captioned_smallest_dominant.jpeg";
    img.setSrc(expectedUrl);
    img.setWidth(400);
    img.setHeight(307);

    root.appendChild(figure);
    figure.appendChild(img);

    IEReadingViewParser parser = new IEReadingViewParser(root);
    MarkupParser.Image[] images = parser.getImages();
    assertEquals(1, images.length);
    MarkupParser.Image image = images[0];
    assertEquals(expectedUrl, image.url);
    assertEquals("", image.secureUrl);
    assertEquals("", image.type);
    assertEquals(expectedCaption, image.caption);
    assertEquals(400, image.width);
    assertEquals(307, image.height);
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:25,代码来源:IEReadingViewParserTest.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: testCaptionedDominantImageWithInvalidSize

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testCaptionedDominantImageWithInvalidSize() {
    Element root = TestUtil.createDiv(0);
    String expectedCaption = "Captioned Dominant Image with Invalid Size";
    Element figure = createFigureWithCaption(expectedCaption);
    ImageElement img = TestUtil.createImage();
    String expectedUrl = "http://example.com/captioned_dominant_with_wrong_dimensions.jpeg";
    img.setSrc(expectedUrl);
    img.setWidth(100);
    img.setHeight(100);

    root.appendChild(figure);
    figure.appendChild(img);

    IEReadingViewParser parser = new IEReadingViewParser(root);
    MarkupParser.Image[] images = parser.getImages();
    assertEquals(1, images.length);
    MarkupParser.Image image = images[0];
    assertEquals(expectedUrl, image.url);
    assertEquals("", image.secureUrl);
    assertEquals("", image.type);
    assertEquals(expectedCaption, image.caption);
    assertEquals(100, image.width);
    assertEquals(100, image.height);
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:25,代码来源:IEReadingViewParserTest.java

示例8: testUncaptionedInlineImageWithBiggestAR

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testUncaptionedInlineImageWithBiggestAR() {
    Element root = TestUtil.createDiv(0);
    Element figure = createDefaultDominantFigure();
    ImageElement img = TestUtil.createImage();
    String expectedUrl = "http://example.com/inline_without_caption.jpeg";
    img.setSrc(expectedUrl);
    img.setWidth(400);
    img.setHeight(134);

    root.appendChild(figure);
    root.appendChild(img);

    IEReadingViewParser parser = new IEReadingViewParser(root);
    MarkupParser.Image[] images = parser.getImages();
    assertEquals(2, images.length);
    MarkupParser.Image image = images[1];
    assertEquals(expectedUrl, image.url);
    assertEquals("", image.secureUrl);
    assertEquals("", image.type);
    assertEquals("", image.caption);
    assertEquals(400, image.width);
    assertEquals(134, image.height);
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:24,代码来源:IEReadingViewParserTest.java

示例9: testCaptionedInlineImageWithInvalidSize

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testCaptionedInlineImageWithInvalidSize() {
    Element root = TestUtil.createDiv(0);
    Element dominant = createDefaultDominantFigure();
    String expectedCaption = "Captioned Inline Image with Smallest AR";
    Element figure = createFigureWithCaption(expectedCaption);
    ImageElement img = TestUtil.createImage();
    String expectedUrl = "http://example.com/captioned_smallest_inline.jpeg";
    img.setSrc(expectedUrl);
    img.setWidth(400);
    img.setHeight(400);

    root.appendChild(dominant);
    root.appendChild(figure);
    figure.appendChild(img);

    IEReadingViewParser parser = new IEReadingViewParser(root);
    MarkupParser.Image[] images = parser.getImages();
    assertEquals(2, images.length);
    MarkupParser.Image image = images[1];
    assertEquals(expectedUrl, image.url);
    assertEquals("", image.secureUrl);
    assertEquals("", image.type);
    assertEquals(expectedCaption, image.caption);
    assertEquals(400, image.width);
    assertEquals(400, image.height);
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:27,代码来源:IEReadingViewParserTest.java

示例10: updateExpandImage

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
private void updateExpandImage()
{
	if( m_tr == null )
		return;

	Element td = m_tr.getChild( 0 ).cast();
	if( td.getChildCount() == 0 )
		return;

	ImageElement img = td.getChild( 0 ).cast();

	if( !hasChilds() )
		img.setSrc( "" );
	else if( getExpanded() )
		img.setSrc( this.treeTable.treeMinus.getSafeUri().asString() );
	else
		img.setSrc( this.treeTable.treePlus.getSafeUri().asString() );
}
 
开发者ID:ltearno,项目名称:hexa.tools,代码行数:19,代码来源:Row.java

示例11: adaptImage

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
private Image adaptImage(String url) {
  ImageElement img = Document.get().createImageElement();
  /*
   * When the server provides an appropriate {@literal
   * Access-Control-Allow-Origin} response header, allow images to be served
   * cross origin on supported, CORS enabled, browsers.
   */
  setCrossOrigin(img, "anonymous");
  img.setSrc(url);
  return new HtmlImage(img);
}
 
开发者ID:fredsa,项目名称:forplay,代码行数:12,代码来源:HtmlAssetManager.java

示例12: testImageExtractorWithAttributesCSSHeightCMAndWidthAttrb

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

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

示例14: testImageExtractorWithWidthHeightCSSPX

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testImageExtractorWithWidthHeightCSSPX() {
    ImageElement image = TestUtil.createImage();
    image.setSrc(IMAGE_BASE64);
    image.getStyle().setHeight(100, 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(100, result.getHeight());
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:13,代码来源:EmbedExtractorTest.java

示例15: testUncaptionedDominantImageWithInvalidSize

import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testUncaptionedDominantImageWithInvalidSize() {
    Element root = TestUtil.createDiv(0);
    ImageElement img = TestUtil.createImage();
    String expectedUrl = "http://example.com/dominant_without_caption.jpeg";
    img.setSrc(expectedUrl);
    img.setWidth(100);
    img.setHeight(100);
    root.appendChild(img);

    IEReadingViewParser parser = new IEReadingViewParser(root);
    // Expect no dominant image.
    MarkupParser.Image[] images = parser.getImages();
    assertEquals(0, images.length);
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:15,代码来源:IEReadingViewParserTest.java


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