Пример #1
0
 private void move(ASDEditNode eNode, MouseEvent e) {
   eNode.getContext().remove(eNode);
   eNode.getContext().add(eNode, 0);
   int newX = eNode.getX() + e.getX();
   int newY = eNode.getY() + e.getY();
   eNode.setLocation(newX, newY);
   // inherited from java.awt.Component
   ASDGrammarNode gNode = eNode.getGrammarNode();
   gNode.setXCoordinate((short) newX);
   gNode.setYCoordinate((short) newY);
   RightLabel rightLabel = eNode.getRightLabel();
   if (rightLabel != null) {
     eNode.getContext().remove(rightLabel);
     eNode.getContext().add(rightLabel, 0);
     rightLabel.setLocation(
         newX + eNode.getWidth() + RightLabel.SEPARATION, newY + eNode.getInsets().top);
   }
   ASDDigraphNode dNode = eNode.getDigraphNode();
   Iterator it;
   for (it = dNode.getInEdges().iterator(); it.hasNext(); )
     ((ASDDigraphEdge) it.next()).getEditEdge().setDefaultCoordinates();
   for (it = dNode.getOutEdges().iterator(); it.hasNext(); )
     ((ASDDigraphEdge) it.next()).getEditEdge().setDefaultCoordinates();
 }
Пример #2
0
 public void mouseDragged(MouseEvent e) {
   if (!e.isShiftDown()) // normal drag
   move(this, e);
   else // drag entire connected component
   {
     ArrayList connectedNodes = dNode.connectedNodes();
     if (connectedNodes.size() == 0) move(this, e);
     else
       for (Iterator it = connectedNodes.iterator(); it.hasNext(); ) {
         ASDDigraphNode dNode2 = (ASDDigraphNode) it.next();
         ASDEditNode eNode2 = dNode2.getEditNode();
         move(eNode2, e);
       }
   }
   getEditor().setGrammarChanged(true);
   getContext().repaint();
 }
Пример #3
0
 public void mousePressed(MouseEvent e) { // needed for MouseListener interface
   if (e.isControlDown()) getEditor().toggleListSelected();
   //      mouseLeftButtonDown = true;
   getEditor().nodeSelected(this);
 }