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


Java ImageElement类代码示例

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


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

示例1: appendEmbeddedImage

import com.google.gwt.dom.client.ImageElement; //导入依赖的package包/类
public final ItemHandle appendEmbeddedImage(
     HAlignment imageAlignment,
     String embeddedImageText,
     String embeddedImageStyle,
     String description
) {
   FlowPanel outer = new FlowPanel(DivElement.TAG);
   String imageAlignment1 = "text-align:center;";
   if (imageAlignment == HAlignment.LEFT) {
      imageAlignment1 = "text-align:left;";
   } else if (imageAlignment == HAlignment.RIGHT) {
      imageAlignment1 = "text-align:right;";
   }
   outer.getElement().setAttribute("style", "display:block;" + imageAlignment1);
   FlowPanel inner = new FlowPanel(ImageElement.TAG);
   inner.getElement().setAttribute("alt",   description);
   inner.getElement().setAttribute("src",   embeddedImageText);
   inner.getElement().setAttribute("style", embeddedImageStyle);
   outer.add(inner);
   appendAndScrollOrFocusAsAppropriate(outer);
   return new ItemHandle(this, outer);
}
 
开发者ID:ainslec,项目名称:gwt-promptly,代码行数:23,代码来源:PromptlyPanel.java

示例2: View1

import com.google.gwt.dom.client.ImageElement; //导入依赖的package包/类
public View1() {
   initWidget(viewUi.createAndBindUi(this));

   // Image renderer
   grid.ready(o -> {
     Column column = grid.getColumns().get(0).cast();
     column.setRenderer(row -> {
         Row r = (Row)row;
         Element e = r.getElement().cast();
         ImageElement img = e.getFirstChild().cast();
         if (img == null) {
           img = Document.get().createImageElement();
           e.appendChild(img);
         }
         img.setSrc(r.getData().toString());
         return 0;
     });

     // Send the request
     Polymer.Base.async(o2 -> ajax.generateRequest(), 1000);
     return 0;
   });
}
 
开发者ID:manolo,项目名称:gwt-pwa-archetype,代码行数:24,代码来源:View1.java

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

示例4: paint

import com.google.gwt.dom.client.ImageElement; //导入依赖的package包/类
@Override
void paint(WebGLRenderingContext gl, Transform parentTransform, float parentAlpha) {
  if (!visible()) return;

  // TODO(jgw): Assert exclusive source-rect vs. repeat.

  WebGLTexture tex = img.ensureTexture(gfx, repeatX, repeatY);
  if (tex != null) {
    ImageElement elem = img.img;

    Transform xform = localTransform(parentTransform);
    float childAlpha = parentAlpha * alpha;

    float width = widthSet ? this.width : elem.getWidth();
    float height = heightSet ? this.height : elem.getHeight();

    if (sourceRectSet) {
      gfx.drawTexture(tex, img.width(), img.height(), xform, 0, 0, width, height, sx, sy, sw, sh,
          childAlpha);
    } else {
      gfx.drawTexture(tex, img.width(), img.height(), xform, width, height, repeatX, repeatY,
          childAlpha);
    }
  }
}
 
开发者ID:fredsa,项目名称:forplay,代码行数:26,代码来源:HtmlImageLayerGL.java

示例5: getIconContainer

import com.google.gwt.dom.client.ImageElement; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public Element getIconContainer(SVGResource icon) {
  if (icon != null) {
    OMSVGSVGElement svg = icon.getSvg();
    svg.addClassNameBaseVal(treeStyles.styles().iconContainer());
    svg.setWidth(Style.Unit.PX, 16);
    svg.setHeight(Style.Unit.PX, 16);
    return svg.getElement();
  }

  ImageElement emptyIcon = Document.get().createImageElement();
  emptyIcon.setSrc(TreeView.blankImageUrl);
  emptyIcon.setClassName(treeStyles.styles().iconContainer());
  return emptyIcon;
}
 
开发者ID:eclipse,项目名称:che,代码行数:17,代码来源:AbstractPresentationRenderer.java

示例6: _createBaseTagElement

import com.google.gwt.dom.client.ImageElement; //导入依赖的package包/类
private static LIElement _createBaseTagElement() {
	// 		<ul class='tags'>
	//			<li><span><img />Tag1</span></li>
	//			<li><span><img />Tag1</span></li>
	//			...
	//		</ul>
	LIElement containerLIEl = DOM.createElement("li").cast();
	SpanElement spanEl = DOM.createSpan().cast();
	ImageElement imgEl = DOM.createImg().cast();
	
	// assemble the structure
	spanEl.appendChild(imgEl);
	spanEl.appendChild(Document.get().createTextNode(""));
	containerLIEl.appendChild(spanEl);
	return containerLIEl;
}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:17,代码来源:TagList.java

