drawio_dsl 0.1.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.builders/.templates/command.rb +8 -0
  3. data/.builders/.templates/schema_shape.rb +9 -0
  4. data/.builders/blueprint/shapes.rb +19 -0
  5. data/.builders/boot.rb +1 -0
  6. data/.builders/generators/10-page-margin.rb +46 -0
  7. data/.builders/generators/15-grid-direction.rb +40 -0
  8. data/.builders/generators/16-grid-alignment.rb +73 -0
  9. data/.builders/generators/20-styles.rb +64 -0
  10. data/.builders/generators/25-themes.rb +24 -0
  11. data/.rubocop.yml +6 -1
  12. data/CHANGELOG.md +24 -0
  13. data/lib/drawio_dsl/configuration.rb +58 -45
  14. data/lib/drawio_dsl/dom_builder.rb +66 -23
  15. data/lib/drawio_dsl/drawio.rb +65 -36
  16. data/lib/drawio_dsl/layout_engine.rb +24 -28
  17. data/lib/drawio_dsl/schema/_.rb +23 -0
  18. data/lib/drawio_dsl/schema/common_style.rb +42 -0
  19. data/lib/drawio_dsl/schema/default_palette.rb +31 -0
  20. data/lib/drawio_dsl/schema/diagram.rb +57 -0
  21. data/lib/drawio_dsl/schema/layouts/flex_layout.rb +87 -0
  22. data/lib/drawio_dsl/schema/layouts/grid_layout.rb +102 -0
  23. data/lib/drawio_dsl/schema/layouts/layout.rb +41 -0
  24. data/lib/drawio_dsl/schema/node.rb +53 -0
  25. data/lib/drawio_dsl/schema/page.rb +135 -0
  26. data/lib/drawio_dsl/schema/shapes/callout.rb +9 -0
  27. data/lib/drawio_dsl/schema/shapes/circle.rb +9 -0
  28. data/lib/drawio_dsl/schema/shapes/cloud.rb +9 -0
  29. data/lib/drawio_dsl/schema/shapes/diamond.rb +9 -0
  30. data/lib/drawio_dsl/schema/shapes/ellipse.rb +9 -0
  31. data/lib/drawio_dsl/schema/shapes/hexagon.rb +9 -0
  32. data/lib/drawio_dsl/schema/shapes/note.rb +9 -0
  33. data/lib/drawio_dsl/schema/shapes/process.rb +9 -0
  34. data/lib/drawio_dsl/schema/shapes/rectangle.rb +9 -0
  35. data/lib/drawio_dsl/schema/shapes/shape.rb +125 -0
  36. data/lib/drawio_dsl/schema/shapes/square.rb +9 -0
  37. data/lib/drawio_dsl/version.rb +1 -1
  38. data/lib/drawio_dsl/xml_builder.rb +7 -7
  39. data/lib/drawio_dsl.rb +1 -2
  40. data/package-lock.json +2 -2
  41. data/package.json +1 -1
  42. metadata +30 -6
  43. data/.builders/generators/10-layout.rb +0 -21
  44. data/lib/drawio_dsl/drawio_dsl-OLD.x +0 -335
  45. data/lib/drawio_dsl/layout_container.rb +0 -54
  46. data/lib/drawio_dsl/schema.rb +0 -346
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6af520857fe09be7e990c254d75364ae3c4f145e77beb8aaf1850c7e99954666
4
- data.tar.gz: ed9f9debe4437765f426cb873cc226eb8721a89b2be257a30345122d59a25217
3
+ metadata.gz: 56780c6c8fa8c1ea29a29e07bf389cf257fd7a33faf52e955b3fe56133367063
4
+ data.tar.gz: f583d40a64cea1177d7d52ab627dcbfa954cb3091dada0903947f69f5792d3b5
5
5
  SHA512:
