本文整理汇总了Java中com.google.gwt.dom.client.ImageElement.setWidth方法的典型用法代码示例。如果您正苦于以下问题:Java ImageElement.setWidth方法的具体用法?Java ImageElement.setWidth怎么用?Java ImageElement.setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.dom.client.ImageElement
的用法示例。
在下文中一共展示了ImageElement.setWidth方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: testCaptionedDominantImageWithBiggestAR
import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testCaptionedDominantImageWithBiggestAR() {
Element root = TestUtil.createDiv(0);
String expectedCaption = "Captioned Dominant Image with Biggest AR";
Element figure = createFigureWithCaption(expectedCaption);
ImageElement img = TestUtil.createImage();
String expectedUrl = "http://example.com/captioned_biggest_dominant.jpeg";
img.setSrc(expectedUrl);
img.setWidth(400);
img.setHeight(134);
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(134, image.height);
}
示例4: 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);
}
示例5: testUncaptionedInlineImageWithSmallestAR
import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testUncaptionedInlineImageWithSmallestAR() {
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(307);
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(307, image.height);
}
示例6: 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);
}
示例7: 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);
}
示例8: 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;
}
示例9: 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);
}
示例10: createDefaultDominantFigure
import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
private Element createDefaultDominantFigure() {
Element figure = createFigureWithCaption("Default Dominant Image");
ImageElement image = TestUtil.createImage();
image.setSrc("http://example.com/dominant.jpeg");
image.setWidth(600);
image.setHeight(400);
figure.appendChild(image);
return figure;
}
示例11: testImageExtractorWithOneAttribute
import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
public void testImageExtractorWithOneAttribute() {
ImageElement image = TestUtil.createImage();
image.setSrc(IMAGE_BASE64);
image.setWidth(32);
mBody.appendChild(image);
EmbedExtractor extractor = new ImageExtractor();
WebImage result = (WebImage) extractor.extract(image);
assertNotNull(result);
assertEquals(32, result.getWidth());
assertEquals(32, result.getHeight());
}
示例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());
}
示例13: createErrorBitmap
import com.google.gwt.dom.client.ImageElement; //导入方法依赖的package包/类
@Override protected Object createErrorBitmap (int pixelWidth, int pixelHeight) {
ImageElement img = Document.get().createImageElement();
img.setWidth(pixelWidth);
img.setHeight(pixelHeight);
return img;
}