import { DbEntity } from './db-entity' ; import { DbEntityPropertyLayout } from './db-entity-property-layout' ; import { DbEntityProperty } from './db-entity-property' ; import { Point } from './point' ; import { DbEntityLayoutDto } from './dto/db-entity-layout-dto' ; export class DbEntityLayout { x : number = null ; y : number = null ; width : number = null ; height : number = null ; zIndex = 0 ; get center ( ) : Point { return new Point ( this . x + this . width / 2 , this . y + this . height / 2 ) ; } readonly properties : DbEntityPropertyLayout [ ] = [ ] ; collapsed = false ; visible = true ; param entity param key constructor ( public readonly entity , public readonly key ) { } getPropertyLayout ( property ) { let result = this . properties . filter ( e => e . property . equals ( property ) ) [ 0 ] ; if ( ! result ) { result = new DbEntityPropertyLayout ( property ) ; this . properties . push ( result ) ; } return result ; } toDto ( ) { const result = new DbEntityLayoutDto ( ) ; result . name = this . entity . name ; result . type = this . entity . clrType ; result . x = this . x ; result . y = this . y ; result . collapsed = this . collapsed ; result . visible = this . visible ; return result ; } applyLayout ( dto ) { this . x = dto . x ; this . y = dto . y ; this . collapsed = dto . collapsed ; this . visible = dto . visible ; } }