ea 0.6.38 → 0.6.40

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: 766805714007ed9c6bff335cc0cdcc0323276ff11cceee7e4982113d64b9f295
4
- data.tar.gz: cb822f672eb96d3d298df5788c007e21d15003fb48232f503cd15c9f3caef76d
3
+ metadata.gz: 164d7f4eec0c15cd5811283a701759887c6b7431337dd9160506d87c9a9ab673
4
+ data.tar.gz: 603a2def1016cee9b7747c6131d6e815be09c566d8d4325bc0109d71565b9b5f
5
5
  SHA512:
6
- metadata.gz: 91c69faf5a4855b583813d23e6f827bd606e611cc2fce020fc601b3af65c8bc00a9c8aa131a4ce78d4b0b387bca797fef12939af7e1b5f5dcff1e0887c1e3bd3
7
- data.tar.gz: b087a7ffc8deea335482b15f5818a4f9e130a728887d6955a769c2f369e945b8ec503f83bacc8318ba6599b4213f68b3086c1b2164e5a7bbd4d95519902d29d0
6
+ metadata.gz: bcdeea949d117ea448e114300f8f3114d78000fd0212a4e2428e120084957df3bf309fe0bea278303432133c3f91168177b43fab6483088f56df26a7d0cc33f4
7
+ data.tar.gz: 847c43fba07dd14374d031f80731cf10656ebb2e1e63f5674a5c0414dffc1024bba9b7e8026a62f93f17a24921cd7ef5da30b9cb2cec1c598f02b6e76e2321d1
@@ -38,6 +38,8 @@ module Ea
38
38
  @model_index = model_index
39
39
  end
40
40
 
41
+ attr_reader :effective_inset_left
42
+
41
43
  def compute
42
44
  points = element_points
43
45
  return [0, 0, 1, 1] if points.empty?
@@ -48,12 +50,13 @@ module Ea
48
50
  min_y = ys.min || 0
49
51
  # When the leftmost element touches stored x=0 the left
50
52
  # inset is 30, not 35 (all five such sample diagrams are
51
- # exactly 5px narrower; min_x>0 diagrams keep 35).
52
- left = min_x.zero? ? INSET_LEFT - 5 : INSET_LEFT
53
+ # exactly 5px narrower; min_x>0 diagrams keep 35). Canvas
54
+ # translation must use the same value.
55
+ @effective_inset_left = min_x.zero? ? INSET_LEFT - 5 : INSET_LEFT
53
56
  [
54
57
  min_x,
55
58
  min_y,
56
- (xs.max - min_x) + left + INSET_RIGHT,
59
+ (xs.max - min_x) + @effective_inset_left + INSET_RIGHT,
57
60
  (ys.max - min_y) + INSET_TOP + INSET_BOTTOM
58
61
  ]
59
62
  end
@@ -21,15 +21,17 @@ module Ea
21
21
  # against the maintenance diagram.
22
22
  PX_PER_CM = 37.795275591
23
23
  FRAME_INSET_LEFT = 35
24
+ INSET_TOUCHING_ORIGIN = 30
24
25
  FRAME_INSET_TOP = 40
25
26
 
26
- attr_reader :min_x, :min_y, :width, :height
27
+ attr_reader :min_x, :min_y, :width, :height, :inset_left
27
28
 
28
- def initialize(min_x:, min_y:, width:, height:)
29
+ def initialize(min_x:, min_y:, width:, height:, inset_left: FRAME_INSET_LEFT)
29
30
  @min_x = min_x
30
31
  @min_y = min_y
31
32
  @width = width
32
33
  @height = height
34
+ @inset_left = inset_left
33
35
  end
34
36
 
35
37
  # Build a Canvas for a diagram by running the bound
@@ -37,9 +39,10 @@ module Ea
37
39
  # element bounds needed) for callers that only need a
38
40
  # frame-size estimate.
39
41
  def self.from(diagram, model_index: nil)
40
- min_x, min_y, width, height =
41
- BoundsCalculator.new(diagram, model_index: model_index).compute
42
- new(min_x: min_x, min_y: min_y, width: width, height: height)
42
+ bc = BoundsCalculator.new(diagram, model_index: model_index)
43
+ min_x, min_y, width, height = bc.compute
44
+ new(min_x: min_x, min_y: min_y, width: width, height: height,
45
+ inset_left: bc.effective_inset_left || FRAME_INSET_LEFT)
43
46
  end
44
47
 
45
48
  # Second-pass canvas over the DRAWN extents captured by the
@@ -62,11 +65,14 @@ module Ea
62
65
  max_y = (pts + extra).map(&:last).max || 0
63
66
  return from(diagram, model_index: model_index) if pts.empty?
64
67
 
68
+ inset_left = min_x.zero? ? INSET_TOUCHING_ORIGIN
69
+ : BoundsCalculator::INSET_LEFT
65
70
  new(min_x: min_x, min_y: min_y,
66
- width: (max_x - min_x) + BoundsCalculator::INSET_LEFT +
71
+ width: (max_x - min_x) + inset_left +
67
72
  BoundsCalculator::INSET_RIGHT,
68
73
  height: (max_y - min_y) + BoundsCalculator::INSET_TOP +
69
- BoundsCalculator::INSET_BOTTOM)
74
+ BoundsCalculator::INSET_BOTTOM,
75
+ inset_left: inset_left)
70
76
  end
71
77
 
72
78
  def view_box
@@ -85,7 +91,7 @@ module Ea
85
91
  # the content area from the canvas top-left by
86
92
  # FRAME_INSET_LEFT/TOP.
87
93
  def translate_x(x)
88
- x - min_x + FRAME_INSET_LEFT
94
+ x - min_x + inset_left
89
95
  end
90
96
 
91
97
  def translate_y(y)
@@ -33,6 +33,17 @@ module Ea
33
33
  return nil if content.nil?
34
34
 
35
35
  mx, my = midpoint(points)
36
+ # EA splits a "name: value" label at the colon-space into
37
+ # two lines centered on the same slot (81F92FC7: "new
38
+ # ownership:" / "LA_Right" at y 172/185, both centered on
39
+ # x=480).
40
+ if (idx = content.index(": ")) && content.length > idx + 2
41
+ return [
42
+ render_text(mx, my, content[0..idx]),
43
+ render_text(mx, my + LINE_PITCH, content[(idx + 2)..])
44
+ ].join("\n")
45
+ end
46
+
36
47
  render_text(mx, my, content)
37
48
  end
38
49
 
@@ -74,6 +85,8 @@ module Ea
74
85
 
75
86
  private
76
87
 
88
+ LINE_PITCH = 13
89
+
77
90
  def midpoint(points)
78
91
  mid_idx = points.size / 2
79
92
  if points.size.odd?
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.38"
7
+ VERSION = "0.6.40"
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.38
4
+ version: 0.6.40
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.