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


Java CanvasElement.getWidth方法代码示例

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


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

示例1: 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

示例2: animatedRedraw

import com.google.gwt.dom.client.CanvasElement; //导入方法依赖的package包/类
/**
 * Redraw the canvas with HTML5 animation
 * 
 * @param old_width
 *            width of viewport in base coordinates before any zoom
 *            operations
 * @param center
 *            optional (x, y) center coordinates. Coordinates are relative
 *            to the HTML5 canvas in the broswer.
 */
public void animatedRedraw(int old_width, int... center) {
    CanvasElement canv = viewport_context.getCanvas();

    int x = center.length == 2 ? center[0] : canv.getWidth() / 2;
    int y = center.length == 2 ? center[1] : canv.getHeight() / 2;

    Animation anim = new ZoomAnimation(viewport_context, canv, cb,
            old_width, area.viewportBaseWidth(), x, y);
    anim.run(400);
}
 
开发者ID:jhu-digital-manuscripts,项目名称:rosa,代码行数:21,代码来源:DisplayAreaView.java

示例3: HtmlImage

import com.google.gwt.dom.client.CanvasElement; //导入方法依赖的package包/类
public HtmlImage (Graphics gfx, Scale scale, CanvasElement elem, String source) {
  super(gfx, scale, elem.getWidth(), elem.getHeight(), source, elem);
  this.canvas = elem;
}
 
开发者ID:playn,项目名称:playn,代码行数:5,代码来源:HtmlImage.java

示例4: getRelativeX

import com.google.gwt.dom.client.CanvasElement; //导入方法依赖的package包/类
/** Kindly borrowed from PlayN. **/
protected int getRelativeX (NativeEvent e, CanvasElement target) {
	float xScaleRatio = target.getWidth() * 1f / target.getClientWidth(); // Correct for canvas CSS scaling
	return Math.round(xScaleRatio
		* (e.getClientX() - target.getAbsoluteLeft() + target.getScrollLeft() + target.getOwnerDocument().getScrollLeft()));
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:7,代码来源:GwtInput.java


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