-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPolygonModel.java
More file actions
66 lines (46 loc) · 1.07 KB
/
PolygonModel.java
File metadata and controls
66 lines (46 loc) · 1.07 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
import java.awt.*;
public class PolygonModel {
int x;
int y;
int [][] xStruct = {
};
int [][] yStruct = {
};
int rectX;
int rectY;
public PolygonModel(int x, int y, int [][]xStruct, int [][]yStruct){
this.x = x;
this.y = y;
this.xStruct = xStruct;
this.yStruct = yStruct;
}
public int getX(){
return x;
}
public void setX(int var){
x = var;
}
public int getY(){
return y;
}
public void setY(int var){
y = var;
}
public void moveBy(int dx, int dy){
//Old move function
x += dx;
y += dy;
}
public void draw(Graphics g){
//Draws the object on the window
for(int poly = 0; poly < xStruct.length; poly++){
int[] xpoints = new int[xStruct[poly].length];
int[] ypoints = new int[yStruct[poly].length];
for(int vert = 0; vert < xStruct[poly].length ; vert++){
xpoints[vert] = xStruct[poly][vert] + x;
ypoints[vert] = yStruct[poly][vert] + y;
}
g.drawPolygon(xpoints, ypoints, xStruct[poly].length);
}
}
}