本文整理汇总了Java中com.google.gwt.canvas.client.Canvas.createIfSupported方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.createIfSupported方法的具体用法?Java Canvas.createIfSupported怎么用?Java Canvas.createIfSupported使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.canvas.client.Canvas
的用法示例。
在下文中一共展示了Canvas.createIfSupported方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCanvas
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public static Canvas createCanvas(int [] pixels, int width, int height) {
Canvas canvas = Canvas.createIfSupported();
if(canvas == null) return null;
canvas.setCoordinateSpaceWidth(width);
canvas.setCoordinateSpaceHeight(height);
Context2d context = canvas.getContext2d();
ImageData data = context.createImageData(width, height);
CanvasPixelArray array = data.getData();
for(int i=0; i<width*height; i++) { // ABGR
array.set(4*i+0, pixels[i] & 0xFF);
array.set(4*i+1, (pixels[i] >> 8) & 0xFF);
array.set(4*i+2, (pixels[i] >> 16) & 0xFF);
array.set(4*i+3, (pixels[i] >> 24) & 0xFF);
}
context.putImageData(data, 0, 0);
return canvas;
}
示例2: createImageCanvas
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
Canvas createImageCanvas(int [] pixels, int width, int height) {
Canvas canvas = Canvas.createIfSupported();
canvas.setCoordinateSpaceWidth(width);
canvas.setCoordinateSpaceHeight(height);
Context2d context = canvas.getContext2d();
ImageData data = context.createImageData(width, height);
CanvasPixelArray array = data.getData();
for(int i=0; i<width*height; i++) {
array.set(4*i+0, pixels[i] & 0xFF);
array.set(4*i+1, (pixels[i] >> 8) & 0xFF);
array.set(4*i+2, (pixels[i] >> 16) & 0xFF);
array.set(4*i+3, (pixels[i] >> 24) & 0xFF);
}
context.putImageData(data, 0, 0);
return canvas;
}
示例3: createImageCanvas
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
private Canvas createImageCanvas(int [] pixels, int width, int height) {
Canvas canvas = Canvas.createIfSupported();
canvas.setCoordinateSpaceWidth(width);
canvas.setCoordinateSpaceHeight(height);
Context2d context = canvas.getContext2d();
ImageData data = context.createImageData(width, height);
CanvasPixelArray array = data.getData();
for(int i=0; i<width*height; i++) { // ABGR
array.set(4*i+0, pixels[i] & 0xFF);
array.set(4*i+1, (pixels[i] >> 8) & 0xFF);
array.set(4*i+2, (pixels[i] >> 16) & 0xFF);
array.set(4*i+3, (pixels[i] >> 24) & 0xFF);
}
context.putImageData(data, 0, 0);
canvas.getElement().getStyle().setMargin(4, Unit.PX);
return canvas;
}
示例4: TextDisplayElement
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public TextDisplayElement(String id, int x, int y, int width, int height,
String text, int[][] coords) {
super(id, x, y, width, height);
this.coords = coords;
this.text = text;
// Create a canvas containing the filled polygon with no border
Canvas sub_canvas = Canvas.createIfSupported();
sub_canvas.setCoordinateSpaceWidth(width);
sub_canvas.setCoordinateSpaceHeight(height);
Context2d context = sub_canvas.getContext2d();
context.beginPath();
context.moveTo(coords[0][0] - baseLeft(), coords[0][1] - baseTop());
for (int i = 1; i < coords.length; i++) {
context.lineTo(coords[i][0] - baseLeft(), coords[i][1] - baseTop());
}
context.setFillStyle(color_fill);
context.fill();
context.closePath();
this.image_data = context.getImageData(0, 0, width, height);
}
示例5: createBillboard
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public static BillboardOptions createBillboard(DrawInteractionOptions options) {
Canvas canvas = Canvas.createIfSupported();
Context2d context = canvas.getContext2d();
context.setFillStyle(options.color.toCssColorString());
context.setStrokeStyle(options.outlineColor.toCssColorString());
context.setLineWidth(options.outlineWidth);
context.translate(canvas.getCoordinateSpaceWidth() / 2, canvas.getCoordinateSpaceHeight() / 2);
context.beginPath();
context.arc(0, 0, options.pixelSize, 0, Math.PI * 2, true);
context.closePath();
context.stroke();
context.fill();
BillboardOptions billboard = new BillboardOptions();
billboard.horizontalOrigin = HorizontalOrigin.CENTER();
billboard.verticalOrigin = VerticalOrigin.CENTER();
billboard.imageCanvas = canvas.getCanvasElement();
return billboard;
}
示例6: createCanvas
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
private Canvas createCanvas()
{
Canvas canvas = Canvas.createIfSupported();
canvas.setCoordinateSpaceWidth(640);
canvas.setCoordinateSpaceHeight(480);
return canvas;
}
示例7: SeattleViewGwtImpl
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public SeattleViewGwtImpl() {
mapCanvas = Canvas.createIfSupported();
flowCanvas = Canvas.createIfSupported();
cameraCanvas = Canvas.createIfSupported();
localStorage = Storage.getLocalStorageIfSupported();
touchDelegate = new TouchDelegate(cameraCanvas);
initWidget(uiBinder.createAndBindUi(this));
if (MGWT.getOsDetection().isAndroid()) {
leftFlexSpacer.setVisible(false);
} else if (MGWT.getOsDetection().isIOs()) {
leftFlexSpacer.setVisible(false);
}
getMap();
}
示例8: TacomaViewGwtImpl
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public TacomaViewGwtImpl() {
mapCanvas = Canvas.createIfSupported();
flowCanvas = Canvas.createIfSupported();
cameraCanvas = Canvas.createIfSupported();
localStorage = Storage.getLocalStorageIfSupported();
touchDelegate = new TouchDelegate(cameraCanvas);
initWidget(uiBinder.createAndBindUi(this));
if (MGWT.getOsDetection().isAndroid()) {
leftFlexSpacer.setVisible(false);
} else if (MGWT.getOsDetection().isIOs()) {
leftFlexSpacer.setVisible(false);
}
getMap();
}
示例9: drawGridOn
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public static void drawGridOn(Context2d context2d) {
if (gridCanvas == null) {
gridCanvas = Canvas.createIfSupported();
gridCanvas.setCoordinateSpaceWidth(3000);
gridCanvas.setCoordinateSpaceHeight(2000);
int width = gridCanvas.getCoordinateSpaceWidth();
int height = gridCanvas.getCoordinateSpaceHeight();
Context2d backgroundContext = gridCanvas.getContext2d();
backgroundContext.setStrokeStyle(Converter.convert(ColorOwn.BLACK.transparency(Transparency.SELECTION_BACKGROUND)));
for (int i = 0; i < width; i += SharedConstants.DEFAULT_GRID_SIZE) {
drawLine(backgroundContext, i, 0, i, height);
}
for (int i = 0; i < height; i += SharedConstants.DEFAULT_GRID_SIZE) {
drawLine(backgroundContext, 0, i, width, i);
}
}
context2d.drawImage(gridCanvas.getCanvasElement(), 0, 0);
}
示例10: createImage
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public static CanvasElement createImage(int width, int height) {
Canvas canvas = Canvas.createIfSupported();
canvas.setWidth(width + "px");
canvas.setCoordinateSpaceWidth(width);
canvas.setHeight(height + "px");
canvas.setCoordinateSpaceHeight(height);
return canvas.getCanvasElement();
}
示例11: prepareCanvas
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
private Widget prepareCanvas() {
canvas = Canvas.createIfSupported();
if (canvas == null) {
// TODO
throw new RuntimeException("Canvas not supported!");
}
canvas.setTabIndex(0);
final SimplePanel panel = new SimplePanel(canvas);
panel.setStyleName("content");
Window.addResizeHandler(e -> resizeCanvas());
Scheduler.get().scheduleFinally(() -> resizeCanvas());
return panel;
}
示例12: packUVImage
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
private void packUVImage(ImageElement element,int split,int x,int y){
if(element==null){
return;
}
int canvasSize=textureCanvas.getCoordinateSpaceWidth();
int unitSize=canvasSize/split;
if(resizeCanvas==null){
resizeCanvas=Canvas.createIfSupported();
}
Canvas resized=CanvasResizer.on(resizeCanvas).image(element).width(unitSize).downscale(false).toCanvas();//downscale transparent problem
textureCanvas.getContext2d().drawImage(resized.getCanvasElement(), unitSize*x, unitSize*y);
}
示例13: getImageUrl
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public String getImageUrl() {
if(sharedCanvas==null){
sharedCanvas=Canvas.createIfSupported();
}
drawGridImage(sharedCanvas, this);
return sharedCanvas.toDataUrl();
}
示例14: createColorImageDataUrl
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public String createColorImageDataUrl(Canvas canvas,int w,int h,String color){
if(canvas==null){
canvas=Canvas.createIfSupported();
}
CanvasUtils.createCanvas(canvas, w, h);
CanvasUtils.fillRect(canvas, color);
return canvas.toDataUrl();
}
示例15: GwtGraphics
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public GwtGraphics (Panel root, GwtApplicationConfiguration config) {
Canvas canvasWidget = Canvas.createIfSupported();
if (canvasWidget == null) throw new GdxRuntimeException("Canvas not supported");
canvas = canvasWidget.getCanvasElement();
root.add(canvasWidget);
canvas.setWidth(config.width);
canvas.setHeight(config.height);
this.config = config;
WebGLContextAttributes attributes = WebGLContextAttributes.create();
attributes.setAntialias(config.antialiasing);
attributes.setStencil(config.stencil);
attributes.setAlpha(false);
attributes.setPremultipliedAlpha(false);
attributes.setPreserveDrawingBuffer(config.preserveDrawingBuffer);
context = WebGLRenderingContext.getContext(canvas, attributes);
context.viewport(0, 0, config.width, config.height);
this.gl = config.useDebugGL ? new GwtGL20Debug(context) : new GwtGL20(context);
}