ea 0.6.34 → 0.6.36
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/carlito_metrics.json +1 -1
- data/lib/ea/fonts/metrics.rb +1 -1
- data/lib/ea/svg/ea_emitter/bounds_calculator.rb +43 -1
- data/lib/ea/svg/ea_emitter/canvas.rb +27 -0
- data/lib/ea/svg/ea_emitter/document.rb +29 -5
- data/lib/ea/version.rb +1 -1
- metadata +1 -1
data/lib/ea/fonts/metrics.rb
CHANGED
|
@@ -91,7 +91,7 @@ module Ea
|
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
# EA's scale factor varies by point size (GDI quantization):
|
|
94
|
-
# Carlito regular fits 1.390 at 7pt but 1.
|
|
94
|
+
# Carlito regular fits 1.390 at 7pt but 1.440 at 9pt. Sizes
|
|
95
95
|
# without a fitted entry use the style's default (7pt, the
|
|
96
96
|
# corpus's dominant size).
|
|
97
97
|
def factor_for(family, size_pt, weight, style)
|
|
@@ -59,7 +59,27 @@ module Ea
|
|
|
59
59
|
# Element x-extent: logical bounds only (matches EA's canvas
|
|
60
60
|
# left/right exactly).
|
|
61
61
|
# Element y-extent: union of logical + image_bounds (image
|
|
62
|
-
# extends below bounds for shadow / image padding)
|
|
62
|
+
# extends below bounds for shadow / image padding), plus the
|
|
63
|
+
# "(from Parent)" subtitle extent: EA draws the subtitle 15px
|
|
64
|
+
# below the body and its text descent adds ~4 more, reserving
|
|
65
|
+
# 19px of canvas below subtitle-bearing packages (the +19
|
|
66
|
+
# height family: 05DF5000 Main, Metadata All, package
|
|
67
|
+
# Clients/Suppliers contexts).
|
|
68
|
+
SUBTITLE_CANVAS_EXTRA = 19
|
|
69
|
+
|
|
70
|
+
def subtitle_points
|
|
71
|
+
pts = []
|
|
72
|
+
(diagram.elements || []).each do |e|
|
|
73
|
+
primary = e.bounds || e.image_bounds
|
|
74
|
+
next unless primary
|
|
75
|
+
next unless subtitle_extends_below?(e)
|
|
76
|
+
|
|
77
|
+
pts << [primary.x, primary.y + primary.height +
|
|
78
|
+
SUBTITLE_CANVAS_EXTRA]
|
|
79
|
+
end
|
|
80
|
+
pts
|
|
81
|
+
end
|
|
82
|
+
|
|
63
83
|
def element_points
|
|
64
84
|
pts = []
|
|
65
85
|
(diagram.elements || []).each do |e|
|
|
@@ -67,6 +87,10 @@ module Ea
|
|
|
67
87
|
if primary
|
|
68
88
|
pts << [primary.x, primary.y]
|
|
69
89
|
pts << [primary.x + primary.width, primary.y + primary.height]
|
|
90
|
+
if subtitle_extends_below?(e)
|
|
91
|
+
pts << [primary.x, primary.y + primary.height +
|
|
92
|
+
SUBTITLE_CANVAS_EXTRA]
|
|
93
|
+
end
|
|
70
94
|
end
|
|
71
95
|
if e.bounds && e.image_bounds
|
|
72
96
|
ib = e.image_bounds
|
|
@@ -76,6 +100,24 @@ module Ea
|
|
|
76
100
|
end
|
|
77
101
|
pts
|
|
78
102
|
end
|
|
103
|
+
|
|
104
|
+
# Mirrors Compartment::PackageFromParent's render conditions:
|
|
105
|
+
# the subtitle draws only on ShowForeign diagrams for a
|
|
106
|
+
# placed package whose parent differs from the diagram's
|
|
107
|
+
# package.
|
|
108
|
+
def subtitle_extends_below?(element)
|
|
109
|
+
return false unless model_index
|
|
110
|
+
return false unless diagram.show_foreign
|
|
111
|
+
|
|
112
|
+
pkg = model_index[element.model_element_ref]
|
|
113
|
+
return false unless pkg.is_a?(Ea::Model::Package)
|
|
114
|
+
|
|
115
|
+
parent_id = pkg.parent_id
|
|
116
|
+
return false if parent_id.nil? || parent_id.empty?
|
|
117
|
+
return false if parent_id == diagram.package_id
|
|
118
|
+
|
|
119
|
+
model_index[parent_id].is_a?(Ea::Model::Package)
|
|
120
|
+
end
|
|
79
121
|
end
|
|
80
122
|
end
|
|
81
123
|
end
|
|
@@ -42,6 +42,33 @@ module Ea
|
|
|
42
42
|
new(min_x: min_x, min_y: min_y, width: width, height: height)
|
|
43
43
|
end
|
|
44
44
|
|
|
45
|
+
# Second-pass canvas over the DRAWN extents captured by the
|
|
46
|
+
# element pass (grown classifiers, autosized packages, plus
|
|
47
|
+
# BoundsCalculator's subtitle reservation). EA sizes the
|
|
48
|
+
# canvas from drawn extents, so diagrams whose lowest/rightmost
|
|
49
|
+
# element grew get a taller/wider canvas than the stored-rect
|
|
50
|
+
# first pass provides.
|
|
51
|
+
def self.from_drawn(diagram, drawn_bounds, model_index: nil)
|
|
52
|
+
base = BoundsCalculator.new(diagram, model_index: model_index)
|
|
53
|
+
pts = []
|
|
54
|
+
drawn_bounds.each_value do |b|
|
|
55
|
+
pts << [b.x, b.y]
|
|
56
|
+
pts << [b.x + b.width, b.y + b.height]
|
|
57
|
+
end
|
|
58
|
+
extra = base.send(:subtitle_points)
|
|
59
|
+
min_x = (pts + extra).map(&:first).min || 0
|
|
60
|
+
min_y = (pts + extra).map(&:last).min || 0
|
|
61
|
+
max_x = (pts + extra).map(&:first).max || 0
|
|
62
|
+
max_y = (pts + extra).map(&:last).max || 0
|
|
63
|
+
return from(diagram, model_index: model_index) if pts.empty?
|
|
64
|
+
|
|
65
|
+
new(min_x: min_x, min_y: min_y,
|
|
66
|
+
width: (max_x - min_x) + BoundsCalculator::INSET_LEFT +
|
|
67
|
+
BoundsCalculator::INSET_RIGHT,
|
|
68
|
+
height: (max_y - min_y) + BoundsCalculator::INSET_TOP +
|
|
69
|
+
BoundsCalculator::INSET_BOTTOM)
|
|
70
|
+
end
|
|
71
|
+
|
|
45
72
|
def view_box
|
|
46
73
|
"0 0 #{width} #{height}"
|
|
47
74
|
end
|
|
@@ -21,11 +21,25 @@ module Ea
|
|
|
21
21
|
|
|
22
22
|
def render
|
|
23
23
|
canvas = Canvas.from(diagram, model_index: model_index)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
seq = LayerSequencer.new(diagram, model_index: model_index,
|
|
25
|
+
canvas: canvas, frame: frame,
|
|
26
|
+
document: document)
|
|
27
|
+
seq.layers
|
|
28
|
+
# Second pass over the DRAWN extents: grown classifiers and
|
|
29
|
+
# autosized packages can exceed the stored-rect canvas EA
|
|
30
|
+
# sizes from drawn extents. Skip when the first pass already
|
|
31
|
+
# covers the drawn extents (the common case).
|
|
32
|
+
grown = seq.drawn_bounds
|
|
33
|
+
if grown && grown.values.any? &&
|
|
34
|
+
exceeds?(canvas, grown.values)
|
|
35
|
+
canvas = Canvas.from_drawn(diagram, grown,
|
|
36
|
+
model_index: model_index)
|
|
37
|
+
seq = LayerSequencer.new(diagram, model_index: model_index,
|
|
38
|
+
canvas: canvas, frame: frame,
|
|
39
|
+
document: document)
|
|
40
|
+
seq.layers
|
|
41
|
+
end
|
|
42
|
+
layers = seq.layers.reject { |s| s.nil? || s.empty? }
|
|
29
43
|
image_layer = emit_images
|
|
30
44
|
layers << image_layer if image_layer
|
|
31
45
|
|
|
@@ -55,6 +69,16 @@ module Ea
|
|
|
55
69
|
%(<g id="images">\n#{fragments.join("\n")}\n</g>)
|
|
56
70
|
end
|
|
57
71
|
|
|
72
|
+
# True when any drawn bound falls outside the stored-rect
|
|
73
|
+
# canvas content area.
|
|
74
|
+
def exceeds?(canvas, bounds)
|
|
75
|
+
bounds.any? do |b|
|
|
76
|
+
b.x < canvas.min_x || b.y < canvas.min_y ||
|
|
77
|
+
b.x + b.width > canvas.min_x + canvas.width ||
|
|
78
|
+
b.y + b.height > canvas.min_y + canvas.height
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
58
82
|
def render_image(image)
|
|
59
83
|
svg = Ea::Image::EmfRenderer.render(image.bytes)
|
|
60
84
|
return nil unless svg
|
data/lib/ea/version.rb
CHANGED