src/share/classes/java/awt/geom/Path2D.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 222,233 ****
public Float(Shape s, AffineTransform at) {
if (s instanceof Path2D) {
Path2D p2d = (Path2D) s;
setWindingRule(p2d.windingRule);
this.numTypes = p2d.numTypes;
! this.pointTypes = Arrays.copyOf(p2d.pointTypes,
! p2d.pointTypes.length);
this.numCoords = p2d.numCoords;
this.floatCoords = p2d.cloneCoordsFloat(at);
} else {
PathIterator pi = s.getPathIterator(at);
setWindingRule(pi.getWindingRule());
--- 222,233 ----
public Float(Shape s, AffineTransform at) {
if (s instanceof Path2D) {
Path2D p2d = (Path2D) s;
setWindingRule(p2d.windingRule);
this.numTypes = p2d.numTypes;
! // trim arrays:
! this.pointTypes = Arrays.copyOf(p2d.pointTypes, p2d.numTypes);
this.numCoords = p2d.numCoords;
this.floatCoords = p2d.cloneCoordsFloat(at);
} else {
PathIterator pi = s.getPathIterator(at);
setWindingRule(pi.getWindingRule());
*** 235,257 ****
this.floatCoords = new float[INIT_SIZE * 2];
append(pi, false);
}
}
float[] cloneCoordsFloat(AffineTransform at) {
float ret[];
if (at == null) {
! ret = Arrays.copyOf(this.floatCoords, this.floatCoords.length);
} else {
! ret = new float[floatCoords.length];
at.transform(floatCoords, 0, ret, 0, numCoords / 2);
}
return ret;
}
double[] cloneCoordsDouble(AffineTransform at) {
! double ret[] = new double[floatCoords.length];
if (at == null) {
for (int i = 0; i < numCoords; i++) {
ret[i] = floatCoords[i];
}
} else {
--- 235,261 ----
this.floatCoords = new float[INIT_SIZE * 2];
append(pi, false);
}
}
+ @Override
float[] cloneCoordsFloat(AffineTransform at) {
+ // trim arrays:
float ret[];
if (at == null) {
! ret = Arrays.copyOf(floatCoords, numCoords);
} else {
! ret = new float[numCoords];
at.transform(floatCoords, 0, ret, 0, numCoords / 2);
}
return ret;
}
+ @Override
double[] cloneCoordsDouble(AffineTransform at) {
! // trim arrays:
! double ret[] = new double[numCoords];
if (at == null) {
for (int i = 0; i < numCoords; i++) {
ret[i] = floatCoords[i];
}
} else {
*** 473,482 ****
--- 477,489 ----
floatCoords[numCoords++] = x3;
floatCoords[numCoords++] = y3;
}
int pointCrossings(double px, double py) {
+ if (numTypes == 0) {
+ return 0;
+ }
double movx, movy, curx, cury, endx, endy;
float coords[] = floatCoords;
curx = movx = coords[0];
cury = movy = coords[1];
int crossings = 0;
*** 550,559 ****
--- 557,569 ----
}
int rectCrossings(double rxmin, double rymin,
double rxmax, double rymax)
{
+ if (numTypes == 0) {
+ return 0;
+ }
float coords[] = floatCoords;
double curx, cury, movx, movy, endx, endy;
curx = movx = coords[0];
cury = movy = coords[1];
int crossings = 0;
*** 1059,1070 ****
public Double(Shape s, AffineTransform at) {
if (s instanceof Path2D) {
Path2D p2d = (Path2D) s;
setWindingRule(p2d.windingRule);
this.numTypes = p2d.numTypes;
! this.pointTypes = Arrays.copyOf(p2d.pointTypes,
! p2d.pointTypes.length);
this.numCoords = p2d.numCoords;
this.doubleCoords = p2d.cloneCoordsDouble(at);
} else {
PathIterator pi = s.getPathIterator(at);
setWindingRule(pi.getWindingRule());
--- 1069,1080 ----
public Double(Shape s, AffineTransform at) {
if (s instanceof Path2D) {
Path2D p2d = (Path2D) s;
setWindingRule(p2d.windingRule);
this.numTypes = p2d.numTypes;
! // trim arrays:
! this.pointTypes = Arrays.copyOf(p2d.pointTypes, p2d.numTypes);
this.numCoords = p2d.numCoords;
this.doubleCoords = p2d.cloneCoordsDouble(at);
} else {
PathIterator pi = s.getPathIterator(at);
setWindingRule(pi.getWindingRule());
*** 1072,1100 ****
this.doubleCoords = new double[INIT_SIZE * 2];
append(pi, false);
}
}
float[] cloneCoordsFloat(AffineTransform at) {
! float ret[] = new float[doubleCoords.length];
if (at == null) {
for (int i = 0; i < numCoords; i++) {
ret[i] = (float) doubleCoords[i];
}
} else {
at.transform(doubleCoords, 0, ret, 0, numCoords / 2);
}
return ret;
}
double[] cloneCoordsDouble(AffineTransform at) {
double ret[];
if (at == null) {
! ret = Arrays.copyOf(this.doubleCoords,
! this.doubleCoords.length);
} else {
! ret = new double[doubleCoords.length];
at.transform(doubleCoords, 0, ret, 0, numCoords / 2);
}
return ret;
}
--- 1082,1113 ----
this.doubleCoords = new double[INIT_SIZE * 2];
append(pi, false);
}
}
+ @Override
float[] cloneCoordsFloat(AffineTransform at) {
! // trim arrays:
! float ret[] = new float[numCoords];
if (at == null) {
for (int i = 0; i < numCoords; i++) {
ret[i] = (float) doubleCoords[i];
}
} else {
at.transform(doubleCoords, 0, ret, 0, numCoords / 2);
}
return ret;
}
+ @Override
double[] cloneCoordsDouble(AffineTransform at) {
+ // trim arrays:
double ret[];
if (at == null) {
! ret = Arrays.copyOf(doubleCoords, numCoords);
} else {
! ret = new double[numCoords];
at.transform(doubleCoords, 0, ret, 0, numCoords / 2);
}
return ret;
}
*** 1200,1209 ****
--- 1213,1225 ----
doubleCoords[numCoords++] = x3;
doubleCoords[numCoords++] = y3;
}
int pointCrossings(double px, double py) {
+ if (numTypes == 0) {
+ return 0;
+ }
double movx, movy, curx, cury, endx, endy;
double coords[] = doubleCoords;
curx = movx = coords[0];
cury = movy = coords[1];
int crossings = 0;
*** 1277,1286 ****
--- 1293,1305 ----
}
int rectCrossings(double rxmin, double rymin,
double rxmax, double rymax)
{
+ if (numTypes == 0) {
+ return 0;
+ }
double coords[] = doubleCoords;
double curx, cury, movx, movy, endx, endy;
curx = movx = coords[0];
cury = movy = coords[1];
int crossings = 0;