Class: RXaal::Style

Inherits:
XaalElement show all
Includes:
Serializable, StyleMod
Defined in:
lib/style.rb

Instance Attribute Summary collapse

Attributes inherited from XaalElement

#doc, #id, #refs

Instance Method Summary collapse

Methods included from StyleMod

included

Methods inherited from XaalElement

#add_attribute, #add_ref, get_new_default_id, modify_ref, #rm_ref, #superclass_serialize

Constructor Details

#initialize(doc, id = nil, uses_style = nil) ⇒ Style

Returns a new instance of Style.



10
11
12
13
# File 'lib/style.rb', line 10

def initialize (doc, id = nil, uses_style = nil)      
  super(doc, id)
  @uses = uses_style
end

Instance Attribute Details

#colorObject

Returns the value of attribute color.



6
7
8
# File 'lib/style.rb', line 6

def color
  @color
end

#fill_colorObject

Returns the value of attribute fill_color.



6
7
8
# File 'lib/style.rb', line 6

def fill_color
  @fill_color
end

Instance Method Details

#font_familyObject



30
31
32
33
34
35
# File 'lib/style.rb', line 30

def font_family
  if font != nil
    return font.family
  end
  return nil
end

#font_family=(_fam) ⇒ Object



37
38
39
40
41
42
43
# File 'lib/style.rb', line 37

def font_family=(_fam)
  if @font == nil
    @font.new(@doc)
  end
  
  @font.family = _fam
end

#font_sizeObject



15
16
17
18
19
20
# File 'lib/style.rb', line 15

def font_size
  if font != nil
    return font.size
  end
  return nil
end

#font_size=(_size) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/style.rb', line 22

def font_size=(_size)
  if @font == nil
    @font.new(@doc)
  end
  
  @font.size = _size
end

#stroke_typeObject



45
46
47
48
49
50
# File 'lib/style.rb', line 45

def stroke_type
  if stroke != nil
    return stroke.type
  end
  return nil
end

#stroke_type=(_type) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/style.rb', line 52

def stroke_type=(_type)
  if @stroke == nil
    @stroke.new(@doc)
  end
  
  @stroke.type = _type
end

#stroke_widthObject



60
61
62
63
64
65
# File 'lib/style.rb', line 60

def stroke_width
   if stroke != nil
    return stroke.width
  end
  return nil
end

#stroke_width=(_width) ⇒ Object



67
68
69
70
71
72
73
# File 'lib/style.rb', line 67

def stroke_width=(_width)
  if @stroke == nil
    @stroke.new(@doc)
  end
  
  @stroke.width = _width
end

#xaal_serialize(parent) ⇒ Object

TODO: this doesn’t really do anything with uses yet



76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/style.rb', line 76

def xaal_serialize(parent)
  style = REXML::Element.new "style"
  parent.elements << style
  
  [:color, :fill_color, :font, :stroke].each { |c|
    t = self.send(c)
    if t != nil
      t.xaal_serialize(style)  
    end
    
  }
  
  superclass_serialize(style)
end