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


Java Canvas类代码示例

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


Canvas类属于com.google.gwt.canvas.client包,在下文中一共展示了Canvas类的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: initializeLoader

import com.google.gwt.canvas.client.Canvas; //导入依赖的package包/类
protected void initializeLoader(String resourceSrc) {
    loader = createJsLoader.get();
    loader.addManifestLoadHandler(this);
    loader.setLibraryURL(getLibraryURL(resourceSrc));
    loader.addCompleteHandler(new CompleteHandler() {

        @Override
        public void onComplete() {
            Optional<Canvas> simulationCanvas = simulationCanvasProvider.getSimulationCanvas(loader);
            if (simulationCanvas.isPresent()) {
                initializeCanvas(simulationCanvas.get());
            }
        }
    });
    loader.load(resourceSrc);
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:17,代码来源:SimulationModule.java

示例6: 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;
}
 
开发者ID:iSergio,项目名称:gwt-cs,代码行数:22,代码来源:MarkerGroup.java

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

示例8: 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();
	}
 
开发者ID:waynedyck,项目名称:mgwt-traffic-flow,代码行数:19,代码来源:SeattleViewGwtImpl.java

示例9: 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();
	}
 
开发者ID:waynedyck,项目名称:mgwt-traffic-flow,代码行数:19,代码来源:TacomaViewGwtImpl.java

示例10: 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);
}
 
开发者ID:umlet,项目名称:umlet,代码行数:19,代码来源:CanvasUtils.java

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

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

示例13: drawCanvas

import com.google.gwt.canvas.client.Canvas; //导入依赖的package包/类
private static void drawCanvas(Canvas canvas,List<Double> points,boolean fill){
	canvas.getContext2d().beginPath();
	for(int i=0;i<points.size();i+=2){
		double x=points.get(i);
		double y=points.get(i+1);
		if(i==0){
			canvas.getContext2d().moveTo(x, y);
		}else{
			canvas.getContext2d().lineTo(x, y);
		}
	}
	canvas.getContext2d().closePath();
	
	if(fill){
		canvas.getContext2d().fill();
	}else{
		canvas.getContext2d().stroke();
	}
}
 
开发者ID:akjava,项目名称:GWTModelWeight,代码行数:20,代码来源:UvPackToolPanel.java

示例14: 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);
}
 
开发者ID:akjava,项目名称:GWTModelWeight,代码行数:16,代码来源:UvPackToolPanel.java

示例15: doRepreview

import com.google.gwt.canvas.client.Canvas; //导入依赖的package包/类
protected void doRepreview() {
	LogUtils.log("doRepreview1");
	int margin=InpaintEngine.INPAINT_MARGIN;
	if(maskImageElement==null){
		 Window.alert("no mask element");
		 return;
	}
	LogUtils.log("doRepreview1");
	ImageElementUtils.copytoCanvasWithMargin(maskImageElement, sharedCanvas,true,margin,true);
	
	Canvas grayscale=CanvasUtils.convertToGrayScale(sharedCanvas, null);
	CanvasUtils.copyTo(grayscale, sharedCanvas);
	
	
	ImageData maskData=CanvasUtils.getImageData(sharedCanvas);
	
	greyScaleMaskPanel.clear();
	
	addToPanel(greyScaleMaskPanel,maskData);
	
	mainTab.selectTab(1);
	LogUtils.log("doRepreview4");
	//CanvasUtils.copyTo(maskData,sharedCanvas);
	//String dataUrl=sharedCanvas.toDataUrl();
	//listener.createGreyScaleMaks(maskData);
}
 
开发者ID:akjava,项目名称:gwthtml5apps,代码行数:27,代码来源:Inpaint.java


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