本文整理汇总了Java中com.google.gwt.dom.client.CanvasElement.getContext2d方法的典型用法代码示例。如果您正苦于以下问题:Java CanvasElement.getContext2d方法的具体用法?Java CanvasElement.getContext2d怎么用?Java CanvasElement.getContext2d使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.dom.client.CanvasElement
的用法示例。
在下文中一共展示了CanvasElement.getContext2d方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareMissingTileImage
import com.google.gwt.dom.client.CanvasElement; //导入方法依赖的package包/类
private CanvasElement prepareMissingTileImage() {
int tileSize = DjvuContext.getTileSize();
CanvasElement canvas = createImage(tileSize, tileSize);
Context2d context2d = canvas.getContext2d();
context2d.setFillStyle("white");
context2d.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
Image image = new Image();
final ImageElement imageElement = image.getElement().cast();
imageElement.getStyle().setProperty("visibility", "hidden");
Event.setEventListener(imageElement, event -> {
if (Event.ONLOAD == event.getTypeInt()) {
missingTileImage.getContext2d().drawImage(imageElement, 0, 0);
RootPanel.get().getElement().removeChild(imageElement);
}
});
RootPanel.get().getElement().appendChild(imageElement);
image.setUrl(getBlankImageUrl());
return canvas;
}
示例2: setTile
import com.google.gwt.dom.client.CanvasElement; //导入方法依赖的package包/类
public void setTile(TileInfo tileInfo, GMap bufferGMap) {
if (bufferImageData == null || bufferImageData.getWidth() != bufferGMap.getDataWidth()
|| bufferImageData.getHeight() != bufferGMap.getDataHeight()) {
bufferImageData = bufferCanvas.getContext2d()
.createImageData(bufferGMap.getDataWidth(), bufferGMap.getDataHeight());
}
Uint8Array imageArray = bufferImageData.getData().cast();
imageArray.set(bufferGMap.getImageData());
bufferCanvas.getContext2d().putImageData(bufferImageData, -bufferGMap.getBorder(), 0);
CanvasElement tile = tiles.get(tileInfo);
if (tile == null) {
tile = createImage(bufferGMap.getDataWidth() - bufferGMap.getBorder(), bufferGMap.getDataHeight());
tiles.put(new TileInfo(tileInfo), tile);
}
Context2d c = tile.getContext2d();
c.setFillStyle("white");
c.fillRect(0, 0, tileSize, tileSize);
c.drawImage(bufferCanvas, 0, 0);
for (Consumer<Integer> listener : tileListeners)
listener.accept(tileInfo.page);
}
示例3: HtmlCanvas
import com.google.gwt.dom.client.CanvasElement; //导入方法依赖的package包/类
HtmlCanvas(CanvasElement canvas, int width, int height) {
this.canvas = canvas;
this.width = width;
this.height = height;
canvas.setWidth(width);
canvas.setHeight(height);
ctx = canvas.getContext2d();
}