本文整理汇总了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);
}
示例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;
});
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
}
}
示例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, ", "));
}
示例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++;
}
}
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}