Ejemplo n.º 1
0
 public void mouseReleased(MouseEvent e) {
   if (ltool.isEnabled()) {
     if (endComponent instanceof GigEDescriptor)
       endComponent = ((GigEDescriptor) endComponent).getUnlinkedPort();
     if (!ltool.addLink(linkGraphic, endComponent)) {
       ExpCoordinator.print(
           new String(
               "LinkTool.ComponentListener::mouseReleased from "
                   + startComponent.getLabel()
                   + " cancelled"),
           TEST_ADD);
       if (ltool.isVirtualTopology())
         ltool
             .expCoordinator
             .getCurrentExp()
             .getVirtualTopology()
             .getTopologyPanel()
             .removeLink(linkGraphic);
       else ExpCoordinator.getMainWindow().getTopologyPanel().removeLink(linkGraphic);
     }
     startComponent = null;
     endComponent = null;
     linkGraphic = null;
     ltool.setEnabled(false);
   }
 }
Ejemplo n.º 2
0
 public void mousePressed(MouseEvent e) {
   if (ltool.isEnabled()) {
     startComponent = ((ONLComponentButton) e.getSource()).getONLComponent();
     if (startComponent instanceof GigEDescriptor) {
       ExpCoordinator.print(
           new String(
               "LinkTool.ComponentListener.mousePressed gige startComponent:"
                   + startComponent.getLabel()),
           TEST_GIGE);
       startComponent = ((GigEDescriptor) startComponent).getUnlinkedPort();
       if (startComponent != null)
         ExpCoordinator.print(
             new String("  unlinked port: " + startComponent.getLabel()), TEST_GIGE);
       else ExpCoordinator.print("  unlinked port: null", TEST_GIGE);
     }
     if (startComponent instanceof HardwareHost)
       startComponent = ((HardwareHost) startComponent).getPort(0);
     endComponent = null;
     if (startComponent.isLinkable() && (!startComponent.isLinked())) {
       LinkDescriptor ld =
           ltool.createLinkDescriptor(
               startComponent); // new LinkDescriptor(ltool.getNextLabel(), startComponent,
                                // ltool.currentBW, ltool.expCoordinator);
       linkGraphic = (LinkGraphic) ld.getGraphic();
       if (linkGraphic.getONLComponent() == null)
         ExpCoordinator.print("LinkTool.ComponentListener::mousePressed onlcomp == null", 2);
       // linkGraphic = new LinkGraphic();
       // linkGraphic.setPoint1(startComponent.getGraphic());
       linkGraphic.setVisible(true);
       ltool
           .getTopologyPanel()
           .addLink(linkGraphic); // expCoordinator.getMainWindow().getTopologyPanel()
       // System.out.println("LinkTool.ComponentListener::mousePressed component " +
       // startComponent.getLabel());
       setIntermediate(
           e.getPoint(), ((ONLComponentButton) e.getSource()).getONLComponent().getGraphic());
     } else {
       ExpCoordinator.print(
           new String(
               "LinkTool::mousePressed startComponent "
                   + startComponent.getLabel()
                   + " is Linked"),
           2);
       startComponent = null;
       ltool.setEnabled(false);
     }
   }
 }
Ejemplo n.º 3
0
 public void mouseExited(MouseEvent e) {
   if (ltool.isEnabled() && startComponent != null && endComponent != null) {
     if (endComponent == ((ONLComponentButton) e.getSource()).getONLComponent())
       endComponent = null;
     // if (endComponent != null) System.out.println("LinkTool.ComponentListener::mouseEntered
     // component " + endComponent.getLabel());
   }
 }
Ejemplo n.º 4
0
 public void mouseDragged(MouseEvent e) {
   if (ltool.isEnabled()) {
     // System.out.println("LinkTool.ComponentListener::mouseDragged");
     // translate point to real coordinates since point is in relation to the source component
     setIntermediate(
         e.getPoint(), ((ONLComponentButton) e.getSource()).getONLComponent().getGraphic());
   }
 }
Ejemplo n.º 5
0
 public void mouseEntered(MouseEvent e) {
   if (ltool.isEnabled()) {
     endComponent = ((ONLComponentButton) e.getSource()).getONLComponent();
     if (endComponent instanceof HardwareHost)
       endComponent = ((HardwareHost) endComponent).getPort(0);
     // System.out.println("LinkTool.ComponentListener::mouseEntered component " +
     // endComponent.getLabel());
   }
 }
Ejemplo n.º 6
0
 public void setIntermediate(Point p, ONLGraphic c) {
   if (ltool.isEnabled()) {
     if (linkGraphic != null) {
       Point pnt = new Point(p);
       // System.out.println("LinkTool::setIntermediate (" + pnt.getX() + ", " + pnt.getY() +
       // ")");
       if (c != null) {
         // System.out.println("                         translated by (" + c.getScreenX()+ ", "
         // + c.getScreenY() + ")");
         pnt.translate(
             (c.getScreenX() + HardwareGraphic.OFFSET),
             (c.getScreenY() + HardwareGraphic.D_OFFSET));
         // System.out.println("                          (" + pnt.getX() + ", " + pnt.getY() +
         // ")");
       }
       linkGraphic.setIntermediate(pnt);
       linkGraphic.revalidate();
       linkGraphic.repaint();
     }
   }
 }