AbstractNode.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import Boundable from './Boundable'
  2. import ArrayList from '../../../../../java/util/ArrayList'
  3. import Serializable from '../../../../../java/io/Serializable'
  4. import Assert from '../../util/Assert'
  5. export default class AbstractNode {
  6. constructor() {
  7. AbstractNode.constructor_.apply(this, arguments)
  8. }
  9. static constructor_() {
  10. this._childBoundables = new ArrayList()
  11. this._bounds = null
  12. this._level = null
  13. if (arguments.length === 0) {} else if (arguments.length === 1) {
  14. const level = arguments[0]
  15. this._level = level
  16. }
  17. }
  18. getLevel() {
  19. return this._level
  20. }
  21. size() {
  22. return this._childBoundables.size()
  23. }
  24. getChildBoundables() {
  25. return this._childBoundables
  26. }
  27. addChildBoundable(childBoundable) {
  28. Assert.isTrue(this._bounds === null)
  29. this._childBoundables.add(childBoundable)
  30. }
  31. isEmpty() {
  32. return this._childBoundables.isEmpty()
  33. }
  34. getBounds() {
  35. if (this._bounds === null)
  36. this._bounds = this.computeBounds()
  37. return this._bounds
  38. }
  39. get interfaces_() {
  40. return [Boundable, Serializable]
  41. }
  42. }