Class: DrawioDsl::Schema::Layout

Inherits:
Node
  • Object
show all
Defined in:
lib/drawio_dsl/schema/layouts/layout.rb

Overview

Provides base configuration for automatic layouts

Direct Known Subclasses

FlexLayout, GridLayout

Instance Attribute Summary collapse

Attributes inherited from Node

#classification, #id, #key, #nodes, #page, #parent

Instance Method Summary collapse

Methods inherited from Node

#add_node, #debug, #debug_detail, #debug_row, #root?

Constructor Details

#initialize(page, **args) ⇒ Layout

Returns a new instance of Layout.



12
13
14
15
16
# File 'lib/drawio_dsl/schema/layouts/layout.rb', line 12

def initialize(page, **args)
  @after_init_fired = false

  super(page, **args.merge(classification: :layout_rule))
end

Instance Attribute Details

#anchor_xObject

represents the x coordinate of the top left corner layout area this coordinate is based on the current location of the page



9
10
11
# File 'lib/drawio_dsl/schema/layouts/layout.rb', line 9

def anchor_x
  @anchor_x
end

#anchor_yObject

Returns the value of attribute anchor_y.



10
11
12
# File 'lib/drawio_dsl/schema/layouts/layout.rb', line 10

def anchor_y
  @anchor_y
end

Instance Method Details

#after_initObject



25
26
27
28
# File 'lib/drawio_dsl/schema/layouts/layout.rb', line 25

def after_init
  @anchor_x ||= page.position_x
  @anchor_y ||= page.position_y
end

#fire_after_initObject



18
19
20
21
22
23
# File 'lib/drawio_dsl/schema/layouts/layout.rb', line 18

def fire_after_init
  return if @after_init_fired

  @after_init_fired = true
  after_init
end

#to_hObject



30
31
32
33
34
35
# File 'lib/drawio_dsl/schema/layouts/layout.rb', line 30

def to_h
  super.merge(
    anchor_x: anchor_x,
    anchor_y: anchor_y
  )
end