Class: Xsdvi::SVG::Symbols::Attribute
- Inherits:
-
Xsdvi::SVG::Symbol
- Object
- Tree::Element
- Xsdvi::SVG::Symbol
- Xsdvi::SVG::Symbols::Attribute
- Defined in:
- lib/xsdvi/svg/symbols/attribute.rb
Overview
Symbol for XSD attributes
Constant Summary
Constants inherited from Xsdvi::SVG::Symbol
Xsdvi::SVG::Symbol::MAX_HEIGHT, Xsdvi::SVG::Symbol::MID_HEIGHT, Xsdvi::SVG::Symbol::MIN_HEIGHT, Xsdvi::SVG::Symbol::MIN_WIDTH, Xsdvi::SVG::Symbol::PC_LAX, Xsdvi::SVG::Symbol::PC_SKIP, Xsdvi::SVG::Symbol::PC_STRICT, Xsdvi::SVG::Symbol::X_INDENT, Xsdvi::SVG::Symbol::Y_INDENT
Instance Attribute Summary collapse
-
#constraint ⇒ Object
Returns the value of attribute constraint.
-
#name ⇒ Object
Returns the value of attribute name.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#required ⇒ Object
Returns the value of attribute required.
-
#type ⇒ Object
Returns the value of attribute type.
Attributes inherited from Xsdvi::SVG::Symbol
#additional_height, #description, #description_string_array, #height, #start_y_position, #svg, #width, #x_position, #y_position, #y_shift
Attributes inherited from Tree::Element
Instance Method Summary collapse
- #calculate_height ⇒ Object
- #calculate_width ⇒ Object
- #draw ⇒ Object
-
#initialize ⇒ Attribute
constructor
A new instance of Attribute.
Methods inherited from Xsdvi::SVG::Symbol
#prepare_box, reset_class_variables, #x_end, #y_end
Methods inherited from Tree::Element
#add_child, #children?, #code, #first_child?, #index, #last_child, #last_child?, #parent?
Constructor Details
#initialize ⇒ Attribute
Returns a new instance of Attribute.
12 13 14 15 16 17 18 19 |
# File 'lib/xsdvi/svg/symbols/attribute.rb', line 12 def initialize super @name = nil @namespace = nil @type = nil @required = false @constraint = nil end |
Instance Attribute Details
#constraint ⇒ Object
Returns the value of attribute constraint.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/attribute.rb', line 10 def constraint @constraint end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/attribute.rb', line 10 def name @name end |
#namespace ⇒ Object
Returns the value of attribute namespace.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/attribute.rb', line 10 def namespace @namespace end |
#required ⇒ Object
Returns the value of attribute required.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/attribute.rb', line 10 def required @required end |
#type ⇒ Object
Returns the value of attribute type.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/attribute.rb', line 10 def type @type end |
Instance Method Details
#calculate_height ⇒ Object
58 59 60 |
# File 'lib/xsdvi/svg/symbols/attribute.rb', line 58 def calculate_height MAX_HEIGHT end |
#calculate_width ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/xsdvi/svg/symbols/attribute.rb', line 48 def calculate_width calc = Utils::WidthCalculator.new(MIN_WIDTH) calc.new_width(15, name, 3) calc.new_width(15, namespace) calc.new_width(15, type) calc.new_width(15, 13) calc.new_width(15, constraint) # Constraint includes "default: " or "fixed: " prefix calc.width end |
#draw ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/xsdvi/svg/symbols/attribute.rb', line 21 def draw process_description draw_g_start print("<rect class='shadow' x='3' y='3' width='#{width}' " \ "height='#{height}' rx='9'/>") if required print("<rect class='boxattribute1' x='0' y='0' " \ "width='#{width}' height='#{height}' rx='9'") else print("<rect class='boxattribute2' x='0' y='0' " \ "width='#{width}' height='#{height}' rx='9'") end print("/>") print("<text class='visible' x='5' y='13'>#{namespace}</text>") if namespace print("<text class='strong' x='5' y='27'><tspan class='big'>@</tspan> #{name}</text>") if name print("<text class='visible' x='5' y='41'>#{type}</text>") if type properties = [] properties << constraint if constraint print("<text x='5' y='59'>#{properties.join(', ')}</text>") draw_description(59) draw_connection draw_g_end end |