Class: DrawioDsl::Schema::Page
- Inherits:
-
Object
- Object
- DrawioDsl::Schema::Page
- Defined in:
- lib/drawio_dsl/schema/page.rb
Overview
Page is a container for nodes
Instance Attribute Summary collapse
-
#active ⇒ Object
Returns the value of attribute active.
-
#arrows ⇒ Object
readonly
arrows = “1”.
-
#background ⇒ Object
readonly
background = “#FFFACD”.
-
#bg_theme ⇒ Object
readonly
Returns the value of attribute bg_theme.
-
#connect ⇒ Object
readonly
connect = “1”.
-
#diagram ⇒ Object
Returns the value of attribute diagram.
-
#fold ⇒ Object
readonly
fold = “1”.
-
#grid ⇒ Object
readonly
grid = “0”.
-
#grid_size ⇒ Object
readonly
gridSize = “10”.
-
#guides ⇒ Object
readonly
guides = “1”.
-
#id ⇒ Object
Returns the value of attribute id.
-
#margin_left ⇒ Object
readonly
Returns the value of attribute margin_left.
-
#margin_top ⇒ Object
readonly
Returns the value of attribute margin_top.
-
#math ⇒ Object
readonly
math = “0”.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#nodes ⇒ Object
readonly
Returns the value of attribute nodes.
-
#page_height ⇒ Object
readonly
pageHeight = “827”.
-
#page_no ⇒ Object
readonly
page = “1”.
-
#page_scale ⇒ Object
readonly
pageScale = “1”.
-
#page_shadow ⇒ Object
readonly
shadow = “0”.
-
#page_width ⇒ Object
readonly
pageWidth = “583”.
-
#palette ⇒ Object
readonly
Returns the value of attribute palette.
-
#position_x ⇒ Object
These transient attributes hold the current x, y location for the last element added to the page.
-
#position_y ⇒ Object
Returns the value of attribute position_y.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
-
#tooltips ⇒ Object
readonly
tooltips = “1”.
Instance Method Summary collapse
-
#active? ⇒ Boolean
rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength.
- #add_node(node) ⇒ Object
- #as_xml(xml) ⇒ Object
- #bg_theme_palette ⇒ Object
-
#initialize(diagram, **args) ⇒ Page
constructor
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength.
- #theme_palette ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(diagram, **args) ⇒ Page
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/drawio_dsl/schema/page.rb', line 40 def initialize(diagram, **args) @diagram = diagram @id = args[:id] @active = args[:active].nil? ? true : !args[:active].nil? @name = args[:name] @theme = args[:theme] || diagram.theme @bg_theme = args[:bg_theme] || diagram.bg_theme # cursor positioning is used by the layout engine @position_x = 0 @position_y = 0 # settings to support the layout engine @margin_left = args[:margin_left] || 50 @margin_top = args[:margin_top] || 50 # settings that live on the drawio page object @grid = args[:grid] || 0 @grid_size = args[:grid_size] || 10 @guides = args[:guides] || 1 @tooltips = args[:tooltips] || 1 @connect = args[:connect] || 1 @arrows = args[:arrows] || 1 @fold = args[:fold] || 1 @page_no = args[:page_no] || 1 @page_scale = args[:page_scale] || 1 @page_width = args[:page_width] || 1169 # A4 @page_height = args[:page_height] || 827 # A4 @background = args[:background] || bg_theme_palette.bg_color @page_shadow = args[:page_shadow] || 0 @math = args[:math] || 0 @style = DrawioDsl::Schema::CommonStyle.new(**args) do # Inherit from the diagram style when specific style not specified. @white_space ||= diagram.style.white_space @html ||= diagram.style.html @rounded ||= diagram.style.rounded @shadow ||= diagram.style.shadow @sketch ||= diagram.style.sketch @glass ||= diagram.style.glass end @palette = DrawioDsl::Schema::DefaultPalette.new(self, **args) do |page| # Inherit from theme when specific palette options are not specified. @fill_color ||= page.theme_palette.fill_color @stroke_color ||= page.theme_palette.stroke_color @font_color ||= page.theme_palette.font_color @gradient ||= page.theme_palette.gradient end @nodes = NodeList.new # [] end |
Instance Attribute Details
#active ⇒ Object
Returns the value of attribute active.
14 15 16 |
# File 'lib/drawio_dsl/schema/page.rb', line 14 def active @active end |
#arrows ⇒ Object (readonly)
arrows = “1”
29 30 31 |
# File 'lib/drawio_dsl/schema/page.rb', line 29 def arrows @arrows end |
#background ⇒ Object (readonly)
background = “#FFFACD”
35 36 37 |
# File 'lib/drawio_dsl/schema/page.rb', line 35 def background @background end |
#bg_theme ⇒ Object (readonly)
Returns the value of attribute bg_theme.
17 18 19 |
# File 'lib/drawio_dsl/schema/page.rb', line 17 def bg_theme @bg_theme end |
#connect ⇒ Object (readonly)
connect = “1”
28 29 30 |
# File 'lib/drawio_dsl/schema/page.rb', line 28 def connect @connect end |
#diagram ⇒ Object
Returns the value of attribute diagram.
7 8 9 |
# File 'lib/drawio_dsl/schema/page.rb', line 7 def diagram @diagram end |
#fold ⇒ Object (readonly)
fold = “1”
30 31 32 |
# File 'lib/drawio_dsl/schema/page.rb', line 30 def fold @fold end |
#grid ⇒ Object (readonly)
grid = “0”
24 25 26 |
# File 'lib/drawio_dsl/schema/page.rb', line 24 def grid @grid end |
#grid_size ⇒ Object (readonly)
gridSize = “10”
25 26 27 |
# File 'lib/drawio_dsl/schema/page.rb', line 25 def grid_size @grid_size end |
#guides ⇒ Object (readonly)
guides = “1”
26 27 28 |
# File 'lib/drawio_dsl/schema/page.rb', line 26 def guides @guides end |
#id ⇒ Object
Returns the value of attribute id.
13 14 15 |
# File 'lib/drawio_dsl/schema/page.rb', line 13 def id @id end |
#margin_left ⇒ Object (readonly)
Returns the value of attribute margin_left.
20 21 22 |
# File 'lib/drawio_dsl/schema/page.rb', line 20 def margin_left @margin_left end |
#margin_top ⇒ Object (readonly)
Returns the value of attribute margin_top.
21 22 23 |
# File 'lib/drawio_dsl/schema/page.rb', line 21 def margin_top @margin_top end |
#math ⇒ Object (readonly)
math = “0”
37 38 39 |
# File 'lib/drawio_dsl/schema/page.rb', line 37 def math @math end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
15 16 17 |
# File 'lib/drawio_dsl/schema/page.rb', line 15 def name @name end |
#nodes ⇒ Object (readonly)
Returns the value of attribute nodes.
22 23 24 |
# File 'lib/drawio_dsl/schema/page.rb', line 22 def nodes @nodes end |
#page_height ⇒ Object (readonly)
pageHeight = “827”
34 35 36 |
# File 'lib/drawio_dsl/schema/page.rb', line 34 def page_height @page_height end |
#page_no ⇒ Object (readonly)
page = “1”
31 32 33 |
# File 'lib/drawio_dsl/schema/page.rb', line 31 def page_no @page_no end |
#page_scale ⇒ Object (readonly)
pageScale = “1”
32 33 34 |
# File 'lib/drawio_dsl/schema/page.rb', line 32 def page_scale @page_scale end |
#page_shadow ⇒ Object (readonly)
shadow = “0”
36 37 38 |
# File 'lib/drawio_dsl/schema/page.rb', line 36 def page_shadow @page_shadow end |
#page_width ⇒ Object (readonly)
pageWidth = “583”
33 34 35 |
# File 'lib/drawio_dsl/schema/page.rb', line 33 def page_width @page_width end |
#palette ⇒ Object (readonly)
Returns the value of attribute palette.
19 20 21 |
# File 'lib/drawio_dsl/schema/page.rb', line 19 def palette @palette end |
#position_x ⇒ Object
These transient attributes hold the current x, y location for the last element added to the page
10 11 12 |
# File 'lib/drawio_dsl/schema/page.rb', line 10 def position_x @position_x end |
#position_y ⇒ Object
Returns the value of attribute position_y.
11 12 13 |
# File 'lib/drawio_dsl/schema/page.rb', line 11 def position_y @position_y end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
18 19 20 |
# File 'lib/drawio_dsl/schema/page.rb', line 18 def style @style end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
16 17 18 |
# File 'lib/drawio_dsl/schema/page.rb', line 16 def theme @theme end |
#tooltips ⇒ Object (readonly)
tooltips = “1”
27 28 29 |
# File 'lib/drawio_dsl/schema/page.rb', line 27 def tooltips @tooltips end |
Instance Method Details
#active? ⇒ Boolean
rubocop:enable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity, Metrics/MethodLength
95 96 97 |
# File 'lib/drawio_dsl/schema/page.rb', line 95 def active? !!@active end |
#add_node(node) ⇒ Object
99 100 101 102 |
# File 'lib/drawio_dsl/schema/page.rb', line 99 def add_node(node) @nodes.add(self, node) node end |
#as_xml(xml) ⇒ Object
112 113 114 |
# File 'lib/drawio_dsl/schema/page.rb', line 112 def as_xml(xml) nodes.as_xml(xml) end |
#bg_theme_palette ⇒ Object
108 109 110 |
# File 'lib/drawio_dsl/schema/page.rb', line 108 def bg_theme_palette @bg_theme_palette ||= KConfig.configuration.drawio.theme.background(bg_theme) end |
#theme_palette ⇒ Object
104 105 106 |
# File 'lib/drawio_dsl/schema/page.rb', line 104 def theme_palette @theme_palette ||= KConfig.configuration.drawio.theme.element(theme) end |
#to_h ⇒ Object
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/drawio_dsl/schema/page.rb', line 116 def to_h { id: id, active: active, name: name, position_x: position_x, position_y: position_y, theme: theme, bg_theme: bg_theme, palette: palette.to_h, style: style.to_h, settings: settings, nodes: nodes.to_h } end |