當前位置: 首頁>>代碼示例>>Java>>正文


Java Context2d.beginPath方法代碼示例

本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.beginPath方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.beginPath方法的具體用法?Java Context2d.beginPath怎麽用?Java Context2d.beginPath使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gwt.canvas.dom.client.Context2d的用法示例。


在下文中一共展示了Context2d.beginPath方法的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);
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:27,代碼來源:TextDisplayElement.java

示例2: drawShape

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
 * Rysuje zakonczenie linii
 *
 * @param shapeName
 * @param context
 * @param centerX
 * @param centerY
 * @param startX
 * @param startY
 */
private void drawShape(String shapeName, Context2d context, double centerX, double centerY, double startX, double startY) {
    if ("dot".equals(shapeName)) {
        context.beginPath();
        context.arc(centerX, centerY, 3, 0, 2 * Math.PI, false);
        context.closePath();
        context.fill();
    } else if ("arrow".equals(shapeName)) {
        CanvasArrow canvas = new CanvasArrow(context, startX, startY, centerX, centerY);
        canvas.draw();
    }
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:22,代碼來源:LabelledImgContent.java

示例3: createBillboard

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的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

示例4: 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();
	}
}
 
開發者ID:umlet,項目名稱:umlet,代碼行數:24,代碼來源:DrawHandlerGwt.java

示例5: 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();
	}
}
 
開發者ID:umlet,項目名稱:umlet,代碼行數:21,代碼來源:DrawHandlerGwt.java

示例6: 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);
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:35,代碼來源:MultiLineTextDisplayElement.java

示例7: 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());
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:30,代碼來源:PolygonDisplayElement.java

示例8: 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;
		}
	}
}
 
開發者ID:Xenoage,項目名稱:Zong,代碼行數:27,代碼來源:GwtPath.java

示例9: 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++;
}
 
開發者ID:Mazku,項目名稱:collabsketch_vaadin,代碼行數:20,代碼來源:CollabSketchWidget.java

示例10: render

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
  if (!isVisible()) {
    return;
  }
  redrawNeeded = false;
  g.save();
  g.translate(x, y);

  if (redrawBufferNeeded) {
    buffer.render();
    redrawBufferNeeded = false;
  }
  if (null != backgroundColor) {
    g.beginPath();
    g.rect(0, 0, width, height);
    g.setFillStyle(backgroundColor);
    g.fill();
  }
  buffer.flip(g);
  g.restore();
}
 
開發者ID:cjmalloy,項目名稱:GwtGameUi,代碼行數:23,代碼來源:Label.java

示例11: 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();
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:10,代碼來源:CanvasViewImpl.java

示例12: 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();
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:10,代碼來源:CanvasViewImpl.java

示例13: draw

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void draw(CanvasWidget canvas)
{
    curve.get(0).draw(canvas);
    canvas.moveTo((double) curve.get(0).getX(), (double) curve.get(0).getY());
    Context2d ctx = canvas.getContext2d();
    ctx.beginPath();
    ctx.setLineWidth(5);
    ctx.setStrokeStyle(canvas.color);
    for (int i = 1; i < curve.size(); i++) {
        curve.get(i).draw(canvas);
        canvas.moveTo((double) curve.get(i).getX(), (double) curve.get(i).getY());
        canvas.lineTo((double) curve.get(i).getX(), (double) curve.get(i).getY());
    }
}
 
開發者ID:LiogkyTeam,項目名稱:DrowGutt,代碼行數:15,代碼來源:Curve.java

示例14: endDrawingLine

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
protected void endDrawingLine(String color, int thickness, int clientX, int clientY){
    int x1 = clientX - canv.getAbsoluteLeft() + Window.getScrollLeft();
    int y1 = clientY - canv.getAbsoluteTop() + Window.getScrollTop();
    Context2d ctx = canv.getContext2d();
    ctx.beginPath();
    ctx.setLineWidth(thickness);
    ctx.setStrokeStyle(color);
    ctx.moveTo(x, y);
    ctx.lineTo(x1, y1);
    ctx.closePath();
    ctx.stroke();
    rpc.addItem(new Line(x, y, x1, y1, color));
}
 
開發者ID:LiogkyTeam,項目名稱:DrowGutt,代碼行數:14,代碼來源:CanvasWidget.java

示例15: endDrawingRect

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
protected void endDrawingRect(int clientX, int clientY, int thickness){
    int x1 = clientX - canv.getAbsoluteLeft() + Window.getScrollLeft();
    int y1 = clientY - canv.getAbsoluteTop() + Window.getScrollTop();
    Context2d ctx = canv.getContext2d();
    ctx.beginPath();
    ctx.setLineWidth(thickness);
    ctx.setStrokeStyle("000000");
    ctx.strokeRect(min(x, x1), min(y, y1), abs(x - x1), abs(y - y1));
    ctx.closePath();
    Rectangle Rect = new Rectangle(min(x, x1), min(y, y1), max(x, x1), max(y, y1));
    x = 0;
    y = 0;
}
 
開發者ID:LiogkyTeam,項目名稱:DrowGutt,代碼行數:14,代碼來源:CanvasWidget.java


注:本文中的com.google.gwt.canvas.dom.client.Context2d.beginPath方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。