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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf0f3e11888e4492386de976f97e4024e39d9dbc95083a5b184c0fb25d8cfead
4
- data.tar.gz: 467687628f21bf50264c0210de75e2fad5013a14d7f2a1572d65dfb218429052
3
+ metadata.gz: 641441bf5b181aaadd045223f47a59069d916f48247f19ab4e6bc6c19cfeee03
4
+ data.tar.gz: 0eb407d782f28301f0747a2f251ce3412f97cc60882f87cc7062567d1e7e4a64
5
5
  SHA512:
6
- metadata.gz: 67a177d6e826985a3526c63bae7ed1f10e55b51ca97ec1507e5cb2f89f309b789f734c27cd41b678777e3ea72cb730a44485799972c3bbab916dedfd51f404c5
7
- data.tar.gz: 55d5d873894f3e26fb786a71efaab326ecd4df2d16d167bf3dc7158e1775e139f9a9c2096cd79c5ae136315421c1d19156320d1c895837d691ecd7a97e772a2a
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
- src_tb, src_mb = end_boxes(boxes, :llt, :llb) ||
82
- default_label_boxes(points, :source)
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]).each { |t| texts << t }
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
@@ -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.91"
7
+ VERSION = "0.6.92"
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.91
4
+ version: 0.6.92
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.