-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPlane.java
54 lines (42 loc) · 1.43 KB
/
Plane.java
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 java.util.*;
public class Plane {
private int layer;
private int[][] plane;
private List<Segment> segments;
public Plane(int[][] pl, int i) {
plane = pl.clone();
layer = i;
segments = new ArrayList<Segment>();
//initializes a bunch of segments that can access the different parts of the plane
for(int r = 0; r < plane.length - 8; r += 8) for(int c = 0; c < plane[0].length - 8; c += 8) segments.add(new Segment(r, c, plane, layer));
}
public String toString() {
String result = "Plane " + layer + "\r\n\r\nCGC Plane\r\n";
for(int k = 0; k < plane.length; k++) {
for(int j = 0; j < plane[0].length; j++) result += plane[k][j] + " ";
result += "\r\n";
}
return result;
}
public int getBit(int r, int c) {//row r, column c, not xy coordinates
return plane[r][c];
}
public int getWidth() {
return plane[0].length;
}
public int getHeight() {
return plane.length;
}
//number of segments
public int size() {
return segments.size();
}
public List<Segment> getAllSegments() {
return segments;
}
public List<Segment> getComplexSegmentsOfPlane() {
List<Segment> complexSegments = new ArrayList<Segment>();
for(Segment segment : segments) if(segment.isComplex()) complexSegments.add(segment);
return complexSegments;
}
}