Index: graph_displayer_canvas-event.cc
===================================================================
--- graph_displayer_canvas-event.cc	(revision 153)
+++ graph_displayer_canvas-event.cc	(revision 160)
@@ -82,9 +82,9 @@
   static Gnome::Canvas::Text *coord_text = 0;
   switch(e->type)
-  {
+    {
     case GDK_BUTTON_PRESS:
       //we mark the location of the event to be able to calculate parameters of dragging
       window_to_world (e->button.x, e->button.y, clicked_x, clicked_y);
-
+      
       active_item=(get_item_at(clicked_x, clicked_y));
       active_node=INVALID;
@@ -100,8 +100,8 @@
     case GDK_BUTTON_RELEASE:
       if (coord_text)
-      {
-        delete coord_text;
-        coord_text = 0;
-      }
+	{
+	  delete coord_text;
+	  coord_text = 0;
+	}
       isbutton=0;
       active_item=NULL;
@@ -111,120 +111,57 @@
       //we only have to do sg. if the mouse button is pressed AND the click was on a node that was found in the set of nodes
       if(active_node!=INVALID)
-      {
-        (mytab.mapstorage).modified = true;
-
-	//new coordinates will be the old values,
-	//because the item will be moved to the
-	//new coordinate therefore the new movement
-	//has to be calculated from here
-
-	double new_x, new_y;
-
-	window_to_world (e->motion.x, e->motion.y, new_x, new_y);
-
-        double dx=new_x-clicked_x;
-        double dy=new_y-clicked_y;
-
-	//repositioning node and its text
-        active_item->move(dx, dy);
-	nodetextmap[active_node]->move(dx, dy);
-
-        // the new coordinates of the centre of the node 
-        double coord_x = new_x - (clicked_x - (mytab.mapstorage).coords[active_node].x);
-        double coord_y = new_y - (clicked_y - (mytab.mapstorage).coords[active_node].y);
-
-        // write back the new coordinates to the coords map
-        (mytab.mapstorage).coords.set(active_node, XY(coord_x, coord_y));
-
-        clicked_x=new_x;
-        clicked_y=new_y;
-
-        // reposition the coordinates text
-        std::ostringstream ostr;
-        ostr << "(" <<
-          (mytab.mapstorage).coords[active_node].x << ", " <<
-          (mytab.mapstorage).coords[active_node].y << ")";
-        double radius =
-          (nodesmap[active_node]->property_x2().get_value() -
-          nodesmap[active_node]->property_x1().get_value()) / 2.0;
-        if (coord_text)
-        {
-          coord_text->property_text().set_value(ostr.str());
-          coord_text->property_x().set_value((mytab.mapstorage).coords[active_node].x +
-              radius);
-          coord_text->property_y().set_value((mytab.mapstorage).coords[active_node].y -
-              radius);
-        }
-        else
-        {
-          coord_text = new Gnome::Canvas::Text(
-              displayed_graph,
-              (mytab.mapstorage).coords[active_node].x + radius,
-              (mytab.mapstorage).coords[active_node].y - radius,
-              ostr.str());
-          coord_text->property_fill_color().set_value("black");
-          coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
-        }
-
-	//all the edges connected to the moved point has to be redrawn
-        for(OutEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei)
-        {
-          XY arrow_pos;
-
-          if (mytab.mapstorage.graph.source(ei) == mytab.mapstorage.graph.target(ei))
-          {
-            arrow_pos = mytab.mapstorage.arrow_pos[ei] + XY(dx, dy);
-          }
-          else
-          {
-            XY moved_node_1(coord_x - dx, coord_y - dy);
-            XY moved_node_2(coord_x, coord_y);
-            Node target = mytab.mapstorage.graph.target(ei);
-            XY fix_node(mytab.mapstorage.coords[target].x,
-                mytab.mapstorage.coords[target].y);
-            XY old_arrow_pos(mytab.mapstorage.arrow_pos[ei]);
-
-            arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
-          }
-
-          mytab.mapstorage.arrow_pos.set(ei, arrow_pos);
-          edgesmap[ei]->draw();
-
-          //reposition of edgetext
-          XY text_pos=mytab.mapstorage.arrow_pos[ei];
-          text_pos+=(XY(10,10));
-          edgetextmap[ei]->property_x().set_value(text_pos.x);
-          edgetextmap[ei]->property_y().set_value(text_pos.y);
-        }
-
-        for(InEdgeIt ei((mytab.mapstorage).graph,active_node);ei!=INVALID;++ei)
-        {
-          if (mytab.mapstorage.graph.source(ei) != mytab.mapstorage.graph.target(ei))
-          {
-            XY moved_node_1(coord_x - dx, coord_y - dy);
-            XY moved_node_2(coord_x, coord_y);
-            Node source = mytab.mapstorage.graph.source(ei);
-            XY fix_node(mytab.mapstorage.coords[source].x,
-                mytab.mapstorage.coords[source].y);
-            XY old_arrow_pos(mytab.mapstorage.arrow_pos[ei]);
-
-            XY arrow_pos;
-            arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
-
-            mytab.mapstorage.arrow_pos.set(ei, arrow_pos);
-            edgesmap[ei]->draw();
-
-            //reposition of edgetext
-            XY text_pos=mytab.mapstorage.arrow_pos[ei];
-            text_pos+=(XY(10,10));
-            edgetextmap[ei]->property_x().set_value(text_pos.x);
-            edgetextmap[ei]->property_y().set_value(text_pos.y);
-          }
-        }
-      }
+	{
+	  (mytab.mapstorage).modified = true;
+	  
+	  //new coordinates will be the old values,
+	  //because the item will be moved to the
+	  //new coordinate therefore the new movement
+	  //has to be calculated from here
+	  
+	  double new_x, new_y;
+	  
+	  window_to_world (e->motion.x, e->motion.y, new_x, new_y);
+	  
+	  double dx=new_x-clicked_x;
+	  double dy=new_y-clicked_y;
+	  
+	  moveNode(dx, dy);
+
+	  clicked_x=new_x;
+	  clicked_y=new_y;
+
+	  // reposition the coordinates text
+	  std::ostringstream ostr;
+	  ostr << "(" <<
+	    (mytab.mapstorage).coords[active_node].x << ", " <<
+	    (mytab.mapstorage).coords[active_node].y << ")";
+	  double radius =
+	    (nodesmap[active_node]->property_x2().get_value() -
+	     nodesmap[active_node]->property_x1().get_value()) / 2.0;
+	  if (coord_text)
+	    {
+	      coord_text->property_text().set_value(ostr.str());
+	      coord_text->property_x().set_value((mytab.mapstorage).coords[active_node].x +
+						 radius);
+	      coord_text->property_y().set_value((mytab.mapstorage).coords[active_node].y -
+						 radius);
+	    }
+	  else
+	    {
+	      coord_text = new Gnome::Canvas::Text(
+						   displayed_graph,
+						   (mytab.mapstorage).coords[active_node].x + radius,
+						   (mytab.mapstorage).coords[active_node].y - radius,
+						   ostr.str());
+	      coord_text->property_fill_color().set_value("black");
+	      coord_text->property_anchor().set_value(Gtk::ANCHOR_SOUTH_WEST);
+	    }
+
+
+	}
     default: break;
-  }
-
-  return false;
+    }
+
+return false;
 }
 
