/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* This class encapsulates a definition of a two dimensional region which
* consists of a number of Y ranges each containing multiple X bands.
* <p>
* A rectangular Region is allowed to have a null band list in which
* case the rectangular shape is defined by the bounding box parameters
* (lox, loy, hix, hiy).
* <p>
* The band list, if present, consists of a list of rows in ascending Y
* order, ending at endIndex which is the index beyond the end of the
* last row. Each row consists of at least 3 + 2n entries (n >= 1)
* where the first 3 entries specify the Y range as start, end, and
* the number of X ranges in that Y range. These 3 entries are
* followed by pairs of X coordinates in ascending order:
* <pre>
* bands[rowstart+0] = Y0; // starting Y coordinate
* bands[rowstart+1] = Y1; // ending Y coordinate - endY > startY
* bands[rowstart+2] = N; // number of X bands - N >= 1
*
* bands[rowstart+3] = X10; // starting X coordinate of first band
* bands[rowstart+4] = X11; // ending X coordinate of first band
* bands[rowstart+5] = X20; // starting X coordinate of second band
* bands[rowstart+6] = X21; // ending X coordinate of second band
* ...
* bands[rowstart+3+N*2-2] = XN0; // starting X coord of last band
* bands[rowstart+3+N*2-1] = XN1; // ending X coord of last band
*
* bands[rowstart+3+N*2] = ... // start of next Y row
* </pre>
*/
public class Region {
/**
* Immutable Region.
*/
}
// Override all the methods that mutate the object
public void setOutputAreaXYWH(int x, int y, int w, int h) {}
}
int lox;
int loy;
int hix;
int hiy;
int endIndex;
int[] bands;
private static native void initIDs();
static {
initIDs();
}
/**
* Adds the dimension <code>dim</code> to the coordinate
* <code>start</code> with appropriate clipping. If
* <code>dim</code> is non-positive then the method returns
* the start coordinate. If the sum overflows an integer
* data type then the method returns <code>Integer.MAX_VALUE</code>.
*/
return dim;
}
/**
* Adds the delta {@code dv} to the value {@code v} with
* appropriate clipping to the bounds of Integer resolution.
* If the answer would be greater than {@code Integer.MAX_VALUE}
* then {@code Integer.MAX_VALUE} is returned.
* If the answer would be less than {@code Integer.MIN_VALUE}
* then {@code Integer.MIN_VALUE} is returned.
* Otherwise the sum is returned.
*/
}
return newv;
}
/**
* Multiply the scale factor {@code sv} and the value {@code v} with
* appropriate clipping to the bounds of Integer resolution. If the answer
* would be greater than {@code Integer.MAX_VALUE} then {@code
* Integer.MAX_VALUE} is returned. If the answer would be less than {@code
* Integer.MIN_VALUE} then {@code Integer.MIN_VALUE} is returned. Otherwise
* the multiplication is returned.
*/
if (sv == 1.0) {
return v;
}
}
}
}
}
/**
* Returns a Region object covering the pixels which would be
* touched by a fill or clip operation on a Graphics implementation
* on the specified Shape object under the optionally specified
* AffineTransform object.
*
* @param s a non-null Shape object specifying the geometry enclosing
* the pixels of interest
* @param at an optional <code>AffineTransform</code> to be applied to the
* coordinates as they are returned in the iteration, or
* <code>null</code> if untransformed coordinates are desired
*/
}
/**
* Returns a Region object covering the pixels which would be
* touched by a fill or clip operation on a Graphics implementation
* on the specified Shape object under the optionally specified
* AffineTransform object further restricted by the specified
* device bounds.
* <p>
* Note that only the bounds of the specified Region are used to
* restrict the resulting Region.
* If devBounds is non-rectangular and clipping to the specific
* bands of devBounds is needed, then an intersection of the
* resulting Region with devBounds must be performed in a
* subsequent step.
*
* @param devBounds a non-null Region specifying some bounds to
* clip the geometry to
* @param s a non-null Shape object specifying the geometry enclosing
* the pixels of interest
* @param at an optional <code>AffineTransform</code> to be applied to the
* coordinates as they are returned in the iteration, or
* <code>null</code> if untransformed coordinates are desired
*/
{
}
/**
* Returns a Region object covering the pixels which would be
* touched by a fill or clip operation on a Graphics implementation
* on the specified Shape object under the optionally specified
* AffineTransform object further restricted by the specified
* device bounds.
* If the normalize parameter is true then coordinate normalization
* is performed as per the 2D Graphics non-antialiasing implementation
* of the VALUE_STROKE_NORMALIZE hint.
* <p>
* Note that only the bounds of the specified Region are used to
* restrict the resulting Region.
* If devBounds is non-rectangular and clipping to the specific
* bands of devBounds is needed, then an intersection of the
* resulting Region with devBounds must be performed in a
* subsequent step.
*
* @param devBounds a non-null Region specifying some bounds to
* clip the geometry to
* @param normalize a boolean indicating whether or not to apply
* normalization
* @param s a non-null Shape object specifying the geometry enclosing
* the pixels of interest
* @param at an optional <code>AffineTransform</code> to be applied to the
* coordinates as they are returned in the iteration, or
* <code>null</code> if untransformed coordinates are desired
*/
{
// Optimize for empty shapes to avoid involving the SpanIterator
if (s instanceof RectangularShape &&
((RectangularShape)s).isEmpty())
{
return EMPTY_REGION;
}
int box[] = new int[4];
try {
r.appendSpans(sr);
return r;
} finally {
}
}
/**
* Returns a Region object with a rectangle of interest specified
* by the indicated Rectangle object.
* <p>
* This method can also be used to create a simple rectangular
* region.
*/
}
/**
* Returns a Region object with a rectangle of interest specified
* by the indicated rectangular area in x, y, width, height format.
* <p>
* This method can also be used to create a simple rectangular
* region.
*/
}
/**
* Returns a Region object with a rectangle of interest specified
* by the indicated span array.
* <p>
* This method can also be used to create a simple rectangular
* region.
*/
}
/**
* Returns a Region object with a rectangle of interest specified
* by the indicated rectangular area in lox, loy, hix, hiy format.
* <p>
* This method can also be used to create a simple rectangular
* region.
*/
}
/**
* Sets the rectangle of interest for storing and returning
* region bands.
* <p>
* This method can also be used to initialize a simple rectangular
* region.
*/
}
/**
* Sets the rectangle of interest for storing and returning
* region bands. The rectangle is specified in x, y, width, height
* format and appropriate clipping is performed as per the method
* <code>dimAdd</code>.
* <p>
* This method can also be used to initialize a simple rectangular
* region.
*/
public void setOutputAreaXYWH(int x, int y, int w, int h) {
}
/**
* Sets the rectangle of interest for storing and returning
* region bands. The rectangle is specified as a span array.
* <p>
* This method can also be used to initialize a simple rectangular
* region.
*/
}
/**
* Sets the rectangle of interest for storing and returning
* region bands. The rectangle is specified in lox, loy,
* hix, hiy format.
* <p>
* This method can also be used to initialize a simple rectangular
* region.
*/
}
/**
* Appends the list of spans returned from the indicated
* SpanIterator. Each span must be at a higher starting
* Y coordinate than the previous data or it must have a
* Y range equal to the highest Y band in the region and a
* higher X coordinate than any of the spans in that band.
*/
int[] box = new int[6];
}
calcBBox();
}
/**
* Returns a Region object that represents the same list of rectangles as
* the current Region object, scaled by the specified sx, sy factors.
*/
return EMPTY_REGION;
}
return this;
}
int i = 0; // index for source bands
int j = 0; // index for translated newbands
int ncol;
while (i < end) {
int savej = j;
while (--ncol >= 0) {
}
}
} else {
i += ncol * 2;
}
// Did we get any non-empty bands in this row?
if (j > savej) {
} else {
j = savej - 3;
}
}
if (j <= 5) {
if (j < 5) {
// No rows or bands were generated...
} else {
// Only generated one single rect in the end...
}
// ret.endIndex and ret.bands were never initialized...
// ret.endIndex = 0;
// ret.newbands = null;
} else {
}
}
return ret;
}
/**
* Returns a Region object that represents the same list of
* rectangles as the current Region object, translated by
* the specified dx, dy translation factors.
*/
return this;
}
{
}
int i = 0;
int ncol;
while (i < end) {
while (--ncol >= 0) {
}
}
}
return ret;
}
int i = 0; // index for source bands
int j = 0; // index for translated newbands
int ncol;
while (i < end) {
int savej = j;
while (--ncol >= 0) {
}
}
} else {
i += ncol * 2;
}
// Did we get any non-empty bands in this row?
if (j > savej) {
} else {
j = savej - 3;
}
}
if (j <= 5) {
if (j < 5) {
// No rows or bands were generated...
} else {
// Only generated one single rect in the end...
}
// ret.endIndex and ret.bands were never initialized...
// ret.endIndex = 0;
// ret.newbands = null;
} else {
}
}
return ret;
}
/**
* Returns a Region object that represents the intersection of
* this object with the specified Rectangle. The return value
* may be this same object if no clipping occurs.
*/
}
/**
* Returns a Region object that represents the intersection of
* this object with the specified rectangular area. The return
* value may be this same object if no clipping occurs.
*/
}
/**
* Returns a Region object that represents the intersection of
* this object with the specified rectangular area. The return
* value may be this same object if no clipping occurs.
*/
return this;
}
}
return ret;
}
/**
* Returns a Region object that represents the intersection of this
* object with the specified Region object.
* <p>
* If {@code A} and {@code B} are both Region Objects and
* <code>C = A.getIntersection(B);</code> then a point will
* be contained in {@code C} iff it is contained in both
* {@code A} and {@code B}.
* <p>
* The return value may be this same object or the argument
* Region object if no clipping occurs.
*/
if (this.isInsideQuickCheck(r)) {
return this;
}
if (r.isInsideQuickCheck(this)) {
return r;
}
}
return ret;
}
/**
* Returns a Region object that represents the union of this
* object with the specified Region object.
* <p>
* If {@code A} and {@code B} are both Region Objects and
* <code>C = A.getUnion(B);</code> then a point will
* be contained in {@code C} iff it is contained in either
* {@code A} or {@code B}.
* <p>
* The return value may be this same object or the argument
* Region object if no augmentation occurs.
*/
if (r.isEmpty() || r.isInsideQuickCheck(this)) {
return this;
}
if (this.isEmpty() || this.isInsideQuickCheck(r)) {
return r;
}
return ret;
}
/**
* Returns a Region object that represents the difference of the
* specified Region object subtracted from this object.
* <p>
* If {@code A} and {@code B} are both Region Objects and
* <code>C = A.getDifference(B);</code> then a point will
* be contained in {@code C} iff it is contained in
* {@code A} but not contained in {@code B}.
* <p>
* The return value may be this same object or the argument
* Region object if no clipping occurs.
*/
if (!r.intersectsQuickCheck(this)) {
return this;
}
if (this.isInsideQuickCheck(r)) {
return EMPTY_REGION;
}
return ret;
}
/**
* Returns a Region object that represents the exclusive or of this
* object with the specified Region object.
* <p>
* If {@code A} and {@code B} are both Region Objects and
* <code>C = A.getExclusiveOr(B);</code> then a point will
* be contained in {@code C} iff it is contained in either
* {@code A} or {@code B}, but not if it is contained in both.
* <p>
* The return value may be this same object or the argument
* Region object if either is empty.
*/
if (r.isEmpty()) {
return this;
}
if (this.isEmpty()) {
return r;
}
return ret;
}
}
}
int box[] = new int[6];
int acolstart = 0;
int bcolstart = 0;
int y = loy;
while (y < hiy) {
if (y >= ay2) {
} else {
}
continue;
}
if (y >= by2) {
} else {
}
continue;
}
int yend;
if (y < by1) {
if (y < ay1) {
continue;
}
// We are in a set of rows that belong only to A
box[1] = y;
}
}
} else if (y < ay1) {
// We are in a set of rows that belong only to B
box[1] = y;
}
}
} else {
// We are in a set of rows that belong to both A and B
box[1] = y;
while (x < hix) {
if (x >= ax2) {
} else {
}
continue;
}
if (x >= bx2) {
} else {
}
continue;
}
int xend;
boolean appendit;
if (x < bx1) {
if (x < ax1) {
appendit = false;
} else {
}
} else if (x < ax1) {
} else {
}
if (appendit) {
box[0] = x;
}
x = xend;
}
}
y = yend;
}
calcBBox();
}
/**
* Returns a Region object that represents the bounds of the
* intersection of this object with the bounds of the specified
* Region object.
* <p>
* The return value may be this same object if no clipping occurs
* and this Region is rectangular.
*/
}
/**
* Returns a Region object that represents the bounds of the
* intersection of this object with the bounds of the specified
* rectangular area in x, y, width, height format.
* <p>
* The return value may be this same object if no clipping occurs
* and this Region is rectangular.
*/
}
/**
* Returns a Region object that represents the bounds of the
* intersection of this object with the bounds of the specified
* rectangular area in lox, loy, hix, hiy format.
* <p>
* The return value may be this same object if no clipping occurs
* and this Region is rectangular.
*/
{
{
return this;
}
}
/**
* Returns a Region object that represents the intersection of
* this object with the bounds of the specified Region object.
* <p>
* The return value may be this same object or the argument
* Region object if no clipping occurs and the Regions are
* rectangular.
*/
if (this.encompasses(r)) {
return r;
}
if (r.encompasses(this)) {
return this;
}
}
/**
* Appends a single span defined by the 4 parameters
* spanlox, spanloy, spanhix, spanhiy.
* This span must be at a higher starting Y coordinate than
* the previous data or it must have a Y range equal to the
* highest Y band in the region and a higher X coordinate
* than any of the spans in that band.
*/
return;
}
} else {
needSpace(5);
}
return;
}
needSpace(2);
} else {
throw new InternalError("bad span");
}
}
}
}
{
cur += 3;
prev += 3;
while (num > 0) {
break;
}
num--;
}
if (num == 0) {
// prev == box[4]
return;
}
}
}
}
private void calcBBox() {
if (endIndex <= 5) {
if (endIndex == 0) {
} else {
endIndex = 0;
}
return;
}
int hiyindex = 0;
int i = 0;
while (i < endIndex) {
hiyindex = i;
i += 3;
}
i += numbands * 2;
}
}
}
/**
* Returns the lowest X coordinate in the Region.
*/
public final int getLoX() {
return lox;
}
/**
* Returns the lowest Y coordinate in the Region.
*/
public final int getLoY() {
return loy;
}
/**
* Returns the highest X coordinate in the Region.
*/
public final int getHiX() {
return hix;
}
/**
* Returns the highest Y coordinate in the Region.
*/
public final int getHiY() {
return hiy;
}
/**
* Returns the width of this Region clipped to the range (0 - MAX_INT).
*/
public final int getWidth() {
int w;
}
return w;
}
/**
* Returns the height of this Region clipped to the range (0 - MAX_INT).
*/
public final int getHeight() {
int h;
}
return h;
}
/**
* Returns true iff this Region encloses no area.
*/
public boolean isEmpty() {
}
/**
* Returns true iff this Region represents a single simple
* rectangular area.
*/
public boolean isRectangular() {
}
/**
* Returns true iff this Region contains the specified coordinate.
*/
public boolean contains(int x, int y) {
int i = 0;
while (i < endIndex) {
if (y < bands[i++]) {
return false;
}
if (y >= bands[i++]) {
i += numspans * 2;
} else {
while (i < end) {
if (x < bands[i++]) return false;
if (x < bands[i++]) return true;
}
return false;
}
}
return false;
}
/**
* Returns true iff this Region lies inside the indicated
* rectangular area specified in x, y, width, height format
* with appropriate clipping performed as per the dimAdd method.
*/
public boolean isInsideXYWH(int x, int y, int w, int h) {
}
/**
* Returns true iff this Region lies inside the indicated
* rectangular area specified in lox, loy, hix, hiy format.
*/
}
/**
* Quickly checks if this Region lies inside the specified
* Region object.
* <p>
* This method will return false if the specified Region
* object is not a simple rectangle.
*/
}
/**
* Quickly checks if this Region intersects the specified
* rectangular area specified in lox, loy, hix, hiy format.
* <p>
* This method tests only against the bounds of this region
* and does not bother to test if the rectangular region
* actually intersects any bands.
*/
{
}
/**
* Quickly checks if this Region intersects the specified
* Region object.
* <p>
* This method tests only against the bounds of this region
* and does not bother to test if the rectangular region
* actually intersects any bands.
*/
}
/**
* Quickly checks if this Region surrounds the specified
* Region object.
* <p>
* This method will return false if this Region object is
* not a simple rectangle.
*/
}
/**
* Quickly checks if this Region surrounds the specified
* rectangular area specified in x, y, width, height format.
* <p>
* This method will return false if this Region object is
* not a simple rectangle.
*/
public boolean encompassesXYWH(int x, int y, int w, int h) {
}
/**
* Quickly checks if this Region surrounds the specified
* rectangular area specified in lox, loy, hix, hiy format.
* <p>
* This method will return false if this Region object is
* not a simple rectangle.
*/
}
/**
* Gets the bbox of the available spans, clipped to the OutputArea.
*/
}
/**
* Clips the indicated bbox array to the bounds of this Region.
*/
}
/**
* Gets an iterator object to iterate over the spans in this region.
*/
return new RegionIterator(this);
}
/**
* Gets a span iterator object that iterates over the spans in this region
*/
return new RegionSpanIterator(this);
}
/**
* Gets a span iterator object that iterates over the spans in this region
* but clipped to the bounds given in the argument (xlo, ylo, xhi, yhi).
*/
return result;
}
/**
* Returns a SpanIterator that is the argument iterator filtered by
* this region.
*/
} else {
}
return si;
}
int col = 0;
}
}
}
}
public int hashCode() {
}
if (!(o instanceof Region)) {
return false;
}
if (this.isEmpty()) {
return r.isEmpty();
} else if (r.isEmpty()) {
return false;
}
{
return false;
}
return false;
}
return false;
}
for (int i = 0; i < endIndex; i++) {
return false;
}
}
return true;
}
}