private static Length [ ] parseStrokeDashArray ( String val ) { TextScanner scan = new TextScanner ( val ) ; scan . skipWhitespace ( ) ; if ( scan . empty ( ) ) return null ; Length dash = scan . nextLength ( ) ; if ( dash == null ) return null ; if ( dash . isNegative ( ) ) return null ; float sum = dash . floatValue ( ) ; List < Length > dashes = new ArrayList <> ( ) ; dashes . add ( dash ) ; while ( ! scan . empty ( ) ) { scan . skipCommaWhitespace ( ) ; dash = scan . nextLength ( ) ; if ( dash == null ) // must have hit something unexpected return null ; if ( dash . isNegative ( ) ) return null ; dashes . add ( dash ) ; sum += dash . floatValue ( ) ; } // Spec (section 11.4) says if the sum of dash lengths is zero, it should // be treated as "none" ie a solid stroke. if ( sum == 0f ) return null ; return dashes . toArray ( new Length [ dashes . size ( ) ] ) ; }
Parse stroke - dasharray