Esempio n. 1
0
 ASDEditNode(ASDGrammarNode grammarNode, Container given) {
   super(" " + grammarNode.word() + " " + grammarNode.instance() + " ");
   gNode = grammarNode;
   context = given;
   addMouseListener((MouseListener) this);
   popupListener = new PopupListener(new EditNodeMenu(this));
   addMouseListener(popupListener);
   addChangeListener((ChangeListener) this);
   addMouseMotionListener((MouseMotionListener) this);
   if (grammarNode.isInitial()) {
     setBackground(Color.yellow);
     setBorder(BorderFactory.createLineBorder(Color.yellow, 1));
     //  two pixels wide
   } else {
     setBackground(Color.white);
     setBorder(BorderFactory.createLineBorder(Color.black, 1));
   }
   if (grammarNode.isFinal()) initializeRightLabel(grammarNode.phraseType());
 }
Esempio n. 2
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();
 }