Class: Ea::Svg::EaEmitter::Marker::Diamond

Inherits:
Kind
  • Object
show all
Defined in:
lib/ea/svg/ea_emitter/marker/diamond.rb

Overview

Diamond marker at the whole end of an aggregation or composition, PLUS a navigability arrow at the part end when the connector's direction is "Destination -> Source". Reference SVGs confirm EA emits BOTH markers for reverse-direction aggregations on the plateau: the diamond distinguishes aggregation from association, the arrow shows navigability direction. Forward-direction ("Source -> Destination") aggregations get the diamond only — verified against basic.qea's "Two Level Class Composition Hierarchy" diagram, where the reference SVG has 17 diamonds and 0 arrows.

Class Method Summary collapse

Methods inherited from Kind

whole_end_at_source?

Class Method Details

.handles?(effective_type) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/ea/svg/ea_emitter/marker/diamond.rb', line 19

def self.handles?(effective_type)
  effective_type == "Aggregation" || effective_type == "Composition"
end

EA renders the navigability arrow at the part end of an aggregation only when the connector's direction is "Destination -> Source" — the conventional EA encoding for "part -> whole" with navigability back to the whole. Forward-direction aggregations ("Source -> Destination") omit the arrow: the diamond already communicates the aggregation semantic and the destination is not explicitly navigable.

Returns:

  • (Boolean)


48
49
50
# File 'lib/ea/svg/ea_emitter/marker/diamond.rb', line 48

def self.navigable_part_end?(connector)
  connector.direction == "Destination -> Source"
end

.specs_for(connector, source, target, before_target, after_source, relationship: nil) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ea/svg/ea_emitter/marker/diamond.rb', line 23

def self.specs_for(connector, source, target, before_target, after_source, relationship: nil)
  whole_end_at_source = whole_end_at_source?(connector)
  whole_anchor = whole_end_at_source ? source : target
  whole_base = whole_end_at_source ? after_source : before_target
  specs = [Registry::Spec.new(shape: :diamond,
                              anchor: whole_anchor,
                              base: whole_base)]
  return specs unless navigable_part_end?(connector)

  part_anchor = whole_end_at_source ? target : source
  part_base = whole_end_at_source ? before_target : after_source
  specs << Registry::Spec.new(shape: :arrow,
                              anchor: part_anchor,
                              base: part_base)
  specs
end