本文整理汇总了Java中javafx.scene.canvas.GraphicsContext.setStroke方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsContext.setStroke方法的具体用法?Java GraphicsContext.setStroke怎么用?Java GraphicsContext.setStroke使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.canvas.GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext.setStroke方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void draw(final GraphicsContext CTX, final boolean FILL, final boolean STROKE) {
PathIterator pi = getPathIterator(new Affine());
CTX.setFillRule(WindingRule.WIND_EVEN_ODD == pi.getWindingRule() ? FillRule.EVEN_ODD : FillRule.NON_ZERO);
CTX.beginPath();
double[] seg = new double[6];
int segType;
while(!pi.isDone()) {
segType = pi.currentSegment(seg);
switch (segType) {
case PathIterator.MOVE_TO : CTX.moveTo(seg[0], seg[1]); break;
case PathIterator.LINE_TO : CTX.lineTo(seg[0], seg[1]); break;
case PathIterator.QUAD_TO : CTX.quadraticCurveTo(seg[0], seg[1], seg[2], seg[3]);break;
case PathIterator.BEZIER_TO: CTX.bezierCurveTo(seg[0], seg[1], seg[2], seg[3], seg[4], seg[5]);break;
case PathIterator.CLOSE : CTX.closePath();break;
default : break;
}
pi.next();
}
if (FILL) { CTX.setFill(fill); CTX.fill(); }
if (STROKE) { CTX.setStroke(stroke); CTX.stroke(); }
}
示例2: draw
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void draw(DungeonTileRenderer renderer, GraphicsContext g)
{
RAND.setSeed((long)(renderer.posX * 17 + renderer.posY));
double ds = MAX_BORDER - MIN_BORDER;
double dx = RAND.nextDouble() * ds + MIN_BORDER;
double dy = RAND.nextDouble() * ds + MIN_BORDER;
double dw = RAND.nextDouble() * ds + MIN_BORDER;
double dh = RAND.nextDouble() * ds + MIN_BORDER;
drawBlock(renderer, g, this.chestPaint, dx, dy, 1 - dx - dw, 1 - dy - dh);
if (this.outlinePaint != null)
{
g.setStroke(this.outlinePaint);
}
g.setLineWidth(OUTLINE_WIDTH);
g.strokeRect(dx, dy, 1 - dx - dw, 1 - dy - dh);
}
示例3: render
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void render(GraphicsContext g)
{
g.setFill(COLOR_BACKGROUND);
g.fillRect(this.x, this.y, this.width, this.height);
g.setLineWidth(this.enabled ? OUTLINE_LINE_WIDTH : INACTIVE_LINE_WIDTH);
g.setStroke(this.outline);
g.strokeRoundRect(this.x, this.y, this.width, this.height,
OUTLINE_ROUND_RADIUS, OUTLINE_ROUND_RADIUS);
this.onRender(g);
if (!this.enabled)
{
g.setFill(COLOR_DISABLED_OVERLAY);
g.fillRoundRect(this.x, this.y, this.width, this.height,
OUTLINE_ROUND_RADIUS, OUTLINE_ROUND_RADIUS);
}
}
示例4: drawGrid
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void drawGrid() {
GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
// Task: draw a grid paper with horizontal lines 20 pixels apart
// and the vertical lines 20 pixels apart, as well
double width = drawingCanvas.getWidth();
double height = drawingCanvas.getHeight();
gc.setStroke(Color.RED);
for (int x = 0; x <= width; x += 20)
gc.strokeLine(x, 0, x, height);
for (int y = 0; y <= height; y += 20)
gc.strokeLine(0, y, width, y);
gc.setStroke(Color.BLUE);
for (int x = 0; x <= width; x += 100)
gc.strokeLine(x, 0, x, height);
for (int y = 0; y <= height; y += 100)
gc.strokeLine(0, y, width, y);
}
示例5: drawTextTick
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
* Draw text tick
* @param x POS
* @param y POS
* @param value - the text to be drawn
*/
@Override
public void drawTextTick(double x, double y, double value) {
GraphicsContext gc = getGraphicsContext2D();
double bigTickLength = 10; //Big Tick
//Draw ticks and draw texts
gc.setLineWidth(0.1);
gc.setStroke(ChartTickColorProperty.getValue());
gc.strokeLine(x, y, x + bigTickLength, y);
String strValue = "";
if (value >= 0 && value <= 0.01) {
strValue = String.format("%.4f", value);
}
else if (value > 0.01 && value <= 0.1) {
strValue = String.format("%.3f", value);
}
else if (value > 0.1 && value <= 1.0) {
strValue = String.format("%.3f", value);
}
else if (value > 1.0 && value <= 10.0) {
strValue = String.format("%.2f", value);
}
else {
strValue = String.format("%.2f", value);
}
gc.setFill(ChartTickColorProperty.getValue());
gc.fillText(strValue, x + bigTickLength + 3, y + 5);
}
示例6: drawBorder
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private void drawBorder(GraphicsContext g2d) {
// fill it in
g2d.setFill(Paint.valueOf("WHITE"));
g2d.fillRect(0, 0, width, height);
// draw bordere
g2d.setStroke(Paint.valueOf("BLACK"));
g2d.setLineWidth(1);
g2d.strokeRect(0, 0, width, height);
}
示例7: drawExportArea
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public static void drawExportArea(GraphicsContext g, Rectangle2D area)
{
g.setStroke(COLOR_EXPORT_AREA);
g.setLineWidth(EXPORT_LINE_WIDTH);
g.strokeRect(area.getMinX(), area.getMinY(),
area.getWidth(), area.getHeight());
}
示例8: drawTextTick
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawTextTick(double x, double y, double value) {
GraphicsContext gc = getGraphicsContext2D();
double bigTickLength = 10; //Big Tick
//Draw ticks and draw texts
gc.setLineWidth(0.1);
gc.setStroke(ChartTickColorProperty.getValue());
gc.strokeLine(x, y, x + bigTickLength, y);
String strValue = "";
if (value >= 0 && value <= 0.01) {
strValue = String.format("%.4f m", value);
}
else if (value > 0.01 && value <= 0.1) {
strValue = String.format("%.3f m", value);
}
else if (value > 0.1 && value <= 1.0) {
strValue = String.format("%.3f m", value);
}
else if (value > 1.0 && value <= 10.0) {
strValue = String.format("%.2f m", value);
}
else {
strValue = String.format("%.2f m", value);
}
gc.setFill(ChartTickColorProperty.getValue());
gc.fillText(strValue, x + bigTickLength + 3, y + 5);
}
示例9: drawGrid
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private void drawGrid() {
double width = drawingCanvas.getWidth();
double height = drawingCanvas.getHeight();
double dx = 20;
double dy = 20;
GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
gc.setLineWidth(1);
gc.setStroke(Color.LIGHTGRAY);
// write two for loops to draw the horizontal and vertical lines
// vertical lines
for (double x = 0; x <= width; x = x + dx) {
gc.strokeLine(x, 0, x, height);
}
// horizontal lines
for (double y = 0; y <= height; y = y + dy) {
gc.strokeLine(0, y, width, y);
}
dx = 100;
dy = 100;
gc.setStroke(Color.DARKGRAY);
// write two for loops to draw the horizontal and vertical lines
// vertical lines
for (double x = 0; x <= width; x = x + dx) {
gc.strokeLine(x, 0, x, height);
}
// horizontal lines
for (double y = 0; y <= height; y = y + dy) {
gc.strokeLine(0, y, width, y);
}
// Hometask:
// 2. brush up on your trigonometry and polar coordinate knowledge
}
示例10: drawNormalTick
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawNormalTick(double x, double y) {
GraphicsContext gc = getGraphicsContext2D();
double tickLength = 5; //Small Tick
//Draw ticks and draw texts
gc.setLineWidth(0.1);
gc.setStroke(ChartTickColorProperty.getValue());
gc.strokeLine(x, y, x + tickLength, y);
}
示例11: drawTextTick
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
@Override
public void drawTextTick(double x, double y, double value) {
GraphicsContext gc = getGraphicsContext2D();
double bigTickLength = 10; //Big Tick
//Draw ticks and draw texts
gc.setLineWidth(0.1);
gc.setStroke(ChartTickColorProperty.getValue());
gc.strokeLine(x, y, x + bigTickLength, y);
String strValue = "";
if (value >= 0 && value <= 0.01) {
strValue = String.format("%.4f", value);
}
else if (value > 0.01 && value <= 0.1) {
strValue = String.format("%.3f", value);
}
else if (value > 0.1 && value <= 1.0) {
strValue = String.format("%.3f", value);
}
else if (value > 1.0 && value <= 10.0) {
strValue = String.format("%.2f", value);
}
else {
strValue = String.format("%.2f", value);
}
gc.setFill(ChartTickColorProperty.getValue());
gc.fillText(strValue, x + bigTickLength + 3, y + 5);
}
示例12: drawGrid
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void drawGrid() {
GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
// Task: draw a grid paper with horizontal lines 20 pixels apart
// and the vertical lines 20 pixels apart, as well
double width = drawingCanvas.getWidth();
double height = drawingCanvas.getHeight();
gc.setStroke(Color.RED);
for (int x = 0; x <= width; x += 20) {
gc.strokeLine(x, 0, x, height);
}
for (int y = 0; y <= height; y += 20) {
gc.strokeLine(0, y, width, y);
}
gc.setStroke(Color.BLUE);
for (int x = 0; x <= width; x += 100) {
gc.strokeLine(x, 0, x, height);
}
for (int y = 0; y <= height; y += 100) {
gc.strokeLine(0, y, width, y);
}
}
示例13: drawHIndicator
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
* Draw mouse hover indicator
*/
public void drawHIndicator() {
if (showMouseHoverIndicator.getValue()) {
double width = getWidth();
GraphicsContext gc = getGraphicsContext2D();
gc.setLineWidth(0.1);
gc.setStroke(CrossIndicatorLineColorProperty.getValue());
gc.strokeLine(0, mouseY.getValue(), width, mouseY.getValue());
gc.strokeLine(0, mouseY.getValue(), width, mouseY.getValue());
gc.strokeLine(0, mouseY.getValue(), width, mouseY.getValue());
gc.strokeLine(0, mouseY.getValue(), width, mouseY.getValue());
gc.strokeLine(0, mouseY.getValue(), width, mouseY.getValue());
gc.strokeLine(0, mouseY.getValue(), width, mouseY.getValue());
}
}
示例14: addGrid
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
* Add a grid to the canvas, send it to the back
*/
public void addGrid() {
double w = getBoundsInLocal().getWidth();
double h = getBoundsInLocal().getHeight();
// add grid
Canvas grid = new Canvas(w, h);
// don't catch mouse events
grid.setMouseTransparent(true);
GraphicsContext gc = grid.getGraphicsContext2D();
gc.setStroke(Color.GRAY);
gc.setLineWidth(1);
// draw grid lines
double offset = 50;
for (double i = offset; i < w; i += offset) {
gc.strokeLine(i, 0, i, h);
gc.strokeLine(0, i, w, i);
}
getChildren().add(grid);
grid.toBack();
}
示例15: drawConner
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
* 设置图形节点为选中样式
*/
public void drawConner() {
canvas.setMouseTransparent(false);
if (node != null) {
node.setMouseTransparent(true);
}
isConnerShow = true;
// System.out.println("draw conner");
double height = getPrefHeight();
double width = getPrefWidth();
GraphicsContext gc = canvas.getGraphicsContext2D();
double whiteR = 12;
double blueR = 10;
double delta = (whiteR - blueR) / 2;
double lineStart = whiteR / 2;
gc.setStroke(Color.GREEN);
gc.setLineWidth(2);
gc.strokeLine(lineStart, lineStart, width - lineStart, lineStart);
gc.strokeLine(lineStart, height - lineStart, width - lineStart, height - lineStart);
gc.strokeLine(lineStart, lineStart, lineStart, height - lineStart);
gc.strokeLine(width - lineStart, lineStart, width - lineStart, height - lineStart);
gc.setFill(Color.WHITE);
gc.fillOval(0, 0, whiteR, whiteR);
gc.fillOval(width - whiteR, 0, whiteR, whiteR);
gc.fillOval(0, height - whiteR, whiteR, whiteR);
gc.fillOval(width - whiteR, height - whiteR, whiteR, whiteR);
gc.setFill(Color.color(0.03, 0.43, 0.81));
gc.fillOval(delta, delta, blueR, blueR);
gc.fillOval(width - blueR - delta, delta, blueR, blueR);
gc.fillOval(delta, height - blueR - delta, blueR, blueR);
gc.fillOval(width - blueR - delta, height - blueR - delta, blueR, blueR);
}