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


Java Canvas.setCoordinateSpaceHeight方法代码示例

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


在下文中一共展示了Canvas.setCoordinateSpaceHeight方法的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;
	
}
 
开发者ID:npedotnet,项目名称:npe-image-library,代码行数:25,代码来源:GwtImageReader.java

示例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;

	}
 
开发者ID:npedotnet,项目名称:TGAReader,代码行数:22,代码来源:TexturedCube.java

示例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;
	
}
 
开发者ID:npedotnet,项目名称:TGAReader,代码行数:24,代码来源:ImageCanvasTest.java

示例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);
}
 
开发者ID:jhu-digital-manuscripts,项目名称:rosa,代码行数:27,代码来源:TextDisplayElement.java

示例5: createCanvas

import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
private Canvas createCanvas()
{
    Canvas canvas = Canvas.createIfSupported();
    canvas.setCoordinateSpaceWidth(640);
    canvas.setCoordinateSpaceHeight(480);
    return canvas;
}
 
开发者ID:sriharshachilakapati,项目名称:WebGL4J,代码行数:8,代码来源:WebGL4J.java

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

示例7: setCanvasSize

import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
private static void setCanvasSize(Canvas canvas, int width, int height)
{
	canvas.setWidth(width + "px");
	canvas.setHeight(height + "px");
	canvas.setCoordinateSpaceWidth(width);
	canvas.setCoordinateSpaceHeight(height);
}
 
开发者ID:dougkoellmer,项目名称:swarm,代码行数:8,代码来源:CanvasBacking.java

示例8: ZoomAnimation

import com.google.gwt.canvas.client.Canvas; //导入方法依赖的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

示例9: MultiLineTextDisplayElement

import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public MultiLineTextDisplayElement(String id, int x, int y, int width, int height,
        String text, String label, int[][] coords) {
    super(id, x, y, width, height);
    this.coords = coords;
    this.label = label;
    this.text = text;
    
    popup = new PopupPanel(true, false);
    HTML content = new HTML(text);
	
    popup.setStylePrimaryName("PopupPanel");
    popup.addStyleName("AnnotationPopup");
	popup.setWidget(content);
    
 // 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);
}
 
开发者ID:jhu-digital-manuscripts,项目名称:rosa,代码行数:35,代码来源:MultiLineTextDisplayElement.java

示例10: PolygonDisplayElement

import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public PolygonDisplayElement(String id, int x, int y, int width,
        int height, int[][] coords) {
    super(id, x, y, width, height);
    this.coords = coords;
    
    // Create a canvas containing the filled polygon with no border
    Canvas sub_canvas = Canvas.createIfSupported();
    sub_canvas.setCoordinateSpaceWidth(baseWidth());
    sub_canvas.setCoordinateSpaceHeight(baseHeight());
    
    Context2d context = sub_canvas.getContext2d();
    
    context.save();
    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(fill_color);
    context.fill();
    
	context.closePath();
	
    context.restore();
    
    this.image_data = context.getImageData(0, 0, baseWidth(), baseHeight());
}
 
开发者ID:jhu-digital-manuscripts,项目名称:rosa,代码行数:30,代码来源:PolygonDisplayElement.java

示例11: Timeline

import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public Timeline(Canvas canvas, ScrollPanel scroll, LayoutPanel viewPanel) {
	logger.setLevel(Level.INFO);

	this.canvas = canvas;
	this.scroll = scroll;
	this.viewPanel = viewPanel;

	landmarks = new Vector<Landmark>();
	landmarkbars = new Vector<LandmarkBar>();

	startTime = new Date();
	currentTime = new Date();

	lenghtOfAMinute = 1000;

	color = CssColor.make("rgba(" + 0 + ", " + 0 + "," + 255 + ", " + 1
			+ ")");

	canvas.setWidth(minWidth + "px");
	canvas.setCoordinateSpaceWidth(minWidth);

	canvas.setHeight(minHeight + "px");
	canvas.setCoordinateSpaceHeight(minHeight);

	timer = new Timer() {
		@Override
		public void run() {
			updateTime();
			drawTimeline();
		}
	};
	timer.scheduleRepeating(5000);

	updateTime();
	drawTimeline();
}
 
开发者ID:metafora-project,项目名称:ReflectionTool,代码行数:37,代码来源:Timeline.java

示例12: scaleImage

