diff -r e2c86ae158cf -r fa28f1071bd6 graph_displayer_canvas-node.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/graph_displayer_canvas-node.cc Fri Jun 24 18:16:12 2005 +0000 @@ -0,0 +1,175 @@ +#include +#include +#include + + +int GraphDisplayerCanvas::changeNodeRadius (std::string mapname, Graph::Node node) +{ + if(node==INVALID) + { + for (NodeIt i(g); i!=INVALID; ++i) + { + int w=(int)(*(mapstorage.nodemap_storage)[mapname])[i]; + if(w>=0) + { + double x1, y1, x2, y2; + nodesmap[i]->get_bounds(x1, y1, x2, y2); + nodesmap[i]->property_x1().set_value((x1+x2)/2-w); + nodesmap[i]->property_x2().set_value((x1+x2)/2+w); + nodesmap[i]->property_y1().set_value((y1+y2)/2-w); + nodesmap[i]->property_y2().set_value((y1+y2)/2+w); + } + } + } + else + { + int w=(int)(*(mapstorage.nodemap_storage)[mapname])[node]; + if(w>=0) + { + double x1, y1, x2, y2; + nodesmap[node]->get_bounds(x1, y1, x2, y2); + nodesmap[node]->property_x1().set_value((x1+x2)/2-w); + nodesmap[node]->property_x2().set_value((x1+x2)/2+w); + nodesmap[node]->property_y1().set_value((y1+y2)/2-w); + nodesmap[node]->property_y2().set_value((y1+y2)/2+w); + } + } + return 0; +}; + +int GraphDisplayerCanvas::changeNodeColor (std::string mapname, Graph::Node node) +{ + + //function maps the range of the maximum and + //the minimum of the nodemap to the range of + //green in RGB + + if(node==INVALID) + { + + for (NodeIt i(g); i!=INVALID; ++i) + { + double w=(*(mapstorage.nodemap_storage)[mapname])[i]; + double max=mapstorage.maxOfNodeMap(mapname); + double min=mapstorage.minOfNodeMap(mapname); + + //std::cout<property_fill_color_gdk().set_value(color); + } + } + else + { + double w=(*(mapstorage.nodemap_storage)[mapname])[node]; + double max=mapstorage.maxOfNodeMap(mapname); + double min=mapstorage.minOfNodeMap(mapname); + + //std::cout<property_fill_color_gdk().set_value(color); + } + return 0; +}; + +int GraphDisplayerCanvas::changeNodeText (std::string mapname, Graph::Node node) +{ + + //the number in the map will be written on the node + //EXCEPT when the name of the map is Text, because + //in that case empty string will be written, because + //that is the deleter map + //\todo isn't it a bit woodcutter? + + if(node==INVALID) + { + for (NodeIt i(g); i!=INVALID; ++i) + { + if(mapname!=node_property_strings[N_TEXT]) + { + double number=(*(mapstorage.nodemap_storage)[mapname])[i]; + int length=1; + //if number is smaller than one, length would be negative, or invalid + if(number>=1) + { + length=(int)(floor(log(number)/log(10)))+1; + } + int maxpos=(int)(pow(10,length-1)); + int strl=length+1+RANGE; + char * str=new char[strl]; + str[length]='.'; + str[strl]='\0'; + + for(int j=0;jproperty_text().set_value(str); + } + else + { + nodetextmap[i]->property_text().set_value(""); + } + } + } + else + { + if(mapname!=node_property_strings[N_TEXT]) + { + double number=(*(mapstorage.nodemap_storage)[mapname])[node]; + int length=1; + //if number is smaller than one, length would be negative, or invalid + if(number>=1) + { + length=(int)(floor(log(number)/log(10)))+1; + } + int maxpos=(int)(pow(10,length-1)); + int strl=length+1+RANGE; + char * str=new char[strl]; + str[length]='.'; + str[strl]='\0'; + + for(int j=0;jproperty_text().set_value(str); + } + else + { + nodetextmap[node]->property_text().set_value(""); + } + } + return 0; +};