def add_popup( x, y, label )
txt_width = label.length * font_size * 0.6 + 10
tx = (x+txt_width > width ? x-5 : x+5)
t = @foreground.add_element( "text", {
"x" => tx.to_s,
"y" => (y - font_size).to_s,
"visibility" => "hidden",
})
t.attributes["style"] = "fill: #000; "+
(x+txt_width > width ? "text-anchor: end;" : "text-anchor: start;")
t.text = label.to_s
t.attributes["id"] = t.object_id.to_s
@foreground.add_element( "circle", {
"cx" => x.to_s,
"cy" => y.to_s,
"r" => "10",
"style" => "opacity: 0",
"onmouseover" =>
"document.getElementById(#{t.object_id}).setAttribute('visibility', 'visible' )",
"onmouseout" =>
"document.getElementById(#{t.object_id}).setAttribute('visibility', 'hidden' )",
})
end