java.awt.geom.PathIterator Java Examples

The following examples show how to use java.awt.geom.PathIterator. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PiscesRenderingEngine.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
NormalizingPathIterator(PathIterator src, NormMode mode) {
    this.src = src;
    switch (mode) {
    case ON_NO_AA:
        // round to nearest (0.25, 0.25) pixel
        lval = rval = 0.25f;
        break;
    case ON_WITH_AA:
        // round to nearest pixel center
        lval = 0f;
        rval = 0.5f;
        break;
    case OFF:
        throw new InternalError("A NormalizingPathIterator should " +
                 "not be created if no normalization is being done");
    default:
        throw new InternalError("Unrecognized normalization mode");
    }
}
 
Example #2
Source File: MutablePath.java    From pumpernickel with MIT License 6 votes vote down vote up
public synchronized void append(Shape s, AffineTransform transform) {
	PathIterator i = s.getPathIterator(transform);
	double[] coords = new double[6];
	while (i.isDone() == false) {
		int k = i.currentSegment(coords);
		if (k == PathIterator.SEG_CLOSE) {
			close();
		} else if (k == PathIterator.SEG_CUBICTO) {
			curveTo(coords[0], coords[1], coords[2], coords[3], coords[4],
					coords[5]);
		} else if (k == PathIterator.SEG_QUADTO) {
			quadTo(coords[0], coords[1], coords[2], coords[3]);
		} else if (k == PathIterator.SEG_LINETO) {
			lineTo(coords[0], coords[1]);
		} else if (k == PathIterator.SEG_MOVETO) {
			moveTo(coords[0], coords[1]);
		} else {
			throw new RuntimeException("unexpected segment type (" + k
					+ ")");
		}
		i.next();
	}
}
 
Example #3
Source File: ChartEntity.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns a string containing the coordinates for a given shape.  This
 * string is intended for use in an image map.
 *
 * @param shape  the shape (<code>null</code> not permitted).
 *
 * @return The coordinates for a given shape as string.
 */
private String getPolyCoords(Shape shape) {
    if (shape == null) {
        throw new IllegalArgumentException("Null 'shape' argument.");
    }
    StringBuffer result = new StringBuffer();
    boolean first = true;
    float[] coords = new float[6];
    PathIterator pi = shape.getPathIterator(null, 1.0);
    while (!pi.isDone()) {
        pi.currentSegment(coords);
        if (first) {
            first = false;
            result.append((int) coords[0]);
            result.append(",").append((int) coords[1]);
        }
        else {
            result.append(",");
            result.append((int) coords[0]);
            result.append(",");
            result.append((int) coords[1]);
        }
        pi.next();
    }
    return result.toString();
}
 
Example #4
Source File: GeoPath.java    From audiveris with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Report the last defining point of the path.
 *
 * @return the last path point
 */
public Point2D getLastPoint ()
{
    final double[] buffer = new double[6];
    final PathIterator it = getPathIterator(null);

    if (it.isDone()) {
        return null;
    }

    double x = 0;
    double y = 0;

    while (!it.isDone()) {
        final int segmentKind = it.currentSegment(buffer);
        final int count = countOf(segmentKind);
        x = buffer[count - 2];
        y = buffer[count - 1];
        it.next();
    }

    return new Point2D.Double(x, y);
}
 
Example #5
Source File: Order3.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
public int getSegment(double coords[]) {
    if (direction == INCREASING) {
        coords[0] = cx0;
        coords[1] = cy0;
        coords[2] = cx1;
        coords[3] = cy1;
        coords[4] = x1;
        coords[5] = y1;
    } else {
        coords[0] = cx1;
        coords[1] = cy1;
        coords[2] = cx0;
        coords[3] = cy0;
        coords[4] = x0;
        coords[5] = y0;
    }
    return PathIterator.SEG_CUBICTO;
}
 
