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


Java Context2d.closePath方法代碼示例

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


在下文中一共展示了Context2d.closePath方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

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

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

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

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

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

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

示例7: 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);
	}
}
 
開發者ID:metafora-project,項目名稱:ReflectionTool,代碼行數:17,代碼來源:Timeline.java

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

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

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

示例11: getImage

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private CanvasElement getImage() {
    if (!Cesium.defined(particleCanvas)) {
        particleCanvas = RootPanel.get().getElement().getOwnerDocument().createCanvasElement();
        particleCanvas.setWidth(20);
        particleCanvas.setHeight(20);
        Context2d context2d = particleCanvas.getContext2d();
        context2d.beginPath();
        context2d.arc(8, 8, 8, 0, Math.TWO_PI(), true);
        context2d.closePath();
        context2d.setFillStyle("rgb(255, 255, 255)");
        context2d.fill();
        Cesium.log(particleCanvas);
    }
    return particleCanvas;
}
 
開發者ID:iSergio,項目名稱:gwt-cs,代碼行數:16,代碼來源:ParticleSystemFireworks.java

示例12: render

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
  g.save();
  g.setFillStyle("#33F");
  g.setStrokeStyle("#999");
  g.beginPath();
  GraphicsUtil.drawRoundedRect(g, 0.5, 0.5, width - 1, height - 1, 8);
  g.closePath();
  g.fill();
  g.stroke();
  renderText(g);
  g.restore();
}
 
開發者ID:cjmalloy,項目名稱:GwtGameUi,代碼行數:14,代碼來源:DefaultAccordianHandleSkin.java

示例13: render

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
  g.save();
  g.setFillStyle("#333");
  g.setStrokeStyle("#999");
  g.beginPath();
  GraphicsUtil.drawRoundedRect(g, 0.5, 0.5, width - 1, height - 1, 8);
  g.closePath();
  g.fill();
  g.stroke();
  renderText(g);
  g.restore();
}
 
開發者ID:cjmalloy,項目名稱:GwtGameUi,代碼行數:14,代碼來源:DefaultButtonSkin.java

示例14: draw

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void draw(Context2d context, DisplayArea area, OnDrawnCallback cb) {
    double zoom = area.zoom();
    context.save();

    context.translate(-area.viewportLeft(), -area.viewportTop());
    context.scale(zoom, zoom);

    // outline
    int[][] coords = el.coordinates();

    context.beginPath();
    context.moveTo(coords[0][0], coords[0][1]);

    for (int i = 1; i < coords.length; i++) {
        context.lineTo(coords[i][0], coords[i][1]);
    }

    context.setLineWidth(6);
    context.stroke();
    
    context.setGlobalAlpha(0.3);
    context.setFillStyle("white");
    context.fill();
    context.setGlobalAlpha(1.0);
    
    context.closePath();

    // text
    context.setFillStyle("black");
    context.setFont("bold 60px sans-serif");
    context.setTextBaseline("top");
    context.fillText(el.text(), el.baseLeft(), el.baseTop(), el.baseWidth());

    context.restore();
    
    cb.onDrawn();
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:39,代碼來源:TextDrawable.java

示例15: draw

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void draw(Context2d context, DisplayArea area, OnDrawnCallback cb) {
    double zoom = area.zoom();

    context.save();

    context.translate(-area.viewportLeft(), -area.viewportTop());
    context.scale(zoom, zoom);

    context.beginPath();
    context.moveTo(coords[0][0], coords[0][1]);

    for (int i = 1; i < coords.length; i++) {
        context.lineTo(coords[i][0], coords[i][1]);
    }

    context.setLineWidth(6);
    context.stroke();
    
    context.setGlobalAlpha(0.3);
    context.setFillStyle("white");
    context.fill();
    context.setGlobalAlpha(1.0);
    
    context.closePath();

    context.restore();
    
    cb.onDrawn();
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:31,代碼來源:PolygonDrawable.java


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