import { BaseContainer } from "./BaseContainer" ; import { Flap } from "../components" ; import { Tree } from "bp/content/context" ; import type { TreeNode } from "bp/content/context" ; import type { Design } from ".." ; /**
 *  FlapContainer 映射  TreeNode 中的葉點成  Flap 。
  @ shrewd export class FlapContainer extends BaseContainer < TreeNode , Flap > { constructor ( design ) { super ( design , ( ) => design . $tree . $leaf , l => new Flap ( design . $LayoutSheet , l ) ) ; } @ shrewd public get $byId ( ) : ReadonlyMap < number , Flap > { let result = new Map < number , Flap > ( ) ; for ( let f of this . values ( ) ) result . set ( f . node . id , f ) ; return result ; } public $delete ( flaps ) { let success = false ; for ( let f of flaps ) { if ( this . _design . $vertices . size == Tree . $MIN_NODES ) break ; f . node . $delete ( ) ; success = true ; } return success ; } public $selectAll ( ) { this . forEach ( f => f . $selected = true ) ; } public $toVertex ( flaps ) { this . _design . $TreeSheet . $clearSelection ( ) ; for ( let f of flaps ) { let v = this . _design . $vertices . get ( f . node ) ; if ( v ) v . $selected = true ; } this . _design . mode = "tree" ; } }