Methods Summary |
---|
public void | append(java.awt.Shape shape, boolean connect)Appends the outline of the specified shape onto the end of this
GeneralPath.
PathIterator p = shape.getPathIterator(null);
append(p, connect);
|
public void | append(java.awt.geom.PathIterator path, boolean connect)Appends the path defined by the specified PathIterator onto the end of
this GeneralPath.
while (!path.isDone()) {
float coords[] = new float[6];
switch (path.currentSegment(coords)) {
case PathIterator.SEG_MOVETO:
if (!connect || typeSize == 0) {
moveTo(coords[0], coords[1]);
break;
}
if (types[typeSize - 1] != PathIterator.SEG_CLOSE
&& points[pointSize - 2] == coords[0]
&& points[pointSize - 1] == coords[1]) {
break;
}
// NO BREAK;
case PathIterator.SEG_LINETO:
lineTo(coords[0], coords[1]);
break;
case PathIterator.SEG_QUADTO:
quadTo(coords[0], coords[1], coords[2], coords[3]);
break;
case PathIterator.SEG_CUBICTO:
curveTo(coords[0], coords[1], coords[2], coords[3], coords[4], coords[5]);
break;
case PathIterator.SEG_CLOSE:
closePath();
break;
}
path.next();
connect = false;
}
|
void | checkBuf(int pointCount, boolean checkMove)Checks the point data buffer sizes to see whether pointCount additional
point-data elements can fit. (Note that the number of point data elements
to add is more than one per point -- it depends on the type of point
being added.) Reallocates the buffers to enlarge the size if necessary.
if (checkMove && typeSize == 0) {
// awt.20A=First segment should be SEG_MOVETO type
throw new IllegalPathStateException(Messages.getString("awt.20A")); //$NON-NLS-1$
}
if (typeSize == types.length) {
byte tmp[] = new byte[typeSize + BUFFER_CAPACITY];
System.arraycopy(types, 0, tmp, 0, typeSize);
types = tmp;
}
if (pointSize + pointCount > points.length) {
float tmp[] = new float[pointSize + Math.max(BUFFER_CAPACITY * 2, pointCount)];
System.arraycopy(points, 0, tmp, 0, pointSize);
points = tmp;
}
|
public java.lang.Object | clone()
try {
GeneralPath p = (GeneralPath)super.clone();
p.types = types.clone();
p.points = points.clone();
return p;
} catch (CloneNotSupportedException e) {
throw new InternalError();
}
|
public void | closePath()Appends the type information to declare that the current endpoint closes
the curve.
if (typeSize == 0 || types[typeSize - 1] != PathIterator.SEG_CLOSE) {
checkBuf(0, true);
types[typeSize++] = PathIterator.SEG_CLOSE;
}
|
public boolean | contains(double px, double py)
return isInside(Crossing.crossShape(this, px, py));
|
public boolean | contains(double rx, double ry, double rw, double rh)
int cross = Crossing.intersectShape(this, rx, ry, rw, rh);
return cross != Crossing.CROSSING && isInside(cross);
|
public boolean | contains(java.awt.geom.Point2D p)
return contains(p.getX(), p.getY());
|
public boolean | contains(java.awt.geom.Rectangle2D r)
return contains(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
public java.awt.Shape | createTransformedShape(java.awt.geom.AffineTransform t)Creates a new GeneralPath whose data is given by this path's data
transformed according to the specified AffineTransform.
GeneralPath p = (GeneralPath)clone();
if (t != null) {
p.transform(t);
}
return p;
|
public void | curveTo(float x1, float y1, float x2, float y2, float x3, float y3)Appends a new segment to the end of this general path by making a cubic
curve from the current endpoint to the point (x3, y3) using (x1, y1) and
(x2, y2) as control points.
checkBuf(6, true);
types[typeSize++] = PathIterator.SEG_CUBICTO;
points[pointSize++] = x1;
points[pointSize++] = y1;
points[pointSize++] = x2;
points[pointSize++] = y2;
points[pointSize++] = x3;
points[pointSize++] = y3;
|
public java.awt.Rectangle | getBounds()
return getBounds2D().getBounds();
|
public java.awt.geom.Rectangle2D | getBounds2D()
float rx1, ry1, rx2, ry2;
if (pointSize == 0) {
rx1 = ry1 = rx2 = ry2 = 0.0f;
} else {
int i = pointSize - 1;
ry1 = ry2 = points[i--];
rx1 = rx2 = points[i--];
while (i > 0) {
float y = points[i--];
float x = points[i--];
if (x < rx1) {
rx1 = x;
} else if (x > rx2) {
rx2 = x;
}
if (y < ry1) {
ry1 = y;
} else if (y > ry2) {
ry2 = y;
}
}
}
return new Rectangle2D.Float(rx1, ry1, rx2 - rx1, ry2 - ry1);
|
public java.awt.geom.Point2D | getCurrentPoint()Gets the current end point of the path.
if (typeSize == 0) {
return null;
}
int j = pointSize - 2;
if (types[typeSize - 1] == PathIterator.SEG_CLOSE) {
for (int i = typeSize - 2; i > 0; i--) {
int type = types[i];
if (type == PathIterator.SEG_MOVETO) {
break;
}
j -= pointShift[type];
}
}
return new Point2D.Float(points[j], points[j + 1]);
|
public java.awt.geom.PathIterator | getPathIterator(java.awt.geom.AffineTransform t)
return new Iterator(this, t);
|
public java.awt.geom.PathIterator | getPathIterator(java.awt.geom.AffineTransform t, double flatness)
return new FlatteningPathIterator(getPathIterator(t), flatness);
|
public int | getWindingRule()Gets the winding rule.
return rule;
|
public boolean | intersects(double rx, double ry, double rw, double rh)
int cross = Crossing.intersectShape(this, rx, ry, rw, rh);
return cross == Crossing.CROSSING || isInside(cross);
|
public boolean | intersects(java.awt.geom.Rectangle2D r)
return intersects(r.getX(), r.getY(), r.getWidth(), r.getHeight());
|
boolean | isInside(int cross)Checks the cross count (number of times a ray from the point crosses the
shape's boundary) to determine whether the number of crossings
corresponds to a point inside the shape or not (according to the shape's
path rule).
if (rule == WIND_NON_ZERO) {
return Crossing.isInsideNonZero(cross);
}
return Crossing.isInsideEvenOdd(cross);
|
public void | lineTo(float x, float y)Appends a new segment to the end of this general path by making a
straight line segment from the current endpoint to the given new point.
checkBuf(2, true);
types[typeSize++] = PathIterator.SEG_LINETO;
points[pointSize++] = x;
points[pointSize++] = y;
|
public void | moveTo(float x, float y)Appends a new point to the end of this general path, disconnected from
the existing path.
if (typeSize > 0 && types[typeSize - 1] == PathIterator.SEG_MOVETO) {
points[pointSize - 2] = x;
points[pointSize - 1] = y;
} else {
checkBuf(2, false);
types[typeSize++] = PathIterator.SEG_MOVETO;
points[pointSize++] = x;
points[pointSize++] = y;
}
|
public void | quadTo(float x1, float y1, float x2, float y2)Appends a new segment to the end of this general path by making a
quadratic curve from the current endpoint to the point (x2, y2) using the
point (x1, y1) as the quadratic curve's control point.
checkBuf(4, true);
types[typeSize++] = PathIterator.SEG_QUADTO;
points[pointSize++] = x1;
points[pointSize++] = y1;
points[pointSize++] = x2;
points[pointSize++] = y2;
|
public void | reset()Resets the GeneralPath to being an empty path. The underlying point and
segment data is not deleted but rather the end indices of the data arrays
are set to zero.
typeSize = 0;
pointSize = 0;
|
public void | setWindingRule(int rule)Sets the winding rule, which determines how to decide whether a point
that isn't on the path itself is inside or outside of the shape.
if (rule != WIND_EVEN_ODD && rule != WIND_NON_ZERO) {
// awt.209=Invalid winding rule value
throw new java.lang.IllegalArgumentException(Messages.getString("awt.209")); //$NON-NLS-1$
}
this.rule = rule;
|
public void | transform(java.awt.geom.AffineTransform t)Transform all of the coordinates of this path according to the specified
AffineTransform.
t.transform(points, 0, points, 0, pointSize / 2);
|