Class: Xsdvi::SVG::Symbol

Inherits:
Tree::Element show all
Defined in:
lib/xsdvi/svg/symbol.rb

Overview

Base class for all SVG symbols

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

Instance Attribute Summary collapse

Attributes inherited from Tree::Element

#children, #parent

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Tree::Element

#add_child, #children?, #code, #first_child?, #index, #last_child, #last_child?, #parent?

Constructor Details

#initializeSymbol

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_restObject

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_positionObject

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_positionObject

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_positionObject

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_heightObject (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

#descriptionObject

Returns the value of attribute description.



22
23
24
# File 'lib/xsdvi/svg/symbol.rb', line 22

def description
  @description
end

#description_string_arrayObject (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

#heightObject

Returns the value of attribute height.



22
23
24
# File 'lib/xsdvi/svg/symbol.rb', line 22

def height
  @height
end

#start_y_positionObject

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

#svgObject

Returns the value of attribute svg.



22
23
24
# File 'lib/xsdvi/svg/symbol.rb', line 22

def svg
  @svg
end

#widthObject

Returns the value of attribute width.



22
23
24
# File 'lib/xsdvi/svg/symbol.rb', line 22

def width
  @width
end

#x_positionObject

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_positionObject

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_shiftObject (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_variablesObject



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_heightObject



78
79
80
# File 'lib/xsdvi/svg/symbol.rb', line 78

def calculate_height
  MAX_HEIGHT
end

#calculate_widthObject



74
75
76
# File 'lib/xsdvi/svg/symbol.rb', line 74

def calculate_width
  MIN_WIDTH
end

#drawObject

Raises:

  • (NotImplementedError)


70
71
72
# File 'lib/xsdvi/svg/symbol.rb', line 70

def draw
  raise NotImplementedError, "Subclasses must implement draw method"
end

#prepare_boxObject



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_endObject



40
41
42
# File 'lib/xsdvi/svg/symbol.rb', line 40

def x_end
  x_position + width
end

#y_endObject



44
45
46
# File 'lib/xsdvi/svg/symbol.rb', line 44

def y_end
  y_position + MAX_HEIGHT
end