import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
private ImageData scaleImage(Image image, double scaleToRatio) {
    Canvas canvasTmp = Canvas.createIfSupported();
    Context2d context = canvasTmp.getContext2d();

    int imageHeight = image.getHeight();

    double ch = (imageHeight * scaleToRatio);
    int imageWidth = image.getWidth();
    
    double cw = (imageWidth * scaleToRatio);

    canvasTmp.setCoordinateSpaceHeight((int) ch);
    canvasTmp.setCoordinateSpaceWidth((int) cw);

    // TODO: make a temp imageElement?
    ImageElement imageElement = ImageElement.as(image.getElement());

    // s = source
    // d = destination
    double sx = 0;
    double sy = 0;
    int imageElementWidth = imageElement.getWidth();
    if (imageElementWidth <= 0) {
        imageElementWidth = imageWidth;
    }
    double sw = imageElementWidth;
    int imageElementHeight = imageElement.getHeight();
    if (imageElementHeight <= 0) {
        imageElementHeight = imageHeight;
    }
    double sh = imageElementHeight;

    double dx = 0;
    double dy = 0;
    double dw = imageElementWidth;
    double dh = imageElementHeight;

    // tell it to scale image
    context.scale(scaleToRatio, scaleToRatio);

    // draw image to canvas
    context.drawImage(imageElement, sx, sy, sw, sh, dx, dy, dw, dh);

    // get image data
    double w = dw * scaleToRatio;
    double h = dh * scaleToRatio;
    ImageData imageData = null;
    try {
        imageData = context.getImageData(0, 0, w, h);
    } catch (Exception e) {
        // no image data. we'll try againg...
        String b = e.getLocalizedMessage();
    }

    int ht = (int) h + 10;
    int wt = (int) w + 10;
    
    // Clear the div, clear the drawing canvas then reinsert.  Otherwise, ghosts of the previous image appear.
    canvasDiv.clear();
            
    imageCanvasContext.clearRect(0, 0, imageCanvas.getCoordinateSpaceWidth(), imageCanvas.getCoordinateSpaceHeight());
    
    canvasDiv.add(imageCanvas, 0, 0);
    canvasDiv.add(drawingCanvas, 0, 0);
    
    imageCanvas.setCoordinateSpaceHeight(ht);
    imageCanvas.setCoordinateSpaceWidth(wt);
    
    drawingCanvas.setCoordinateSpaceHeight(ht);
    drawingCanvas.setCoordinateSpaceWidth(wt);
    
    canvasDiv.setSize(wt + "px", ht + "px");

    return imageData;
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:76,代码来源:OutputPanel.java

示例13: scaleImage

import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
private ImageData scaleImage(double scaleToRatio) {
	Canvas canvasTmp = Canvas.createIfSupported();
	Context2d context = canvasTmp.getContext2d();

	int imageHeight = plotImage.getHeight();
	double ch = (imageHeight * scaleToRatio);
	int imageWidth = plotImage.getWidth();
	double cw = (imageWidth * scaleToRatio);
	
	if ( imageHeight <= 0 || imageWidth <=0 ) {
	    return null;
	}

	canvasTmp.setCoordinateSpaceHeight((int) ch);
	canvasTmp.setCoordinateSpaceWidth((int) cw);

	// TODO: make a temp imageElement?
	ImageElement imageElement = ImageElement.as(plotImage.getElement());

	// s = source
	// d = destination
	double sx = 0;
	double sy = 0;
	int imageElementWidth = imageElement.getWidth();
	if (imageElementWidth <= 0) {
		imageElementWidth = imageWidth;
	}
	double sw = imageElementWidth;
	int imageElementHeight = imageElement.getHeight();
	if (imageElementHeight <= 0) {
		imageElementHeight = imageHeight;
	}
	double sh = imageElementHeight;

	double dx = 0;
	double dy = 0;
	double dw = imageElementWidth;
	double dh = imageElementHeight;

	// tell it to scale image
	context.scale(scaleToRatio, scaleToRatio);

	// draw image to canvas
	context.drawImage(imageElement, sx, sy, sw, sh, dx, dy, dw, dh);

	// get image data
	double w = dw * scaleToRatio;
	double h = dh * scaleToRatio;
	ImageData imageData = null;
	try {
		imageData = context.getImageData(0, 0, w, h);
	} catch (Exception e) {
		// Well bummer
	}
       int ht = (int) h + 10;
       int wt = (int) w + 10;
       
       // Clear the div, clear the drawing canvas then reinsert.  Otherwise, ghosts of the previous image appear.
       canvasDiv.clear();
               
       imageCanvasContext.clearRect(0, 0, imageCanvas.getCoordinateSpaceWidth(), imageCanvas.getCoordinateSpaceHeight());
       
       canvasDiv.add(imageCanvas, 0, 0);
       canvasDiv.add(drawingCanvas, 0, 0);
       
	imageCanvas.setCoordinateSpaceHeight(ht);
	imageCanvas.setCoordinateSpaceWidth(wt);
	drawingCanvas.setCoordinateSpaceHeight(ht);
	drawingCanvas.setCoordinateSpaceWidth(wt);
	canvasDiv.setSize(wt + "px", ht + "px");

	return imageData;
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:74,代码来源:Correlation.java

示例14: scaleImage

import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
private ImageData scaleImage(double scaleToRatio) {
    Canvas canvasTmp = Canvas.createIfSupported();
    Context2d context = canvasTmp.getContext2d();

    int imageHeight = plotImage.getHeight();
    double ch = (imageHeight * scaleToRatio);
    int imageWidth = plotImage.getWidth();
    double cw = (imageWidth * scaleToRatio);

    canvasTmp.setCoordinateSpaceHeight((int) ch);
    canvasTmp.setCoordinateSpaceWidth((int) cw);

    // TODO: make a temp imageElement?
    ImageElement imageElement = ImageElement.as(plotImage.getElement());

    // s = source
    // d = destination
    double sx = 0;
    double sy = 0;
    int imageElementWidth = imageElement.getWidth();
    if (imageElementWidth <= 0) {
        imageElementWidth = imageWidth;
    }
    double sw = imageElementWidth;
    int imageElementHeight = imageElement.getHeight();
    if (imageElementHeight <= 0) {
        imageElementHeight = imageHeight;
    }
    double sh = imageElementHeight;

    double dx = 0;
    double dy = 0;
    double dw = imageElementWidth;
    double dh = imageElementHeight;

    // tell it to scale image
    context.scale(scaleToRatio, scaleToRatio);

    // draw image to canvas
    context.drawImage(imageElement, sx, sy, sw, sh, dx, dy, dw, dh);

    // get image data
    double w = dw * scaleToRatio;
    double h = dh * scaleToRatio;
    ImageData imageData = null;
    try {
        imageData = context.getImageData(0, 0, w, h);
    } catch (Exception e) {
        // well, bummer
    }

    int ht = (int) h + 10;
    int wt = (int) w + 10;
         
    // Clear the div, clear the drawing canvas then reinsert. Otherwise, ghosts of the previous image appear.
    canvasDiv.clear();
            
    imageCanvasContext.clearRect(0, 0, imageCanvas.getCoordinateSpaceWidth(), imageCanvas.getCoordinateSpaceHeight());
    
    canvasDiv.add(imageCanvas, 0, 0);
    canvasDiv.add(drawingCanvas, 0, 0);
    
    imageCanvas.setCoordinateSpaceHeight(ht);
    imageCanvas.setCoordinateSpaceWidth(wt);
    
    drawingCanvas.setCoordinateSpaceHeight(ht);
    drawingCanvas.setCoordinateSpaceWidth(wt);
    
    
    canvasDiv.setSize(wt+"px", ht+"px");
    
    return imageData;
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:74,代码来源:SimplePropPropViewer.java

示例15: onModuleLoad

import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
public void onModuleLoad() {
	
	Canvas canvas = Canvas.createIfSupported();
	canvas.setStyleName("MyCanvas");
	canvas.setCoordinateSpaceWidth(400);
	canvas.setCoordinateSpaceHeight(400);
	RootLayoutPanel.get().add(canvas);
	
	gl = (WebGLRenderingContext)canvas.getContext("experimental-webgl");
	gl.viewport(0, 0, 400, 400);
	
	WebGLBuffer vertexBuffer = gl.createBuffer();
	gl.bindBuffer(ARRAY_BUFFER, vertexBuffer);
	gl.bufferData(ARRAY_BUFFER, Float32Array.create(VERTICES), STATIC_DRAW);

	WebGLShader vertexShader = gl.createShader(VERTEX_SHADER);
	gl.shaderSource(vertexShader, VERTEX_SHADER_SOURCE);
	gl.compileShader(vertexShader);
	
	WebGLShader fragmentShader = gl.createShader(FRAGMENT_SHADER);
	gl.shaderSource(fragmentShader, FRAGMENT_SHADER_SOURCE);
	gl.compileShader(fragmentShader);
	
	program = gl.createProgram();
	gl.attachShader(program, vertexShader);
	gl.attachShader(program, fragmentShader);
	gl.linkProgram(program);
	
	gl.useProgram(program);
	gl.bindBuffer(ARRAY_BUFFER, vertexBuffer);
	
	WebGLUniformLocation texture = gl.getUniformLocation(program, "texture");
	gl.uniform1i(texture, 0);
	
	int posAttr = gl.getAttribLocation(program, "position");
	gl.vertexAttribPointer(posAttr, 3, FLOAT, false, 5*4, 0);
	gl.enableVertexAttribArray(posAttr);
	
	int texAttr = gl.getAttribLocation(program, "texcoord");
	gl.vertexAttribPointer(texAttr, 2, FLOAT, false, 5*4, 3*4);
	gl.enableVertexAttribArray(texAttr);
	
	for(int i=0; i<TEXTURE_URLS.length; i++) {
		loadTexture(TEXTURE_URLS[i], i);
	}
	
}
 
开发者ID:npedotnet,项目名称:TGAReader,代码行数:48,代码来源:TexturedCube.java


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