22 |
*/ |
*/ |
23 |
package gzz.vob; |
package gzz.vob; |
24 |
class OrthoCoordsys { |
class OrthoCoordsys { |
|
OrthoCoordsysMap map; |
|
25 |
OrthoDepthSorter sorter; |
OrthoDepthSorter sorter; |
26 |
|
|
|
Object[] key; |
|
27 |
float[] depth, x, y, w, h; |
float[] depth, x, y, w, h; |
28 |
int[] parent; |
int[] parent; |
29 |
int[] nancestors; |
int[] nancestors; |
37 |
} |
} |
38 |
|
|
39 |
OrthoCoordsys(float mw, float mh, int initialSize) { |
OrthoCoordsys(float mw, float mh, int initialSize) { |
|
map = new OrthoCoordsysMap(this, initialSize); |
|
40 |
sorter = new OrthoDepthSorter(this, initialSize); |
sorter = new OrthoDepthSorter(this, initialSize); |
41 |
|
|
|
key = new Object[initialSize]; |
|
42 |
depth = new float[initialSize]; |
depth = new float[initialSize]; |
43 |
x = new float[initialSize]; |
x = new float[initialSize]; |
44 |
y = new float[initialSize]; |
y = new float[initialSize]; |
52 |
} |
} |
53 |
|
|
54 |
void clear(float mw, float mh) { |
void clear(float mw, float mh) { |
55 |
key[0] = null; depth[0] = 0; |
depth[0] = 0; |
56 |
x[0] = 0; y[0] = 0; w[0] = mw; h[0] = mh; |
x[0] = 0; y[0] = 0; w[0] = mw; h[0] = mh; |
57 |
parent[0] = -1; nancestors[0] = 0; |
parent[0] = -1; nancestors[0] = 0; |
58 |
|
|
59 |
nsys = 1; |
nsys = 1; |
60 |
|
|
61 |
map.clear(); sorter.clear(); |
sorter.clear(); |
62 |
} |
} |
63 |
|
|
64 |
int add(int mparent, Object mkey, float mdepth, float mx, float my, |
int add(int mparent, float mdepth, float mx, float my, |
65 |
float mw, float mh) { |
float mw, float mh) { |
66 |
int cs = next(); |
int cs = next(); |
|
key[cs] = mkey; |
|
67 |
|
|
68 |
w[cs] = mw; |
w[cs] = mw; |
69 |
h[cs] = mh; |
h[cs] = mh; |
78 |
|
|
79 |
nextHashtableEntry[cs] = 0; |
nextHashtableEntry[cs] = 0; |
80 |
|
|
|
map.add(cs); |
|
81 |
return cs; |
return cs; |
82 |
} |
} |
83 |
|
|
84 |
protected int next() { |
protected int next() { |
85 |
int n = nsys; |
int n = nsys; |
86 |
nsys++; |
nsys++; |
87 |
if(nsys > key.length) { |
if(nsys > depth.length) { |
88 |
int o = key.length, l = key.length * 2; |
int o = depth.length, l = depth.length * 2; |
89 |
|
|
|
Object[] nkey = new Object[l]; |
|
90 |
float[] ndepth = new float[l]; |
float[] ndepth = new float[l]; |
91 |
float[] nx = new float[l]; |
float[] nx = new float[l]; |
92 |
float[] ny = new float[l]; |
float[] ny = new float[l]; |
96 |
int[] nnancestors = new int[l]; |
int[] nnancestors = new int[l]; |
97 |
int[] nnext = new int[l]; |
int[] nnext = new int[l]; |
98 |
|
|
|
System.arraycopy(key, 0, nkey, 0, o); |
|
99 |
System.arraycopy(depth, 0, ndepth, 0, o); |
System.arraycopy(depth, 0, ndepth, 0, o); |
100 |
System.arraycopy(x, 0, nx, 0, o); |
System.arraycopy(x, 0, nx, 0, o); |
101 |
System.arraycopy(y, 0, ny, 0, o); |
System.arraycopy(y, 0, ny, 0, o); |
105 |
System.arraycopy(nancestors, 0, nnancestors, 0, o); |
System.arraycopy(nancestors, 0, nnancestors, 0, o); |
106 |
System.arraycopy(nextHashtableEntry, 0, nnext, 0, o); |
System.arraycopy(nextHashtableEntry, 0, nnext, 0, o); |
107 |
|
|
108 |
key = nkey; depth = ndepth; |
depth = ndepth; |
109 |
x = nx; y = ny; w = nw; h = nh; |
x = nx; y = ny; w = nw; h = nh; |
110 |
parent = nparent; |
parent = nparent; |
111 |
nancestors = nnancestors; |
nancestors = nnancestors; |