public Segment.SplitResults split(double y) { if ((y == p1.y) || (y == p2.y)) return null; if ((y <= p1.y) && (y <= p2.y)) return null; if ((y >= p1.y) && (y >= p2.y)) return null; // This should be checked for numerical stability. So you // need to ensure that p2.y-p1.y retains enough bits to be // useful. double t = (y-p1.y)/(p2.y-p1.y); Segment [] t0 = {getSegment(0,t)}; Segment [] t1 = {getSegment(t,1)}; if (p2.y < y) return new Segment.SplitResults(t0, t1); return new Segment.SplitResults(t1, t0); }
/** * Determines whether the specified {@link Point} is inside this * <code>Polygon</code>. * @param p the specified <code>Point</code> to be tested * @return <code>true</code> if the <code>Polygon</code> contains the * <code>Point</code>; <code>false</code> otherwise. * @see #contains(double, double) */ public boolean contains(Point p) { return contains(p.x, p.y); }
/** * Construct a <code>RectListManager</code> with one rectangle * @param rect The rectangle to put in this rlm. */ public RectListManager(Rectangle rect) { this(); add(rect); }
public boolean retainAll(Collection c) { if (c instanceof RectListManager) return retainAll((RectListManager)c); return retainAll(new RectListManager(c)); } public boolean retainAll(RectListManager rlm) {
/** * Implements {@link PathHandler#linetoHorizontalAbs(float)}. */ public void linetoHorizontalAbs(float x) throws ParseException { path.lineTo(xCenter = currentX = x, yCenter = currentY); }
public Polyline2D getPolyline2D() { Polyline2D pol = new Polyline2D( xpoints, ypoints, npoints ); pol.addPoint( xpoints[0], ypoints[0]); return pol; }
/** * Implements {@link PathHandler#movetoAbs(float,float)}. */ public void movetoAbs(float x, float y) throws ParseException { path.moveTo(xCenter = currentX = x, yCenter = currentY = y); }
/** * Returns the angle at the specified length * along the path. * * @param length The length along the path. * @return The angle. */ public float angleAtLength(float length) { return pathLength.angleAtLength(length); }
/** * Implements {@link PathHandler#curvetoQuadraticSmoothAbs(float,float)}. */ public void curvetoQuadraticSmoothAbs(float x, float y) throws ParseException { path.quadTo(xCenter = currentX * 2 - xCenter, yCenter = currentY * 2 - yCenter, currentX = x, currentY = y); }
/** * Implements {@link * PathHandler#curvetoCubicAbs(float,float,float,float,float,float)}. */ public void curvetoCubicAbs(float x1, float y1, float x2, float y2, float x, float y) throws ParseException { path.curveTo(x1, y1, xCenter = x2, yCenter = y2, currentX = x, currentY = y); }
/** * Implements {@link * PathHandler#arcRel(float,float,float,boolean,boolean,float,float)}. */ public void arcRel(float rx, float ry, float xAxisRotation, boolean largeArcFlag, boolean sweepFlag, float x, float y) throws ParseException { path.arcTo(rx, ry, xAxisRotation, largeArcFlag, sweepFlag, xCenter = currentX += x, yCenter = currentY += y); }
/** * Creates a new PathLength object for the specified {@link Shape}. * @param path The Path (or Shape) to use. */ public PathLength(Shape path) { setPath(path); }
public double minY() { double [] minMax = {0, 0}; getMinMax(p1.y, p2.y, p3.y, p4.y, minMax); return minMax[0]; } public double maxY() {
public double minX() { double [] minMax = {0, 0}; getMinMax(p1.x, p2.x, p3.x, minMax); return minMax[0]; } public double maxX() {
/** * Subdivides this Quadradic curve into two curves at t = 0.5. * can be done with getSegment but this is more efficent. * @param s0 if non-null contains portion of curve from 0->.5 * @param s1 if non-null contains portion of curve from .5->1 */ public void subdivide(Segment s0, Segment s1) { Quadradic q0=null, q1=null; if (s0 instanceof Quadradic) q0 = (Quadradic)s0; if (s1 instanceof Quadradic) q1 = (Quadradic)s1; subdivide(q0, q1); }
/** * Delegates to the enclosed <code>GeneralPath</code>. */ public synchronized void moveTo(float x, float y) { // Don't add moveto to general path unless there is a reason. makeRoom(2); types [numSeg++] = PathIterator.SEG_MOVETO; cx = mx = values[numVals++] = x; cy = my = values[numVals++] = y; }
/** * Implements {@link PathHandler#linetoHorizontalRel(float)}. */ public void linetoHorizontalRel(float x) throws ParseException { path.lineTo(xCenter = currentX += x, yCenter = currentY); }
/** * Implements {@link PathHandler#linetoVerticalRel(float)}. */ public void linetoVerticalRel(float y) throws ParseException { path.lineTo(xCenter = currentX, yCenter = currentY += y); }
/** * Implements {@link PathHandler#linetoVerticalAbs(float)}. */ public void linetoVerticalAbs(float y) throws ParseException { path.lineTo(xCenter = currentX, yCenter = currentY = y); }