本文整理匯總了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;
}