ea 0.6.26 → 0.6.28

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: 523062f8a2bc8628a3c5b35aa5a074057307e4405b1d87ebf4150e471e592e29
4
- data.tar.gz: 5ea75aecf1ed9a73b9a387e424073e1e7cc83e0161d9a2ab4db2c270136eea33
3
+ metadata.gz: c16a0778688fad772b4373999864fc0cd86d6b3d53cec3561ae14a97ad2457c8
4
+ data.tar.gz: 81408c1e187f5eda70ad9ed46f1f7904cc5931ca5152b43ea6385df5445f77b6
5
5
  SHA512:
6
- metadata.gz: f1e366645ba375c9fd3701e97d7da847753bfa2719d52887f9df5b563f352b8b7d0172b3396967ff38529473f49f91d289dc8ea12937defc4ad3dba72f5ac4e7
7
- data.tar.gz: 5389a63e4b5833ae5361e1d058059ecd4346f34de7e4965d4801dba2fc586ed43477729b81fc2a0e0897150d3853a82dbcd5d01f5b8f9caaf6a345e47159a034
6
+ metadata.gz: 1d2902fa0c76cf946a8751d01f3466295785c3326820e7a1e7fa029433e137a21046786caaf47f983e7edc4f8d5fd248004c25264eb3487fac67cbe79a36490e
7
+ data.tar.gz: 6972a73efe7333fa0cfc3af841f323d34d5c2077daa5572fdaa0976d650554b62a66c2f14ee24add12e750c5ded179c9ed6258798b15f16f19c2b8c7d00e92d9
@@ -408,6 +408,22 @@ module Ea
408
408
  [bend[0], target_y]]
409
409
  elsif intermediate.any?
410
410
  points = [source_point, *intermediate, target_point]
411
+ # Generalizations with the parent ABOVE keep their stored
412
+ # interior bends verbatim but re-dock the endpoints onto
413
+ # the box edges AT THE ADJACENT BEND's x (hand-verified:
414
+ # stored (542,975)(541,807)(543,807)(486,757) draws as
415
+ # (541,975)(541,807)(543,807)(543,757) — only the two
416
+ # endpoints move; the stale final x is replaced by the
417
+ # last bend's trunk x).
418
+ if connector.connector_type == "Generalization"
419
+ src_b = bounds_from_rect(source_placement)
420
+ tgt_b = bounds_from_rect(target_placement)
421
+ if tgt_b.y + tgt_b.height <= src_b.y
422
+ points[0] = [points[1][0].clamp(src_b.x, src_b.x + src_b.width), src_b.y]
423
+ points[-1] = [points[-2][0].clamp(tgt_b.x, tgt_b.x + tgt_b.width),
424
+ tgt_b.y + tgt_b.height]
425
+ end
426
+ end
411
427
  elsif source_port || target_port
412
428
  # Exact ports are known — the SX/SY bend heuristics in
413
429
  # sx_sy_ex_ey_waypoints would double-apply the offsets.
@@ -416,11 +432,89 @@ module Ea
416
432
  points = sx_sy_ex_ey_waypoints(source_point, target_point, geom)
417
433
  end
418
434
 
435
+ # Associations/Aggregations between DISJOINT boxes: when the
436
+ # stored route does not already dock the closest FACING edge
437
+ # pair, EA redraws a straight aligned line between those
438
+ # edges (corpus: edge pair = min facing gap, 85% accurate;
439
+ # dock coordinate = the stored route's own coordinate
440
+ # clamped into the edges' overlap; simulation on 417
441
+ # identity-paired connectors: exact routes 41 -> 100).
442
+ # Tree-style (EDGE=2) connectors are excluded — their
443
+ # computed routes are already byte-exact.
444
+ if %w[Association Aggregation].include?(connector.connector_type) &&
445
+ edge_out != 2
446
+ points = facing_edge_route(points,
447
+ bounds_from_rect(source_placement),
448
+ bounds_from_rect(target_placement))
449
+ end
450
+
419
451
  points.map do |x, y|
420
452
  Ea::Model::Waypoint.new(position: Ea::Model::Point.new(x: x, y: y))
421
453
  end
422
454
  end
423
455
 
456
+ # Returns a replacement 2-point route between the closest
457
+ # facing edges, or the original points when: the boxes overlap
458
+ # on both axes, the current route already docks those edges,
459
+ # or no aligned dock fits the edges' overlap range.
460
+ def facing_edge_route(points, src, tgt)
461
+ v_gap = v_dir = h_gap = h_dir = nil
462
+ if src.y >= tgt.y + tgt.height
463
+ v_gap = src.y - (tgt.y + tgt.height)
464
+ v_dir = [:t, :b]
465
+ elsif tgt.y >= src.y + src.height
466
+ v_gap = tgt.y - (src.y + src.height)
467
+ v_dir = [:b, :t]
468
+ end
469
+ if src.x >= tgt.x + tgt.width
470
+ h_gap = src.x - (tgt.x + tgt.width)
471
+ h_dir = [:l, :r]
472
+ elsif tgt.x >= src.x + src.width
473
+ h_gap = tgt.x - (tgt.x + tgt.width)
474
+ h_dir = [:r, :l]
475
+ end
476
+ return points if v_gap.nil? && h_gap.nil?
477
+
478
+ if !v_gap.nil? && (h_gap.nil? || v_gap <= h_gap)
479
+ src_edge, tgt_edge = v_dir
480
+ else
481
+ src_edge, tgt_edge = h_dir
482
+ end
483
+ return points if docks_edges?(points, src, src_edge, tgt, tgt_edge)
484
+
485
+ if %i[t b].include?(src_edge)
486
+ lo = [src.x, tgt.x].max
487
+ hi = [src.x + src.width, tgt.x + tgt.width].min
488
+ return points if lo > hi
489
+
490
+ x = points.first[0].clamp(lo, hi)
491
+ [[x, src_edge == :t ? src.y : src.y + src.height],
492
+ [x, tgt_edge == :t ? tgt.y : tgt.y + tgt.height]]
493
+ else
494
+ lo = [src.y, tgt.y].max
495
+ hi = [src.y + src.height, tgt.y + tgt.height].min
496
+ return points if lo > hi
497
+
498
+ y = points.first[1].clamp(lo, hi)
499
+ [[src_edge == :l ? src.x : src.x + src.width, y],
500
+ [tgt_edge == :l ? tgt.x : tgt.x + tgt.width, y]]
501
+ end
502
+ end
503
+
504
+ def docks_edges?(points, src, src_edge, tgt, tgt_edge)
505
+ on_edge?(points.first, src, src_edge) && on_edge?(points.last, tgt, tgt_edge)
506
+ end
507
+
508
+ def on_edge?(pt, b, edge, tol = 2)
509
+ x, y = pt
510
+ case edge
511
+ when :l then (x - b.x).abs <= tol && y.between?(b.y - tol, b.y + b.height + tol)
512
+ when :r then (x - (b.x + b.width)).abs <= tol && y.between?(b.y - tol, b.y + b.height + tol)
513
+ when :t then (y - b.y).abs <= tol && x.between?(b.x - tol, b.x + b.width + tol)
514
+ else (y - (b.y + b.height)).abs <= tol && x.between?(b.x - tol, b.x + b.width + tol)
515
+ end
516
+ end
517
+
424
518
  # A tree Path is current when its bend height still falls
425
519
  # within the source element's y-range (the exit height EA
426
520
  # records); a bend outside the element is stale and EA
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.26"
7
+ VERSION = "0.6.28"
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.26
4
+ version: 0.6.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.