ea 0.6.45 → 0.6.47

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70775a4db6ad6a0d240e3eb3de0e60aa31db24561ad167898a9613df3f431810
4
- data.tar.gz: b15a7d2bcce540619ed08e2fb32d6fe427850a6381e6db15dd72a25b6bc6739f
3
+ metadata.gz: 883c961d3fd0e63b7d48117b76db47d79e90a62ed1027ad2cf4aa55082ee5132
4
+ data.tar.gz: d499d2e8b9376a7b79004f7da6c82ed8558cbebaca22fe7b9b83f4e3f534df87
5
5
  SHA512:
6
- metadata.gz: 1d3e2a0d75fc280ab1eea83db6376dd9d6e045569ca99ef5ba5fa7bbc7a39d8c3b5eff7af59fa12bd7ad5b63f2518b16dbc20694b605c80574c5415617635036
7
- data.tar.gz: 49baf9df9e8d0327b9d81bc5549edbf3a8d71e4401adbbe5cf895a17bcae8e283daf178e4e87ef5a509b9d7e0a94a2630899e22adebddebcdd9a40f5c1e2042a
6
+ metadata.gz: f056a65fa2b30039c1602d38e90b775f0fd712be85f36774ddbb068c74649bd47f756eb7aa67c45124fbe698c64119849d468d3b29f527ceb113ce4707ea1b96
7
+ data.tar.gz: 8dc93dcf117c9ba1cfaff73a4f521f6c1e9ca8189173f992dbd3e7b15cd43712c843f3b9a80b8d668b3d9ca79043a462cffd2404936d441e09202d1c6f9a5c04
@@ -85,6 +85,7 @@ module Ea
85
85
  end
86
86
 
87
87
  def build_element(obj_row, diagram_row)
88
+ @current_obj_row = obj_row
88
89
  style_hash = DiagramStyleParser.parse(obj_row.objectstyle)
89
90
  Ea::Model::DiagramElement.new(
90
91
  id: IdNormalizer.synthetic("de", diagram_row.diagram_id,
@@ -123,9 +124,25 @@ module Ea
123
124
  raw = style_hash[:fontsz]
124
125
  return nil if raw.nil? || raw.to_s.empty?
125
126
 
127
+ return nil if raw.to_i.zero?
128
+
129
+ stored = (raw.to_f / 10).round
130
+ return stored - 1 if note_element? && stored > 1
131
+
126
132
  return nil if USE_DEFAULT_FONTSZ.include?(raw.to_i)
127
133
 
128
- (raw.to_f / 10).round
134
+ stored
135
+ end
136
+
137
+ # Text/Note elements carry their real font size in fontsz
138
+ # shifted by one point (stored 100 renders 9pt, 80 renders
139
+ # 7pt - corpus-verified on EA-published note SVGs);
140
+ # classifiers keep the use-default convention.
141
+ def note_element?
142
+ return false unless database && @current_obj_row
143
+
144
+ obj = database.find_object(@current_obj_row.ea_object_id.to_i)
145
+ obj&.object_type.to_s == "Text"
129
146
  end
130
147
 
131
148
  def build_connectors(diagram_row)
@@ -26,23 +26,35 @@ module Ea
26
26
  # cumulative integer textLength fits bounds.width - 15.
27
27
  # Verified against EA-published reference SVGs.
28
28
  def wrapped_lines(context, body)
29
- usable = context.bounds.width - 15
29
+ # EA's note wrap padding is 4: lines fit bounds.width - 4
30
+ # (9BA1CE54: width 214, longest line tl 210). Pitch and
31
+ # first-line offset scale with the note font (9pt: pitch
32
+ # 16 = size+7, first line at bounds.y + 18 = size+9), and
33
+ # each paragraph break adds one blank pitch row
34
+ # (paragraph 2 starts 32 after the last line of
35
+ # paragraph 1).
36
+ usable = context.bounds.width - 4
30
37
  size = context.size
31
38
  family = context.family
32
- body.to_s.split(/\n/).flat_map do |para|
33
- wrap_paragraph(para, usable, size, family)
34
- end.each_with_index.map do |line, idx|
35
- y = context.bounds.y + context.theme.note.text_y_offset +
36
- (idx * context.theme.note.line_height)
37
- TextRenderer.new(
38
- content: line,
39
- x: context.bounds.x + context.theme.note.text_x_offset,
40
- y: y,
41
- family: context.family, size: context.size, size_unit: context.size_unit,
42
- fill: context.theme.text_color,
43
- stroke_in_text: context.theme.stroke_in_text_color,
44
- width_factor: context.theme.text_width_factor
45
- ).to_svg
39
+ pitch = size + 7
40
+ first_offset = size + 9
41
+ y_index = 0
42
+ paragraphs = body.to_s.split(/\n/).reject { |p| p.strip.empty? }
43
+ paragraphs.flat_map do |para|
44
+ lines = wrap_paragraph(para, usable, size, context.family)
45
+ lines.each_with_index.map do |line, i|
46
+ y = context.bounds.y + first_offset + ((y_index + i) * pitch)
47
+ TextRenderer.new(
48
+ content: line,
49
+ x: context.bounds.x + context.theme.note.text_x_offset,
50
+ y: y,
51
+ family: context.family, size: context.size,
52
+ size_unit: context.size_unit,
53
+ fill: context.theme.text_color,
54
+ stroke_in_text: context.theme.stroke_in_text_color,
55
+ width_factor: context.theme.text_width_factor
56
+ ).to_svg
57
+ end.tap { y_index += lines.size + 1 }
46
58
  end
47
59
  end
48
60
 
@@ -19,8 +19,10 @@ module Ea
19
19
  )
20
20
  elsif context.model_element.is_a?(Ea::Model::Package) ||
21
21
  context.model_element.is_a?(Ea::Model::Note)
22
- label = package_label(context.model_element)
23
- stereotype = package_stereotype(context.model_element)
22
+ # Notes keep the folder silhouette but never render a
23
+ # label (EA publishes note bodies only).
24
+ label = package_label(context.model_element) if context.model_element.is_a?(Ea::Model::Package)
25
+ stereotype = package_stereotype(context.model_element) if context.model_element.is_a?(Ea::Model::Package)
24
26
  Element::PackageShapeRenderer.render(
25
27
  context.bounds,
26
28
  fill: context.fill, stroke: context.stroke,
data/lib/ea/version.rb CHANGED
@@ -4,5 +4,5 @@ module Ea
4
4
  # Gem release version. Extracted to its own file so the
5
5
  # `gem-release` tool's `gem bump` can find and update it via the
6
6
  # standard `lib/<gem>/version.rb` convention.
7
- VERSION = "0.6.45"
7
+ VERSION = "0.6.47"
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ea
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.45
4
+ version: 0.6.47
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.