Class: Xsdvi::SVG::Symbol
- Inherits:
-
Tree::Element
- Object
- Tree::Element
- Xsdvi::SVG::Symbol
- Defined in:
- lib/xsdvi/svg/symbol.rb
Overview
Base class for all SVG symbols
Direct Known Subclasses
Xsdvi::SVG::Symbols::All, Xsdvi::SVG::Symbols::Any, Xsdvi::SVG::Symbols::AnyAttribute, Xsdvi::SVG::Symbols::Attribute, Xsdvi::SVG::Symbols::Choice, Xsdvi::SVG::Symbols::Element, Xsdvi::SVG::Symbols::Field, Xsdvi::SVG::Symbols::Key, Xsdvi::SVG::Symbols::Keyref, Xsdvi::SVG::Symbols::Loop, Xsdvi::SVG::Symbols::Schema, Xsdvi::SVG::Symbols::Selector, Xsdvi::SVG::Symbols::Sequence, Xsdvi::SVG::Symbols::Unique
Constant Summary collapse
- PC_STRICT =
Process contents constants
1- PC_SKIP =
2- PC_LAX =
3- X_INDENT =
Layout constants
45- Y_INDENT =
25- MIN_WIDTH =
60- MAX_HEIGHT =
46- MID_HEIGHT =
31- MIN_HEIGHT =
21
Class Attribute Summary collapse
-
.additional_height_rest ⇒ Object
Returns the value of attribute additional_height_rest.
-
.highest_y_position ⇒ Object
Returns the value of attribute highest_y_position.
-
.prev_x_position ⇒ Object
Returns the value of attribute prev_x_position.
-
.prev_y_position ⇒ Object
Returns the value of attribute prev_y_position.
Instance Attribute Summary collapse
-
#additional_height ⇒ Object
readonly
Returns the value of attribute additional_height.
-
#description ⇒ Object
Returns the value of attribute description.
-
#description_string_array ⇒ Object
readonly
Returns the value of attribute description_string_array.
-
#height ⇒ Object
Returns the value of attribute height.
-
#start_y_position ⇒ Object
Returns the value of attribute start_y_position.
-
#svg ⇒ Object
Returns the value of attribute svg.
-
#width ⇒ Object
Returns the value of attribute width.
-
#x_position ⇒ Object
Returns the value of attribute x_position.
-
#y_position ⇒ Object
Returns the value of attribute y_position.
-
#y_shift ⇒ Object
readonly
Returns the value of attribute y_shift.
Attributes inherited from Tree::Element
Class Method Summary collapse
Instance Method Summary collapse
- #calculate_height ⇒ Object
- #calculate_width ⇒ Object
- #draw ⇒ Object
-
#initialize ⇒ Symbol
constructor
A new instance of Symbol.
- #prepare_box ⇒ Object
- #x_end ⇒ Object
- #y_end ⇒ Object
Methods inherited from Tree::Element
#add_child, #children?, #code, #first_child?, #index, #last_child, #last_child?, #parent?
Constructor Details
#initialize ⇒ Symbol
Returns a new instance of Symbol.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/xsdvi/svg/symbol.rb', line 27 def initialize super @x_position = 0 @y_position = 0 @width = 0 @height = 0 @start_y_position = 50 @description = [] @description_string_array = [] @y_shift = 14 @additional_height = 0 end |
Class Attribute Details
.additional_height_rest ⇒ Object
Returns the value of attribute additional_height_rest.
83 84 85 |
# File 'lib/xsdvi/svg/symbol.rb', line 83 def additional_height_rest @additional_height_rest end |
.highest_y_position ⇒ Object
Returns the value of attribute highest_y_position.
83 84 85 |
# File 'lib/xsdvi/svg/symbol.rb', line 83 def highest_y_position @highest_y_position end |
.prev_x_position ⇒ Object
Returns the value of attribute prev_x_position.
83 84 85 |
# File 'lib/xsdvi/svg/symbol.rb', line 83 def prev_x_position @prev_x_position end |
.prev_y_position ⇒ Object
Returns the value of attribute prev_y_position.
83 84 85 |
# File 'lib/xsdvi/svg/symbol.rb', line 83 def prev_y_position @prev_y_position end |
Instance Attribute Details
#additional_height ⇒ Object (readonly)
Returns the value of attribute additional_height.
24 25 26 |
# File 'lib/xsdvi/svg/symbol.rb', line 24 def additional_height @additional_height end |
#description ⇒ Object
Returns the value of attribute description.
22 23 24 |
# File 'lib/xsdvi/svg/symbol.rb', line 22 def description @description end |
#description_string_array ⇒ Object (readonly)
Returns the value of attribute description_string_array.
24 25 26 |
# File 'lib/xsdvi/svg/symbol.rb', line 24 def description_string_array @description_string_array end |
#height ⇒ Object
Returns the value of attribute height.
22 23 24 |
# File 'lib/xsdvi/svg/symbol.rb', line 22 def height @height end |
#start_y_position ⇒ Object
Returns the value of attribute start_y_position.
22 23 24 |
# File 'lib/xsdvi/svg/symbol.rb', line 22 def start_y_position @start_y_position end |
#svg ⇒ Object
Returns the value of attribute svg.
22 23 24 |
# File 'lib/xsdvi/svg/symbol.rb', line 22 def svg @svg end |
#width ⇒ Object
Returns the value of attribute width.
22 23 24 |
# File 'lib/xsdvi/svg/symbol.rb', line 22 def width @width end |
#x_position ⇒ Object
Returns the value of attribute x_position.
22 23 24 |
# File 'lib/xsdvi/svg/symbol.rb', line 22 def x_position @x_position end |
#y_position ⇒ Object
Returns the value of attribute y_position.
22 23 24 |
# File 'lib/xsdvi/svg/symbol.rb', line 22 def y_position @y_position end |
#y_shift ⇒ Object (readonly)
Returns the value of attribute y_shift.
24 25 26 |
# File 'lib/xsdvi/svg/symbol.rb', line 24 def y_shift @y_shift end |
Class Method Details
.reset_class_variables ⇒ Object
86 87 88 89 90 91 |
# File 'lib/xsdvi/svg/symbol.rb', line 86 def reset_class_variables @highest_y_position = 0 @additional_height_rest = 0 @prev_x_position = 0 @prev_y_position = 0 end |
Instance Method Details
#calculate_height ⇒ Object
78 79 80 |
# File 'lib/xsdvi/svg/symbol.rb', line 78 def calculate_height MAX_HEIGHT end |
#calculate_width ⇒ Object
74 75 76 |
# File 'lib/xsdvi/svg/symbol.rb', line 74 def calculate_width MIN_WIDTH end |
#draw ⇒ Object
70 71 72 |
# File 'lib/xsdvi/svg/symbol.rb', line 70 def draw raise NotImplementedError, "Subclasses must implement draw method" end |
#prepare_box ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/xsdvi/svg/symbol.rb', line 48 def prepare_box if parent? @x_position = parent.x_end + X_INDENT highest = Symbol.highest_y_position || 0 @y_position = if first_child? highest else highest + MAX_HEIGHT + Y_INDENT end else @x_position = 20 @y_position = start_y_position end # Ensure values are integers @x_position = @x_position.to_i @y_position = @y_position.to_i @width = calculate_width @height = calculate_height Symbol.highest_y_position = @y_position end |
#x_end ⇒ Object
40 41 42 |
# File 'lib/xsdvi/svg/symbol.rb', line 40 def x_end x_position + width end |
#y_end ⇒ Object
44 45 46 |
# File 'lib/xsdvi/svg/symbol.rb', line 44 def y_end y_position + MAX_HEIGHT end |