Class: Ea::Svg::EaEmitter::GhostLabels
- Inherits:
-
Object
- Object
- Ea::Svg::EaEmitter::GhostLabels
- Defined in:
- lib/ea/svg/ea_emitter/ghost_labels.rb
Overview
Emits ghost classifier name <text> elements for connector
endpoints that reference off-canvas classifiers. Each ghost
label appears as italic text near the connector's on-canvas
endpoint.
Constant Summary collapse
- DEFAULT_FAMILY =
"Carlito"- DEFAULT_SIZE =
9- DEFAULT_UNIT =
"pt"- DEFAULT_FILL =
"#000000"
Instance Attribute Summary collapse
-
#canvas ⇒ Object
readonly
Returns the value of attribute canvas.
-
#diagram ⇒ Object
readonly
Returns the value of attribute diagram.
-
#family ⇒ Object
readonly
Returns the value of attribute family.
-
#fill ⇒ Object
readonly
Returns the value of attribute fill.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#size_unit ⇒ Object
readonly
Returns the value of attribute size_unit.
Instance Method Summary collapse
-
#initialize(diagram, canvas: nil, family: DEFAULT_FAMILY, size: DEFAULT_SIZE, size_unit: DEFAULT_UNIT, fill: DEFAULT_FILL) ⇒ GhostLabels
constructor
A new instance of GhostLabels.
- #render ⇒ Object
Constructor Details
#initialize(diagram, canvas: nil, family: DEFAULT_FAMILY, size: DEFAULT_SIZE, size_unit: DEFAULT_UNIT, fill: DEFAULT_FILL) ⇒ GhostLabels
Returns a new instance of GhostLabels.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ea/svg/ea_emitter/ghost_labels.rb', line 18 def initialize(diagram, canvas: nil, family: DEFAULT_FAMILY, size: DEFAULT_SIZE, size_unit: DEFAULT_UNIT, fill: DEFAULT_FILL) @diagram = diagram @canvas = canvas @family = family @size = size @size_unit = size_unit @fill = fill end |
Instance Attribute Details
#canvas ⇒ Object (readonly)
Returns the value of attribute canvas.
16 17 18 |
# File 'lib/ea/svg/ea_emitter/ghost_labels.rb', line 16 def canvas @canvas end |
#diagram ⇒ Object (readonly)
Returns the value of attribute diagram.
16 17 18 |
# File 'lib/ea/svg/ea_emitter/ghost_labels.rb', line 16 def diagram @diagram end |
#family ⇒ Object (readonly)
Returns the value of attribute family.
16 17 18 |
# File 'lib/ea/svg/ea_emitter/ghost_labels.rb', line 16 def family @family end |
#fill ⇒ Object (readonly)
Returns the value of attribute fill.
16 17 18 |
# File 'lib/ea/svg/ea_emitter/ghost_labels.rb', line 16 def fill @fill end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
16 17 18 |
# File 'lib/ea/svg/ea_emitter/ghost_labels.rb', line 16 def size @size end |
#size_unit ⇒ Object (readonly)
Returns the value of attribute size_unit.
16 17 18 |
# File 'lib/ea/svg/ea_emitter/ghost_labels.rb', line 16 def size_unit @size_unit end |
Instance Method Details
#render ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ea/svg/ea_emitter/ghost_labels.rb', line 29 def render texts = visible_connectors.flat_map do |connector| (connector.ghost_labels || []).map { |g| text_for(g) } end return "" if texts.empty? group_style = "stroke-width:1;stroke-linecap:round;" \ "stroke-linejoin:bevel; fill:#{fill};" \ "fill-opacity:1.00; stroke:#000000;" \ " stroke-opacity:0.00" %(<g style="#{group_style}">\n#{texts.join("\n")}\n</g>) end |