下面列出了javafx.scene.shape.Polyline#setFill ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static Node createIconContent() {
Polyline polyline = new Polyline(new double[]{
45, 10,
10, 80,
80, 80,
});
polyline.setStroke(Color.web("#b9c0c5"));
polyline.setStrokeWidth(5);
polyline.getStrokeDashArray().addAll(15d,15d);
polyline.setFill(null);
javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
effect.setOffsetX(1);
effect.setOffsetY(1);
effect.setRadius(3);
effect.setColor(Color.rgb(0,0,0,0.6));
polyline.setEffect(effect);
return polyline;
}
public static Node createIconContent() {
Polyline polyline = new Polyline(new double[]{
45, 10,
10, 80,
80, 80,
});
polyline.setStroke(Color.web("#b9c0c5"));
polyline.setStrokeWidth(5);
polyline.getStrokeDashArray().addAll(15d,15d);
polyline.setFill(null);
javafx.scene.effect.InnerShadow effect = new javafx.scene.effect.InnerShadow();
effect.setOffsetX(1);
effect.setOffsetY(1);
effect.setRadius(3);
effect.setColor(Color.rgb(0,0,0,0.6));
polyline.setEffect(effect);
return polyline;
}
public PolylineSample() {
super(180,90);
// Red stroked not closed triangle
Polyline polyline1 = new Polyline(new double[]{
45, 10,
10, 80,
80, 80,
});
polyline1.setFill(Color.TRANSPARENT);
polyline1.setStroke(Color.RED);
// Blue stroked closed triangle
Polyline polyline2 = new Polyline(new double[]{
135, 10,
100, 80,
170, 80,
135, 10,
});
polyline2.setStroke(Color.DODGERBLUE);
polyline2.setStrokeWidth(2);
polyline2.setFill(null);
// Create a group to show all the polylines);
getChildren().add(new Group(polyline1, polyline2));
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Polyline 1 Fill", polyline1.fillProperty()),
new SimplePropertySheet.PropDesc("Polyline 1 Stroke", polyline1.strokeProperty()),
new SimplePropertySheet.PropDesc("Polyline 2 Stroke", polyline2.strokeProperty())
);
// END REMOVE ME
}
public PolylineSample() {
super(180,90);
// Red stroked not closed triangle
Polyline polyline1 = new Polyline(new double[]{
45, 10,
10, 80,
80, 80,
});
polyline1.setFill(Color.TRANSPARENT);
polyline1.setStroke(Color.RED);
// Blue stroked closed triangle
Polyline polyline2 = new Polyline(new double[]{
135, 10,
100, 80,
170, 80,
135, 10,
});
polyline2.setStroke(Color.DODGERBLUE);
polyline2.setStrokeWidth(2);
polyline2.setFill(null);
// Create a group to show all the polylines);
getChildren().add(new Group(polyline1, polyline2));
// REMOVE ME
setControls(
new SimplePropertySheet.PropDesc("Polyline 1 Fill", polyline1.fillProperty()),
new SimplePropertySheet.PropDesc("Polyline 1 Stroke", polyline1.strokeProperty()),
new SimplePropertySheet.PropDesc("Polyline 2 Stroke", polyline2.strokeProperty())
);
// END REMOVE ME
}
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
// Create a pane
Pane pane = new Pane();
// Create a polyline
Polyline polyline = new Polyline(new Double(100.0), new Double(100.0));
polyline.setFill(Color.WHITE);
polyline.setStroke(Color.BLACK);
pane.getChildren().add(polyline);
ObservableList<Double> list = polyline.getPoints();
// Create and register handler
pane.setOnKeyPressed(e -> {
double x = 0, y = 0;
double length = 10;
switch (e.getCode()) {
case DOWN: x = list.get(list.size() - 2);
y = list.get(list.size() - 1) + length; break;
case UP: x = list.get(list.size() - 2);
y = list.get(list.size() - 1) - length; break;
case RIGHT: x = list.get(list.size() - 2) + length;
y = list.get(list.size() - 1); break;
case LEFT: x = list.get(list.size() - 2) - length;
y = list.get(list.size() - 1); break;
}
list.add(x);
list.add(y);
});
// Create a scene and place it in the stage
Scene scene = new Scene(pane, 200, 200);
primaryStage.setTitle("Exercise_15_09"); // Set the stage title
primaryStage.setScene(scene); // Place the scene in the stage
primaryStage.show(); // Display the stage
pane.requestFocus(); // Pane is focused to receive key input
}