-
Notifications
You must be signed in to change notification settings - Fork 0
/
icons.java
67 lines (60 loc) · 1.66 KB
/
icons.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
55
56
57
58
59
60
61
62
63
64
65
66
67
package assignment5;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
public class icons {
static int size = 10;
static Shape getIcon(Critter.CritterShape shape) {
Shape s = null;
switch(shape) {
case SQUARE: s = new Rectangle(size, size);
break;
case CIRCLE: s = new Circle(size/2);
break;
case TRIANGLE: s = makeT();
break;
case DIAMOND: s = makeD();
break;
case STAR: s = makeS();
default:
break;
}
return s;
}
public static void changeSize(int i) {
size = i; ///?????
}
private static Shape makeT() {
Polygon triangle = new Polygon();
triangle.getPoints().addAll(new Double[]{
(double)size/2.0, 1.0,
(double)size - 1.0, (double)size - 1.0,
1.0, (double)size-1.0
});
return triangle;
}
private static Shape makeD() {
Polygon diamond = new Polygon();
diamond.getPoints().addAll(new Double[]{
(double)size/2.0, 1.0,
(double)size - 1.0, (double)size/2.0,
(double)size/2.0, (double)size - 1.0,
1.0, (double)size/2.0
});
return diamond;
}
private static Shape makeS() {
Polygon star = new Polygon();
star.getPoints().addAll(new Double[]{
(double)size/2.0, 1.0,
(double)size/2.0 + (double)size/4.0, (double)size/3.0,
(double)size - 1.0, (double)size/2.0,
(double)size/2.0 + (double)size/4.0, (double)size/2.0 + 1.0,
(double)size - 1.0, (double)size - 1.0,
(double)size/2.0, (double)size/2.0 + (double)size/4.0,
1.0, (double)size-1.0,
(double)size/2.0 - (double)size/4.0, (double)size/2.0 + 1.0,
2.0, (double)size/2.0
});
return star;
}
}