本文整理汇总了Java中javafx.scene.canvas.GraphicsContext.setLineWidth方法的典型用法代码示例。如果您正苦于以下问题:Java GraphicsContext.setLineWidth方法的具体用法?Java GraphicsContext.setLineWidth怎么用?Java GraphicsContext.setLineWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.canvas.GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext.setLineWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initDraw
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private void initDraw(GraphicsContext gc) {
double canvasWidth = gc.getCanvas().getWidth();
double canvasHeight = gc.getCanvas().getHeight();
log.info("canvasWidth = {}, canvasHeight = {}", canvasWidth, canvasHeight);
gc.clearRect(0, 0, canvasWidth, canvasHeight);
gc.setStroke(borderRectangleColor);
gc.setLineWidth(5);
gc.strokeRect(0, // x of the upper left corner
0, // y of the upper left corner
canvasWidth, // width of the rectangle
canvasHeight); // height of the rectangle
gc.setFill(Color.RED);
gc.setStroke(Color.BLUE);
gc.setLineWidth(drawLineWidth);
}
示例2: drawZeroLine
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
* Draw RSM Zero Lines
*/
public void drawZeroLine() {
BaseYCanvas yCanvas = this.getYCanvas();
if (yCanvas == null) {
return;
}
GraphicsContext gc1 = getGraphicsContext2D();
Double width = getWidth();
Double x = 0d;
Double y = yCanvas.getYPosByValue(0.0f);
gc1.setLineWidth(0.618);
//The color if I set it here to use the Color Properties that I have defined
//It doesn work !!!! I don't know why If I set it as white color
//It works perfectly
gc1.setStroke(Color.WHITE);
gc1.strokeLine(x, y, width, y);
}
示例3: 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);
}
示例4: 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);
}
}
示例5: drawShapes
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
private void drawShapes() {
GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
gc.setStroke(Color.RED);
gc.setFill(Color.YELLOW);
gc.setLineWidth(5);
double w = 100;
double h = 100;
double width = drawingCanvas.getWidth();
double height = drawingCanvas.getHeight();
gc.fillRect(width / 2 - w / 2, height / 2 - h / 2, w, h);
gc.strokeRect(width / 2 - w / 2, height / 2 - h / 2, w, h);
double initialX = 100;
double initialY = 200;
double dr = -20;
for (double radius = 100; radius >= 20; radius += dr, initialX -= dr, initialY -= dr) {
gc.strokeOval(initialX, initialY, 2 * radius, 2 * radius);
}
// Hometasks:
// 1. draw a sun!
// 2. draw regular ngons (fix the function that I wrote)
}
示例6: NodeView
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public NodeView(GraphicsContext graphicsContext) {
this.graphicsContext = graphicsContext;
graphicsContext.setLineWidth(12);
try {
spriteNodes = new HashMap<>();
for (String type: nodeTypes) {
try (FileInputStream fi = new FileInputStream("sprites/" + type + ".png")) {
spriteNodes.put(type, new Image(fi));
}
}
spriteStations=new HashMap<>();
spriteLoaderStations=new HashMap<>();
for (String color: model.util.Color.getValidColors()) {
try (FileInputStream fi = new FileInputStream("sprites/station_" + color + ".png")) {
spriteStations.put(color, new Image(fi));
}
try (FileInputStream fi = new FileInputStream("sprites/loader_" + color + ".png")) {
spriteLoaderStations.put(color, new Image(fi));
}
}
} catch (IOException e) {
System.err.println("NodeView.NodeView: File error: " + e.getMessage());
}
}
示例7: 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);
}
示例8: 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);
}
示例9: 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);
}
示例10: 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);
}
示例11: draw
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
public void draw() {
drawGrid();
GraphicsContext gc = drawingCanvas.getGraphicsContext2D();
gc.setStroke(Color.BLACK);
gc.setLineWidth(5);
plotFunction();
// Hometasks:
// 1. Draw a circle right at the center with radius of 150 pixels
// 2. Draw 20 concentric circles in the top left box
// 3. Draw a sun (circle + rays)
// 4. Draw a regular n-gon (like pentagon)
}
示例12: 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();
}
示例13: 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);
}
示例14: drawVIndicator
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
* Draw mouse hover indicator
*/
public void drawVIndicator() {
if (showMouseHoverIndicator.getValue()) {
double height = getHeight();
GraphicsContext gc = getGraphicsContext2D();
gc.setLineWidth(0.1);
gc.setStroke(CrossIndicatorLineColorProperty.getValue());
gc.strokeLine(mouseX.getValue(), 0, mouseX.getValue(), height);
gc.strokeLine(mouseX.getValue(), 0, mouseX.getValue(), height);
gc.strokeLine(mouseX.getValue(), 0, mouseX.getValue(), height);
gc.strokeLine(mouseX.getValue(), 0, mouseX.getValue(), height);
gc.strokeLine(mouseX.getValue(), 0, mouseX.getValue(), height);
gc.strokeLine(mouseX.getValue(), 0, mouseX.getValue(), height);
Calendar current = myTimeLine.getDayByXPos(mouseX.getValue());
if(current!=null){
currentCalendar.setValue(current);
OHLC ohlc = getOHLCByDate(current);
if (ohlc != null){
openProperty.setValue(ohlc.getOpen());
highProperty.setValue(ohlc.getHigh());
lowProperty.setValue(ohlc.getLow());
closeProperty.setValue(ohlc.getClose());
volumeProperty.setValue(ohlc.getVolume());
}
}
}
}
示例15: drawBarChart
import javafx.scene.canvas.GraphicsContext; //导入方法依赖的package包/类
/**
* Draw bar chart
*/
public void drawBarChart() {
BaseTimeCanvas timeCanvas = this.getTimeCanvas();
if (timeCanvas == null) {
return;
}
BaseYCanvas priceCanvas = this.getYCanvas();
if (priceCanvas == null) {
return;
}
GraphicsContext gc = getGraphicsContext2D();
ObservableList<OHLC> data = FXCollections.observableArrayList();
if (this.ChartTypeProperty.getValue() == ChartType.DAY.ordinal()){
data.setAll(dailyData);
}
else if (this.ChartTypeProperty.getValue() == ChartType.WEEK.ordinal()) {
data.setAll(weeklyData);
}
else if (this.ChartTypeProperty.getValue() == ChartType.MONTH.ordinal()) {
data.setAll(monthlyData);
}
else if (this.ChartTypeProperty.getValue() == ChartType.YEAR.ordinal()) {
data.setAll(yearlyData);
}
for (int i = 0; i<data.size(); i++) {
OHLC cur = data.get(i);
Color curColor = getBarColor(data, i);
Calendar calendar = cur.getDate();
Double xCenter = timeCanvas.getXPosByDay(calendar);
if (xCenter == null){
//System.out.println("getXPOSByDate returns Null: " + calendar.getTime().toString());
continue;
}
Double xOpen = xCenter - new Double((xIntervalProperty.getValue()/2)).intValue() + 1;
Double xClose = xCenter + new Double((xIntervalProperty.getValue()/2)).intValue() - 1;
Double yHigh = priceCanvas.getYPosByValue(cur.getHigh());
if (yHigh == null) {
continue;
}
Double yLow = priceCanvas.getYPosByValue(cur.getLow());
if (yLow == null) {
continue;
}
Double yOpen = priceCanvas.getYPosByValue(cur.getOpen());
if (yOpen == null) {
continue;
}
Double yClose = yOpen;
if (cur.getOpen()!= cur.getClose()){
yClose = priceCanvas.getYPosByValue(cur.getClose());
if (yClose == null) {
continue;
}
}
//Draw Bar
gc.setLineWidth(1);
gc.setStroke(curColor);
gc.strokeLine(xCenter, yHigh, xCenter, yLow);
gc.strokeLine(xCenter, yHigh, xCenter, yLow);
gc.strokeLine(xCenter, yHigh, xCenter, yLow);
//Draw tick open
gc.strokeLine(xOpen, yOpen, xCenter, yOpen);
gc.strokeLine(xOpen, yOpen, xCenter, yOpen);
gc.strokeLine(xOpen, yOpen, xCenter, yOpen);
//Draw tick close
gc.strokeLine(xCenter, yClose, xClose, yClose);
gc.strokeLine(xCenter, yClose, xClose, yClose);
gc.strokeLine(xCenter, yClose, xClose, yClose);
}
}