6
- metadata.gz: 13a320ccac8daefe68036dafe8982451e28cb1ba56dd0be1b22694106fee82aa4625e8eee214a8a0cecdff476a5b2b56b90b45a6bbf8df82c1a315d36ea18a57
7
- data.tar.gz: 912a578341300d29b610fb053b5d4d98a161e7be9c1decd65b72af0398305a216d785245572b020b7463ad708ed74d6f7ddf936708175337eb6834f92611dcd8
6
+ metadata.gz: 92b5c4e8e2a8210c3e2213df96f1d35034689a3d2ff9132e17fc1fa30f68b89551cb395f725e0b1b5da3b506e62471e2e64def33683f8959f53a41a43e4f5805
7
+ data.tar.gz: 112eb4f963aa4c295559f8d1e8ed0eaf0121bb768282924ca54059c3de4924d16a33b5a3d33dd9044378315840aafda7db34d228aa2064606eccf5d29776da52
@@ -0,0 +1,8 @@
1
+ KManager.model :{{command.name}}, namespace: %i[blueprint command] do
2
+ # microapp = import(:handlebars_helpers, :microapp)
3
+
4
+ settings do
5
+ name :{{command.name}}
6
+ description "{{command.description}}"
7
+ end
8
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module DrawioDsl
4
+ module Schema
5
+ class {{camle type}} < Shape
6
+ configure_shape(:{{snake type}})
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ KManager.model :shapes, namespace: %i[domain] do
2
+ # microapp = import(:handlebars_helpers, :microapp)
3
+
4
+ table :shapes do
5
+ fields :type, :x, :y, :w, :h, :style_modifiers
6
+
7
+ # row :shape , x: 0, y: 0, w: 20, h: 20, style_modifiers: ''
8
+ row :square , x: 0, y: 0, w: 160, h: 160, style_modifiers: ''
9
+ row :rectangle , x: 0, y: 0, w: 200, h: 120, style_modifiers: ''
10
+ row :circle , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;ellipse'
11
+ row :process , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;shape=process'
12
+ row :ellipse , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;ellipse'
13
+ row :diamond , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;rhombus'
14
+ row :hexagon , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;shape=hexagon'
15
+ row :cloud , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=cloud'
16
+ row :note , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=note'
17
+ row :callout , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=callout'
18
+ end
19
+ end
data/.builders/boot.rb CHANGED
@@ -60,6 +60,7 @@ resource_manager
60
60
  .fileset
61
61
  .glob('*.rb', exclude: ['boot.rb'])
62
62
  .glob('generators/**/*.rb')
63
+ .glob('blueprint/**/*.rb')
63
64
  resource_manager.add_resources
64
65
 
65
66
  KManager.boot
