本文整理汇总了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;
}
示例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: 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);
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
示例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);
}
示例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();
}
示例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;
}
示例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();
}
}
示例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);
}
示例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);
}