示例7: onBrowserEvent

import com.google.gwt.dom.client.ImageElement; //导入依赖的package包/类
@Override
	@SuppressWarnings("fallthrough")
	public void onBrowserEvent(final Event event) {
		super.onBrowserEvent(event);
		
		int eventType = DOM.eventGetType(event);
		Element eventTargetEl = DOM.eventGetTarget(event);
		
//		GWT.log("_____" + eventTargetEl.getNodeName() + ": " + event.getType());
		
		switch (eventType) {
		case Event.ONCLICK: {
			if (ImageElement.is(eventTargetEl)) {
				LIElement tagLIElement = _findTagLIElementContaining(eventTargetEl);
				T tag = _tagForElement(tagLIElement);
				this.removeTag(tag);
			}
			break;
		}
		}
	}
 
开发者ID:opendata-euskadi,项目名称:r01fb,代码行数:22,代码来源:TagList.java

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

示例9: stripImageElement

import com.google.gwt.dom.client.ImageElement; //导入依赖的package包/类
/**
 * Only keep some attributes for image elements.
 * @param imgElement The image element to strip in-place.
 */
public static void stripImageElement(ImageElement imgElement) {
    JsArray<Node> attrs = getAttributes(imgElement);
    for (int i = 0; i < attrs.length(); ) {
        String name = attrs.get(i).getNodeName();
        if (!"src".equals(name) &&
            !"alt".equals(name) &&
            !"srcset".equals(name) &&
            !"dir".equals(name) &&
            !"width".equals(name) &&
            !"height".equals(name) &&
            !"title".equals(name)) {
            imgElement.removeAttribute(name);
        } else {
            i++;
        }
    }
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:22,代码来源:DomUtil.java

示例10: getImageUrlList

import com.google.gwt.dom.client.ImageElement; //导入依赖的package包/类
/**
 * Get the list of source URLs of this image.
 * It's more efficient to call after generateOutput().
 * @return Source URLs or an empty List.
 */
public List<String> getImageUrlList() {
    if (cloned == null) {
        cloneAndProcessNode();
    }
    List<String> imgUrls = new ArrayList<>();
    NodeList<Element> imgs = DomUtil.querySelectorAll(cloned, "IMG, SOURCE");
    for (int i = 0; i < imgs.getLength(); i++) {
        ImageElement ie = (ImageElement) imgs.getItem(i);
        if (!ie.getSrc().isEmpty()) {
            imgUrls.add(ie.getSrc());
        }
        imgUrls.addAll(DomUtil.getAllSrcSetUrls(ie));
    }
    return imgUrls;
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:21,代码来源:WebTable.java

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

示例12: getCaption

import com.google.gwt.dom.client.ImageElement; //导入依赖的package包/类
private static String getCaption(ImageElement image) {
    // If |image| is a child of <figure>, then get the <figcaption> elements.
    Element parent = image.getParentElement();
    if (!parent.hasTagName("FIGURE")) return "";
    NodeList<Element> captions = parent.getElementsByTagName("FIGCAPTION");
    int numCaptions = captions.getLength();
    String caption = "";
    if (numCaptions > 0 && numCaptions <= 2) {
        // Use javascript innerText (instead of javascript textContent) to get only visible
        // captions.
        for (int i = 0; i < numCaptions && caption.isEmpty(); i++) {
            caption = DomUtil.getInnerText(captions.getItem(i));
        }
    }
    return caption;
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:17,代码来源:IEReadingViewParser.java

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

示例14: testUncaptionedDominantImage

import com.google.gwt.dom.client.ImageElement; //导入依赖的package包/类
public void testUncaptionedDominantImage() {
    Element root = TestUtil.createDiv(0);
    ImageElement img = TestUtil.createImage();
    String expectedUrl = "http://example.com/dominant_without_caption.jpeg";
    img.setSrc(expectedUrl);
    img.setWidth(600);
    img.setHeight(400);
    root.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("", image.caption);
    assertEquals(600, image.width);
    assertEquals(400, image.height);
}
 
开发者ID:chromium,项目名称:dom-distiller,代码行数:21,代码来源:IEReadingViewParserTest.java

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


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