flow-gui/src/main/java/de/javagl/flow/gui/Shapes.java
/**
     * Create a list containing line segments that approximate the given 
     * shape.
     * 
     * NOTE: Copied from https://github.com/javagl/Geom/blob/master/
     *     src/main/java/de/javagl/geom/Shapes.java
     * 
     * @param shape The shape
     * @param flatness The allowed flatness
     * @return The list of line segments
     */
Create a list containing line segments that approximate the given
shape.



@param shape The shape
@param flatness The allowed flatness
@return The list of line segments
Create a list containing line segments that approximate the given shape . @param shape The shape @param flatness The allowed flatness @return The list of line segments
public static List<Line2D> computeLineSegments(
        Shape shape, double flatness)
    {
        List<Line2D> result = new ArrayList<Line2D>();
        PathIterator pi = shape.getPathIterator(null, flatness);
        double[] coords = new double[6];
        double previous[] = new double[2];
        double first[] = new double[2];
        while (!pi.isDone())
        {
            int segment = pi.currentSegment(coords);
            switch (segment)
            {
                case PathIterator.SEG_MOVETO:
                    previous[0] = coords[0];
                    previous[1] = coords[1];
                    first[0] = coords[0];
                    first[1] = coords[1];
                    break;
                case PathIterator.SEG_CLOSE:
                    result.add(new Line2D.Double(
                        previous[0], previous[1],
                        first[0], first[1]));
                    previous[0] = first[0];
                    previous[1] = first[1];
                    break;
                case PathIterator.SEG_LINETO:
                    result.add(new Line2D.Double(
                        previous[0], previous[1],
                        coords[0], coords[1]));
                    previous[0] = coords[0];
                    previous[1] = coords[1];
                    break;
                case PathIterator.SEG_QUADTO:
                    throw new AssertionError(
                        "SEG_QUADTO in flattened path!");
                case PathIterator.SEG_CUBICTO:
                    throw new AssertionError(
                        "SEG_CUBICTO in flattened path!");
                default:
                    throw new AssertionError(
                        "Invalid segment in flattened path!");
            }
            pi.next();
        }
        return result;
    }
public static List < Line2D > computeLineSegments ( Shape shape , double flatness ) { List < Line2D > result = new ArrayList < Line2D > ( ) ; PathIterator pi = shape . getPathIterator ( null , flatness ) ; double [ ] coords = new double [ 6 ] ; double previous [ ] = new double [ 2 ] ; double first [ ] = new double [ 2 ] ; while ( ! pi . isDone ( ) ) { int segment = pi . currentSegment ( coords ) ; switch ( segment ) { case PathIterator . SEG_MOVETO : previous [ 0 ] = coords [ 0 ] ; previous [ 1 ] = coords [ 1 ] ; first [ 0 ] = coords [ 0 ] ; first [ 1 ] = coords [ 1 ] ; break ; case PathIterator . SEG_CLOSE : result . add ( new Line2D . Double ( previous [ 0 ] , previous [ 1 ] , first [ 0 ] , first [ 1 ] ) ) ; previous [ 0 ] = first [ 0 ] ; previous [ 1 ] = first [ 1 ] ; break ; case PathIterator . SEG_LINETO : result . add ( new Line2D . Double ( previous [ 0 ] , previous [ 1 ] , coords [ 0 ] , coords [ 1 ] ) ) ; previous [ 0 ] = coords [ 0 ] ; previous [ 1 ] = coords [ 1 ] ; break ; case PathIterator . SEG_QUADTO : throw new AssertionError ( "SEG_QUADTO in flattened path!" ) ; case PathIterator . SEG_CUBICTO : throw new AssertionError ( "SEG_CUBICTO in flattened path!" ) ; default : throw new AssertionError ( "Invalid segment in flattened path!" ) ; } pi . next ( ) ; } return result ; }
Create a list containing line segments that approximate the given
 shape.
Create a list containing line segments that approximate the given shape .
// Should never occur
 // Should never occur
 // Should never occur
