1 #include <graph_displayer_canvas.h>
2 #include <broken_edge.h>
6 int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Graph::Node node)
10 for (NodeIt i(g); i!=INVALID; ++i)
12 int w=(int)(*(mapstorage.nodemap_storage)[mapname])[i];
15 double x1, y1, x2, y2;
16 nodesmap[i]->get_bounds(x1, y1, x2, y2);
17 nodesmap[i]->property_x1().set_value((x1+x2)/2-w);
18 nodesmap[i]->property_x2().set_value((x1+x2)/2+w);
19 nodesmap[i]->property_y1().set_value((y1+y2)/2-w);
20 nodesmap[i]->property_y2().set_value((y1+y2)/2+w);
26 int w=(int)(*(mapstorage.nodemap_storage)[mapname])[node];
29 double x1, y1, x2, y2;
30 nodesmap[node]->get_bounds(x1, y1, x2, y2);
31 nodesmap[node]->property_x1().set_value((x1+x2)/2-w);
32 nodesmap[node]->property_x2().set_value((x1+x2)/2+w);
33 nodesmap[node]->property_y1().set_value((y1+y2)/2-w);
34 nodesmap[node]->property_y2().set_value((y1+y2)/2+w);
40 int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Graph::Node node)
43 //function maps the range of the maximum and
44 //the minimum of the nodemap to the range of
50 for (NodeIt i(g); i!=INVALID; ++i)
52 double w=(*(mapstorage.nodemap_storage)[mapname])[i];
53 double max=mapstorage.maxOfNodeMap(mapname);
54 double min=mapstorage.minOfNodeMap(mapname);
56 //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl;
60 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
64 color.set_rgb_p (0, 0, 100);
67 nodesmap[i]->property_fill_color_gdk().set_value(color);
72 double w=(*(mapstorage.nodemap_storage)[mapname])[node];
73 double max=mapstorage.maxOfNodeMap(mapname);
74 double min=mapstorage.minOfNodeMap(mapname);
76 //std::cout<<w<<" "<<max<<" "<<min<<" "<<100*(w-min)/(max-min)<<std::endl;
80 color.set_rgb_p (0, 0, 100*(w-min)/(max-min));
84 color.set_rgb_p (0, 0, 100);
87 nodesmap[node]->property_fill_color_gdk().set_value(color);
92 int GraphDisplayerCanvas::changeNodeText (std::string mapname, Graph::Node node)
95 //the number in the map will be written on the node
96 //EXCEPT when the name of the map is Text, because
97 //in that case empty string will be written, because
98 //that is the deleter map
99 //\todo isn't it a bit woodcutter?
103 for (NodeIt i(g); i!=INVALID; ++i)
105 if(mapname!=node_property_strings[N_TEXT])
107 double number=(*(mapstorage.nodemap_storage)[mapname])[i];
109 //if number is smaller than one, length would be negative, or invalid
112 length=(int)(floor(log(number)/log(10)))+1;
114 int maxpos=(int)(pow(10,length-1));
115 int strl=length+1+RANGE;
116 char * str=new char[strl];
120 for(int j=0;j<strl;j++)
124 int digit=(int)(number/maxpos);
126 number-=digit*maxpos;
131 nodetextmap[i]->property_text().set_value(str);
135 nodetextmap[i]->property_text().set_value("");
141 if(mapname!=node_property_strings[N_TEXT])
143 double number=(*(mapstorage.nodemap_storage)[mapname])[node];
145 //if number is smaller than one, length would be negative, or invalid
148 length=(int)(floor(log(number)/log(10)))+1;
150 int maxpos=(int)(pow(10,length-1));
151 int strl=length+1+RANGE;
152 char * str=new char[strl];
156 for(int j=0;j<strl;j++)
160 int digit=(int)(number/maxpos);
162 number-=digit*maxpos;
167 nodetextmap[node]->property_text().set_value(str);
171 nodetextmap[node]->property_text().set_value("");