Example #6
Source File: BasicMouseSmoothing.java    From pumpernickel with MIT License 6 votes vote down vote up
/** Flattens this shape and calculates its length */
protected static float getLength(Shape shape) {
	PathIterator i = shape.getPathIterator(null, .5);
	float[] s = new float[6];
	float sum = 0;
	float lastX = -1;
	float lastY = -1;
	while (i.isDone() == false) {
		int k = i.currentSegment(s);
		if (k == PathIterator.SEG_LINETO) {
			sum += (float) Math.sqrt((lastX - s[0]) * (lastX - s[0])
					+ (lastY - s[1]) * (lastY - s[1]));
		}
		lastX = s[0];
		lastY = s[1];
		i.next();
	}
	return sum;
}
 
Example #7
Source File: GeoPath.java    From audiveris with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Report the first defining point of the path.
 *
 * @return the first path point
 */
public Point2D getFirstPoint ()
{
    final double[] buffer = new double[6];
    final PathIterator it = getPathIterator(null);

    if (!it.isDone()) {
        final int segmentKind = it.currentSegment(buffer);
        final int count = countOf(segmentKind);
        final double x = buffer[count - 2];
        final double y = buffer[count - 1];

        if ((segmentKind == SEG_MOVETO) || (segmentKind == SEG_CLOSE)) {
            return new Point2D.Double(x, y);
        } else {
            return new Point2D.Double(0, 0);
        }
    }

    return null;
}
 
Example #8
Source File: LayoutPathImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public Shape mapShape(Shape s) {
    if (LOGMAP) LOG.format("mapshape on path: %s\n", LayoutPathImpl.SegmentPath.this);
    PathIterator pi = s.getPathIterator(null, 1); // cheap way to handle curves.

    if (LOGMAP) LOG.format("start\n");
    init();

    final double[] coords = new double[2];
    while (!pi.isDone()) {
        switch (pi.currentSegment(coords)) {
        case SEG_CLOSE: close(); break;
        case SEG_MOVETO: moveTo(coords[0], coords[1]); break;
        case SEG_LINETO: lineTo(coords[0], coords[1]); break;
        default: break;
        }

        pi.next();
    }
    if (LOGMAP) LOG.format("finish\n\n");

    GeneralPath gp = new GeneralPath();
    for (Segment seg: segments) {
        gp.append(seg.gp, false);
    }
    return gp;
}
 
Example #9
Source File: LayoutPathImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
public Shape mapShape(Shape s) {
    if (LOGMAP) LOG.format("mapshape on path: %s\n", LayoutPathImpl.SegmentPath.this);
    PathIterator pi = s.getPathIterator(null, 1); // cheap way to handle curves.

    if (LOGMAP) LOG.format("start\n");
    init();

    final double[] coords = new double[2];
    while (!pi.isDone()) {
        switch (pi.currentSegment(coords)) {
        case SEG_CLOSE: close(); break;
        case SEG_MOVETO: moveTo(coords[0], coords[1]); break;
        case SEG_LINETO: lineTo(coords[0], coords[1]); break;
        default: break;
        }

        pi.next();
    }
    if (LOGMAP) LOG.format("finish\n\n");

    GeneralPath gp = new GeneralPath();
    for (Segment seg: segments) {
        gp.append(seg.gp, false);
    }
    return gp;
}
 
Example #10
Source File: LayoutPathImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public Shape mapShape(Shape s) {
    if (LOGMAP) LOG.format("mapshape on path: %s\n", LayoutPathImpl.SegmentPath.this);
    PathIterator pi = s.getPathIterator(null, 1); // cheap way to handle curves.

    if (LOGMAP) LOG.format("start\n");
    init();

    final double[] coords = new double[2];
    while (!pi.isDone()) {
        switch (pi.currentSegment(coords)) {
        case SEG_CLOSE: close(); break;
        case SEG_MOVETO: moveTo(coords[0], coords[1]); break;
        case SEG_LINETO: lineTo(coords[0], coords[1]); break;
        default: break;
        }

        pi.next();
    }
    if (LOGMAP) LOG.format("finish\n\n");

    GeneralPath gp = new GeneralPath();
    for (Segment seg: segments) {
        gp.append(seg.gp, false);
    }
    return gp;
}
 
