Class: Ea::Diagram::DisplayConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/diagram/display_config.rb

Overview

Models the behavioral display flags from t_diagram.Style and t_diagram.StyleEx. Controls WHAT is rendered (compartments, visibility levels, notes) — distinct from Theme which controls HOW it looks (colors, fonts, stroke widths).

Style (a.k.a. Style1) carries the per-diagram visibility toggles set via the "Features" panel:

HideAtts=1   → hide attribute compartment
HideOps=1    → hide operation compartment
HideStereo=1 → hide stereotype labels

StyleEx carries extended flags including the theme identifier and notes/labels visibility:

Theme=:119    → theme id (consumed by Ea::Theme::Registry)
SuppressFOC=1 → suppress foreign object content (images, OLE)
AttPub=1      → show public attributes
AttPri=1      → show private attributes
AttPro=1      → show protected attributes
ShowNotes=0   → hide element notes
ShowBorder=1  → render diagram frame
HideQuals=0   → show qualifier names
SuppConnLbls=0 → show connector labels

Usage:

config = DisplayConfig.from_style(style: diagram.style,
                                 style_ex: diagram.style_ex)
config.show_attributes?  # → false iff Style has HideAtts=1

Constant Summary collapse

DEFAULT_SHOW_PUBLIC =
"1"
DEFAULT_SHOW_PRIVATE =
"1"
DEFAULT_SHOW_PROTECTED =
"1"
DEFAULT_SHOW_BORDER =
"1"
DEFAULT_SUPPRESS_CONN_LABELS =
"0"
DEFAULT_SHOW_NOTES =
"0"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(style_flags: {}, style_ex_flags: {}) ⇒ DisplayConfig

Returns a new instance of DisplayConfig.



45
46
47
48
# File 'lib/ea/diagram/display_config.rb', line 45

def initialize(style_flags: {}, style_ex_flags: {})
  @style_flags = style_flags
  @style_ex_flags = style_ex_flags
end

Instance Attribute Details

#style_ex_flagsObject (readonly)

Returns the value of attribute style_ex_flags.



43
44
45
# File 'lib/ea/diagram/display_config.rb', line 43

def style_ex_flags
  @style_ex_flags
end

#style_flagsObject (readonly)

Returns the value of attribute style_flags.



43
44
45
# File 'lib/ea/diagram/display_config.rb', line 43

def style_flags
  @style_flags
end

Class Method Details

.from_style(style:, style_ex:) ⇒ DisplayConfig

Build a DisplayConfig from the raw Style and StyleEx strings. Both are optional; missing strings produce an empty flag set.

Parameters:

  • style (String, nil)

    t_diagram.Style content

  • style_ex (String, nil)

    t_diagram.StyleEx content

Returns:



56
57
58
59
# File 'lib/ea/diagram/display_config.rb', line 56

def self.from_style(style:, style_ex:)
  new(style_flags: parse_flags(style),
      style_ex_flags: parse_flags(style_ex))
end

.from_style_ex(style_ex) ⇒ Object

Backwards-compatible single-arg form: treats the argument as StyleEx. New callers should pass both style: and style_ex:.



63
64
65
# File 'lib/ea/diagram/display_config.rb', line 63

def self.from_style_ex(style_ex)
  from_style(style: nil, style_ex: style_ex)
end

Instance Method Details

#hide_qualifiers?Boolean

Returns:

  • (Boolean)


154
155
156
# File 'lib/ea/diagram/display_config.rb', line 154

def hide_qualifiers?
  style_ex_flags["HideQuals"] == "1"
end

#scale_page_indicators?Boolean

Page indicator scaling (Print... → Show Page Breaks).

Returns:

  • (Boolean)


121
122
123
# File 'lib/ea/diagram/display_config.rb', line 121

def scale_page_indicators?
  style_flags["ScalePI"] == "1"
end

#show_attributes?Boolean

---- Feature visibility (Style) ----

Returns:

  • (Boolean)


69
70
71
# File 'lib/ea/diagram/display_config.rb', line 69

def show_attributes?
  style_flags["HideAtts"] != "1"
end

#show_border?Boolean

Returns:

  • (Boolean)


145
146
147
# File 'lib/ea/diagram/display_config.rb', line 145

def show_border?
  style_ex_flags.fetch("ShowBorder", DEFAULT_SHOW_BORDER) == "1"
end

#show_connector_labels?Boolean

Returns:

  • (Boolean)


149
150
151
152
# File 'lib/ea/diagram/display_config.rb', line 149

