예제 #1
0
 public void selectionChanged(SelectionEvent e) {
   int act = e.getAction();
   if (act == SelectionEvent.ACTION_ADDED) {
     Set<AppearancePort> ports = shouldShowPopup(e.getAffected());
     if (ports == null) {
       hideCurrentPopup();
     } else {
       showPopup(ports);
     }
   }
 }
예제 #2
0
  private void showPopup(Set<AppearancePort> portObjects) {
    dragStart = null;
    CircuitState circuitState = canvas.getCircuitState();
    if (circuitState == null) return;
    ArrayList<Instance> ports = new ArrayList<Instance>(portObjects.size());
    for (AppearancePort portObject : portObjects) {
      ports.add(portObject.getPin());
    }

    hideCurrentPopup();
    LayoutThumbnail layout = new LayoutThumbnail();
    layout.setCircuit(circuitState, ports);
    JViewport owner = canvasPane.getViewport();
    Point ownerLoc = owner.getLocationOnScreen();
    Dimension ownerDim = owner.getSize();
    Dimension layoutDim = layout.getPreferredSize();
    int x = ownerLoc.x + Math.max(0, ownerDim.width - layoutDim.width - 5);
    int y = ownerLoc.y + Math.max(0, ownerDim.height - layoutDim.height - 5);
    PopupFactory factory = PopupFactory.getSharedInstance();
    Popup popup = factory.getPopup(canvasPane.getViewport(), layout, x, y);
    popup.show();
    curPopup = popup;
    curPopupTime = System.currentTimeMillis();
  }
예제 #3
0
 public void mouseDragged(MouseEvent e) {
   Location start = dragStart;
   if (start != null && start.manhattanDistanceTo(e.getX(), e.getY()) > 4) {
     hideCurrentPopup();
   }
 }
예제 #4
0
 public void mousePressed(MouseEvent e) {
   long sincePopup = System.currentTimeMillis() - curPopupTime;
   if (sincePopup > 50) hideCurrentPopup();
   dragStart = Location.create(e.getX(), e.getY());
 }
예제 #5
0
 public void mouseExited(MouseEvent e) {
   long sincePopup = System.currentTimeMillis() - curPopupTime;
   if (sincePopup > 50) hideCurrentPopup();
 }
예제 #6
0
 public void mouseEntered(MouseEvent e) {
   hideCurrentPopup();
 }
예제 #7
0
 private void hidePopup() {
   LayoutPopupManager man = popupManager;
   if (man != null) {
     man.hideCurrentPopup();
   }
 }