create Line Area - Java java.lang

Java examples for java.lang:Math Geometry Line

Description

create Line Area

Demo Code

/*//  ww  w .  ja  v  a 2s . c  o m
 * Copyright (c) 2014 tabletoptool.com team.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     rptools.com team - initial implementation
 *     tabletoptool.com team - further development
 */
//package com.java2s;
import java.awt.geom.Area;
import java.awt.geom.GeneralPath;
import java.awt.geom.Line2D;

import java.awt.geom.Point2D;

import java.util.List;

public class Main {
    public static Area createLine(List<Point2D> points, int width) {

        Point2D lastPoint = null;
        Line2D lastLine = null;
        for (Point2D point : points) {
            if (lastPoint == null) {
                lastPoint = point;
                continue;
            }

            if (lastLine == null) {
                // First line segment
                lastLine = new Line2D.Double(lastPoint, point);

                // Keep track 
                continue;
            }

        }

        GeneralPath path = new GeneralPath();
        return new Area(path);
    }
}

Related Tutorials