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


Java CanvasElement类代码示例

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


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

示例1: setFullscreenJSNI

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
private native boolean setFullscreenJSNI(GwtGraphics graphics, CanvasElement element) /*-{
	if (element.webkitRequestFullScreen) {
		element.width = $wnd.screen.width;
		element.height = $wnd.screen.height;
		element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
		$doc
				.addEventListener(
						"webkitfullscreenchange",
						function() {
							[email protected]::fullscreenChanged()();
						}, false);
		return true;
	}
	if (element.mozRequestFullScreen) {
		element.width = $wnd.screen.width;
		element.height = $wnd.screen.height;
		element.mozRequestFullScreen();
		$doc
				.addEventListener(
						"mozfullscreenchange",
						function() {
							[email protected]::fullscreenChanged()();
						}, false);
		return true;
	}
	return false;
}-*/;
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:28,代码来源:GwtGraphics.java

示例2: getContext

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/**
 * Returns a WebGL context for the given canvas element. Returns null if no 3d
 * context is available.
 */
public static native WebGLRenderingContext getContext(CanvasElement canvas, WebGLContextAttributes attributes) /*-{
  var names = ["webgl", "experimental-webgl", "moz-webgl", "webkit-webgl", "webkit-3d"];
  for (var i = 0; i < names.length; i++) {
    try {
      var ctx = canvas.getContext(names[i], attributes);
      if (ctx != null) {
        // Hook for the semi-standard WebGLDebugUtils script.
        if ($wnd.WebGLDebugUtils) {
          if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled');
          return $wnd.WebGLDebugUtils.makeDebugContext(ctx);
        }
        return ctx;
      }
    } catch(e) {
    }
  }
  return null;
}-*/;
 
开发者ID:playn,项目名称:playn,代码行数:23,代码来源:WebGLRenderingContext.java

示例3: createContext

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/**
 * Creates a WebGL 1.0 context upon a canvas element using the specified context attributes. This method alerts the
 * user if there is no WebGL support and also redirects the browser to <a href="http://get.webgl.org/">get.webgl.org
 * </a>.
 *
 * @param canvas     The canvas element to creeate the context upon.
 * @param attributes The context attributes to request the context with.
 *
 * @return The created WebGL context object.
 */
public static native WebGLContext createContext(CanvasElement canvas, WebGLContext.Attributes attributes) /*-{
    try
    {
        if (attributes)
            $wnd.gl = canvas.getContext("webgl", attributes) || canvas.getContext("experimental-webgl", attributes);
        else
            $wnd.gl = canvas.getContext("webgl") || canvas.getContext("experimental-webgl");

        $wnd.attribs = $wnd.gl.getContextAttributes();
        $wnd.glv = 1.0;
    }
    catch (e)
    {
        alert(e);

        $wnd.alert("Your browser doesn't appear to support WebGL. Try upgrading your browser.");
        $wnd.location.href = 'http://get.webgl.org/';
    }

    return $wnd.context = {
        gl: $wnd.gl,
        attribs: $wnd.attribs,
        glv: $wnd.glv
    };
}-*/;
 
开发者ID:sriharshachilakapati,项目名称:WebGL4J,代码行数:36,代码来源:WebGL10.java

示例4: createContext

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
public static native WebGLContext createContext(CanvasElement canvas, WebGLContext.Attributes attributes) /*-{
    try
    {
        if (attributes)
            $wnd.gl = canvas.getContext("webgl2", attributes) || canvas.getContext("experimental-webgl2", attributes);
        else
            $wnd.gl = canvas.getContext("webgl2") || canvas.getContext("experimental-webgl2");

        $wnd.attribs = $wnd.gl.getContextAttributes();
        $wnd.glv = 2.0;
    }
    catch (e)
    {
        alert(e);

        $wnd.alert("Your browser doesn't appear to support WebGL 2. Try upgrading your browser.");
        $wnd.location.href = 'http://get.webgl.org/';
    }

    return $wnd.context = {
        gl: $wnd.gl,
        attribs: $wnd.attribs,
        glv: $wnd.glv
    };
}-*/;
 
开发者ID:sriharshachilakapati,项目名称:WebGL4J,代码行数:26,代码来源:WebGL20.java

