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


Java Context2d.stroke方法代碼示例

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


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

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

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

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void repaint(Tool tool, int x, int y, int tileSize){
	Context2d context = canvasLayer.getContext();
	context.clearRect(0, 0, canvasLayer.getWidth(), canvasLayer.getHeight());
	
	if (tool == Tool.BRUSH) {
		
	} else if (tool == Tool.ERASER) {
		Eraser eraser = ToolBox.getInstance().getEraser();
		int size = eraser.getSize()*tileSize;
		context.save();
		context.setLineWidth(1.0);
		context.setStrokeStyle(CssColors.RED);
		context.setFillStyle(CssColors.LIGHT_GREY);
		
		context.rect(x, y, size, size);
		context.stroke();
		context.setGlobalAlpha(0.25);
		context.fill();
		
		context.restore();
	}
}
 
開發者ID:PsiAmp,項目名稱:punk-toads,代碼行數:23,代碼來源:CursorOverlay.java

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

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

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

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

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

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

示例11: drawGrid

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void drawGrid() {
	Context2d ctx = canvasLayer.getContext();
	
	ctx.save();
	ctx.translate(0.5, 0.5);
	ctx.setStrokeStyle(CssColors.BLACK);
	ctx.setLineWidth(1);
	
	ctx.beginPath();

	// Horizontal grid lines
	for (int i = startX; i < height; i += stepY) {
		if (dashed) {
			drawDashedLine(startX, i, width, 2, 2, true, ctx);
		} else {
			ctx.moveTo(startX, i);
			ctx.lineTo(width, i);
		}
	}

	// Vertical grid lines
	for (int i = startY; i < width; i += stepX) {
		if (dashed) {
			drawDashedLine(i, startY, height, 2, 2, false, ctx);
		} else {
			ctx.moveTo(i, startY);
			ctx.lineTo(i, height);
		}

	}
	
	ctx.stroke();
	ctx.restore();
}
 
開發者ID:PsiAmp,項目名稱:punk-toads,代碼行數:35,代碼來源:Grid.java

示例12: render

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void render() {
    Context2d context = canvas.getContext2d();
    context.setFillStyle("white");
    context.setStrokeStyle("grey");
    context.fillRect(0, 0, 600, 600);
    context.save();
    context.translate(0, 600);
    context.scale(1, -1);
    context.scale(100, 100);
    context.setLineWidth(0.01);
    for (Body body = scene.getWorld().getBodyList(); body != null; body = body.getNext()) {
        Vec2 center = body.getPosition();
        context.save();
        context.translate(center.x, center.y);
        context.rotate(body.getAngle());
        for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
            Shape shape = fixture.getShape();
            if (shape.getType() == ShapeType.CIRCLE) {
                CircleShape circle = (CircleShape) shape;
                context.beginPath();
                context.arc(circle.m_p.x, circle.m_p.y, circle.getRadius(), 0, Math.PI * 2, true);
                context.closePath();
                context.stroke();
            } else if (shape.getType() == ShapeType.POLYGON) {
                PolygonShape poly = (PolygonShape) shape;
                Vec2[] vertices = poly.getVertices();
                context.beginPath();
                context.moveTo(vertices[0].x, vertices[0].y);
                for (int i = 1; i < poly.getVertexCount(); ++i) {
                    context.lineTo(vertices[i].x, vertices[i].y);
                }
                context.closePath();
                context.stroke();
            }
        }
        context.restore();
    }
    context.restore();
}
 
開發者ID:konsoletyper,項目名稱:teavm,代碼行數:40,代碼來源:BenchmarkStarter.java

示例13: draw

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void draw() {
    // Draw a line from the source port to the current mouse coordinates
    Context2d canvas = getCanvas();
    IPoint coordinates = getModel().getMouseCoordinates();

    canvas.save();
    canvas.beginPath();
    canvas.setStrokeStyle("#000");
    canvas.moveTo(sourcePort.getConnectorX(), sourcePort.getConnectorY());
    canvas.lineTo(coordinates.getX(), coordinates.getY());
    canvas.closePath();
    canvas.stroke();
    canvas.restore();
}
 
開發者ID:peergreen,項目名稱:vaadin-diagram,代碼行數:16,代碼來源:IntermediateConnectorUI.java

示例14: render

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
  g.save();
  g.setFillStyle("#F33");
  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

示例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.stroke方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。