-
Notifications
You must be signed in to change notification settings - Fork 3
/
Cell.java
136 lines (130 loc) · 2.97 KB
/
Cell.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package DRAKO.table;
import DRAKO.unit.*;
import DRAKO.img.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Cell extends ImgJButton
{
private static final long serialVersionUID=1L;
int x,y,sb=4,firej;
float al=1.0f;
boolean have_thing;
Image[] chess_img;
Image img_uh,img_h,img2;
Map map;
public Cell(int x,int y,int x2,int y2,boolean th,ImgLoader imgloader,ActionListener listener,Map map){
super(imgloader.get_btn(4));
img2=img_h=img_uh=imgloader.get_btn(4);
System.out.println(x+" "+y+" TTGGF");
setBounds(x,y,101,86);
this.x=x2;
this.y=y2;
have_thing=th;
this.map=map;
setVisible(!have_thing);
setBorderPainted(false);
setEnabled(false);
al=0.0f;
addActionListener(listener);
chess_img=new Image[5];
chess_img[0]=imgloader.get_btn(0);
chess_img[1]=imgloader.get_btn(1);
chess_img[2]=imgloader.get_btn(2);
chess_img[3]=imgloader.get_btn(3);
chess_img[4]=imgloader.get_btn(4);
System.out.println(" FF "+x+" "+y);
addMouseListener(new MouseAdapter(){
public void mouseEntered(MouseEvent e){
if(isEnabled()){
if(sb==4)al=0.9f;
else al=1.0f;
img2=img_h;
repaint();
}else{
if(sb==4)al=0.0f;
else al=1.0f;
img2=img_uh;
}
}
public void mouseExited(MouseEvent e){
img2=img_uh;
if(isEnabled()){
if(sb!=4)al=0.8f;
else al=0.5f;
repaint();
}else{
if(sb!=4)al=1.0f;
else al=0.0f;
}
}
});
}
public void setSB(int sb){
this.sb=sb;
if(sb==4)al=0.0f;
else al=1.0f;
off();
repaint();
}
public boolean can(){
if(have_thing||sb!=4)return false;
return true;
}
public boolean on(){
//System.out.println(x2+" "+y2);
if(have_thing||sb!=4)return false;
setEnabled(true);
al=0.5f;
repaint();
return true;
}
public void th_on(int j){
if(sb!=4){
setEnabled(true);
al=0.5f;
repaint();
firej=j;
}
}
public void on_HU(int id){
if(this.sb!=4)return;
boolean tmp=x==0&&(y==0||y==1||y==2)||x==1&&(y==0||y==3)||x==2&&(y==0||y==4)||x==3&&(y==1||y==4)||x==4&&(y==2||y==3||y==4);
if(tmp){
img_uh=chess_img[4];
img_h=chess_img[id];
img2=chess_img[4];
al=0.5f;
repaint();
setEnabled(true);
}
}
public boolean off(){
setEnabled(false);
img_uh=chess_img[sb];
img_h=chess_img[sb];
img2=chess_img[sb];
if(sb==4)al=0.0f;
repaint();
return true;
}
@Override public void paintComponent(Graphics g){
Graphics2D g2=(Graphics2D) g;
Composite alpha = AlphaComposite.getInstance(AlphaComposite.SRC_OVER,al);
g2.setComposite(alpha);
g2.drawImage(img2,null,null);
}
public int get_x(){
return x;
}
public int get_y(){
return y;
}
public int getSB(){
return sb;
}
public int get_firej(){
return firej;
}
}