lib/rubyvis/scene/svg_panel.rb in rubyvis-0.4.1 vs lib/rubyvis/scene/svg_panel.rb in rubyvis-0.5.0
- old
+ new
@@ -1,47 +1,73 @@
module Rubyvis
module SvgScene
def self.panel(scenes)
puts " -> panel: #{scenes.inspect}" if $DEBUG
g=scenes._g
- e=(g.nil?) ? nil : g.elements[1]
+ #e=(g.nil?) ? nil : g.elements[1]
+ e=(g.nil?) ? nil : g.get_element(1)
if g
- e=g.elements[1]
+ #e=g.elements[1]
+ e=g.get_element(1)
end
scenes.each_with_index do |s,i|
next unless s.visible
if(!scenes.parent)
if g and g.parent!=s.canvas
- g=s.canvas.elements[1]
- e=(@g.nil?) ? nil : @g.elements[1]
+ #g=s.canvas.elements[1]
+ g=s.canvas.get_element(1)
+ #e=(@g.nil?) ? nil : @g.elements[1]
+ e=(@g.nil?) ? nil : @g.get_element(1)
end
if(!g)
g=s.canvas.add_element(self.create('svg'))
- g.attributes["font-size"]="10px"
- g.attributes["font-family"]="sans-serif"
- g.attributes["fill"]="none"
- g.attributes["stroke"]="none"
- g.attributes["stroke-width"]=1.5
- e=g.elements[1]
+ g.set_attributes(
+ {
+ 'font-size'=>"10px",
+ 'font-family'=>'sans-serif',
+ 'fill'=>'none',
+ 'stroke'=>'none',
+ 'stroke-width'=>1.5
+ }
+ )
+ e=g.get_element(1)
+ # g.attributes["font-size"]="10px"
+ # g.attributes["font-family"]="sans-serif"
+ # g.attributes["fill"]="none"
+ # g.attributes["stroke"]="none"
+ # g.attributes["stroke-width"]=1.5
+ # e=g.elements[1]
end
scenes._g=g
#p s
- g.attributes['width']=s.width+s.left+s.right
- g.attributes['height']=s.height+s.top+s.bottom
+ g.set_attributes({
+ 'width'=>s.width+s.left+s.right,
+ 'height'=>s.height+s.top+s.bottom
+ })
+ #g.attributes['width']=s.width+s.left+s.right
+ #g.attributes['height']=s.height+s.top+s.bottom
end
if s.overflow=='hidden'
id=Rubyvis.id.to_s(36)
c=self.expect(e,'g',{'clip-path'=>'url(#'+id+')'});
g.add_element(c) if(!c.parent)
scenes._g=g=c
- e=c.elements[1]
+ #e=c.elements[1]
+ e=c.get_element(1)
e=self.expect(e,'clipPath',{'id'=>id})
- r=(e.elements[1]) ? e.elements[1] : e.add_element(self.create('rect'))
- r.attributes['x']=s.left
- r.attributes['y']=s.top
- r.attributes['width']=s.width
- r.attributes['height']=s.height
+ #r=(e.elements[1]) ? e.elements[1] : e.add_element(self.create('rect'))
+ r=(e.get_element(1)) ? e.get_element(1) : e.add_element(self.create('rect'))
+ r.set_attributes({
+ 'x'=>s.left,
+ 'y'=>s.top,
+ 'width'=>s.width,
+ 'height'=>s.height
+ })
+ #r.attributes['x']=s.left
+ #r.attributes['y']=s.top
+ #r.attributes['width']=s.width
+ #r.attributes['height']=s.height
g.add_element(e) if !e.parent
e=e.next_sibling_node
end
# fill