Mercurial > MadButterfly
annotate Android/java/org/madbutterfly/paint.java @ 1049:9d4f02715987
Fix the forward reference issue.
author | wycc |
---|---|
date | Tue, 23 Nov 2010 23:57:29 +0800 |
parents | 2d7df44e6299 |
children |
rev | line source |
---|---|
493
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1 package org.madbutterfly; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 import java.util.ArrayList; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 |
499 | 5 public class paint { |
493
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
6 protected int addr; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 redraw_man rdman; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 ArrayList members; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
10 public paint(redraw_man rdman, int addr) { |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
11 this.addr = addr; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
12 this.rdman = rdman; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
13 members = new ArrayList(); |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 } |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
15 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
16 protected void invalid() { |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
17 addr = 0; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
18 } |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
19 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
20 protected void finalize() { |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
21 if(addr != 0) |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
22 _jni.rdman_paint_free(rdman._rdman_addr, addr); |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
23 } |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
24 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
25 public void stroke(shape sh) { |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
26 no_stroke(sh); |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
27 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
28 if(sh.fill != this) |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
29 members.add(sh); |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
30 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
31 sh.stroke = this; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
32 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
33 _jni.rdman_paint_stroke(rdman._rdman_addr, addr, sh.addr); |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
34 } |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
35 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
36 public void fill(shape sh) { |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
37 no_fill(sh); |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
38 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
39 if(sh.stroke != this) |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 members.add(sh); |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
41 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
42 sh.fill = this; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
43 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
44 _jni.rdman_paint_fill(rdman._rdman_addr, addr, sh.addr); |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
45 } |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
46 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
47 public boolean is_empty() { |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
48 return members.size() == 0; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
49 } |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
50 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
51 public static void no_stroke(shape sh) { |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
52 int i; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
53 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
54 if(sh.stroke != null && sh.stroke != sh.fill) { |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
55 i = sh.stroke.members.indexOf(sh); |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
56 sh.stroke.members.remove(i); |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
57 } |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
58 sh.stroke = null; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
59 } |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
60 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
61 public static void no_fill(shape sh) { |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
62 int i; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
63 |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
64 if(sh.fill != null && sh.stroke != sh.fill) { |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
65 i = sh.stroke.members.indexOf(sh); |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
66 sh.stroke.members.remove(i); |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
67 } |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
68 sh.fill = null; |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
69 } |
1b6228092a57
Java code for MadButterfly JNI.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
70 } |