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