package Ġde . u ul m . se . co uched it . client . controller . canvas . processing Ċ Ċ import Ġcom . google . inject . Inject Ċ import Ġde . u ul m . se . co uched it . client . controller . canvas . ge f . part . Base Part Ċ import Ġde . u ul m . se . co uched it . client . controller . canvas . ge f . part . system . Root Drawing Part Ċ import Ġde . u ul m . se . co uched it . client . util . ge f . content Viewer Ċ import Ġde . u ul m . se . co uched it . processing . common . model . Element Add Diff Ċ import Ġde . u ul m . se . co uched it . processing . common . model . Element Remove Diff Ċ import Ġde . u ul m . se . co uched it . processing . common . model . Model Diff Ċ import Ġio . reactivex . rx java fx . schedul ers . Java Fx Scheduler Ċ import Ġio . reactivex . subjects . Replay Subject Ċ import Ġorg . eclipse . ge f . mvc . fx . domain . ID omain Ċ import Ġorg . eclipse . ge f . mvc . fx . parts . Abstract Content Part Ċ Ċ internal Ġclass ĠCanvas Composition Manager Ġ@ Inject Ġconstructor ( private Ġval Ġdomain : ĠID omain ) Ġ{ ĊĠĠĠ Ġinternal Ġval Ġelement Update Subject Ġ= ĠRe play Subject . create < Triple < Base Part < *, Ġ* >, ĠBase Part < *, Ġ* >, ĠModel Diff >>() ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . element Update Subject . observe On ( Java Fx Scheduler . platform ()). subscribe Ġ{ Ġ( included Part , Ġcomposite Part , Ġdiff ) Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthis . on Incoming Diff ( included Part , Ġcomposite Part , Ġdiff ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġon Incoming Diff ( included Part : ĠBase Part < *, Ġ* >, Ġcomposite Part : ĠBase Part < *, Ġ* >, Ġdiff : ĠModel Diff ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( diff Ġis ĠElement Add Diff ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( included Part . getParent () Ġ=== Ġcomposite Part ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġcontent Ġ= Ġincluded Part . getContent () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġan ch ore ds Ġ= Ġincluded Part . get An ch ore ds Un modifiable (). filter Is Instance ( Base Part :: class . java ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġparent Part Ġ= Ġincluded Part . getParent () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġan ch ore ds With Roles Ġ= Ġmutable ListOf < Pair < Base Part < *, Ġ* >, ĠString >>() ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( parent Part Ġ!== Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfor Ġ( anch ored Ġin Ġan ch ore ds ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġroles Ġ= Ġan ch ored . getContent An ch orage s Un modifiable (). get ( content ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġfor Ġ( role Ġin Ġroles ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġan ch ored . detach From Content An ch orage ( content , Ġrole ) ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġan ch ore ds With Roles . add ( Pair ( anch ored , Ġrole )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( parent Part Ġis ĠAbstract Content Part ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġparent Part . remove Content Child ( content ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġparent Part . removeChild ( included Part ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġcomposite Part . add Content Child ( content , Ġcomposite Part . getContent Children Un modifiable (). size ) ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġfor Ġ(( anch ored , Ġrole ) Ġin Ġan ch ore ds With Roles ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġan ch ored . attach To Content An ch orage ( content , Ġrole ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġif Ġ( diff Ġis ĠElement Remove Diff ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( composite Part . getChildren Un modifiable (). contains ( included Part )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġcomposite Part . removeChild ( included Part ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġget Root Drawing Part (). addChild ( included Part ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Root Drawing Part () Ġ= Ġdomain . content Viewer . root Part . children Un modifiable [ 0 ] Ġas ĠRoot Drawing Part Ċ } Ċ