ea 0.6.9 → 0.6.11
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/fonts/metrics.rb +18 -7
- data/lib/ea/sources/qea/diagram_builder.rb +24 -1
- data/lib/ea/svg/ea_emitter/element/header_line_provider/name.rb +5 -8
- data/lib/ea/svg/ea_emitter/element/header_lines.rb +2 -2
- data/lib/ea/svg/ea_emitter/element/legend_renderer.rb +10 -7
- data/lib/ea/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c33a8ed4fa47f762a4ced58e7525a0612927510f35c3367423c14651c1aa7017
|
|
4
|
+
data.tar.gz: d0e757281769b12bbee152bc415d0fdfd441fb022a2dbd29213efb1cce06a41c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f76e15be4c2a04d97fdc169ff4bf79da55c72a49c14b8e553c26e4659ec04373bd6b479364c86447a732b8405d5c9c1d108bd8ae8d4e57506ed673cd21e924d4
|
|
7
|
+
data.tar.gz: '025978b5e6c9ce71457d0a86635072ffc0082bfff9dcd3a0f64657d498adc5ffd6b347097af3974993ef1f5e42f0e2824d5a59197504e6a3839df4dd96167f39'
|
data/lib/ea/fonts/metrics.rb
CHANGED
|
@@ -28,8 +28,10 @@ module Ea
|
|
|
28
28
|
DEFAULT_ADVANCE = 0.25
|
|
29
29
|
|
|
30
30
|
# Carlito has no CJK glyphs; EA's renderer falls back to a
|
|
31
|
-
#
|
|
32
|
-
|
|
31
|
+
# proportional CJK font whose advances measure ~0.709em at the
|
|
32
|
+
# NOMINAL size (not scaled by the per-style factors) — fitted
|
|
33
|
+
# from EA-published textLengths (52 mixed-script samples).
|
|
34
|
+
CJK_ADVANCE = 0.709
|
|
33
35
|
CJK_RANGES = [
|
|
34
36
|
(0x3000..0x303F), # CJK punctuation
|
|
35
37
|
(0x3040..0x309F), # Hiragana
|
|
@@ -46,19 +48,28 @@ module Ea
|
|
|
46
48
|
return nil unless supported_family?(family)
|
|
47
49
|
return nil if text.nil? || text.empty?
|
|
48
50
|
|
|
49
|
-
|
|
50
|
-
(
|
|
51
|
+
latin, cjk_count = split_advance(text, weight: weight, style: style)
|
|
52
|
+
(latin * size_pt.to_f * factor_for(weight, style) +
|
|
53
|
+
cjk_count * CJK_ADVANCE * size_pt.to_f).round(3)
|
|
51
54
|
end
|
|
52
55
|
|
|
53
56
|
def supported_family?(family)
|
|
54
57
|
SUPPORTED_FAMILIES.include?(family.to_s)
|
|
55
58
|
end
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
# Returns [latin_em (factor-scaled later), cjk_glyph_count].
|
|
61
|
+
def split_advance(text, weight: nil, style: nil)
|
|
58
62
|
table = table_for(weight, style)
|
|
59
|
-
|
|
60
|
-
|
|
63
|
+
latin = 0.0
|
|
64
|
+
cjk = 0
|
|
65
|
+
text.each_char.each do |ch|
|
|
66
|
+
if cjk?(ch.ord)
|
|
67
|
+
cjk += 1
|
|
68
|
+
else
|
|
69
|
+
latin += table[cp_key(ch)] || DEFAULT_ADVANCE
|
|
70
|
+
end
|
|
61
71
|
end
|
|
72
|
+
[latin, cjk]
|
|
62
73
|
end
|
|
63
74
|
|
|
64
75
|
def cjk?(cp)
|
|
@@ -377,7 +377,10 @@ module Ea
|
|
|
377
377
|
element_edge_point(target_placement, :target, edge_out)
|
|
378
378
|
|
|
379
379
|
intermediate = intermediate_waypoints(link_row)
|
|
380
|
-
if intermediate
|
|
380
|
+
if tree_route?(edge_out, intermediate)
|
|
381
|
+
points = tree_waypoints(source_placement, target_placement,
|
|
382
|
+
intermediate.first)
|
|
383
|
+
elsif intermediate.any?
|
|
381
384
|
points = [source_point, *intermediate, target_point]
|
|
382
385
|
elsif source_port || target_port
|
|
383
386
|
# Exact ports are known — the SX/SY bend heuristics in
|
|
@@ -392,6 +395,26 @@ module Ea
|
|
|
392
395
|
end
|
|
393
396
|
end
|
|
394
397
|
|
|
398
|
+
# EA's tree-style routing (Geometry EDGE=2 with a single Path
|
|
399
|
+
# bend): the visible line leaves the SOURCE's right edge at
|
|
400
|
+
# the bend's y, runs horizontally to the bend x, then
|
|
401
|
+
# vertically to the target's facing edge — replacing the
|
|
402
|
+
# ray-cast ports entirely. Verified against the
|
|
403
|
+
# CityObjectGroup reference (parent + groupMember lines).
|
|
404
|
+
def tree_route?(edge_out, intermediate)
|
|
405
|
+
edge_out == 2 && intermediate.size == 1
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
def tree_waypoints(source_placement, target_placement, bend)
|
|
409
|
+
src = bounds_from_rect(source_placement)
|
|
410
|
+
tgt = bounds_from_rect(target_placement)
|
|
411
|
+
bend_x = bend[0]
|
|
412
|
+
source_point = [src.x + src.width, bend[1]]
|
|
413
|
+
going_up = tgt.y + tgt.height <= src.y
|
|
414
|
+
target_y = going_up ? tgt.y + tgt.height : tgt.y
|
|
415
|
+
[source_point, [bend_x, bend[1]], [bend_x, target_y]]
|
|
416
|
+
end
|
|
417
|
+
|
|
395
418
|
# Absolute connection point EA docks the connector's visible
|
|
396
419
|
# endpoint at, derived from the Geometry SX/SY (source) and
|
|
397
420
|
# EX/EY (target) offsets. The offsets are measured inward from
|
|
@@ -33,8 +33,7 @@ module Ea
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def self.wrapped_name_lines(classifier, context, weight)
|
|
36
|
-
name = display_name(classifier
|
|
37
|
-
context.visually_nested)
|
|
36
|
+
name = display_name(classifier)
|
|
38
37
|
unless context.bounds_width && name.include?("::") &&
|
|
39
38
|
name_exceeds_bounds?(name, context.bounds_width,
|
|
40
39
|
context.font_size || 9)
|
|
@@ -51,12 +50,10 @@ module Ea
|
|
|
51
50
|
(bounds_width - QUALIFIED_WRAP_PADDING)
|
|
52
51
|
end
|
|
53
52
|
|
|
54
|
-
# EA renders the plain classifier name in element headers
|
|
55
|
-
# (
|
|
56
|
-
#
|
|
57
|
-
|
|
58
|
-
def self.display_name(classifier, _diagram_package_id = nil,
|
|
59
|
-
_visually_nested = false)
|
|
53
|
+
# EA renders the plain classifier name in element headers.
|
|
54
|
+
# (Some ISO-corpus diagrams show "Pkg::Name" headers — the
|
|
55
|
+
# storage of that flag is not in the QEA; render plain.)
|
|
56
|
+
def self.display_name(classifier, *_)
|
|
60
57
|
classifier.name.to_s
|
|
61
58
|
end
|
|
62
59
|
end
|
|
@@ -17,8 +17,8 @@ module Ea
|
|
|
17
17
|
|
|
18
18
|
# Delegate to the Name provider so historical callers and
|
|
19
19
|
# specs that test display_name keep working.
|
|
20
|
-
def display_name(classifier,
|
|
21
|
-
HeaderLineProvider::Name.display_name(classifier
|
|
20
|
+
def display_name(classifier, *_)
|
|
21
|
+
HeaderLineProvider::Name.display_name(classifier)
|
|
22
22
|
end
|
|
23
23
|
end
|
|
24
24
|
end
|
|
@@ -136,21 +136,25 @@ module Ea
|
|
|
136
136
|
end
|
|
137
137
|
|
|
138
138
|
# EA centers the title over the ITEM BLOCK (icon left edge
|
|
139
|
-
# to the right end of the widest label)
|
|
140
|
-
#
|
|
139
|
+
# to the right end of the widest label) by its INTEGER
|
|
140
|
+
# textLength and floors x - verified against EA-published
|
|
141
|
+
# reference SVGs.
|
|
141
142
|
def title_x
|
|
142
143
|
icon_left = bounds.x + ICON_X_OFFSET
|
|
143
144
|
block_right = icon_left + ICON_LABEL_GAP +
|
|
144
145
|
widest_item_label_width
|
|
145
146
|
block_left = icon_left
|
|
146
|
-
block_left + (block_right - block_left - title_text_width) / 2.0
|
|
147
|
+
(block_left + (block_right - block_left - title_text_width.round) / 2.0).floor
|
|
147
148
|
end
|
|
148
149
|
|
|
149
150
|
CJK_RANGE = /[\u3000-\u9fff\uff00-\uffef]/
|
|
150
151
|
|
|
151
|
-
#
|
|
152
|
-
#
|
|
152
|
+
# Real font metrics when available; legacy per-char
|
|
153
|
+
# estimate otherwise (families without metric tables).
|
|
153
154
|
def estimated_width(text, size)
|
|
155
|
+
measured = Ea::Fonts::Metrics.text_length(text, size, family: family)
|
|
156
|
+
return measured if measured
|
|
157
|
+
|
|
154
158
|
text.to_s.each_char.sum do |ch|
|
|
155
159
|
ch.match?(CJK_RANGE) ? size * 0.70 : size * 0.612
|
|
156
160
|
end
|
|
@@ -181,8 +185,7 @@ module Ea
|
|
|
181
185
|
TextRenderer.new(
|
|
182
186
|
content: content.to_s, x: tx, y: ty,
|
|
183
187
|
family: family, size: size, size_unit: "pt",
|
|
184
|
-
weight: weight, fill: label_fill
|
|
185
|
-
text_length: (content.to_s.length * size * 0.65).round
|
|
188
|
+
weight: weight, fill: label_fill
|
|
186
189
|
).to_svg
|
|
187
190
|
end
|
|
188
191
|
|
data/lib/ea/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ea
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.6.
|
|
4
|
+
version: 0.6.11
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-09-
|
|
11
|
+
date: 2026-09-29 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: lutaml-model
|