Exemplo n.º 1
0
Autolayout::Graph  * Autolayout::AutolayouterAdapter::setGraph( UMLView * view )
  {
  if (! view) return 0;
  Autolayout::Graph * g=getGraph();
  if (g&&g->empty())
    {
    UMLWidgetList list = view->getWidgetList();
    UMLWidget* widget;
    for ( widget = list.first(); widget; widget= list.next() )
      {
      if (widget->getBaseType() == Uml::wt_Class)
        {


        g->addNode(widget->getID().c_str(),widget->getWidth(),
                   widget->getHeight());
        }
      }
    AssociationWidgetList as_list=view->getAssociationList();
    AssociationWidget* assoc;
    AssociationWidgetListIt it(as_list);
    while ( (assoc = it.current()) != 0 )
      {
      ++it;
      addRelationship(assoc);
      }
    }
  return g;
  }
Exemplo n.º 2
0
void Autolayout::AutolayouterAdapter::updateView( UMLView* view )
  {
if (! view) return ;
UMLWidgetList list = view->getWidgetList();
  UMLWidget* widget;
  Graph *g=getGraph();
  if (! view||!g)  return ;
  for ( widget = list.first(); widget; widget= list.next() )
    if (widget->getBaseType() == Uml::wt_Class)
      {
      Node* n =g->getNode(widget->getID().c_str());
      //printf("old values widgets %s x,y:%d,%d\n",widget->getID().c_str(),widget->getX(),widget->getY());
      //int x_old=widget->getX();
      //int x_calc=n.getX();
      //int x_calc2=30 +n.getX()-widget->getWidth()/2;
      widget->setX(getCanvas()->getBaseX() +n->getX()-widget->getWidth()/2);
      //int x=widget->getX();
      widget->setY(getCanvas()->getMaxY()/2-(n->getY()+(widget->getHeight()/2)));

      widget->updateWidget();

      }
  }