@@ -0,0 +1,46 @@
1
+ KManager.action :bootstrap do
2
+ action do
3
+ director = DrawioDsl::Drawio
4
+ .init(k_builder)
5
+ .diagram(theme: :style_01)
6
+ .page('PgMargin-default') do
7
+ grid_layout(wrap_at: 4)
8
+ square(title: 'Page Margin 50, 50 (Default)')
9
+ circle
10
+ square
11
+ circle
12
+ square
13
+ circle
14
+ square
15
+ circle
16
+ end
17
+ .page('PgMargin-0-0', margin_left: 0, margin_top: 0) do
18
+ grid_layout(wrap_at: 4)
19
+ square(title: 'Page Margin 0, 0')
20
+ circle
21
+ square
22
+ circle
23
+ square
24
+ circle
25
+ square
26
+ circle
27
+ end
28
+ .page('PgMargin-90-70', margin_left: 90, margin_top: 70) do
29
+ grid_layout(wrap_at: 4)
30
+ square(title: 'Page Margin 90, 70')
31
+ circle
32
+ square
33
+ circle
34
+ square
35
+ circle
36
+ square
37
+ circle
38
+ end
39
+
40
+ diagram = DrawioDsl::XmlBuilder.new(director.builder.diagram)
41
+
42
+
43
+ File.write('../spec/.samples/drawio/10-page-margin.xml', diagram.build)
44
+ File.write('../spec/.samples/drawio/10-page-margin.drawio', diagram.build)
45
+ end
46
+ end
@@ -0,0 +1,40 @@
1
+ KManager.action :bootstrap do
2
+ action do
3
+
4
+ # KConfig.configuration.drawio.square.w = KConfig.configuration.drawio.square.w / 4
5
+ # KConfig.configuration.drawio.square.h = KConfig.configuration.drawio.square.h / 4
6
+ # KConfig.configuration.drawio.circle.w = KConfig.configuration.drawio.circle.w / 4
7
+ # KConfig.configuration.drawio.circle.h = KConfig.configuration.drawio.circle.h / 4
8
+ # KConfig.configuration.drawio.rectangle.w = KConfig.configuration.drawio.rectangle.w / 4
9
+ # KConfig.configuration.drawio.rectangle.h = KConfig.configuration.drawio.rectangle.h / 4
10
+
11
+ director = DrawioDsl::Drawio
12
+ .init(k_builder)
13
+ .diagram(theme: :style_01)
14
+ .page('Horizontal', margin_left: 0, margin_top: 0) do
15
+ grid_layout(wrap_at: 3, direction: :horizontal)
16
+ circle(title: '01')
17
+ square(title: '02')
18
+ circle(title: '03')
19
+ square(title: '04')
20
+ circle(title: '05')
21
+ square(title: '06')
22
+ circle(title: '07')
23
+ end
24
+ .page('Vertical', margin_left: 0, margin_top: 0) do
25
+ grid_layout(wrap_at: 3, direction: :vertical)
26
+ circle(title: '01')
27
+ square(title: '02')
28
+ circle(title: '03')
29
+ square(title: '04')
30
+ circle(title: '05')
31
+ square(title: '06')
32
+ circle(title: '07')
33
+ end
34
+
35
+ diagram = DrawioDsl::XmlBuilder.new(director.builder.diagram)
36
+
37
+ File.write('../spec/.samples/drawio/15-grid-direction.xml', diagram.build)
38
+ File.write('../spec/.samples/drawio/15-grid-direction.drawio', diagram.build)
39
+ end
40
+ end
@@ -0,0 +1,73 @@
1
+ KManager.action :bootstrap do
2
+ action do
3
+
4
+ # KConfig.configuration.drawio.square.w = KConfig.configuration.drawio.square.w / 4
5
+ # KConfig.configuration.drawio.square.h = KConfig.configuration.drawio.square.h / 4
6
+ # KConfig.configuration.drawio.circle.w = KConfig.configuration.drawio.circle.w / 4
7
+ # KConfig.configuration.drawio.circle.h = KConfig.configuration.drawio.circle.h / 4
8
+ # KConfig.configuration.drawio.rectangle.w = KConfig.configuration.drawio.rectangle.w / 4
9
+ # KConfig.configuration.drawio.rectangle.h = KConfig.configuration.drawio.rectangle.h / 4
10
+
11
+ director = DrawioDsl::Drawio
12
+ .init(k_builder,
13
+ on_exist: :skip, # %i[skip write compare]
14
+ on_action: :queue # %i[queue execute]
15
+ )
16
+ .diagram(theme: :style_01)
17
+ .page('Grid-Center', margin_left: 0, margin_top: 0) do
18
+ grid_layout(wrap_at: 3)
19
+ circle
20
+ square
21
+ circle
22
+ square
23
+ circle
24
+ square
25
+ circle
26
+ end
27
+ .page('Grid-Top', margin_left: 0, margin_top: 0) do
28
+ grid_layout(wrap_at: 3, v_align: :top, h_align: :center)
29
+ circle
30
+ square
31
+ circle
32
+ square
33
+ circle
34
+ square
35
+ circle
36
+ end
37
+ .page('Grid-Bottom', margin_left: 0, margin_top: 0) do
38
+ grid_layout(wrap_at: 3, v_align: :bottom, h_align: :center)
39
+ circle
40
+ square
41
+ circle
42
+ square
43
+ circle
44
+ square
45
+ circle
46
+ end
47
+ .page('Grid-Left', margin_left: 0, margin_top: 0) do
48
+ grid_layout(wrap_at: 3, v_align: :center, h_align: :left)
49
+ circle
50
+ square
51
+ circle
52
+ square
53
+ circle
54
+ square
55
+ circle
56
+ end
57
+ .page('Grid-Right', margin_left: 0, margin_top: 0) do
58
+ grid_layout(wrap_at: 3, v_align: :center, h_align: :right)
59
+ circle
60
+ square
61
+ circle
62
+ square
63
+ circle
64
+ square
65
+ circle
66
+ end
67
+
68
+ diagram = DrawioDsl::XmlBuilder.new(director.builder.diagram)
69
+
70
+ File.write('../spec/.samples/drawio/16-grid-alignment.xml', diagram.build)
71
+ File.write('../spec/.samples/drawio/16-grid-alignment.drawio', diagram.build)
72
+ end
73
+ end
@@ -0,0 +1,64 @@
1
+ KManager.action :bootstrap do
2
+ action do
3
+
4
+ # :rounded, :shadow, :sketch, :glass
5
+ director = DrawioDsl::Drawio
6
+ .init(k_builder)
7
+ .diagram(theme: :style_06)
8
+ .page('Style-Plain', margin_left: 0, margin_top: 0) do
9
+ grid_layout(wrap_at: 4)
10
+ circle
11
+ square
12
+ circle
13
+ square
14
+ circle
15
+ square
16
+ circle
17
+ end
18
+ .page('Style-Shadow', shadow: 1, margin_left: 0, margin_top: 0) do
19
+ grid_layout(wrap_at: 4)
20
+ circle
21
+ square
22
+ circle
23
+ square
24
+ circle
25
+ square
26
+ circle
27
+ end
28
+ .page('Style-Rounded', rounded: 1, margin_left: 0, margin_top: 0) do
29
+ grid_layout(wrap_at: 4)
30
+ circle
31
+ square
32
+ circle
33
+ square
34
+ circle
35
+ square
36
+ circle
37
+ end
38
+ .page('Style-Glass', glass: 1, margin_left: 0, margin_top: 0) do
39
+ grid_layout(wrap_at: 4)
40
+ circle
41
+ square
42
+ circle
43
+ square
44
+ circle
45
+ square
46
+ circle
47
+ end
48
+ .page('Style-Sketch', sketch: 1, margin_left: 0, margin_top: 0) do
49
+ grid_layout(wrap_at: 4)
50
+ circle
51
+ square
52
+ circle
53
+ square
54
+ circle
55
+ square
56
+ circle
57
+ end
58
+
59
+ diagram = DrawioDsl::XmlBuilder.new(director.builder.diagram)
60
+
61
+ File.write('../spec/.samples/drawio/20-styles.xml', diagram.build)
62
+ File.write('../spec/.samples/drawio/20-styles.drawio', diagram.build)
63
+ end
64
+ end
@@ -0,0 +1,24 @@
1
+ KManager.action :bootstrap do
2
+ action do
3
+
4
+ # :rounded, :shadow, :sketch, :glass
5
+ director = DrawioDsl::Drawio
6
+ .init(k_builder)
7
+ .diagram(theme: :style_06)
8
+ .page('Style-Plain', margin_left: 0, margin_top: 0) do
9
+ grid_layout(wrap_at: 5)
10
+
11
+ square(title: 'The quick brown fox jumps over the lazy dog')
12
+ circle(title: 'Mary had a little lamb')
13
+
14
+ KConfig.configuration.drawio.themes.keys.each do |theme|
15
+ random(title: theme.to_s, theme: theme)
16
+ end
17
+ end
18
+
19
+ diagram = DrawioDsl::XmlBuilder.new(director.builder.diagram)
20
+
21
+ File.write('../spec/.samples/drawio/25-themes.xml', diagram.build)
22
+ File.write('../spec/.samples/drawio/25-themes.drawio', diagram.build)
23
+ end
24
+ end
data/.rubocop.yml CHANGED
@@ -67,6 +67,10 @@ Naming/VariableNumber:
67
67
  Naming/MethodParameterName:
