/*
* 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.
*
* 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.
*/
/*
* @test %W% %E%
* @bug 6504874
* @summary This test verifies the operation (and performance) of the
* various CAG operations on the internal Region class.
* @run main RegionOps
*/
public class RegionOps {
public static boolean useArea;
static int numops;
static int numErrors;
static boolean skipCheck;
static boolean countErrors;
static {
// Instantiating BufferedImage initializes sun.java2d
}
}
"[-regions N] [-rects M] "+
"[-[min|max]rects M] [-area]");
"[-add|union] [-sub|diff] "+
"[-int[ersect]] [-xor]");
"[-seed S] [-nocheck] [-count[errors]] [-help]");
}
if (b != null) {
}
if (countErrors) {
numErrors++;
} else {
throw new RuntimeException(problem);
}
}
int numregions = DEFAULT_NUMREGIONS;
int minsubrects = DEFAULT_MINSUBRECTS;
int maxsubrects = DEFAULT_MAXSUBRECTS;
boolean doUnion = false;
boolean doIntersect = false;
boolean doSubtract = false;
boolean doXor = false;
usage("missing arg for -regions");
}
usage("missing arg for -rects");
}
usage("missing arg for -minrects");
}
usage("missing arg for -maxrects");
}
useArea = true;
{
doUnion = true;
{
doSubtract = true;
{
doIntersect = true;
doXor = true;
usage("missing arg for -seed");
}
skipCheck = true;
{
countErrors = true;
} else {
}
}
if (maxsubrects < minsubrects) {
usage("maximum number of subrectangles less than minimum");
}
if (minsubrects <= 0) {
usage("minimum number of subrectangles must be positive");
}
}
int totalrects = 0;
int numsubrects =
for (int j = 0; j < numsubrects; j++) {
totalrects++;
}
}
totalrects+" subrectangles");
RectListImpl a = rlist[i];
testTranslate(a);
RectListImpl b = rlist[j];
if (doSubtract) testDifference(a, b);
if (doIntersect) testIntersection(a, b);
if (doXor) testExclusiveOr(a, b);
}
}
if (numErrors > 0) {
}
}
}
{
}
if (!a.equals(b)) {
}
}
if (!maxTrans.checkTransEmpty()) {
}
if (!minTrans.checkTransEmpty()) {
}
}
}
}
boolean isNonDestructive,
{
if (skipCheck) return;
}
}
}
}
if (skipCheck) return;
}
{
}
}
}
}
if (skipCheck) return;
// Note that difference is not commutative so we cannot check equals
// checkEqual(a, b, "Difference");
testDifference(a, b, aDb);
testDifference(b, a, bDa);
}
{
}
}
}
}
if (skipCheck) return;
testIntersection(a, b, aIb);
testIntersection(a, b, bIa);
}
{
}
}
}
}
if (skipCheck) return;
testExclusiveOr(a, b, aXb);
testExclusiveOr(a, b, bXa);
}
{
}
}
}
}
public abstract static class RectListImpl {
if (useArea) {
return new AreaImpl();
} else {
return new RegionImpl();
}
}
// Used for making sure that 3xMAX translates yields an empty region
public abstract boolean checkTransEmpty();
public abstract boolean contains(int x, int y);
public abstract int hashCode();
}
public AreaImpl() {
}
theArea = a;
}
} else {
}
}
}
}
}
}
}
// Used for making sure that 3xMAX translates yields an empty region
public boolean checkTransEmpty() {
// Area objects will actually survive 3 MAX translates so just
// pretend that it had the intended effect...
return true;
}
public boolean contains(int x, int y) {
}
public int hashCode() {
// Area does not override hashCode...
return 0;
}
}
}
}
public RegionImpl() {
}
theRegion = r;
}
} else {
}
}
}
return new RegionImpl(r2);
}
return new RegionImpl(r2);
}
return new RegionImpl(r2);
}
return new RegionImpl(r2);
}
// Used for making sure that 3xMAX translates yields an empty region
public boolean checkTransEmpty() {
// Region objects should be empty after 3 MAX translates...
}
public boolean contains(int x, int y) {
}
public int hashCode() {
}
}
}
}
}