protected void drawDashedLine ( final Context2D context , double x , double y , final double x2 , final double y2 , final double [ ] da , final double plus ) { final int dashCount = da . length ; final double dx = ( x2 - x ) ; final double dy = ( y2 - y ) ; final boolean xbig = ( Math . abs ( dx ) > Math . abs ( dy ) ) ; final double slope = ( xbig ) ? dy / dx : dx / dy ; context . moveTo ( x , y ) ; double distRemaining = Math . sqrt ( ( dx * dx ) + ( dy * dy ) ) + plus ; int dashIndex = 0 ; while ( distRemaining >= 0.1 ) { final double dashLength = Math . min ( distRemaining , da [ dashIndex % dashCount ] ) ; double step = Math . sqrt ( ( dashLength * dashLength ) / ( 1 + ( slope * slope ) ) ) ; if ( xbig ) { if ( dx < 0 ) { step = - step ; } x += step ; y += slope * step ; } else { if ( dy < 0 ) { step = - step ; } x += slope * step ; y += step ; } if ( ( dashIndex % 2 ) == 0 ) { context . lineTo ( x , y ) ; } else { context . moveTo ( x , y ) ; } distRemaining -= dashLength ; dashIndex ++ ; } }
Draws a dashed line instead of a solid one for the shape .