質問編集履歴

1

ご指摘によりソースの縮小、全文を載せました。

2018/04/09 12:16

投稿

maiko0318
maiko0318

スコア876

test CHANGED
File without changes
test CHANGED
@@ -36,15 +36,85 @@
36
36
 
37
37
 
38
38
 
39
- public class clock3 extends Applet implements Runnable {
39
+ public class clock4 extends Applet implements Runnable {
40
40
 
41
41
  Dimension d;
42
42
 
43
43
  Thread kicker = null;
44
44
 
45
+ Image offs;
46
+
47
+ Graphics grf;
48
+
49
+ int r;
50
+
51
+ int yohaku;
52
+
53
+ int Time4 = 999;
54
+
55
+ int kirikae = 0;
45
56
 
46
57
 
58
+
59
+ public void init() {
60
+
61
+ d=getSize();
62
+
63
+ String param = getParameter("yohaku");
64
+
65
+ yohaku = (param != null)? Integer.parseInt(param):5;
66
+
67
+ r=(d.width<d.height)? (int)(d.width-yohaku*2)/2 : (int)(d.height-yohaku*2)/2;
68
+
69
+
70
+
71
+ offs=createImage(d.width, d.height);
72
+
73
+ grf=offs.getGraphics();
74
+
75
+ }
76
+
77
+
78
+
79
+ public void run() {
80
+
81
+ Thread.currentThread().setPriority(Thread.NORM_PRIORITY-3);
82
+
83
+ while(kicker != null) {
84
+
85
+ repaint();
86
+
47
- (途中省略)
87
+ try {
88
+
89
+ Thread.sleep(100);
90
+
91
+ } catch(InterruptedException e) {}
92
+
93
+ }
94
+
95
+ // kicker=null;
96
+
97
+ }
98
+
99
+
100
+
101
+ public void update(Graphics g){
102
+
103
+ paint(g);
104
+
105
+ }
106
+
107
+
108
+
109
+ public void paint(Graphics g) {
110
+
111
+ grf.setColor(Color.white);
112
+
113
+ grf.fillRect(0, 0, r * 2 + yohaku*2, r * 2 + yohaku*2);
114
+
115
+
116
+
117
+ int x1, y1, x, y;
48
118
 
49
119
 
50
120
 
@@ -62,4 +132,54 @@
62
132
 
63
133
  int Time3 = (int) (Now.get(Calendar.SECOND) * 6 + Now.get(Calendar.MILLISECOND) * 0.006);
64
134
 
135
+
136
+
137
+ grf.setColor(Color.black);
138
+
139
+ for(int i=0;i<360;i+=6){
140
+
141
+ x = (int) Math.round( ( r * Math.sin( i * 2.0 * Math.PI / 360.0 ) ) );
142
+
143
+ y = (int) Math.round( ( r * Math.cos( (360.0 - i) * 2.0 * Math.PI / 360.0 ) ) );
144
+
145
+ grf.drawLine( x + r + yohaku, y * (-1) + r + yohaku, x + r + yohaku, y * (-1) + r + yohaku );
146
+
147
+ }
148
+
149
+
150
+
151
+ g.drawImage(offs,0,0,this);
152
+
153
+ }
154
+
155
+
156
+
157
+ public void start() {
158
+
159
+ if(kicker == null) {
160
+
161
+ kicker = new Thread(this);
162
+
163
+ kicker.start();
164
+
165
+ }
166
+
167
+ }
168
+
169
+
170
+
171
+ public void stop() {
172
+
173
+ if(kicker != null) {
174
+
175
+ // kicker.stop();
176
+
177
+ kicker = null;
178
+
179
+ }
180
+
181
+ }
182
+
183
+ }
184
+
65
185
  ```