public Path2D path ( ) throws IOException { List < List < AdobePathSegment >> subPaths = new ArrayList < List < AdobePathSegment > > ( ) ; List < AdobePathSegment > currentPath = null ; int currentPathLength = 0 ; AdobePathSegment segment ; while ( ( segment = nextSegment ( ) ) != null ) { if ( DEBUG ) { System . out . println ( segment ) ; } if ( segment . selector == AdobePathSegment . OPEN_SUBPATH_LENGTH_RECORD || segment . selector == AdobePathSegment . CLOSED_SUBPATH_LENGTH_RECORD ) { if ( currentPath != null ) { if ( currentPathLength != currentPath . size ( ) ) { throw new IIOException ( String . format ( "Bad path, expected %d segments, found only %d" , currentPathLength , currentPath . size ( ) ) ) ; } subPaths . add ( currentPath ) ; } currentPath = new ArrayList < AdobePathSegment > ( segment . length ) ; currentPathLength = segment . length ; } else if ( segment . selector == AdobePathSegment . OPEN_SUBPATH_BEZIER_LINKED || segment . selector == AdobePathSegment . OPEN_SUBPATH_BEZIER_UNLINKED || segment . selector == AdobePathSegment . CLOSED_SUBPATH_BEZIER_LINKED || segment . selector == AdobePathSegment . CLOSED_SUBPATH_BEZIER_UNLINKED ) { if ( currentPath == null ) { throw new IIOException ( "Bad path, missing subpath length record" ) ; } if ( currentPath . size ( ) >= currentPathLength ) { throw new IIOException ( String . format ( "Bad path, expected %d segments, found%d" , currentPathLength , currentPath . size ( ) ) ) ; } currentPath . add ( segment ) ; } } // now add the last one if ( currentPath != null ) { if ( currentPathLength != currentPath . size ( ) ) { throw new IIOException ( String . format ( "Bad path, expected %d segments, found only %d" , currentPathLength , currentPath . size ( ) ) ) ; } subPaths . add ( currentPath ) ; } // now we have collected the PathPoints now create a Shape. return pathToShape ( subPaths ) ; }
Builds the path .