本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.setStrokeStyle方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.setStrokeStyle方法的具體用法?Java Context2d.setStrokeStyle怎麽用?Java Context2d.setStrokeStyle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.canvas.dom.client.Context2d
的用法示例。
在下文中一共展示了Context2d.setStrokeStyle方法的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;
}
示例2: drawGridOn
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public static void drawGridOn(Context2d context2d) {
if (gridCanvas == null) {
gridCanvas = Canvas.createIfSupported();
gridCanvas.setCoordinateSpaceWidth(3000);
gridCanvas.setCoordinateSpaceHeight(2000);
int width = gridCanvas.getCoordinateSpaceWidth();
int height = gridCanvas.getCoordinateSpaceHeight();
Context2d backgroundContext = gridCanvas.getContext2d();
backgroundContext.setStrokeStyle(Converter.convert(ColorOwn.BLACK.transparency(Transparency.SELECTION_BACKGROUND)));
for (int i = 0; i < width; i += SharedConstants.DEFAULT_GRID_SIZE) {
drawLine(backgroundContext, i, 0, i, height);
}
for (int i = 0; i < height; i += SharedConstants.DEFAULT_GRID_SIZE) {
drawLine(backgroundContext, 0, i, width, i);
}
}
context2d.drawImage(gridCanvas.getCanvasElement(), 0, 0);
}
示例3: 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();
}
}
示例4: 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);
}
}
示例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++;
}
示例6: 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();
}
示例7: 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();
}
示例8: 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());
}
}
示例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));
}
示例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;
}
示例11: 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());
}
示例12: 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();
}
示例13: paintFragmentNumbers
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void paintFragmentNumbers(Context2d g) {
if (mFragmentNoColor != null && mMolecule != null) {
double averageBondLength = calculateAverageBondLength();
g.save();
// FillStrokeStyle oldStroke = g.getStrokeStyle();
// FillStrokeStyle oldFill = g.getFillStyle();
g.setStrokeStyle(mFragmentNoColor);
g.setFillStyle(mFragmentNoColor);
//Font font = Font.font("Helvetica", FontWeight.BOLD, (int) (1.6 * averageBondLength));
int size = (int) (1.6 * averageBondLength);
String font = "bold " + size + "px Helvetica";
g.setFont(font);
// com.sun.javafx.tk.FontMetrics fm = Toolkit.getToolkit().getFontLoader().getFontMetrics(font);
for (int i = 0; i < mMolecule.length; i++) {
if (mMolecule[i].getAllAtoms() != 0) {
Point cog = new Point();
for (int atom = 0; atom < mMolecule[i].getAllAtoms(); atom++) {
cog.x += mMolecule[i].getAtomX(atom);
cog.y += mMolecule[i].getAtomY(atom);
}
cog.x /= mMolecule[i].getAllAtoms();
cog.y /= mMolecule[i].getAllAtoms();
cog.x = (int) mDepictor[i].getTransformation().transformX(cog.x);
cog.y = (int) mDepictor[i].getTransformation().transformY(cog.y);
String str = (mReactantOrCoreCount == -1) ? "F" + (i + 1)
: (i < mReactantOrCoreCount) ? "" + (char) ('A' + i)
: (mIsMarkushStructure) ? "R" + (i + 1 - mReactantOrCoreCount)
: "P" + (i + 1 - mReactantOrCoreCount);
drawString(g,str,cog.x,cog.y);
// int width = (int) getStringWidth(str);
// g.fillText(str, cog.x - width / 2, cog.y + (int) (0.3 * fm.getLineHeight()));
}
}
g.restore();
}
}
示例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();
}
示例15: 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();
}