static void renderText ( GraphicFactory graphicFactory , Tile upperLeft , Tile lowerRight , String text , Display display , int priority , float dy , Paint fill , Paint stroke , boolean repeat , float repeatGap , float repeatStart , boolean rotate , Point [ ] [ ] coordinates , List < MapElementContainer > currentLabels ) { if ( coordinates . length == 0 ) { return ; } Point [ ] c ; if ( dy == 0f ) { c = coordinates [ 0 ] ; } else { c = RendererUtils . parallelPath ( coordinates [ 0 ] , dy ) ; } if ( c . length < 2 ) { return ; } LineString path = new LineString ( ) ; for ( int i = 1 ; i < c . length ; i ++ ) { LineSegment segment = new LineSegment ( c [ i - 1 ] , c [ i ] ) ; path . segments . add ( segment ) ; } int textWidth = ( stroke == null ) ? fill . getTextWidth ( text ) : stroke . getTextWidth ( text ) ; int textHeight = ( stroke == null ) ? fill . getTextHeight ( text ) : stroke . getTextHeight ( text ) ; double pathLength = path . length ( ) ; for ( float pos = repeatStart ; pos + textWidth < pathLength ; pos += repeatGap + textWidth ) { LineString linePart = path . extractPart ( pos , pos + textWidth ) ; boolean tooSharp = false ; for ( int i = 1 ; i < linePart . segments . size ( ) ; i ++ ) { double cornerAngle = linePart . segments . get ( i - 1 ) . angleTo ( linePart . segments . get ( i ) ) ; if ( Math . abs ( cornerAngle ) > MAX_LABEL_CORNER_ANGLE ) { tooSharp = true ; break ; } } if ( tooSharp ) continue ; currentLabels . add ( new WayTextContainer ( graphicFactory , linePart , display , priority , text , fill , stroke , textHeight ) ) ; } }
Finds the segments of a line along which a name can be drawn and then adds WayTextContainers to the list of drawable items .