author | erikj |
Thu, 07 Jun 2012 18:05:09 -0700 | |
changeset 12813 | c10ab96dcf41 |
parent 5506 | 202f599c92aa |
child 13165 | 679567fae315 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.java2d.pipe; |
|
27 |
||
28 |
import java.awt.Rectangle; |
|
29 |
||
12813
c10ab96dcf41
7170969: Add @GenerateNativeHeader to classes whose fields need to be exported for JNI
erikj
parents:
5506
diff
changeset
|
30 |
import javax.tools.annotation.GenerateNativeHeader; |
c10ab96dcf41
7170969: Add @GenerateNativeHeader to classes whose fields need to be exported for JNI
erikj
parents:
5506
diff
changeset
|
31 |
|
2 | 32 |
/** |
33 |
* This class defines the API for iterating through the bands |
|
34 |
* of a region object. |
|
35 |
*/ |
|
12813
c10ab96dcf41
7170969: Add @GenerateNativeHeader to classes whose fields need to be exported for JNI
erikj
parents:
5506
diff
changeset
|
36 |
/* No native methods here, but the constants are needed in the supporting JNI code */ |
c10ab96dcf41
7170969: Add @GenerateNativeHeader to classes whose fields need to be exported for JNI
erikj
parents:
5506
diff
changeset
|
37 |
@GenerateNativeHeader |
2 | 38 |
public class RegionIterator { |
39 |
Region region; |
|
40 |
int curIndex; |
|
41 |
int numXbands; |
|
42 |
||
43 |
RegionIterator(Region r) { |
|
44 |
region = r; |
|
45 |
} |
|
46 |
||
47 |
/** |
|
48 |
* Returns a new RegionIterator object representing the same |
|
49 |
* iteration state as this object to allow multiple iteration |
|
50 |
* branches from the current position. |
|
51 |
*/ |
|
52 |
public RegionIterator createCopy() { |
|
53 |
RegionIterator r = new RegionIterator(region); |
|
54 |
r.curIndex = this.curIndex; |
|
55 |
r.numXbands = this.numXbands; |
|
56 |
return r; |
|
57 |
} |
|
58 |
||
59 |
/** |
|
60 |
* Copies the iteration state from this RegionIterator object |
|
61 |
* into another RegionIterator object to allow multiple iteration |
|
62 |
* branches from the current position. |
|
63 |
*/ |
|
64 |
public void copyStateFrom(RegionIterator ri) { |
|
65 |
if (this.region != ri.region) { |
|
66 |
throw new InternalError("region mismatch"); |
|
67 |
} |
|
68 |
this.curIndex = ri.curIndex; |
|
69 |
this.numXbands = ri.numXbands; |
|
70 |
} |
|
71 |
||
72 |
/** |
|
73 |
* Moves the iteration state to the beginning of the next |
|
74 |
* Y range in the region returning true if one is found |
|
75 |
* and recording the low and high Y coordinates of the |
|
76 |
* range in the array at locations 1 and 3 respectively. |
|
77 |
*/ |
|
78 |
public boolean nextYRange(int range[]) { |
|
79 |
curIndex += numXbands * 2; |
|
80 |
numXbands = 0; |
|
81 |
if (curIndex >= region.endIndex) { |
|
82 |
return false; |
|
83 |
} |
|
84 |
range[1] = region.bands[curIndex++]; |
|
85 |
range[3] = region.bands[curIndex++]; |
|
86 |
numXbands = region.bands[curIndex++]; |
|
87 |
return true; |
|
88 |
} |
|
89 |
||
90 |
/** |
|
91 |
* Moves the iteration state to the beginning of the next |
|
92 |
* X band in the current Y range returning true if one is |
|
93 |
* found and recording the low and high X coordinates of |
|
94 |
* the range in the array at locations 0 and 2 respectively. |
|
95 |
*/ |
|
96 |
public boolean nextXBand(int range[]) { |
|
97 |
if (numXbands <= 0) { |
|
98 |
return false; |
|
99 |
} |
|
100 |
numXbands--; |
|
101 |
range[0] = region.bands[curIndex++]; |
|
102 |
range[2] = region.bands[curIndex++]; |
|
103 |
return true; |
|
104 |
} |
|
105 |
} |