Example #11
Source File: WPathGraphics.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void deviceClip(PathIterator pathIter) {

    WPrinterJob wPrinterJob = (WPrinterJob) getPrinterJob();

    convertToWPath(pathIter);
    wPrinterJob.selectClipPath();
}
 
Example #12
Source File: SunGraphics2D.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected void validateCompClip() {
    int origClipState = clipState;
    if (usrClip == null) {
        clipState = CLIP_DEVICE;
        clipRegion = devClip;
    } else if (usrClip instanceof Rectangle2D) {
        clipState = CLIP_RECTANGULAR;
        clipRegion = devClip.getIntersection((Rectangle2D) usrClip);
    } else {
        PathIterator cpi = usrClip.getPathIterator(null);
        int box[] = new int[4];
        ShapeSpanIterator sr = LoopPipe.getFillSSI(this);
        try {
            sr.setOutputArea(devClip);
            sr.appendPath(cpi);
            sr.getPathBox(box);
            Region r = Region.getInstance(box);
            r.appendSpans(sr);
            clipRegion = r;
            clipState =
                r.isRectangular() ? CLIP_RECTANGULAR : CLIP_SHAPE;
        } finally {
            sr.dispose();
        }
    }
    if (origClipState != clipState &&
        (clipState == CLIP_SHAPE || origClipState == CLIP_SHAPE))
    {
        validFontInfo = false;
        invalidatePipe();
    }
}
 
Example #13
Source File: PathSegment.java    From pumpernickel with MIT License 5 votes vote down vote up
public Float cubicTo(float cx0, float cy0, float cx1, float cy1,
		float x1, float y1) {
	Float newSegment = newSegment();
	newSegment.type = PathIterator.SEG_CUBICTO;
	newSegment.data = new float[] { cx0, cy0, cx1, cy1, x1, y1 };
	append(newSegment);
	return newSegment;
}
 
Example #14
Source File: DMarlinRenderingEngine.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
@Override
PathIterator getNormalizingPathIterator(final DRendererContext rdrCtx,
                                        final PathIterator src)
{
    // return original path iterator if normalization is disabled:
    return src;
}
 
