import { TileKey } from "@here/harp-geoutils" ; import { assert } from "@here/harp-utils" ; import { TextElementGroup } from "./TextElementGroup" ; import { TextElementState } from "./TextElementState" ; import { TextElementType } from "./TextElementType" ; param textElementState returns export type TextElementFilter = ( textElementState : TextElementState ) => number | undefined ; /**
 * `TextElementGroupState` keeps the state of a text element group and each element in it while
 * they're being rendered.
 */ export class TextElementGroupState { private readonly m_textElementStates : TextElementState [ ] ; private m_visited : boolean = false ; param group param tileKey param filter see constructor ( readonly group , readonly tileKey , filter ) { assert ( group . elements . length > 0 ) ; const length = group . elements . length ; this . m_textElementStates = [ ] ; this . m_visited = true ; for ( let i = 0 ; i < length ; ++ i ) { const textElement = group . elements [ i ] ; if ( textElement . type === TextElementType . LineMarker && textElement . path !== undefined ) { const numPoints = textElement . path . length ; for ( let p = 0 ; p < numPoints ; p ++ ) { const state = new TextElementState ( textElement , p ) ; const textDistance = filter ( state ) ; state . update ( textDistance ) ; this . m_textElementStates . push ( state ) ; } } else { const state = new TextElementState ( textElement ) ; const textDistance = filter ( state ) ; state . update ( textDistance ) ; this . m_textElementStates . push ( state ) ; } } } /**
     * Indicates whether the group has been submitted to the
     *  TextElementsRenderer in the current frame.
      get visited ( ) : boolean { return this . m_visited ; } set visited ( visited ) { this . m_visited = visited ; } returns get priority ( ) { return this . group . priority ; } param time param disableFading updateFading ( time , disableFading ) { for ( const elementState of this . m_textElementStates ) { if ( elementState !== undefined ) { elementState . updateFading ( time , disableFading ) ; } } } param visibleElementsCallback traverseVisibleElements ( visibleElementsCallback ) { for ( const elementState of this . m_textElementStates ) { if ( elementState !== undefined && elementState . visible ) { visibleElementsCallback ( elementState ) ; } } } param filter see updateElements ( filter ) { for ( const elementState of this . m_textElementStates ) { const textDistance = filter ( elementState ) ; elementState . update ( textDistance ) ; } } get size ( ) : number { return this . m_textElementStates . length ; } returns get textElementStates ( ) : TextElementState [ ] { return this . m_textElementStates ; } }