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


Java Context2d.setLineWidth方法代碼示例

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


在下文中一共展示了Context2d.setLineWidth方法的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: 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

示例3: drawText

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void drawText(String string, float x, float y, Paint fill, Paint stroke) {
	if (bitmap == null) {
		//log.debug("no bitmap set");
		return;
	}

	GwtPaint p = (GwtPaint) fill;

	if (p.stroke && GwtGdxGraphics.NO_STROKE_TEXT)
		return;

	Context2d ctx = bitmap.pixmap.getContext();
	ctx.setFont(p.font);

	if (p.stroke) {
		ctx.setLineWidth(p.strokeWidth);
		ctx.setStrokeStyle(p.color);
		ctx.strokeText(string, (int) (x + 1), (int) (y + 1));
	} else {
		ctx.setFillStyle(p.color);
		ctx.fillText(string, (int) (x + 1), (int) (y + 1));
	}
}
 
開發者ID:opensciencemap,項目名稱:vtm,代碼行數:25,代碼來源:GwtCanvas.java

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

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

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

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

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

示例9: setStyle

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void setStyle(Context2d ctx, Style style) {
	if (style.getBackgroundColor() != null) {
		ctx.setFillStyle(Converter.convert(style.getBackgroundColor()));
	}
	ColorOwn fgColor = getOverlay().getForegroundColor() != null ? getOverlay().getForegroundColor() : style.getForegroundColor();
	if (fgColor != null) {
		ctx.setStrokeStyle(Converter.convert(fgColor));
	}
	ctx.setLineWidth(style.getLineWidth());
	setLineDash(ctx, style.getLineType(), style.getLineWidth());
}
 
開發者ID:umlet,項目名稱:umlet,代碼行數:12,代碼來源:DrawHandlerGwt.java

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

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

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

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

示例14: getContext

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private Context2d getContext(String globalCompositeOperation) {
    Context2d context2d = canvas.getContext2d();
    context2d.setLineWidth(currentLineWidth);
    context2d.setGlobalCompositeOperation(globalCompositeOperation);
    return context2d;
}
 
開發者ID:YoungDigitalPlanet,項目名稱:empiria.player,代碼行數:7,代碼來源:CanvasViewImpl.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);
	
	// Draw 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();
	
	// Write text
	context.setFillStyle("black");
	context.setFont("bold 60px sans-serif");
	context.setTextBaseline("top");
	
	if (el.text().contains("<") && el.text().contains(">")) {
		context.fillText(el.label() + "...", el.baseLeft(), el.baseTop(), el.baseWidth());
		el.neverShowPopup(false);
	} else {
		String[] words = el.text().split(" ");
		String line = "";
		
		int y = el.baseTop();
		
		for (int i = 0; i < words.length; i++) {
			String test_line = line + words[i] + " ";
			
			if (context.measureText(test_line).getWidth() > el.baseWidth() && i > 0
					|| words[i].contains("\n")) {
				context.fillText(line, el.baseLeft(), y);
				y += step;
				line = words[i] + " ";
				
				if (y + step > el.baseTop() + el.baseHeight()) {
    				context.restore();
    				el.neverShowPopup(false);
    				cb.onDrawn();
    				return;
    			}
			} else {
				line = test_line;
			}
		}
		context.fillText(line, el.baseLeft(), y);
		el.neverShowPopup(true);
	}
	context.restore();
	
	cb.onDrawn();
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:69,代碼來源:MultiLineTextDrawable.java


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