本文整理汇总了Java中javafx.scene.shape.Polygon.toBack方法的典型用法代码示例。如果您正苦于以下问题:Java Polygon.toBack方法的具体用法?Java Polygon.toBack怎么用?Java Polygon.toBack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Polygon
的用法示例。
在下文中一共展示了Polygon.toBack方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawDiamond
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
private Group drawDiamond(double startX, double startY, double endX, double endY){
Group group = new Group();
double phi = Math.toRadians(40);
int barb = 14;
double dy = startY - endY;
double dx = startX - endX;
double theta = Math.atan2(dy, dx);
double x, y, rho = theta + phi;
double[] xs = new double[2];
double[] ys = new double[2];
double x4, y4;
x4 = startX - 23*Math.cos(theta);
y4 = startY - 23*Math.sin(theta);
for (int j = 0; j < 2; j++) {
x = startX - barb * Math.cos(rho);
y = startY - barb * Math.sin(rho);
xs[j] = x;
ys[j] = y;
rho = theta - phi;
}
Polygon background = new Polygon();
background.getPoints().setAll(startX, startY,
xs[0], ys[0],
x4, y4,
xs[1], ys[1]);
background.setFill(Color.WHITE);
background.toBack();
Line line1 = new Line(startX, startY, xs[0], ys[0]);
Line line2 = new Line(startX, startY, xs[1], ys[1]);
Line line3 = new Line(xs[0], ys[0], x4, y4);
Line line4 = new Line(xs[1], ys[1], x4, y4);
line1.setStrokeWidth(super.STROKE_WIDTH);
line2.setStrokeWidth(super.STROKE_WIDTH);
line3.setStrokeWidth(super.STROKE_WIDTH);
line4.setStrokeWidth(super.STROKE_WIDTH);
group.getChildren().add(background);
group.getChildren().add(line1);
group.getChildren().add(line2);
group.getChildren().add(line3);
group.getChildren().add(line4);
diamondLines.addAll(Arrays.asList(line1, line2, line3, line4));
if(super.isSelected()){
for(Line l : diamondLines){
l.setStroke(Constants.selected_color);
}
}
return group;
}
示例2: drawArrowHead
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
/**
* Draws an ArrowHead and returns it in a group.
* Based on code from http://www.coderanch.com/t/340443/GUI/java/Draw-arrow-head-line
* @param startX
* @param startY
* @param endX
* @param endY
* @return Group.
*/
private Group drawArrowHead(double startX, double startY, double endX, double endY) {
Group group = new Group();
double phi = Math.toRadians(40);
int barb = 20;
double dy = startY - endY;
double dx = startX - endX;
double theta = Math.atan2(dy, dx);
double x, y, rho = theta + phi;
double[] xs = new double[2];
double[] ys = new double[2];
for (int j = 0; j < 2; j++) {
x = startX - barb * Math.cos(rho);
y = startY - barb * Math.sin(rho);
xs[j] = x;
ys[j] = y;
rho = theta - phi;
}
Polygon background = new Polygon();
background.getPoints().addAll(startX, startY,
xs[0], ys[0],
xs[1], ys[1]);
background.setFill(Color.WHITE);
background.toBack();
Line line1 = new Line(startX, startY, xs[0], ys[0]);
Line line2 = new Line(startX, startY, xs[1], ys[1]);
Line line3 = new Line(xs[0], ys[0], xs[1], ys[1]);
line1.setStrokeWidth(super.STROKE_WIDTH);
line2.setStrokeWidth(super.STROKE_WIDTH);
line3.setStrokeWidth(super.STROKE_WIDTH);
group.getChildren().add(background);
group.getChildren().add(line1);
group.getChildren().add(line2);
group.getChildren().add(line3);
arrowHeadLines.addAll(Arrays.asList(line1, line2, line3));
if(super.isSelected()){
for(Line l : arrowHeadLines){
l.setStroke(Constants.selected_color);
}
}
return group;
}
示例3: drawDiamond
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
private Group drawDiamond(double startX, double startY, double endX, double endY){
Group group = new Group();
double phi = Math.toRadians(40);
int barb = 14;
double dy = startY - endY;
double dx = startX - endX;
double theta = Math.atan2(dy, dx);
double x, y, rho = theta + phi;
double[] xs = new double[2];
double[] ys = new double[2];
double x4, y4;
x4 = startX - 23*Math.cos(theta);
y4 = startY - 23*Math.sin(theta);
for (int j = 0; j < 2; j++) {
x = startX - barb * Math.cos(rho);
y = startY - barb * Math.sin(rho);
xs[j] = x;
ys[j] = y;
rho = theta - phi;
}
diamondBackground = new Polygon();
diamondBackground.getPoints().setAll(startX, startY,
xs[0], ys[0],
x4, y4,
xs[1], ys[1]);
if(super.isSelected()){
diamondBackground.setFill(Constants.selected_color);
} else {
diamondBackground.setFill(Color.BLACK);
}
diamondBackground.toBack();
Line line1 = new Line(startX, startY, xs[0], ys[0]);
Line line2 = new Line(startX, startY, xs[1], ys[1]);
Line line3 = new Line(xs[0], ys[0], x4, y4);
Line line4 = new Line(xs[1], ys[1], x4, y4);
line1.setStrokeWidth(super.STROKE_WIDTH);
line2.setStrokeWidth(super.STROKE_WIDTH);
line3.setStrokeWidth(super.STROKE_WIDTH);
line4.setStrokeWidth(super.STROKE_WIDTH);
group.getChildren().add(diamondBackground);
group.getChildren().add(line1);
group.getChildren().add(line2);
group.getChildren().add(line3);
group.getChildren().add(line4);
diamondLines.addAll(Arrays.asList(line1, line2, line3, line4));
if(super.isSelected()){
for(Line l : diamondLines){
l.setStroke(Constants.selected_color);
}
}
return group;
}
示例4: drawArrowHead
import javafx.scene.shape.Polygon; //导入方法依赖的package包/类
/**
* Draws an ArrowHead and returns it in a group.
* Based on code from http://www.coderanch.com/t/340443/GUI/java/Draw-arrow-head-line
* @param startX
* @param startY
* @param endX
* @param endY
* @return Group.
*/
private Group drawArrowHead(double startX, double startY, double endX, double endY) {
Group group = new Group();
double phi = Math.toRadians(40);
int barb = 20;
double dy = startY - endY;
double dx = startX - endX;
double theta = Math.atan2(dy, dx);
double x, y, rho = theta + phi;
double[] xs = new double[2];
double[] ys = new double[2];
for (int j = 0; j < 2; j++) {
x = startX - barb * Math.cos(rho);
y = startY - barb * Math.sin(rho);
xs[j] = x;
ys[j] = y;
rho = theta - phi;
}
Polygon background = new Polygon();
background.getPoints().addAll(startX, startY, xs[0], ys[0], xs[1], ys[1]);
background.setFill(Color.WHITE);
background.toBack();
Line line1 = new Line(startX, startY, xs[0], ys[0]);
Line line2 = new Line(startX, startY, xs[1], ys[1]);
Line line3 = new Line(xs[0], ys[0], xs[1], ys[1]);
line1.setStrokeWidth(super.STROKE_WIDTH);
line2.setStrokeWidth(super.STROKE_WIDTH);
line3.setStrokeWidth(super.STROKE_WIDTH);
group.getChildren().add(background);
group.getChildren().add(line1);
group.getChildren().add(line2);
group.getChildren().add(line3);
arrowHeadLines.addAll(Arrays.asList(line1, line2, line3));
if(super.isSelected()){
for(Line l : arrowHeadLines){
l.setStroke(Constants.selected_color);
}
}
return group;
}