Method: NodeNetworkView#setup_ellipse

Defined in:
lib/gui/node_network_view.rb

#setup_ellipse(root, status, icon_file, label) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/gui/node_network_view.rb', line 3

def setup_ellipse(root, status, icon_file, label)

      node_size = get_node_size()
      @group = Goo::CanvasGroup.new(root,{:x => 0.0,:y => 0.0, :can_focus => true})
  @group.visibility = Goo::CanvasItem::HIDDEN
  @icon=Goo::CanvasEllipse.new(@group, node.x+node_size/2, node.y+node_size/2,
                                          node_size/2, node_size/2,
                                          :fill_color_rgba => status,
                                          :stroke_color => "black",
                                          :line_width => 1.0)
  if (icon_file == nil) || (!FileTest.exist?(icon_file))
icon_file="#{PIXMAP_PATH}/unknown.png"
  end
  @image=nil
  if FileTest.exist?(icon_file)
im=Gdk::Pixbuf.new(icon_file)
#the network type icon
@image=Goo::CanvasImage.new(@group, im, @icon.x1, @icon.y1,
                                    :width => node_size*80/100.0,
                                    :height => node_size*80/100.0,
                  :can_focus => false,
          :scale_to_fit => true
          )
          
@image.x= @icon.x1+(node_size/2.0)-@image.width/2.0
@image.y= @icon.y1+(node_size/2.0)-@image.height/2.0
  else 
puts "Could not find img #{icon_file}"
  end
      #box for the network label background, pos will be fixed by resize method
  cl = Integer("0x#{rgb_to_hex_color(Gdk::Color.new($config.label_bg[0],$config.label_bg[1],$config.label_bg[2]))}ff")
  @bg_text=Goo::CanvasRect.new(@group,@icon.x1-3*label.size/2, @icon.y2+node_size/5-5,
                                       node_size+3*label.size, 
       node_size/5+5,
       :fill_color_rgba => cl,
       :stroke_color_rgba => cl,
                                       :line_width => 1.0)
       
 #the label, pos will be fixed by resize method
 @text=Goo::CanvasText.new(@group, label, @icon.x1+node_size/2, @icon.y2+2+node_size/5, 0, 
                        Gtk::ANCHOR_CENTER, 
    :fill_color_rgba => Integer("0x#{rgb_to_hex_color(Gdk::Color.new($config.label_text[0],$config.label_text[1],$config.label_text[2]))}ff"), 
    :font => "Sans 8")

  setup_item(@group)
  #set_tooltips()
end