本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.moveTo方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.moveTo方法的具體用法?Java Context2d.moveTo怎麽用?Java Context2d.moveTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.canvas.dom.client.Context2d
的用法示例。
在下文中一共展示了Context2d.moveTo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: TextDisplayElement
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的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);
}
示例2: drawEllipseHelper
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
* based on http://stackoverflow.com/questions/2172798/how-to-draw-an-oval-in-html5-canvas/2173084#2173084
*/
private static void drawEllipseHelper(Context2d ctx, boolean drawOuterLine, double x, double y, double w, double h) {
double kappa = .5522848f;
double ox = w / 2 * kappa; // control point offset horizontal
double oy = h / 2 * kappa; // control point offset vertical
double xe = x + w; // x-end
double ye = y + h; // y-end
double xm = x + w / 2; // x-middle
double ym = y + h / 2; // y-middle
ctx.beginPath();
ctx.moveTo(x, ym);
ctx.bezierCurveTo(x, ym - oy, xm - ox, y, xm, y);
ctx.bezierCurveTo(xm + ox, y, xe, ym - oy, xe, ym);
ctx.bezierCurveTo(xe, ym + oy, xm + ox, ye, xm, ye);
ctx.bezierCurveTo(xm - ox, ye, x, ym + oy, x, ym);
ctx.fill();
if (drawOuterLine) {
ctx.stroke();
}
}
示例3: drawRoundRectHelper
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
* based on http://js-bits.blogspot.co.at/2010/07/canvas-rounded-corner-rectangles.html
*/
private static void drawRoundRectHelper(Context2d ctx, boolean drawOuterLine, final double x, final double y, final double width, final double height, final double radius) {
ctx.beginPath();
ctx.moveTo(x + radius, y);
ctx.lineTo(x + width - radius, y);
ctx.quadraticCurveTo(x + width, y, x + width, y + radius);
ctx.lineTo(x + width, y + height - radius);
ctx.quadraticCurveTo(x + width, y + height, x + width - radius, y + height);
ctx.lineTo(x + radius, y + height);
ctx.quadraticCurveTo(x, y + height, x, y + height - radius);
ctx.lineTo(x, y + radius);
ctx.quadraticCurveTo(x, y, x + radius, y);
ctx.closePath();
ctx.fill();
if (drawOuterLine) {
ctx.stroke();
}
}
示例4: drawDashedLine
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void drawDashedLine(int x, int y, int length, int dash, int space, boolean horizontal, Context2d ctx) {
if (horizontal)
while (x < length) {
ctx.moveTo(x, y);
x += dash;
ctx.lineTo(x, y);
x += space;
}
else
while (y < length) {
ctx.moveTo(x, y);
y += dash;
ctx.lineTo(x, y);
y += space;
}
}
示例5: MultiLineTextDisplayElement
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的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);
}
示例6: PolygonDisplayElement
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的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());
}
示例7: drawPath
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public static void drawPath(Path path, Context2d context) {
context.beginPath();
for (PathElement e : path.getElements()) {
switch (e.getType()) {
case ClosePath:
context.closePath();
break;
case CubicCurveTo:
CubicCurveTo c = (CubicCurveTo) e;
context.bezierCurveTo(c.cp1.x, c.cp1.y, c.cp2.x, c.cp2.y, c.p.x, c.p.y);
break;
case LineTo:
LineTo l = (LineTo) e;
context.lineTo(l.p.x, l.p.y);
break;
case MoveTo:
MoveTo m = (MoveTo) e;
context.moveTo(m.p.x, m.p.y);
break;
case QuadraticCurveTo:
QuadraticCurveTo q = (QuadraticCurveTo) e;
context.quadraticCurveTo(q.cp.x, q.cp.y, q.p.x, q.p.y);
break;
}
}
}
示例8: drawCone
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
* Draw a cone. Does not call beginPath().
*/
public static void drawCone(Context2d g, double x, double y, double radius, double height) {
double kappa = .5522848;
double w = (2 * radius) * SQRT1_5;
double h = (2 * radius) * SQRT0_5;
double xm = w / 2f; // x-middle
double ym = h / 2f; // y-middle
double ox = xm * kappa; // control point offset horizontal
double oy = ym * kappa; // control point offset vertical
g.translate(x, y);
g.moveTo(w, ym);
g.bezierCurveTo(w, ym + oy, xm + ox, h, xm, h);
g.bezierCurveTo(xm - ox, h, 0, ym + oy, 0, ym);
g.lineTo(xm, ym - height);
g.closePath();
g.translate(-x, -y);
}
示例9: drawEllipse
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
* Draw an ellipse. Does not call beginPath().
*/
public static void drawEllipse(Context2d g, double x, double y, double w, double h) {
double kappa = .5522848;
double xm = w / 2f; // x-middle
double ym = h / 2f; // y-middle
double ox = xm * kappa; // control point offset horizontal
double oy = ym * kappa; // control point offset vertical
g.translate(x, y);
g.moveTo(0, ym);
g.bezierCurveTo(0, ym - oy, xm - ox, 0, xm, 0);
g.bezierCurveTo(xm + ox, 0, w, ym - oy, w, ym);
g.bezierCurveTo(w, ym + oy, xm + ox, h, xm, h);
g.bezierCurveTo(xm - ox, h, 0, ym + oy, 0, ym);
g.translate(-x, -y);
}
示例10: drawRoundedRect
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
* Draw a rounded rect. Does not call beginPath().
*/
public static void drawRoundedRect(Context2d g, double x, double y, double width, double height,
double topLeftRadiusX, double topLeftRadiusY, double topRightRadiusX, double topRightRadiusY,
double bottomLeftRadiusX, double bottomLeftRadiusY, double bottomRightRadiusX,
double bottomRightRadiusY) {
g.translate(x, y);
g.moveTo(topLeftRadiusX, 0);
g.lineTo(width - topRightRadiusX, 0);
x = width;
y = 0;
g.bezierCurveTo(x, y, x, y, width, topRightRadiusY);
g.lineTo(width, height - bottomRightRadiusY);
x = width;
y = height;
g.bezierCurveTo(x, y, x, y, width - bottomRightRadiusX, height);
g.lineTo(bottomLeftRadiusX, height);
x = 0;
y = height;
g.bezierCurveTo(x, y, x, y, 0, height - bottomLeftRadiusY);
g.lineTo(0, topLeftRadiusY);
x = 0;
y = 0;
g.bezierCurveTo(x, y, x, y, topLeftRadiusX, 0);
g.translate(-x, -y);
}
示例11: continueDrawing
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void continueDrawing(int clientX, int clientY) {
Context2d context = canv.getContext2d();
float x = clientX - canv.getAbsoluteLeft() + Window.getScrollLeft();
float y = clientY - canv.getAbsoluteTop() + Window.getScrollTop();
if (getDistance(last_x, last_y, x, y) > dist_buffer) {
context.beginPath();
context.setLineWidth(5);
context.setStrokeStyle(color);
context.moveTo(last_x, last_y);
context.lineTo(x, y);
context.moveTo(x, y);
context.closePath();
context.stroke();
points.add(new DrawPoint(x, y));
last_x = x;
last_y = y;
if (lastUpdate + updateTime < new Date().getTime()) {
endDrawing();
startDrawing(clientX, clientY);
}
}
}
示例12: drawLine
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void drawLine(DrawLine line) {
Context2d context = canv.getContext2d();
context.beginPath();
context.setLineWidth(5);
context.setStrokeStyle(line.color);
boolean first = true;
for(DrawPoint point : line.points) {
if (first) {
context.moveTo(point.x, point.y);
first = false;
} else {
context.lineTo(point.x, point.y);
context.moveTo(point.x, point.y);
}
}
context.closePath();
context.stroke();
lines++;
}
示例13: drawTics
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void drawTics(int count, int len, long factor, String unit) {
Context2d context = canvas.getContext2d();
context.setFillStyle(color);
context.setStrokeStyle(color);
for (int i = 1; i <= count; i++) {
context.beginPath();
context.moveTo(len * i, 0);
context.lineTo(len * i, 15);
context.closePath();
context.stroke();
context.fillText((i * factor) + unit, len * i, 25, 20);
}
}
示例14: drawLine
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void drawLine(Point startPoint, Point endPoint, ColorModel color) {
Context2d context2d = getContext(defaultGlobalCompositeOperation);
context2d.beginPath();
context2d.setStrokeStyle("#" + color.toStringRgb());
context2d.moveTo(startPoint.getX(), startPoint.getY());
context2d.lineTo(endPoint.getX(), endPoint.getY());
context2d.stroke();
}
示例15: eraseLine
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void eraseLine(Point startPoint, Point endPoint) {
Context2d context2d = getContext(destinationOutCompositeOperation);
context2d.beginPath();
context2d.moveTo(startPoint.getX(), startPoint.getY());
context2d.lineTo(endPoint.getX(), endPoint.getY());
context2d.setStrokeStyle(eraserColor);
context2d.stroke();
}