-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGUI.java
More file actions
57 lines (50 loc) · 1.21 KB
/
Copy pathGUI.java
File metadata and controls
57 lines (50 loc) · 1.21 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
import processing.core.*;
class GUI {
static PApplet pa;
static int[][] coords = {{10,10},{10,50},{10,90},{10,130},{10,170},{10,210}};
static PImage[] icons=new PImage[coords.length];
static void init(PApplet p){
pa=p;
icons[0]=pa.loadImage("folder.png");
icons[1]=pa.loadImage("save.png");
icons[2]=pa.loadImage("picture.png");
icons[3]=pa.loadImage("polygon.png");
icons[4]=pa.loadImage("zoomin.png");
icons[5]=pa.loadImage("zoomout.png");
}
static void draw() {
for (int i=0;i<icons.length;i++) {
pa.image(icons[i],coords[i][0],coords[i][1]);
}
}
static boolean clicked(int x, int y){
int selected=-1;
for (int i=0;i<icons.length;i++) {
if (x>coords[i][0] && x<coords[i][0]+icons[i].width && y>coords[i][1] && y<coords[i][1]+icons[i].height) {
selected=i;
break;
}
}
switch (selected) {
case 0:
ExportImport.importData();
break;
case 1:
ExportImport.export(ShapeManager.getShapeCoordinates());
break;
case 2:
FileChooser.showOpen(new ImageLoader(pa));
break;
case 3:
ShapeManager.newShape();
break;
case 4:
ZoomControl.decrease();
break;
case 5:
ZoomControl.increase();
break;
}
return selected!=-1;
}
}