-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFanDisplay.java
More file actions
54 lines (43 loc) · 1.52 KB
/
FanDisplay.java
File metadata and controls
54 lines (43 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
import javafx.stage.Stage;
public class FanDisplay extends Application {
private static final int WIDTH = 400;
private static final int HEIGHT = 400;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) {
Group root = new Group();
for (int row = 0; row < 2; row++) {
for (int col = 0; col < 2; col++) {
double x = col * (WIDTH / 2);
double y = row * (HEIGHT / 2);
createFan(root, x, y);
}
}
Scene scene = new Scene(root, WIDTH, HEIGHT);
primaryStage.setTitle("X-Shaped Fans in Circles");
primaryStage.setScene(scene);
primaryStage.show();
}
private void createFan(Group root, double x, double y) {
Group fanGroup = new Group();
fanGroup.setLayoutX(x + WIDTH / 4);
fanGroup.setLayoutY(y + HEIGHT / 4);
Line line1 = new Line(-50, -50, 50, 50);
Line line2 = new Line(-50, 50, 50, -50);
line1.setStroke(Color.BLACK);
line2.setStroke(Color.BLACK);
Circle circle = new Circle(0, 0, 70);
circle.setFill(Color.TRANSPARENT);
circle.setStroke(Color.BLACK);
fanGroup.getChildren().addAll(circle, line1, line2);
root.getChildren().add(fanGroup);
}
}