示例5: getContext

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/**
 * Returns a WebGL context for the given canvas element. Returns null if no 3d
 * context is available.
 */
public static native WebGLRenderingContext getContext(CanvasElement canvas, WebGLContextAttributes attributes) /*-{
  var names = ["experimental-webgl", "webgl", "moz-webgl", "webkit-webgl", "webkit-3d"];
  for (var i = 0; i < names.length; i++) {
    try {
      var ctx = canvas.getContext(names[i], attributes);
      if (ctx != null) {
        // Hook for the semi-standard WebGLDebugUtils script.
        if ($wnd.WebGLDebugUtils) {
          if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled');
          return $wnd.WebGLDebugUtils.makeDebugContext(ctx);
        }
        return ctx;
      }
    } catch(e) {
    }
  }
  return null;
}-*/;
 
开发者ID:fredsa,项目名称:forplay,代码行数:23,代码来源:WebGLRenderingContext.java

示例6: 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;
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:20,代码来源:DataStore.java

示例7: 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);
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:23,代码来源:DataStore.java

示例8: createImage

import com.google.gwt.dom.client.CanvasElement; //导入依赖的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();
}
 
开发者ID:mateusz-matela,项目名称:djvu-html5,代码行数:9,代码来源:DataStore.java

示例9: setFullscreenJSNI

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
private native boolean setFullscreenJSNI (GwtGraphics graphics, CanvasElement element) /*-{
if(element.webkitRequestFullScreen) {
element.width = $wnd.screen.width;
element.height = $wnd.screen.height;
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
$doc.addEventListener("webkitfullscreenchange", function() {
[email protected]::fullscreenChanged()();
}, false);
return true;
}
if(element.mozRequestFullScreen) {
element.width = $wnd.screen.width;
element.height = $wnd.screen.height;
element.mozRequestFullScreen();
$doc.addEventListener("mozfullscreenchange", function() {
[email protected]::fullscreenChanged()();
}, false);
return true;
}
return false;
}-*/;
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:22,代码来源:GwtGraphics.java

示例10: setCursorCatchedJSNI

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/** from https://github.com/toji/game-shim/blob/master/game-shim.js
 * @param element Canvas */
private native void setCursorCatchedJSNI (CanvasElement element) /*-{
	// Navigator pointer is not the right interface according to spec.
	// Here for backwards compatibility only
	if (!navigator.pointer) {
		navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
	}
	// element.requestPointerLock
	if (!element.requestPointerLock) {
		element.requestPointerLock = (function() {
			return element.webkitRequestPointerLock
					|| element.mozRequestPointerLock || function() {
						if (navigator.pointer) {
							navigator.pointer.lock(element);
						}
					};
		})();
	}
	element.requestPointerLock();
}-*/;
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:22,代码来源:GwtInput.java

示例11: getContext

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/** Returns a WebGL context for the given canvas element. Returns null if no 3d context is available. */
public static native WebGLRenderingContext getContext (CanvasElement canvas, WebGLContextAttributes attributes) /*-{
																																						var names = ["experimental-webgl", "webgl", "moz-webgl", "webkit-webgl", "webkit-3d"];
																																						for (var i = 0; i < names.length; i++) {
																																						try {
																																						var ctx = canvas.getContext(names[i], attributes);
																																						if (ctx != null) {
																																						// Hook for the semi-standard WebGLDebugUtils script.
																																						if ($wnd.WebGLDebugUtils) {
																																						if ($wnd.console && $wnd.console.log) console.log('WebGL debugging enabled');
																																						return $wnd.WebGLDebugUtils.makeDebugContext(ctx);
																																						}
																																						return ctx;
																																						}
																																						} catch(e) {
																																						}
																																						}
																																						return null;
																																						}-*/;
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:20,代码来源:WebGLRenderingContext.java

示例12: setCursorCatchedJSNI

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/**
 * from https://github.com/toji/game-shim/blob/master/game-shim.js
 * 
 * @param element Canvas
 */
