add Path Segment - Java 2D Graphics

Java examples for 2D Graphics:Path

Description

add Path Segment

Demo Code

/*******************************************************************************
 * Copyright (c)  2012  Wompi /*from   w w w . j a  v  a 2 s.com*/
 * 
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the ZLIB
 * which accompanies this distribution, and is available at
 * http://robowiki.net/wiki/ZLIB
 * 
 * Contributors:
 *     Wompi - initial API and implementation
 ******************************************************************************/
//package com.java2s;

import java.awt.geom.GeneralPath;

import java.awt.geom.Point2D;

public class Main {
    public static GeneralPath addPathSegment(GeneralPath path, Point2D point) {
        if (path == null) {
            path = new GeneralPath(GeneralPath.WIND_EVEN_ODD, 2000);
            path.moveTo(point.getX(), point.getY());
        } else {
            path.lineTo(point.getX(), point.getY());
        }
        return path;
    }
}

Related Tutorials