Class: Ea::Svg::EaEmitter::RenderContext

Inherits:
Struct
  • Object
show all
Defined in:
lib/ea/svg/ea_emitter/render_context.rb

Overview

Per-element render context. Holds the immutable inputs each compartment renderer needs (bounds, classifier, fill/stroke, font, geometry, line data). Built once per element; passed to every compartment in the pipeline so they don't reach back into the parent Elements orchestrator.

Value object: equality by structural attributes. Each instance is frozen after construction.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attr_linesObject

Returns the value of attribute attr_lines

Returns:

  • (Object)

    the current value of attr_lines



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def attr_lines
  @attr_lines
end

#boundsObject

Returns the value of attribute bounds

Returns:

  • (Object)

    the current value of bounds



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def bounds
  @bounds
end

#canvasObject

Returns the value of attribute canvas

Returns:

  • (Object)

    the current value of canvas



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def canvas
  @canvas
end

#classifierObject

Returns the value of attribute classifier

Returns:

  • (Object)

    the current value of classifier



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def classifier
  @classifier
end

#constraintsObject

Returns the value of attribute constraints

Returns:

  • (Object)

    the current value of constraints



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def constraints
  @constraints
end

#diagramObject

Returns the value of attribute diagram

Returns:

  • (Object)

    the current value of diagram



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def diagram
  @diagram
end

#elementObject

Returns the value of attribute element

Returns:

  • (Object)

    the current value of element



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def element
  @element
end

#enum_literalsObject

Returns the value of attribute enum_literals

Returns:

  • (Object)

    the current value of enum_literals



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def enum_literals
  @enum_literals
end

#familyObject

Returns the value of attribute family

Returns:

  • (Object)

    the current value of family



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def family
  @family
end

#fillObject

Returns the value of attribute fill

Returns:

  • (Object)

    the current value of fill



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def fill
  @fill
end

#geometryObject

Returns the value of attribute geometry

Returns:

  • (Object)

    the current value of geometry



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def geometry
  @geometry
end

#header_linesObject

Returns the value of attribute header_lines

Returns:

  • (Object)

    the current value of header_lines



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def header_lines
  @header_lines
end

#model_elementObject

Returns the value of attribute model_element

Returns:

  • (Object)

    the current value of model_element



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def model_element
  @model_element
end

#model_indexObject

Returns the value of attribute model_index

Returns:

  • (Object)

    the current value of model_index



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def model_index
  @model_index
end

#off_canvas_parent_nameObject

Returns the value of attribute off_canvas_parent_name

Returns:

  • (Object)

    the current value of off_canvas_parent_name



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def off_canvas_parent_name
  @off_canvas_parent_name
end

#op_linesObject

Returns the value of attribute op_lines

Returns:

  • (Object)

    the current value of op_lines



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def op_lines
  @op_lines
end

#package_content_linesObject

Returns the value of attribute package_content_lines

Returns:

  • (Object)

    the current value of package_content_lines



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def package_content_lines
  @package_content_lines
end

#sizeObject

Returns the value of attribute size

Returns:

  • (Object)

    the current value of size



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def size
  @size
end

#size_unitObject

Returns the value of attribute size_unit

Returns:

  • (Object)

    the current value of size_unit



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def size_unit
  @size_unit
end

#strokeObject

Returns the value of attribute stroke

Returns:

  • (Object)

    the current value of stroke



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def stroke
  @stroke
end

#stroke_widthObject

Returns the value of attribute stroke_width

Returns:

  • (Object)

    the current value of stroke_width



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def stroke_width
  @stroke_width
end

#tagged_valuesObject

Returns the value of attribute tagged_values

Returns:

  • (Object)

    the current value of tagged_values



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def tagged_values
  @tagged_values
end

#text_fillObject

Returns the value of attribute text_fill

Returns:

  • (Object)

    the current value of text_fill



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def text_fill
  @text_fill
end

#themeObject

Returns the value of attribute theme

Returns:

  • (Object)

    the current value of theme



14
15
16
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 14

def theme
  @theme
end

Instance Method Details

#content_below_header?Boolean

Compartments below the header that produce a divider when any of them has content. Returns true when at least one is non-empty.

Returns:

  • (Boolean)


43
44
45
46
47
48
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 43

def content_below_header?
  !attr_lines.empty? || !op_lines.empty? ||
    enum_literals.any? || tagged_values.any? ||
    (constraints&.any?) ||
    (!package_content_lines.nil? && !package_content_lines.empty?)
end

#model_index_for(id) ⇒ Object

Resolve a model element by id via the threaded model index. Returns nil when no index is wired in or the id is absent.



34
35
36
37
38
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 34

def model_index_for(id)
  return nil unless model_index && id

  model_index[id]
end

#note_bodyObject



25
26
27
28
29
30
# File 'lib/ea/svg/ea_emitter/render_context.rb', line 25

def note_body
  return nil unless model_element.is_a?(Ea::Model::Note)

  body = model_element.body
  body.nil? || body.empty? ? nil : body
end