Example #15
Source File: AWT2SWT.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Converts a Java2D {@link PathIterator} into an SWT {@link PathData}. Note
 * that while Java2D's {@link PathIterator} contains the specification of a
 * {@link PathIterator#WIND_EVEN_ODD} or {@link PathIterator#WIND_NON_ZERO}
 * winding rule ({@link PathIterator#getWindingRule()}), this information is
 * not kept in SWT's {@link PathData}, but is instead specified when drawing
 * an SWT {@link Path} (which can be constructed from the {@link PathData})
 * on an SWT {@link GC} (via {@link SWT#FILL_WINDING} or
 * {@link SWT#FILL_EVEN_ODD}). Therefore the returned SWT {@link PathData}
 * will not contain any information about the winding rule that was
 * specified in the passed in {@link PathIterator}.
 * 
 * @param iterator
 *            the {@link PathIterator} to transform
 * @return a new {@link PathData} representing the same geometric path
 */
public static PathData toSWTPathData(PathIterator iterator) {
	byte[] types = new byte[0];
	float[] points = new float[0];
	while (!iterator.isDone()) {
		float[] segment = new float[6];
		int type = iterator.currentSegment(segment);
		switch (type) {
		case PathIterator.SEG_MOVETO:
			types = getTypeAppended(types, (byte) SWT.PATH_MOVE_TO);
			points = getPointAppended(points, segment[0], segment[1]);
			break;
		case PathIterator.SEG_LINETO:
			types = getTypeAppended(types, (byte) SWT.PATH_LINE_TO);
			points = getPointAppended(points, segment[0], segment[1]);
			break;
		case PathIterator.SEG_QUADTO:
			types = getTypeAppended(types, (byte) SWT.PATH_QUAD_TO);
			points = getPointAppended(points, segment[0], segment[1]);
			points = getPointAppended(points, segment[2], segment[3]);
			break;
		case PathIterator.SEG_CUBICTO:
			types = getTypeAppended(types, (byte) SWT.PATH_CUBIC_TO);
			points = getPointAppended(points, segment[0], segment[1]);
			points = getPointAppended(points, segment[2], segment[3]);
			points = getPointAppended(points, segment[4], segment[5]);
			break;
		case PathIterator.SEG_CLOSE:
			types = getTypeAppended(types, (byte) SWT.PATH_CLOSE);
			break;
		}
		iterator.next();
	}
	PathData pathData = new PathData();
	pathData.points = points;
	pathData.types = types;
	return pathData;
}
 
Example #16
Source File: ShapeUtils.java    From pumpernickel with MIT License 5 votes vote down vote up
/** Returns the number of separate paths in the shape provided. */
public static int getSubPathCount(Shape s) {
	PathIterator i = s.getPathIterator(null);
	int ctr = 0;
	float[] coords = new float[6];
	while (i.isDone() == false) {
		if (i.currentSegment(coords) == PathIterator.SEG_MOVETO) {
			ctr++;
		}
		i.next();
	}
	return ctr++;
}
 
Example #17
Source File: CurvedPolyline.java    From pumpernickel with MIT License 5 votes vote down vote up
/**
 * Set a winding rule.
 * 
 * @param newWindingRule
 *            <code>PathIterator.WIND_EVEN_ODD</code> or
 *            <code>PathIterator.WIND_NON_ZERO</code>.
 * @return true if a change occurred.
 */
public synchronized boolean setWindingRule(int newWindingRule) {
	if (newWindingRule == PathIterator.WIND_EVEN_ODD
			|| newWindingRule == PathIterator.WIND_NON_ZERO) {
		throw new IllegalArgumentException();
	}
	if (windingRule == newWindingRule)
		return false;
	windingRule = newWindingRule;
	return true;
}
 
Example #18
Source File: SunGraphics2D.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
protected void validateCompClip() {
    int origClipState = clipState;
    if (usrClip == null) {
        clipState = CLIP_DEVICE;
        clipRegion = devClip;
    } else if (usrClip instanceof Rectangle2D) {
        clipState = CLIP_RECTANGULAR;
        if (usrClip instanceof Rectangle) {
            clipRegion = devClip.getIntersection((Rectangle)usrClip);
        } else {
            clipRegion = devClip.getIntersection(usrClip.getBounds());
        }
    } else {
        PathIterator cpi = usrClip.getPathIterator(null);
        int box[] = new int[4];
        ShapeSpanIterator sr = LoopPipe.getFillSSI(this);
        try {
            sr.setOutputArea(devClip);
            sr.appendPath(cpi);
            sr.getPathBox(box);
            Region r = Region.getInstance(box);
            r.appendSpans(sr);
            clipRegion = r;
            clipState =
                r.isRectangular() ? CLIP_RECTANGULAR : CLIP_SHAPE;
        } finally {
            sr.dispose();
        }
    }
    if (origClipState != clipState &&
        (clipState == CLIP_SHAPE || origClipState == CLIP_SHAPE))
    {
        validFontInfo = false;
        invalidatePipe();
    }
}
 
Example #19
Source File: ExtendedGeneralPath.java    From blog-codes with Apache License 2.0 5 votes vote down vote up
/**
 * Delegates to the enclosed <code>GeneralPath</code>.
 */
public synchronized void lineTo(float x, float y)
{
	checkMoveTo(); // check if prev command was moveto
	path.lineTo(x, y);

	makeRoom(2);
	types[numSeg++] = PathIterator.SEG_LINETO;
	cx = values[numVals++] = x;
	cy = values[numVals++] = y;
}
 
Example #20
Source File: FXGraphics2D.java    From buffer_bci with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Maps a shape to a path in the graphics context. 
 * 
 * @param s  the shape ({@code null} not permitted).
 */
private void shapeToPath(Shape s) {
    double[] coords = new double[6];
    this.gc.beginPath();
    PathIterator iterator = s.getPathIterator(null);
    while (!iterator.isDone()) {
        int segType = iterator.currentSegment(coords);
        switch (segType) {
            case PathIterator.SEG_MOVETO:
                this.gc.moveTo(coords[0], coords[1]);
                break;
            case PathIterator.SEG_LINETO:
                this.gc.lineTo(coords[0], coords[1]);
                break;
            case PathIterator.SEG_QUADTO:
                this.gc.quadraticCurveTo(coords[0], coords[1], coords[2], 
                        coords[3]);
                break;
            case PathIterator.SEG_CUBICTO:
                this.gc.bezierCurveTo(coords[0], coords[1], coords[2], 
                        coords[3], coords[4], coords[5]);
                break;
            case PathIterator.SEG_CLOSE:
                this.gc.closePath();
                break;
            default:
                throw new RuntimeException("Unrecognised segment type " 
                        + segType);
        }
        iterator.next();
    }
}
 
Example #21
Source File: RenderingEngine.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Utility method to feed a {@link PathConsumer2D} object from a
 * given {@link PathIterator}.
 * This method deals with the details of running the iterator and
 * feeding the consumer a segment at a time.
 */
public static void feedConsumer(PathIterator pi, PathConsumer2D consumer) {
    float coords[] = new float[6];
    while (!pi.isDone()) {
        switch (pi.currentSegment(coords)) {
        case PathIterator.SEG_MOVETO:
            consumer.moveTo(coords[0], coords[1]);
            break;
        case PathIterator.SEG_LINETO:
            consumer.lineTo(coords[0], coords[1]);
            break;
        case PathIterator.SEG_QUADTO:
            consumer.quadTo(coords[0], coords[1],
                            coords[2], coords[3]);
            break;
        case PathIterator.SEG_CUBICTO:
            consumer.curveTo(coords[0], coords[1],
                             coords[2], coords[3],
                             coords[4], coords[5]);
            break;
        case PathIterator.SEG_CLOSE:
            consumer.closePath();
            break;
        }
        pi.next();
    }
}
 
Example #22
Source File: Order1.java    From mil-sym-android with Apache License 2.0 5 votes vote down vote up
public int getSegment(double coords[]) {
    if (direction == Curve.INCREASING) {
        coords[0] = x1;
        coords[1] = y1;
    } else {
        coords[0] = x0;
        coords[1] = y0;
    }
    return PathIterator.SEG_LINETO;
}
 
Example #23
Source File: ShapeSpanIterator.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public void appendPath(PathIterator pi) {
    float coords[] = new float[6];

    setRule(pi.getWindingRule());
    while (!pi.isDone()) {
        addSegment(pi.currentSegment(coords), coords);
        pi.next();
    }
    pathDone();
}
 
Example #24
Source File: Order2.java    From HtmlUnit-Android with Apache License 2.0 5 votes vote down vote up
public int getSegment(double coords[]) {
    coords[0] = cx0;
    coords[1] = cy0;
    if (direction == INCREASING) {
        coords[2] = x1;
        coords[3] = y1;
    } else {
        coords[2] = x0;
        coords[3] = y0;
    }
    return PathIterator.SEG_QUADTO;
}
 
Example #25
Source File: ShapeInformation.java    From han3_ji7_tsoo1_kian3 with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * 建立一個相關資訊物件
 * 
 * @param area
 *            要計算資訊的area
 */
public ShapeInformation(Area area)
{
	approximativeCircumference = 0.0;
	approximativeRegion = 0.0;
	double[] controlPoint = new double[6];
	SimplePolygon simplePolygon = new SimplePolygon();
	for (PathIterator pathIterator = area.getPathIterator(null); !pathIterator.isDone(); pathIterator
			.next())
	{
		int type = pathIterator.currentSegment(controlPoint);
		switch (type)
		{
		case PathIterator.SEG_CUBICTO:
			simplePolygon.addPoint(controlPoint[0], controlPoint[1]);
			simplePolygon.addPoint(controlPoint[2], controlPoint[3]);
			simplePolygon.addPoint(controlPoint[4], controlPoint[5]);
			break;
		case PathIterator.SEG_QUADTO:
			simplePolygon.addPoint(controlPoint[0], controlPoint[1]);
			simplePolygon.addPoint(controlPoint[2], controlPoint[3]);
			break;
		case PathIterator.SEG_LINETO:
			simplePolygon.addPoint(controlPoint[0], controlPoint[1]);
			break;
		case PathIterator.SEG_MOVETO:
			simplePolygon.addPoint(controlPoint[0], controlPoint[1]);
			break;
		case PathIterator.SEG_CLOSE:
			simplePolygon.finish();
			approximativeCircumference += simplePolygon.getCircumference();
			approximativeRegion += simplePolygon.getRegionSize();
			simplePolygon.clear();
			break;
		}
	}
}
 
Example #26
Source File: Path2DCopyConstructor.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static int getLength(int type) {
    switch(type) {
        case PathIterator.SEG_CUBICTO:
            return 6;
        case PathIterator.SEG_QUADTO:
            return 4;
        case PathIterator.SEG_LINETO:
        case PathIterator.SEG_MOVETO:
            return 2;
        case PathIterator.SEG_CLOSE:
            return 0;
        default:
            throw new IllegalStateException("Invalid type: " + type);
    }
}
 
Example #27
Source File: Elixir_001_t.java    From coming with MIT License 5 votes vote down vote up
/**
 * Tests two polygons for equality.  If both are <code>null</code> this
 * method returns <code>true</code>.
 *
 * @param p1  path 1 (<code>null</code> permitted).
 * @param p2  path 2 (<code>null</code> permitted).
 *
 * @return A boolean.
 */
public static boolean equal(GeneralPath p1, GeneralPath p2) {
    if (p1 == null) {
        return (p2 == null);
    }
    if (p2 == null) {
        return false;
    }
    if (p1.getWindingRule() != p2.getWindingRule()) {
        return false;
    }
    PathIterator iterator1 = p1.getPathIterator(null);
    PathIterator iterator2 = p2.getPathIterator(null);
    double[] d1 = new double[6];
    double[] d2 = new double[6];
    boolean done = iterator1.isDone() && iterator2.isDone();
    while (!done) {
        if (iterator1.isDone() != iterator2.isDone()) {
            return false;
        }
        int seg1 = iterator1.currentSegment(d1);
        int seg2 = iterator2.currentSegment(d2);
        if (seg1 != seg2) {
            return false;
        }
        if (!Arrays.equals(d1, d2)) {
            return false;
        }
        iterator1.next();
        iterator2.next();
        done = iterator1.isDone() && iterator2.isDone();
    }
    return true;
}
 
Example #28
Source File: PencilDrawing.java    From tracker with GNU General Public License v3.0 5 votes vote down vote up
/**
  * Gets the points that define the GeneralPath.
  *
  * @return double[][], each point is double[] {Seg_type, x, y}
  */
public double[][] getPathPoints() {
	pointArray.clear();
	for (PathIterator pi = generalPath.getPathIterator(null); !pi.isDone(); pi.next()) {
    int type = pi.currentSegment(coords); // type will be SEG_LINETO or SEG_MOVETO
    if (type==PathIterator.SEG_LINETO) {
    	pointArray.add(new double[] {type, coords[0], coords[1]});
    }
	}
	return pointArray.toArray(new double[pointArray.size()][3]);
}
 
Example #29
Source File: WPathGraphics.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void deviceFill(PathIterator pathIter, Color color) {

    WPrinterJob wPrinterJob = (WPrinterJob) getPrinterJob();

    convertToWPath(pathIter);
    wPrinterJob.selectSolidBrush(color);
    wPrinterJob.fillPath();
}
 
Example #30
Source File: Order1.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public int getSegment(double coords[]) {
    if (direction == INCREASING) {
        coords[0] = x1;
        coords[1] = y1;
    } else {
        coords[0] = x0;
        coords[1] = y0;
    }
    return PathIterator.SEG_LINETO;
}