68
68
  AllowedNames:
69
69
  - as
70
+ - x
71
+ - y
72
+ - w
73
+ - h
70
74
  Style/EmptyMethod:
71
75
  Exclude:
72
76
  - "**/spec/**/*"
@@ -79,7 +83,8 @@ Metrics/ParameterLists:
79
83
  Layout/EmptyLineBetweenDefs:
80
84
  Exclude:
81
85
  - "**/spec/**/*"
82
-
86
+ Style/Documentation:
87
+ Enabled: false
83
88
  Lint/AmbiguousBlockAssociation:
84
89
  Exclude:
85
90
  - "**/spec/**/*"
data/CHANGELOG.md CHANGED
@@ -1,3 +1,27 @@
1
+ # [0.3.0](https://github.com/klueless-io/drawio_dsl/compare/v0.2.0...v0.3.0) (2022-03-04)
2
+
3
+
4
+ ### Features
5
+
6
+ * add samples for direction, alignment, themes, styles and page margin ([2e9f735](https://github.com/klueless-io/drawio_dsl/commit/2e9f735ba50c9391d7dea64c565ca9c0fb61978a))
7
+
8
+ # [0.2.0](https://github.com/klueless-io/drawio_dsl/compare/v0.1.0...v0.2.0) (2022-03-04)
9
+
10
+
11
+ ### Features
12
+
13
+ * update drawio with grid layout engine ([cc5dc51](https://github.com/klueless-io/drawio_dsl/commit/cc5dc51debfd902a815df704fa2dd77f39f498c7))
14
+
15
+ # [0.1.0](https://github.com/klueless-io/drawio_dsl/compare/v0.0.1...v0.1.0) (2022-03-02)
16
+
17
+
18
+ ### Features
19
+
20
+ * initial draw-io dsl ([ac197c8](https://github.com/klueless-io/drawio_dsl/commit/ac197c88b66b883b5fcce93090c285bc9ccdb7a3))
21
+ * initial draw-io dsl ([12c8b98](https://github.com/klueless-io/drawio_dsl/commit/12c8b98392e5f7da598cf2f9c375f1ca7041533b))
22
+ * initial draw-io dsl ([6ef32ad](https://github.com/klueless-io/drawio_dsl/commit/6ef32adcb1287d9993ebe30c437326716357a08e))
23
+ * initial draw-io dsl ([16827b5](https://github.com/klueless-io/drawio_dsl/commit/16827b57767d12c387167b86f17b33115d1d0378))
24
+
1
25
  ## [Unreleased]
2
26
 
3
27
  ## [0.1.0] - 2022-02-25
@@ -16,38 +16,33 @@ module DrawioDsl
16
16
  include KLog::Logging
17
17
 
18
18
  BaseStyle = Struct.new(:white_space, :html, :rounded, :shadow, :sketch, :glass, keyword_init: true)
19
-
20
- ElementDefaults = Struct.new(:type, :x, :y, :w, :h, :style_modifiers)
21
- ElementThemeStyle = Struct.new(:fill_color, :stroke_color, :font_color, :gradient, keyword_init: true)
19
+ ShapeDefaults = Struct.new(:type, :x, :y, :w, :h, :style_modifiers, keyword_init: true)
20
+ ShapeThemeStyle = Struct.new(:fill_color, :stroke_color, :font_color, :gradient, keyword_init: true)
21
+
22
+ Shapes = Struct.new(
23
+ :shape,
24
+ :square,
25
+ :rectangle,
26
+ :circle,
27
+ :process,
28
+ :ellipse,
29
+ :diamond,
30
+ :hexagon,
31
+ :cloud,
32
+ :note,
33
+ :callout,
34
+ keyword_init: true
35
+ )
22
36
 
23
37
  attr_accessor :base_style
24
38
 
25
- # Theme colors
26
39
  attr_accessor :themes
27
-
28
- # Element shapes
29
- attr_accessor :element
30
- attr_accessor :square
31
- attr_accessor :rectangle
32
- attr_accessor :circle
33
- attr_accessor :process
34
- attr_accessor :ellipse
35
- attr_accessor :triangle
36
- attr_accessor :parallelogram
37
- attr_accessor :hexagon
40
+ attr_accessor :shapes
38
41
 
39
42
  def initialize
40
43
  @base_style = BaseStyle.new(white_space: :wrap, html: 1, rounded: nil, shadow: nil, sketch: nil, glass: nil)
41
44
 
42
- @element = ElementDefaults.new(:element , 0, 0, 20, 20, '')
43
- @square = ElementDefaults.new(:square , 0, 0, 160, 160, '')
44
- @rectangle = ElementDefaults.new(:rectangle , 0, 0, 240, 120, '')
45
- @circle = ElementDefaults.new(:circle , 0, 0, 160, 160, 'ellipse')
46
- @process = ElementDefaults.new(:process , 0, 0, 240, 120, 'shape=process')
47
- @ellipse = ElementDefaults.new(:ellipse , 0, 0, 240, 120, 'ellipse')
48
- @triangle = ElementDefaults.new(:triangle , 0, 0, 160, 160, 'rhombus')
49
-
50
- @themes = {}
45
+ add_shapes
51
46
  add_themes
52
47
  end
53
48
 
@@ -61,12 +56,30 @@ module DrawioDsl
61
56
 
62
57
  private
63
58
 
59
+ def add_shapes
60
+ @shapes = Shapes.new(
61
+ shape: ShapeDefaults.new(type: :shape , x: 0, y: 0, w: 20, h: 20, style_modifiers: ''),
62
+ square: ShapeDefaults.new(type: :square , x: 0, y: 0, w: 160, h: 160, style_modifiers: ''),
63
+ rectangle: ShapeDefaults.new(type: :rectangle , x: 0, y: 0, w: 200, h: 120, style_modifiers: ''),
64
+ circle: ShapeDefaults.new(type: :circle , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;ellipse'),
65
+ process: ShapeDefaults.new(type: :process , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;shape=process'),
66
+ ellipse: ShapeDefaults.new(type: :ellipse , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;ellipse'),
67
+ diamond: ShapeDefaults.new(type: :diamond , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;rhombus'),
68
+ hexagon: ShapeDefaults.new(type: :hexagon , x: 0, y: 0, w: 200, h: 120, style_modifiers: 'double=1;shape=hexagon'),
69
+ cloud: ShapeDefaults.new(type: :cloud , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=cloud'),
70
+ note: ShapeDefaults.new(type: :note , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=note'),
71
+ callout: ShapeDefaults.new(type: :callout , x: 0, y: 0, w: 160, h: 160, style_modifiers: 'double=1;shape=callout')
72
+ )
73
+ end
74
+
64
75
  def add_theme(name, **opts)
65
- @themes[name] = ElementThemeStyle.new(**opts)
76
+ @themes[name] = ShapeThemeStyle.new(**opts)
66
77
  end
67
78
 
68
79
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
69
80
  def add_themes
81
+ @themes = {}
82
+
70
83
  add_theme(:style_01 , fill_color: '#f5f5f5', stroke_color: '#666666', font_color: '#333333')
71
84
  add_theme(:style_02 , fill_color: '#dae8fc', stroke_color: '#6c8ebf', font_color: '#333333')
72
85
  add_theme(:style_03 , fill_color: '#d5e8d4', stroke_color: '#82b366', font_color: '#333333')
@@ -90,26 +103,26 @@ module DrawioDsl
90
103
  add_theme(:style_21 , fill_color: '#647687', stroke_color: '#314354', font_color: '#ffffff')
91
104
  add_theme(:style_22 , fill_color: '#76608a', stroke_color: '#432D57', font_color: '#ffffff')
92
105
  add_theme(:style_23 , fill_color: '#a0522d', stroke_color: '#6D1F00', font_color: '#ffffff')
93
- add_theme(:style_24 , fill_color: '#fad7ac', stroke_color: '#b46504')
94
- add_theme(:style_25 , fill_color: '#fad9d5', stroke_color: '#ae4132')
95
- add_theme(:style_26 , fill_color: '#b0e3e6', stroke_color: '#0e8088')
96
- add_theme(:style_27 , fill_color: '#b1ddf0', stroke_color: '#10739e')
97
- add_theme(:style_28 , fill_color: '#d0cee2', stroke_color: '#56517e')
98
- add_theme(:style_29 , fill_color: '#bac8d3', stroke_color: '#23445d')
99
- add_theme(:style_30 , fill_color: '#f5f5f5', stroke_color: '#666666', gradient: '#b3b3b3')
100
- add_theme(:style_31 , fill_color: '#dae8fc', stroke_color: '#6c8ebf', gradient: '#7ea6e0')
101
- add_theme(:style_32 , fill_color: '#d5e8d4', stroke_color: '#82b366', gradient: '#97d077')
102
- add_theme(:style_33 , fill_color: '#ffcd28', stroke_color: '#d79b00', gradient: '#ffa500')
103
- add_theme(:style_34 , fill_color: '#fff2cc', stroke_color: '#d6b656', gradient: '#ffd966')
104
- add_theme(:style_35 , fill_color: '#f8cecc', stroke_color: '#b85450', gradient: '#ea6b66')
105
- add_theme(:style_36 , fill_color: '#e6d0de', stroke_color: '#996185', gradient: '#d5739d')
106
- add_theme(:style_37 , fill_color: '#eeeeee', stroke_color: '#36393d')
107
- add_theme(:style_38 , fill_color: '#f9f7ed', stroke_color: '#36393d')
108
- add_theme(:style_39 , fill_color: '#ffcc99', stroke_color: '#36393d')
109
- add_theme(:style_40 , fill_color: '#cce5ff', stroke_color: '#36393d')
110
- add_theme(:style_41 , fill_color: '#ffff88', stroke_color: '#36393d')
111
- add_theme(:style_42 , fill_color: '#cdeb8b', stroke_color: '#36393d')
112
- add_theme(:style_43 , fill_color: '#ffcccc', stroke_color: '#36393d')
106
+ add_theme(:style_24 , fill_color: '#fad7ac', stroke_color: '#b46504', font_color: '#333333')
107
+ add_theme(:style_25 , fill_color: '#fad9d5', stroke_color: '#ae4132', font_color: '#333333')
108
+ add_theme(:style_26 , fill_color: '#b0e3e6', stroke_color: '#0e8088', font_color: '#000000')
109
+ add_theme(:style_27 , fill_color: '#b1ddf0', stroke_color: '#10739e', font_color: '#000000')
110
+ add_theme(:style_28 , fill_color: '#d0cee2', stroke_color: '#56517e', font_color: '#000000')
111
+ add_theme(:style_29 , fill_color: '#bac8d3', stroke_color: '#23445d', font_color: '#000000')
112
+ add_theme(:style_30 , fill_color: '#f5f5f5', stroke_color: '#666666', font_color: '#000000', gradient: '#b3b3b3')
113
+ add_theme(:style_31 , fill_color: '#dae8fc', stroke_color: '#6c8ebf', font_color: '#000000', gradient: '#7ea6e0')
114
+ add_theme(:style_32 , fill_color: '#d5e8d4', stroke_color: '#82b366', font_color: '#000000', gradient: '#97d077')
115
+ add_theme(:style_33 , fill_color: '#ffcd28', stroke_color: '#d79b00', font_color: '#000000', gradient: '#ffa500')
116
+ add_theme(:style_34 , fill_color: '#fff2cc', stroke_color: '#d6b656', font_color: '#000000', gradient: '#ffd966')
117
+ add_theme(:style_35 , fill_color: '#f8cecc', stroke_color: '#b85450', font_color: '#000000', gradient: '#ea6b66')
118
+ add_theme(:style_36 , fill_color: '#e6d0de', stroke_color: '#996185', font_color: '#000000', gradient: '#d5739d')
119
+ add_theme(:style_37 , fill_color: '#eeeeee', stroke_color: '#36393d', font_color: '#000000')
120
+ add_theme(:style_38 , fill_color: '#f9f7ed', stroke_color: '#36393d', font_color: '#000000')
121
+ add_theme(:style_39 , fill_color: '#ffcc99', stroke_color: '#36393d', font_color: '#000000')
122
+ add_theme(:style_40 , fill_color: '#cce5ff', stroke_color: '#36393d', font_color: '#000000')
123
+ add_theme(:style_41 , fill_color: '#ffff88', stroke_color: '#36393d', font_color: '#000000')
124
+ add_theme(:style_42 , fill_color: '#cdeb8b', stroke_color: '#36393d', font_color: '#000000')
125
+ add_theme(:style_43 , fill_color: '#ffcccc', stroke_color: '#36393d', font_color: '#000000')
113
126
  end
114
127
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
115
128
  end
@@ -7,7 +7,8 @@ module DrawioDsl
7
7
  attr_reader :last_action
8
8
 
9
9
  attr_reader :current_page
10
- attr_reader :current_element
10
+ attr_reader :current_layout_rule
11
+ attr_reader :current_shape
11
12
 
12
13
  def initialize
13
14
  @actions = []
@@ -18,7 +19,7 @@ module DrawioDsl
18
19
  @actions = []
19
20
  @last_action = {}
20
21
  set_diagram
21
- set_layout_engine
22
+ # set_layout_engine
22
23
  end
23
24
 
24
25
  def queue_action(action)
@@ -26,16 +27,6 @@ module DrawioDsl
26
27
  @last_action = action
27
28
  end
28
29
 
29
- def set_layout_engine(**opts)
30
- @layout_engine = DrawioDsl::LayoutEngine.new(**opts)
31
- end
32
-
33
- def layout_engine
34
- return @layout_engine if defined? @layout_engine
35
-
36
- set_layout_engine
37
- end
38
-
39
30
  def set_diagram(**opts)
40
31
  @diagram = DrawioDsl::Schema::Diagram.new(**opts)
41
32
  end
@@ -55,40 +46,92 @@ module DrawioDsl
55
46
  @current_page
56
47
  end
57
48
 
58
- def add_element(element)
59
- @current_element = element
49
+ # ----------------------------------------------------------------------
50
+ # Layout provides rules for positioning components
51
+ # ----------------------------------------------------------------------
52
+
53
+ def add_grid_layout(**opts)
54
+ rule = DrawioDsl::Schema::GridLayout.new(current_page, **opts)
55
+ add_layout_rule(rule)
56
+ end
57
+
58
+ def add_flex_layout(**opts)
59
+ rule = DrawioDsl::Schema::FlexLayout.new(current_page, **opts)
60
+ add_layout_rule(rule)
61
+ end
62
+
63
+ def add_layout_rule(rule)
64
+ @current_layout_rule = rule
65
+
66
+ rule.id = "rule-#{current_page.nodes.length + 1}" unless rule.id
67
+
68
+ current_page.nodes << rule
69
+
70
+ rule
71
+ end
72
+
73
+ # ----------------------------------------------------------------------
74
+ # Shapes represent visual components
75
+ # ----------------------------------------------------------------------
60
76
 
61
- element.id = "#{current_page.id}-#{current_page.elements.length + 1}" unless element.id
77
+ def add_shape(shape)
78
+ @current_shape = shape
62
79
 
63
- layout_engine.container.place_element(element)
80
+ shape.id = "#{current_page.id}-#{current_page.nodes.length + 1}" unless shape.id
64
81
 
65
- current_page.elements << element
66
- @current_element
82
+ current_page.nodes << shape
83
+
84
+ shape
67
85
  end
68
86
 
69
87
  def add_square(**opts)
70
88
  square = DrawioDsl::Schema::Square.new(current_page, **opts)
71
- add_element(square)
89
+ add_shape(square)
72
90
  end
73
91
 
74
92
  def add_rectangle(**opts)
75
93
  rectangle = DrawioDsl::Schema::Rectangle.new(current_page, **opts)
76
- add_element(rectangle)
94
+ add_shape(rectangle)
77
95
  end
78
96
 
79
97
  def add_circle(**opts)
80
98
  circle = DrawioDsl::Schema::Circle.new(current_page, **opts)
81
- add_element(circle)
99
+ add_shape(circle)
82
100
  end
83
101
 
84
102
  def add_process(**opts)
85
103
  process = DrawioDsl::Schema::Process.new(current_page, **opts)
86
- add_element(process)
104
+ add_shape(process)
87
105
  end
88
106
 
89
107
  def add_ellipse(**opts)
90
108
  ellipse = DrawioDsl::Schema::Ellipse.new(current_page, **opts)
91
- add_element(ellipse)
109
+ add_shape(ellipse)
110
+ end
111
+
112
+ def add_diamond(**opts)
113
+ diamond = DrawioDsl::Schema::Diamond.new(current_page, **opts)
114
+ add_shape(diamond)
115
+ end
116
+
117
+ def add_hexagon(**opts)
118
+ add_hexagon = DrawioDsl::Schema::Hexagon.new(current_page, **opts)
119
+ add_shape(add_hexagon)
120
+ end
121
+
122
+ def add_cloud(**opts)
123
+ cloud = DrawioDsl::Schema::Cloud.new(current_page, **opts)
124
+ add_shape(cloud)
125
+ end
126
+
127
+ def add_note(**opts)
128
+ note = DrawioDsl::Schema::Note.new(current_page, **opts)
129
+ add_shape(note)
130
+ end
131
+
132
+ def add_callout(**opts)
133
+ callout = DrawioDsl::Schema::Callout.new(current_page, **opts)
134
+ add_shape(callout)
92
135
  end
93
136
 
94
137
  def debug