ea 0.6.20 → 0.6.21
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 +4 -4
- data/lib/ea/svg/ea_emitter/compartment/enum_literals.rb +46 -2
- data/lib/ea/svg/ea_emitter/elements.rb +11 -3
- data/lib/ea/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 548d074902dd1fa399222eecf7bce3890790951fdd62f8d1d5e4c054e602e680
|
|
4
|
+
data.tar.gz: 95bc0204957914b6451a505b29adb96d8ad4906229b488406d3cb1b2efcc6f53
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 71b2b781fbfdc1839b5211aa3d193be4b7daa035fbfa6b1947d8339d71acb8075a80aede566df22cd0709029904be2508203bd726811a27dd9d9be74fd5c2a99
|
|
7
|
+
data.tar.gz: 4844d29466fe899fcb10900455dcfcc5f2aecf6f7d77ab25243a78f7ef61f9d85e64db4a1d0432aa13f39d473c38f7452b3738aeb95917dacadc994b747222c4
|
|
@@ -25,14 +25,48 @@ module Ea
|
|
|
25
25
|
def render_literals_block(context)
|
|
26
26
|
line_h = context.size + LITERAL_LINE_OFFSET
|
|
27
27
|
text_blocks = []
|
|
28
|
+
row_y = context.geometry.enum_literal_first_y
|
|
29
|
+
# EA renders a centered italic "literals" caption above
|
|
30
|
+
# the rows when the literals carry stored code values
|
|
31
|
+
# (t_attribute.Default); bare literal lists render the
|
|
32
|
+
# rows directly. Corpus-verified (PT_TypeOfSA:
|
|
33
|
+
# "literals" caption + "ServingParcel = SP" rows;
|
|
34
|
+
# CV_SequenceType: bare rows, no caption).
|
|
35
|
+
if caption?(context)
|
|
36
|
+
text_blocks << caption_text(context, row_y)
|
|
37
|
+
row_y += line_h
|
|
38
|
+
end
|
|
28
39
|
context.enum_literals.each_with_index do |literal, idx|
|
|
29
|
-
y =
|
|
40
|
+
y = row_y + (idx * line_h)
|
|
30
41
|
text_blocks << visibility_placeholder(context, y)
|
|
31
42
|
text_blocks << literal_name_text(context, literal, y)
|
|
32
43
|
end
|
|
33
44
|
wrap_group(text_blocks, context.theme.text_color)
|
|
34
45
|
end
|
|
35
46
|
|
|
47
|
+
def caption?(context)
|
|
48
|
+
context.enum_literals.any? do |l|
|
|
49
|
+
value = l.value.to_s
|
|
50
|
+
!value.empty? && value != l.name.to_s
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def caption_text(context, y)
|
|
55
|
+
content = "literals"
|
|
56
|
+
len = TextRenderer.estimate_width(content, context.size, nil,
|
|
57
|
+
family: context.family).round
|
|
58
|
+
x = (context.bounds.x + (context.bounds.width - len) / 2.0).floor
|
|
59
|
+
TextRenderer.new(
|
|
60
|
+
content: content,
|
|
61
|
+
x: x, y: y,
|
|
62
|
+
family: context.family, size: context.size, size_unit: context.size_unit,
|
|
63
|
+
fill: context.theme.text_color,
|
|
64
|
+
stroke_in_text: context.theme.stroke_in_text_color,
|
|
65
|
+
width_factor: context.theme.text_width_factor,
|
|
66
|
+
style: "italic"
|
|
67
|
+
).to_svg
|
|
68
|
+
end
|
|
69
|
+
|
|
36
70
|
def visibility_placeholder(context, y)
|
|
37
71
|
TextRenderer.new(
|
|
38
72
|
content: " ",
|
|
@@ -46,8 +80,9 @@ module Ea
|
|
|
46
80
|
end
|
|
47
81
|
|
|
48
82
|
def literal_name_text(context, literal, y)
|
|
83
|
+
content = literal_display(literal)
|
|
49
84
|
TextRenderer.new(
|
|
50
|
-
content:
|
|
85
|
+
content: content,
|
|
51
86
|
x: context.bounds.x + (context.theme.attribute_spec.content_x_offset || 26),
|
|
52
87
|
y: y,
|
|
53
88
|
family: context.family, size: context.size, size_unit: context.size_unit,
|
|
@@ -57,6 +92,15 @@ module Ea
|
|
|
57
92
|
).to_svg
|
|
58
93
|
end
|
|
59
94
|
|
|
95
|
+
# EA shows "Name = Code" for literals with a stored
|
|
96
|
+
# default value; bare names otherwise.
|
|
97
|
+
def literal_display(literal)
|
|
98
|
+
value = literal.value.to_s
|
|
99
|
+
return literal.name.to_s if value.empty? || value == literal.name.to_s
|
|
100
|
+
|
|
101
|
+
"#{literal.name} = #{value}"
|
|
102
|
+
end
|
|
103
|
+
|
|
60
104
|
def wrap_group(text_blocks, text_color)
|
|
61
105
|
style = "stroke-width:1;stroke-linecap:round;stroke-linejoin:bevel; " \
|
|
62
106
|
"fill:#{text_color};fill-opacity:1.00; " \
|
|
@@ -87,7 +87,7 @@ module Ea
|
|
|
87
87
|
header_lines,
|
|
88
88
|
constraints_count: constraints_for(classifier).size,
|
|
89
89
|
marker_count: marker_lines_for(classifier).size,
|
|
90
|
-
enum_literals_count:
|
|
90
|
+
enum_literals_count: enum_row_count_for(classifier))
|
|
91
91
|
# EA suppresses the whole attribute compartment when its
|
|
92
92
|
# rows do not fit the stored box height (never truncates
|
|
93
93
|
# rows) - the AOS box on CityFurniture hides its
|
|
@@ -103,7 +103,7 @@ module Ea
|
|
|
103
103
|
header_lines,
|
|
104
104
|
constraints_count: constraints_for(classifier).size,
|
|
105
105
|
marker_count: marker_lines_for(classifier).size,
|
|
106
|
-
enum_literals_count:
|
|
106
|
+
enum_literals_count: enum_row_count_for(classifier))
|
|
107
107
|
end
|
|
108
108
|
# EA suppresses the operations compartment when its rows
|
|
109
109
|
# overflow the stored box height (same rule as attributes).
|
|
@@ -115,7 +115,7 @@ module Ea
|
|
|
115
115
|
header_lines,
|
|
116
116
|
constraints_count: constraints_for(classifier).size,
|
|
117
117
|
marker_count: marker_lines_for(classifier).size,
|
|
118
|
-
enum_literals_count:
|
|
118
|
+
enum_literals_count: enum_row_count_for(classifier))
|
|
119
119
|
end
|
|
120
120
|
RenderContext.new(
|
|
121
121
|
element: element,
|
|
@@ -196,6 +196,14 @@ module Ea
|
|
|
196
196
|
classifier.literals || []
|
|
197
197
|
end
|
|
198
198
|
|
|
199
|
+
# The "literals" caption occupies a row slot when any
|
|
200
|
+
# literal carries a stored code value.
|
|
201
|
+
def enum_row_count_for(classifier)
|
|
202
|
+
literals = enum_literals_for(classifier)
|
|
203
|
+
caption = literals.any? { |l| !l.value.to_s.empty? && l.value.to_s != l.name.to_s }
|
|
204
|
+
literals.size + (caption ? 1 : 0)
|
|
205
|
+
end
|
|
206
|
+
|
|
199
207
|
def tagged_values_for(classifier)
|
|
200
208
|
return [] unless classifier.is_a?(Ea::Model::Classifier)
|
|
201
209
|
|
data/lib/ea/version.rb
CHANGED