Class: ElementSvg

Inherits:
Object
  • Object
show all
Defined in:
lib/render_svg3.rb

Overview

< SvgEnvironment

Direct Known Subclasses

ElementEllipse, ElementLine, ElementRect, ElementText

Instance Method Summary collapse

Constructor Details

#initializeElementSvg

this initialize method should be overridden with a class_eval from the calling RSF job



29
30
31
32
33
# File 'lib/render_svg3.rb', line 29

def initialize()
  initialize_variables()
  #@@shape = RVGShape::Shape.new
  #@@shape = Shape.new
end

Instance Method Details

#get_style_properties(properties_string) ⇒ Object



75
76
77
78
79
# File 'lib/render_svg3.rb', line 75

def get_style_properties(properties_string)
  properties_string.split(/;/).map do |a|
    a.match(/^(.[^:]+):([^$]+$)/).captures.map {|x| x.strip}
  end
end

#initialize_variablesObject



35
36
37
38
# File 'lib/render_svg3.rb', line 35

def initialize_variables()
  @property = {'style' => ''}
  @style_property = {}    
end

#load_properties(attributes) ⇒ Object



81
82
83
84
85
86
# File 'lib/render_svg3.rb', line 81

def load_properties(attributes)
  attributes.each_attribute do |attribute|
    @property[attribute.name] = attribute.value if @property.has_key? attribute.name
  end
  parse_style()
end

#load_renderer(renderer) ⇒ Object



88
89
90
# File 'lib/render_svg3.rb', line 88

def load_renderer(renderer)
  @@shape = renderer
end

#parse_styleObject



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/render_svg3.rb', line 63

def parse_style()
  if @property['style'] then
    properties = get_style_properties(@property['style']) 

    #h = Hash[*properties.join(';').split(';')]
    properties.each do |name, value|
      @style_property[name] = value if @style_property.has_key? name
    end

  end
end

#render_elementObject



57
58
59
60
61
# File 'lib/render_svg3.rb', line 57

def render_element()
  #parse_style()
  properties = yield
  @@shape.draw @type, properties
end

#scaleObject



49
# File 'lib/render_svg3.rb', line 49

def scale()    @@scale  end

#scale=(val) ⇒ Object



48
# File 'lib/render_svg3.rb', line 48

def scale=(val);    @@scale = val;  end

#textObject



44
45
46
# File 'lib/render_svg3.rb', line 44

def text()
  @text
end

#text=(val) ⇒ Object



40
41
42
# File 'lib/render_svg3.rb', line 40

def text=(val)
  @text = val
end

#x_offsetObject



52
# File 'lib/render_svg3.rb', line 52

def x_offset();    @@x_offset;  end

#x_offset=(val) ⇒ Object



51
# File 'lib/render_svg3.rb', line 51

def x_offset=(val);    @@x_offset = val;  end

#y_offsetObject



55
# File 'lib/render_svg3.rb', line 55

def y_offset();    @@y_offset;  end

#y_offset=(val) ⇒ Object



54
# File 'lib/render_svg3.rb', line 54

def y_offset=(val);    @@y_offset = val;  end