private native void setCursorCatchedJSNI(CanvasElement element) /*-{
	// Navigator pointer is not the right interface according to spec.
	// Here for backwards compatibility only
	if (!navigator.pointer) {
		navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
	}
	// element.requestPointerLock
	if (!element.requestPointerLock) {
		element.requestPointerLock = (function() {
			return element.webkitRequestPointerLock
					|| element.mozRequestPointerLock || function() {
						if (navigator.pointer) {
							navigator.pointer.lock(element);
						}
					};
		})();
	}
	element.requestPointerLock();
}-*/;
 
开发者ID:opensciencemap,项目名称:vtm,代码行数:25,代码来源:GwtInput.java

示例13: ZoomAnimation

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
/**
 * Animate zoom and tranlate on the HTML5 canvas, after the DisplayArea has zoomed in.
 * 
 * @param context
 * @param canvas_img
 * 			the CanvasElement of the canvas to be animated
 * @param cb
 * 			callback for when the animation completes
 * @param old_width
 * 			the width of the viewport before zoom
 * @param new_width
 * 			the width of the viewport after zoom, in the same coordinates as old_width
 * @param new_x
 * 			x coordinate of the new viewport center, relative to the HTML5 canvas 
 * 			in the browser
 * @param new_y
 * 			y coordinate of the new viewport center, relative to the HTML5 canvas
 * 			in the browser
 */
public ZoomAnimation(Context2d context, CanvasElement canvas_img,
		AnimationCallback cb, int old_width, int new_width, int new_x, int new_y) {
	this.context = context;
	
	Canvas buffer = Canvas.createIfSupported();
	Context2d buff_context = buffer.getContext2d();
	
	buffer.setPixelSize(canvas_img.getWidth(), canvas_img.getHeight());
	buffer.setCoordinateSpaceWidth(canvas_img.getWidth());
	buffer.setCoordinateSpaceHeight(canvas_img.getHeight());
	
	buff_context.drawImage(canvas_img, 0, 0);
	
	this.canvas_img = buff_context.getCanvas();
	
	scale = (double) old_width / new_width;
	
	this.width_from = canvas_img.getWidth();
	this.height_from = canvas_img.getHeight();
	
	this.x_from = width_from / 2;
	this.y_from = height_from / 2;
	
	this.x_to = new_x;
	this.y_to = new_y;
	
	this.cb = cb;
}
 
开发者ID:jhu-digital-manuscripts,项目名称:rosa,代码行数:48,代码来源:ZoomAnimation.java

示例14: addAreaClickListener

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
private void addAreaClickListener(final ColorfillAreaClickListener listener) {
    interactionHandlerFactory.applyUserClickHandler(new Command() {

        @Override
        public void execute(NativeEvent event) {
            event.preventDefault();
            CanvasElement canvasElement = canvasStubView.getCanvas().getCanvasElement();
            Area area = new Area(positionHelper.getXPositionRelativeToTarget(event, canvasElement), positionHelper.getYPositionRelativeToTarget(event,
                    canvasElement));
            if (area.getX() >= 0 && area.getY() >= 0) {
                listener.onAreaClick(area);
            }
        }
    }, canvasStubView.getCanvas());
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:16,代码来源:ColorfillCanvasImpl.java

示例15: onModuleLoad

import com.google.gwt.dom.client.CanvasElement; //导入依赖的package包/类
public void onModuleLoad() {
    canvas = Canvas.createIfSupported();
    if (canvas == null) {
        Window.alert("Canvas not supported");
        return;
    }
    RootPanel.get("screen").add(canvas);

    CanvasElement el = canvas.getCanvasElement();
    el.setWidth(960);
    el.setHeight(540);

    Context2d ctx = canvas.getContext2d();
    setupContext(ctx);
    ctx.scale(3, 3);

    RootPanel.get().addDomHandler(this, KeyDownEvent.getType());

    font = new Image("images/font.png");
    fontElement = ImageElement.as(font.getElement());

    audio = Audio.createIfSupported();

    game = new Game(this);
    game.pushState(new WelcomeState(game));

    new Timer() {
        @Override
        public void run() {
            game.handleEvent();
            game.update();
            game.draw();
        }
    }.scheduleRepeating(50);
}
 
开发者ID:czak,项目名称:retronix,代码行数:36,代码来源:Application.java


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