def show_connector_labels?
  style_ex_flags.fetch("SuppConnectorLabels",
                        DEFAULT_SUPPRESS_CONN_LABELS) != "1"
end

#show_connector_names?Boolean

Connector role/name labels. EA defaults to showing them.

Returns:

  • (Boolean)


111
112
113
# File 'lib/ea/diagram/display_config.rb', line 111

def show_connector_names?
  style_flags["SuppCN"] != "1"
end

#show_constraints?Boolean

Constraints compartment (OCL invariants). Defaults to false.

Returns:

  • (Boolean)


116
117
118
# File 'lib/ea/diagram/display_config.rb', line 116

def show_constraints?
  style_flags["ShowCons"] == "1"
end

#show_extended_stereotypes?Boolean

Extended stereotype labels (e.g., profile-specific stereotypes beyond UML's standard set). EA defaults to showing them.

Returns:

  • (Boolean)


89
90
91
# File 'lib/ea/diagram/display_config.rb', line 89

def show_extended_stereotypes?
  style_flags["HideEStereo"] != "1"
end

#show_notes?Boolean

---- Diagram decorations (StyleEx) ----

Returns:

  • (Boolean)


141
142
143
# File 'lib/ea/diagram/display_config.rb', line 141

def show_notes?
  style_ex_flags.fetch("ShowNotes", DEFAULT_SHOW_NOTES) == "1"
end

#show_operation_parameters?Boolean

Operation parameter type list. When false, EA shows op() instead of op(name: Type). Defaults to true.

Returns:

  • (Boolean)


100
101
102
# File 'lib/ea/diagram/display_config.rb', line 100

def show_operation_parameters?
  style_flags["OpParams"] != "0"
end

#show_operations?Boolean

Returns:

  • (Boolean)


73
74
75
# File 'lib/ea/diagram/display_config.rb', line 73

def show_operations?
  style_flags["HideOps"] != "1"
end

#show_private_attributes?Boolean

Returns:

  • (Boolean)


131
132
133
# File 'lib/ea/diagram/display_config.rb', line 131

def show_private_attributes?
  style_ex_flags.fetch("AttPri", DEFAULT_SHOW_PRIVATE) == "1"
end

#show_protected_attributes?Boolean

Returns:

  • (Boolean)


135
136
137
# File 'lib/ea/diagram/display_config.rb', line 135

def show_protected_attributes?
  style_ex_flags.fetch("AttPro", DEFAULT_SHOW_PROTECTED) == "1"
end

#show_public_attributes?Boolean

---- Attribute visibility levels (StyleEx) ----

Returns:

  • (Boolean)


127
128
129
# File 'lib/ea/diagram/display_config.rb', line 127

def show_public_attributes?
  style_ex_flags.fetch("AttPub", DEFAULT_SHOW_PUBLIC) == "1"
end

#show_sequence_numbers?Boolean

Sequence numbers on elements. EA defaults to hiding them.

Returns:

  • (Boolean)


94
95
96
# File 'lib/ea/diagram/display_config.rb', line 94

def show_sequence_numbers?
  style_flags["ShowSN"] == "1"
end

#show_stereotypes?Boolean

Returns:

  • (Boolean)


77
78
79
# File 'lib/ea/diagram/display_config.rb', line 77

def show_stereotypes?
  style_flags["HideStereo"] != "1"
end

#show_tagged_values?Boolean

Tagged values compartment. EA defaults to hiding it; the user explicitly opts in via Style1 ShowTags=1.

Returns:

  • (Boolean)


83
84
85
# File 'lib/ea/diagram/display_config.rb', line 83

def show_tagged_values?
  style_flags["ShowTags"] == "1"
end

#suppress_foreign_object_content?Boolean

Returns:

  • (Boolean)


158
159
160
# File 'lib/ea/diagram/display_config.rb', line 158

def suppress_foreign_object_content?
  style_ex_flags["SuppressFOC"] == "1"
end

#to_style_exObject

Serialize the union of flags back to a StyleEx-shaped string. Style and StyleEx are merged because EA serializes them as one string when round-tripped through some tools.



165
166
167
# File 'lib/ea/diagram/display_config.rb', line 165

def to_style_ex
  style_flags.merge(style_ex_flags).map { |k, v| "#{k}=#{v}" }.join(";")
end

#use_alias?Boolean

Element Alias instead of Name in the header. Defaults to false — most diagrams show the Name.

Returns:

  • (Boolean)


106
107
108
# File 'lib/ea/diagram/display_config.rb', line 106

def use_alias?
  style_flags["UseAlias"] == "1"
end