import OncoprintModel , { TrackGroupProp , TrackProp } from "./oncoprintmodel" ; export function calculateTrackTops ( model , zoomed ) { return calculateTrackAndHeaderTops ( model , zoomed ) . trackTops ; } export function calculateHeaderTops ( model , zoomed ) { return calculateTrackAndHeaderTops ( model , zoomed ) . headerTops ; } export function calculateTrackAndHeaderTops ( model , zoomed ) { const trackTops = { } ; const headerTops = { } ; const groups = model . getTrackGroups ( ) ; let y = 0 ; for ( let i = 0 ; i < groups . length ; i ++ ) { const group = groups [ i ] ; if ( group . header ) { headerTops [ i ] = y ; } if ( group . tracks . length > 0 ) { y += model . getTrackGroupHeaderHeight ( group ) ; } for ( let j = 0 ; j < group . tracks . length ; j ++ ) { const track_id = group . tracks [ j ] ; trackTops [ track_id ] = y ; y += model . getTrackHeight ( track_id , ! zoomed ) ; } if ( group . tracks . length > 0 ) { y += model . getTrackGroupPadding ( ! zoomed ) ; } } return { trackTops , headerTops } ; }