-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneralGrid.java
More file actions
109 lines (90 loc) · 2.63 KB
/
GeneralGrid.java
File metadata and controls
109 lines (90 loc) · 2.63 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import javafx.scene.*;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import javafx.scene.shape.Line;
import java.util.Scanner;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.stage.Stage;
public class GeneralGrid extends Application{
static int row = 0, col = 0;
static float cell_small = 0 , cell_big = 0;
@Override
public void start(Stage primaryStage) throws Exception {
Group root = new Group();
Scene scene = new Scene(root,500, 650);
Line line1 ;
//gridsmall
//horizontal lines
float i = 150;
for(int m = 0 ; m <= row ; m ++){
line1 = new Line(100, i, 400, i);
line1.setStroke(Color.RED);
root.getChildren().add(line1);
i = i + cell_small;
}
//vertical lines
i = 100;
for(int m = 0 ; m <= col ; m ++){
line1 = new Line( i, 150 , i , 600 );
line1.setStroke(Color.RED);
root.getChildren().add(line1);
i = i + cell_small;
}
//gridbig
i = 132;
for(int m = 0 ; m <= row ; m ++){
line1 = new Line(88, i, 412, i);
line1.setStroke(Color.RED);
root.getChildren().add(line1);
i = i + cell_big;
}
i = 88;
for(int m = 0 ; m <= col ; m ++){
line1 = new Line( i, 132 , i , 618 );
line1.setStroke(Color.RED);
root.getChildren().add(line1);
i = i + cell_big;
}
//nestedloop
float x1 = 88;
float y1 = 132;
float x2 = 100;
float y2 = 150;
for(i = 1; i <= row + 1 ; i ++){
x1 = 88;
x2 = 100;
for(int j = 1; j <= col + 1 ; j ++){
line1 = new Line(x1, y1, x2, y2);
root.getChildren().add(line1);
line1.setStroke(Color.RED);
x1 = x1 + cell_big;
x2 = x2 + cell_small;
}
y1 = y1 + cell_big;
y2 = y2 + cell_small;
}
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main (String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter grid size");
int x = sc.nextInt();
int y = sc.nextInt();
if(x == 9 && y == 6){
row = 9;
col = 6;
cell_small = 50;
cell_big = 54;
}
else{
row = 15;
col = 10;
cell_small = 30;
cell_big = (float) 32.4;
}
launch(args);
}
}