Class: Xsdvi::SVG::Symbols::Element
- Inherits:
-
Xsdvi::SVG::Symbol
- Object
- Tree::Element
- Xsdvi::SVG::Symbol
- Xsdvi::SVG::Symbols::Element
- Defined in:
- lib/xsdvi/svg/symbols/element.rb
Overview
Symbol for XSD elements
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
-
#abstract ⇒ Object
Returns the value of attribute abstract.
-
#cardinality ⇒ Object
Returns the value of attribute cardinality.
-
#name ⇒ Object
Returns the value of attribute name.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#nillable ⇒ Object
Returns the value of attribute nillable.
-
#optional ⇒ Object
Returns the value of attribute optional.
-
#substitution ⇒ Object
Returns the value of attribute substitution.
-
#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 ⇒ Element
constructor
A new instance of Element.
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 ⇒ Element
Returns a new instance of Element.
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/xsdvi/svg/symbols/element.rb', line 13 def initialize super @name = nil @namespace = nil @type = nil @cardinality = nil @optional = false @nillable = false @abstract = false @substitution = nil end |
Instance Attribute Details
#abstract ⇒ Object
Returns the value of attribute abstract.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/element.rb', line 10 def abstract @abstract end |
#cardinality ⇒ Object
Returns the value of attribute cardinality.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/element.rb', line 10 def cardinality @cardinality end |
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/element.rb', line 10 def name @name end |
#namespace ⇒ Object
Returns the value of attribute namespace.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/element.rb', line 10 def namespace @namespace end |
#nillable ⇒ Object
Returns the value of attribute nillable.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/element.rb', line 10 def nillable @nillable end |
#optional ⇒ Object
Returns the value of attribute optional.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/element.rb', line 10 def optional @optional end |
#substitution ⇒ Object
Returns the value of attribute substitution.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/element.rb', line 10 def substitution @substitution end |
#type ⇒ Object
Returns the value of attribute type.
10 11 12 |
# File 'lib/xsdvi/svg/symbols/element.rb', line 10 def type @type end |
Instance Method Details
#calculate_height ⇒ Object
85 86 87 |
# File 'lib/xsdvi/svg/symbols/element.rb', line 85 def calculate_height MAX_HEIGHT end |
#calculate_width ⇒ Object
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/xsdvi/svg/symbols/element.rb', line 74 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, cardinality) calc.new_width(15, substitution ? 22 : 11) calc.new_width(15, substitution, 8) calc.width end |
#draw ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/xsdvi/svg/symbols/element.rb', line 30 def draw print("<a href=\"#\" onclick=\"window.parent.location.href = " \ "window.parent.location.href.split('#')[0] + " \ "'#element_#{name}'\">") process_description draw_g_start print("<rect class='shadow' x='3' y='3' width='#{width}' " \ "height='#{height}'/>") if optional print("<rect class='boxelementoptional' x='0' y='0' " \ "width='#{width}' height='#{height}'/>") else print("<rect class='boxelement' x='0' y='0' width='#{width}' " \ "height='#{height}'/>") end # Show namespace at y=13 (always shown in Java if present) if namespace && !namespace.empty? print("<text class='visible' x='5' y='13'>#{namespace}</text>") end # Show name at y=27 (always shown in Java) print("<text class='strong elementlink' x='5' y='27'>#{name}</text>") if name # Show type at y=41 (always shown in Java if present) print("<text class='visible' x='5' y='41'>#{type}</text>") if type && !type.empty? # Properties at y=59 properties = [] properties << cardinality if cardinality properties << "subst.: #{substitution}" if substitution properties << "nillable: true" if nillable properties << "abstract: true" if abstract print("<text x='5' y='59'>#{properties.join(', ')}</text>") draw_description(59) draw_connection draw_use draw_g_end print("</a>") end |