-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSelect.java
More file actions
67 lines (47 loc) · 1.42 KB
/
Select.java
File metadata and controls
67 lines (47 loc) · 1.42 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
import java.awt.Component;
import javax.swing.ImageIcon;
//import jdk.javadoc.internal.tool.Main;
public class Select extends MainButton{
int x1, x2, y1, y2;
public Select(String button_name, GUI m) {
super(button_name, m);
}
public void CanvasClickEvent(int x, int y) {
super.main_GUI.clear_selected_list();
System.out.println("Clicked!");
}
public void CanvasPressEvent(int x, int y) {
super.main_GUI.clear_selected_list();
System.out.println("Press!");
this.x1 = x;
this.y1 = y;
}
public void CanvasReleaseEvent(int x, int y) {
super.main_GUI.clear_selected_list();
System.out.println("Release!");
this.x2 = x;
this.y2 = y;
if(this.x1> this.x2) {
int temp = this.x1;
this.x1 =this.x2;
this.x2 = temp;
}
if(this.y1> this.y2) {
int temp = this.y1;
this.y1 =this.y2;
this.y2 = temp;
}
main_GUI.clear_selected_list();
for(Component obj: main_GUI.canvas_area.getComponents()) {
if(obj.getLocation().x > this.x1 && obj.getLocation().y>this.y1 && obj.getLocation().x<this.x2 && obj.getLocation().y<this.y2) {
MainObject obj_main_object = (MainObject)obj;
if(obj_main_object.group_belong!=null){
CompositeGroup root_group = CompositeGroup.get_root_group(obj_main_object.group_belong);
obj_main_object.group_belong.select_all_object_relative(root_group);
}else{
main_GUI.selected_object.add(obj_main_object);
}
}
}
}
}