@@ -824,13 +761,96 @@
   }
   else
-  {
-    if(forming_edge!=INVALID)
-    {
-      forming_edge=INVALID;
-    }
-    else
-    {
-      std::cerr << "ERROR!!!! Invalid edge found!" << std::endl;
-    }
-  }
-}
+    {
+      if(forming_edge!=INVALID)
+	{
+	  forming_edge=INVALID;
+	}
+      else
+	{
+	  std::cerr << "ERROR!!!! Invalid edge found!" << std::endl;
+	}
+    }
+}
+
+void GraphDisplayerCanvas::moveNode(double dx, double dy, Gnome::Canvas::Item * item, Node node)
+{
+  Gnome::Canvas::Item * moved_item=item;
+  Node moved_node=node;
+
+  if(item==NULL && node==INVALID)
+    {
+      moved_item=active_item;
+      moved_node=active_node;
+    }
+  else
+    {
+      isbutton=1;
+    }
+
+  //repositioning node and its text
+  moved_item->move(dx, dy);
+  nodetextmap[moved_node]->move(dx, dy);
+
+  // the new coordinates of the centre of the node 
+  double coord_x = dx + (mytab.mapstorage).coords[moved_node].x;
+  double coord_y = dy + (mytab.mapstorage).coords[moved_node].y;
+
+  // write back the new coordinates to the coords map
+  (mytab.mapstorage).coords.set(moved_node, XY(coord_x, coord_y));
+
+  //all the edges connected to the moved point has to be redrawn
+  for(OutEdgeIt ei((mytab.mapstorage).graph,moved_node);ei!=INVALID;++ei)
+    {
+      XY arrow_pos;
+
+      if (mytab.mapstorage.graph.source(ei) == mytab.mapstorage.graph.target(ei))
+	{
+	  arrow_pos = mytab.mapstorage.arrow_pos[ei] + XY(dx, dy);
+	}
+      else
+	{
+	  XY moved_node_1(coord_x - dx, coord_y - dy);
+	  XY moved_node_2(coord_x, coord_y);
+	  Node target = mytab.mapstorage.graph.target(ei);
+	  XY fix_node(mytab.mapstorage.coords[target].x,
+		      mytab.mapstorage.coords[target].y);
+	  XY old_arrow_pos(mytab.mapstorage.arrow_pos[ei]);
+
+	  arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
+	}
+
+      mytab.mapstorage.arrow_pos.set(ei, arrow_pos);
+      edgesmap[ei]->draw();
+
+      //reposition of edgetext
+      XY text_pos=mytab.mapstorage.arrow_pos[ei];
+      text_pos+=(XY(10,10));
+      edgetextmap[ei]->property_x().set_value(text_pos.x);
+      edgetextmap[ei]->property_y().set_value(text_pos.y);
+    }
+
+  for(InEdgeIt ei((mytab.mapstorage).graph,moved_node);ei!=INVALID;++ei)
+    {
+      if (mytab.mapstorage.graph.source(ei) != mytab.mapstorage.graph.target(ei))
+	{
+	  XY moved_node_1(coord_x - dx, coord_y - dy);
+	  XY moved_node_2(coord_x, coord_y);
+	  Node source = mytab.mapstorage.graph.source(ei);
+	  XY fix_node(mytab.mapstorage.coords[source].x,
+		      mytab.mapstorage.coords[source].y);
+	  XY old_arrow_pos(mytab.mapstorage.arrow_pos[ei]);
+
+	  XY arrow_pos;
+	  arrow_pos = calcArrowPos(moved_node_1, moved_node_2, fix_node, old_arrow_pos, isbutton);
+
+	  mytab.mapstorage.arrow_pos.set(ei, arrow_pos);
+	  edgesmap[ei]->draw();
+
+	  //reposition of edgetext
+	  XY text_pos=mytab.mapstorage.arrow_pos[ei];
+	  text_pos+=(XY(10,10));
+	  edgetextmap[ei]->property_x().set_value(text_pos.x);
+	  edgetextmap[ei]->property_y().set_value(text_pos.y);
+	}
+    }
+}
