本文整理汇总了Java中com.google.gwt.canvas.client.Canvas.setHeight方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.setHeight方法的具体用法?Java Canvas.setHeight怎么用?Java Canvas.setHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.gwt.canvas.client.Canvas
的用法示例。
在下文中一共展示了Canvas.setHeight方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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);
}
示例3: 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();
}
示例4: measureHeight
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
private static int measureHeight(Font font, String text) {
Canvas canvas = canvas();
Context2d ctx = canvas.getContext2d();
ctx.setFont(getFontString(font));
ctx.setFillStyle("rgb(255, 0, 0)");
int width = (int) ctx.measureText(text).getWidth();
int canvasHeight = font.getSize() * 2;
canvas.setHeight(canvasHeight + "px");
canvas.setHeight(font.getSize() * 2 + "px");
canvas.setWidth(width + "px");
ctx.fillText(text, 0, font.getSize());
ImageData data = ctx.getImageData(0, 0, width, canvasHeight);
int firstY = canvasHeight - 1;
int lastY = 0;
for (int x = 0; x < width; x++) {
for (int y = 0; y < canvasHeight; y++) {
int red = data.getRedAt(x, y);
if (red != 0) {
if (firstY > y) {
firstY = y;
}
if (lastY < y) {
lastY = y;
}
}
}
}
return lastY - firstY;
}
示例5: initCanvas
import com.google.gwt.canvas.client.Canvas; //导入方法依赖的package包/类
private void initCanvas(Canvas canvas) {
canvas.setWidth(width + "px");
canvas.setHeight(height + "px");
canvas.setCoordinateSpaceWidth(width);
canvas.setCoordinateSpaceHeight(height);
}