ea 0.6.91 → 0.6.92
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/label/end_label.rb +66 -1
- data/lib/ea/svg/ea_emitter/labels.rb +8 -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: 641441bf5b181aaadd045223f47a59069d916f48247f19ab4e6bc6c19cfeee03
|
|
4
|
+
data.tar.gz: 0eb407d782f28301f0747a2f251ce3412f97cc60882f87cc7062567d1e7e4a64
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d705861a5209c8646e01fb097b4329e634744bdeef07355d00598a45bff1134ab186c69c0088250a3a3c5ece15d2c39281653c0e667a473fea80dbfd4bb9b9c0
|
|
7
|
+
data.tar.gz: 84fce6fa28c77169812dda317ef720035c1ac9b17ac854238aa376480980308b7c506e6f3fa52e23807e7cc851546fe65b0c6b8bda72b937b1d9a99ab82953ad
|
|
@@ -19,6 +19,8 @@ module Ea
|
|
|
19
19
|
# for those — only simple role names render.
|
|
20
20
|
class EndLabel
|
|
21
21
|
PROPERTY_STEREOTYPE = "«Property»"
|
|
22
|
+
SEAT_FONT_SIZE = 7
|
|
23
|
+
SEAT_X_INSET = 3
|
|
22
24
|
|
|
23
25
|
attr_reader :canvas, :model_index, :document, :theme,
|
|
24
26
|
:font_family, :font_size, :font_unit
|
|
@@ -41,8 +43,9 @@ module Ea
|
|
|
41
43
|
# anchor - [x, y] of the connector endpoint
|
|
42
44
|
# connector - the DiagramConnector (for relationship lookup)
|
|
43
45
|
# end_kind - :source or :target
|
|
46
|
+
# heading - [dx, dy] of the first leg leaving the anchor
|
|
44
47
|
def texts(text_box:, mult_box:, anchor:, connector:, end_kind:,
|
|
45
|
-
tree: false)
|
|
48
|
+
tree: false, heading: nil)
|
|
46
49
|
from_property, role, mult = role_and_multiplicity(connector, end_kind)
|
|
47
50
|
if role_empty?(role) && mult_empty?(mult)
|
|
48
51
|
other_from_prop, other_role, other_mult = role_and_multiplicity(connector,
|
|
@@ -73,6 +76,11 @@ module Ea
|
|
|
73
76
|
# the end has none.
|
|
74
77
|
stereo = connector_source_dest_stereotype(connector, end_kind)
|
|
75
78
|
stereo = stereo.nil? || stereo.empty? ? nil : "«#{stereo}»"
|
|
79
|
+
direction = leg_direction(end_kind, heading)
|
|
80
|
+
if direction && !(tree && zero_offset?(text_box, mult_box))
|
|
81
|
+
text_pos = role_seat(direction, anchor, text_box, role) || text_pos
|
|
82
|
+
mult_pos = mult_seat(direction, anchor, mult_box) || mult_pos
|
|
83
|
+
end
|
|
76
84
|
|
|
77
85
|
build_texts(role:, mult:, standalone:,
|
|
78
86
|
text_pos:, mult_pos:, stereo:, text_box:)
|
|
@@ -109,6 +117,63 @@ module Ea
|
|
|
109
117
|
end
|
|
110
118
|
end
|
|
111
119
|
|
|
120
|
+
# Stored source-end boxes on a 7pt label whose first leg
|
|
121
|
+
# leaves straight up or straight right are seated at the box
|
|
122
|
+
# corner, anchor + (OX, OY) with no sign flip, 3px to its
|
|
123
|
+
# right: the multiplicity 6px above it on an upward leg and
|
|
124
|
+
# 15px below it on a rightward one, the role 7px above it on
|
|
125
|
+
# a rightward one. Other sizes, headings, the target end,
|
|
126
|
+
# custom presentation keep their offsets; zero multiplicity boxes keep their default seat.
|
|
127
|
+
def leg_direction(end_kind, heading)
|
|
128
|
+
return nil unless source_seat?(end_kind, heading)
|
|
129
|
+
|
|
130
|
+
dx, dy = heading
|
|
131
|
+
return :up if dx.zero? && dy.negative?
|
|
132
|
+
return :right if dy.zero? && dx.positive?
|
|
133
|
+
|
|
134
|
+
nil
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Role text on a rightward leg is left-aligned at the corner,
|
|
138
|
+
# 7px above it. Upward legs keep the plain role offset.
|
|
139
|
+
def role_seat(direction, anchor, box, role)
|
|
140
|
+
return nil unless direction == :right
|
|
141
|
+
return nil if box.nil? || role_empty?(role)
|
|
142
|
+
return nil unless default_presentation?(box)
|
|
143
|
+
|
|
144
|
+
x, y = seat_corner(anchor, box)
|
|
145
|
+
[x + SEAT_X_INSET, y - 7]
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def mult_seat(direction, anchor, box)
|
|
149
|
+
return nil if box.nil? || stored_offsets_zero?(box)
|
|
150
|
+
return nil unless default_presentation?(box)
|
|
151
|
+
|
|
152
|
+
x, y = seat_corner(anchor, box)
|
|
153
|
+
[x + SEAT_X_INSET, direction == :right ? y + 15 : y - 6]
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def source_seat?(end_kind, heading)
|
|
157
|
+
end_kind == :source && heading &&
|
|
158
|
+
font_size == SEAT_FONT_SIZE && font_unit == "pt"
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Boxes with explicit string-keyed OX/OY (the QEA shape) that
|
|
162
|
+
# are unrotated, unhidden, unstyled and left/center aligned.
|
|
163
|
+
def default_presentation?(box)
|
|
164
|
+
return false unless box["ox"] && box["oy"]
|
|
165
|
+
return false unless [nil, 0, 1].include?(box["alignment"])
|
|
166
|
+
return false unless [nil, -1].include?(box["color"])
|
|
167
|
+
|
|
168
|
+
box["rotation"].to_i.zero? && box["direction"].to_i.zero? &&
|
|
169
|
+
box.values_at("hidden", "bold", "italic", "underline")
|
|
170
|
+
.none?
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def seat_corner(anchor, box)
|
|
174
|
+
[anchor[0] + box["ox"].to_i, anchor[1] + box["oy"].to_i]
|
|
175
|
+
end
|
|
176
|
+
|
|
112
177
|
def build_texts(role:, mult:, standalone:, text_pos:, mult_pos:,
|
|
113
178
|
stereo:, text_box:)
|
|
114
179
|
if role && !role.empty? && text_pos
|
|
@@ -78,15 +78,16 @@ module Ea
|
|
|
78
78
|
boxes = connector.label_boxes || {}
|
|
79
79
|
tree = tree_shaped?(points)
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
stored_src = end_boxes(boxes, :llt, :llb)
|
|
82
|
+
src_tb, src_mb = stored_src || default_label_boxes(points, :source)
|
|
83
83
|
tgt_tb, tgt_mb = end_boxes(boxes, :lrt, :lrb) ||
|
|
84
84
|
default_label_boxes(points, :target)
|
|
85
85
|
|
|
86
86
|
texts = []
|
|
87
87
|
end_renderer.texts(text_box: src_tb, mult_box: src_mb,
|
|
88
88
|
anchor: source_pt, connector: connector,
|
|
89
|
-
end_kind: :source, tree: tree && tree[:source]
|
|
89
|
+
end_kind: :source, tree: tree && tree[:source],
|
|
90
|
+
heading: stored_src && leg_heading(points)).each { |t| texts << t }
|
|
90
91
|
end_renderer.texts(text_box: tgt_tb,
|
|
91
92
|
mult_box: tgt_mb,
|
|
92
93
|
anchor: target_pt, connector: connector,
|
|
@@ -105,6 +106,10 @@ module Ea
|
|
|
105
106
|
{ source: true, target: true }
|
|
106
107
|
end
|
|
107
108
|
|
|
109
|
+
def leg_heading(points)
|
|
110
|
+
[points[1][0] - points[0][0], points[1][1] - points[0][1]]
|
|
111
|
+
end
|
|
112
|
+
|
|
108
113
|
def end_boxes(boxes, text_key, mult_key)
|
|
109
114
|
return nil if boxes[text_key].nil? && boxes[mult_key].nil?
|
|
110
115
|
|
data/lib/ea/version.rb
CHANGED