0N/A/*
2362N/A * Copyright (c) 1998, 2002, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.java2d.pipe;
0N/A
0N/Aimport java.awt.Rectangle;
0N/A
0N/A/**
0N/A * This class defines the API for iterating through the bands
0N/A * of a region object.
0N/A */
0N/Apublic class RegionIterator {
0N/A Region region;
0N/A int curIndex;
0N/A int numXbands;
0N/A
0N/A RegionIterator(Region r) {
0N/A region = r;
0N/A }
0N/A
0N/A /**
0N/A * Returns a new RegionIterator object representing the same
0N/A * iteration state as this object to allow multiple iteration
0N/A * branches from the current position.
0N/A */
0N/A public RegionIterator createCopy() {
0N/A RegionIterator r = new RegionIterator(region);
0N/A r.curIndex = this.curIndex;
0N/A r.numXbands = this.numXbands;
0N/A return r;
0N/A }
0N/A
0N/A /**
0N/A * Copies the iteration state from this RegionIterator object
0N/A * into another RegionIterator object to allow multiple iteration
0N/A * branches from the current position.
0N/A */
0N/A public void copyStateFrom(RegionIterator ri) {
0N/A if (this.region != ri.region) {
0N/A throw new InternalError("region mismatch");
0N/A }
0N/A this.curIndex = ri.curIndex;
0N/A this.numXbands = ri.numXbands;
0N/A }
0N/A
0N/A /**
0N/A * Moves the iteration state to the beginning of the next
0N/A * Y range in the region returning true if one is found
0N/A * and recording the low and high Y coordinates of the
0N/A * range in the array at locations 1 and 3 respectively.
0N/A */
0N/A public boolean nextYRange(int range[]) {
0N/A curIndex += numXbands * 2;
0N/A numXbands = 0;
0N/A if (curIndex >= region.endIndex) {
0N/A return false;
0N/A }
0N/A range[1] = region.bands[curIndex++];
0N/A range[3] = region.bands[curIndex++];
0N/A numXbands = region.bands[curIndex++];
0N/A return true;
0N/A }
0N/A
0N/A /**
0N/A * Moves the iteration state to the beginning of the next
0N/A * X band in the current Y range returning true if one is
0N/A * found and recording the low and high X coordinates of
0N/A * the range in the array at locations 0 and 2 respectively.
0N/A */
0N/A public boolean nextXBand(int range[]) {
0N/A if (numXbands <= 0) {
0N/A return false;
0N/A }
0N/A numXbands--;
0N/A range[0] = region.bands[curIndex++];
0N/A range[2] = region.bands[curIndex++];
0N/A return true;
0N/A }
0N/A}