import { IQuestion , ItemValue , QuestionRankingModel } from 'survey-core' ; import { SurveyPDF } from '../survey' ; import { IPoint , IRect , DocController } from '../doc_controller' ; import { FlatQuestion } from './flat_question' ; import { FlatRepository } from './flat_repository' ; import { IPdfBrick } from '../pdf_render/pdf_brick' ; import { TextBrick } from '../pdf_render/pdf_text' ; import { RankingItemBrick } from '../pdf_render/pdf_rankingitem' ; import { CompositeBrick } from '../pdf_render/pdf_composite' ; import { SurveyHelper } from '../helper_survey' ; export class FlatRanking extends FlatQuestion { protected question : QuestionRankingModel ; public constructor ( protected survey , question , protected controller ) { super ( survey , question , controller ) ; this . question = < QuestionRankingModel > question ; } protected async generateFlatComposite ( point , item , index ) { const itemRect = SurveyHelper . createRect ( point , this . controller . unitWidth , this . controller . unitHeight ) ; const itemScaledRect = SurveyHelper . moveRect ( SurveyHelper . scaleRect ( itemRect , SurveyHelper . SELECT_ITEM_FLAT_SCALE ) , point . xLeft ) ; const itemFlat = new RankingItemBrick ( this . question , this . controller , itemScaledRect , this . question . getNumberByIndex ( index ) ) ; const textPoint = SurveyHelper . clone ( point ) ; textPoint . xLeft = itemFlat . xRight + this . controller . unitWidth * SurveyHelper . GAP_BETWEEN_ITEM_TEXT ; const textFlat = await SurveyHelper . createTextFlat ( textPoint , this . question , this . controller , item . locText , TextBrick ) ; return new CompositeBrick ( itemFlat , textFlat ) ; } public async generateFlatsContent ( point ) { const currPoint = SurveyHelper . clone ( point ) ; const flats = [ ] ; for ( let i = 0 ; i < this . question . rankingChoices . length ; i ++ ) { const itemFlat = await this . generateFlatComposite ( currPoint , this . question . rankingChoices [ i ] , i ) ; currPoint . yTop = itemFlat . yBot + SurveyHelper . GAP_BETWEEN_ROWS * this . controller . unitHeight ; flats . push ( itemFlat ) ; } return flats ; } } FlatRepository . getInstance ( ) . register ( 'ranking' , FlatRanking ) ;