Exemple #1
0
 /** This method cannot be called directly. */
 public void mousePressed(MouseEvent e) {
   synchronized (mouseLock) {
     mouseX = StdDraw.userX(e.getX());
     mouseY = StdDraw.userY(e.getY());
     mousePressed = true;
   }
 }
    public void mouseClicked(MouseEvent ev) {
      Window w = (Window) ev.getSource();
      Frame f = null;

      if (w instanceof Frame) {
        f = (Frame) w;
      } else {
        return;
      }

      Point convertedPoint = SwingUtilities.convertPoint(w, ev.getPoint(), getTitlePane());

      int state = f.getExtendedState();
      if (getTitlePane() != null && getTitlePane().contains(convertedPoint)) {
        if ((ev.getClickCount() % 2) == 0 && ((ev.getModifiers() & InputEvent.BUTTON1_MASK) != 0)) {
          if (f.isResizable()) {
            if ((state & Frame.MAXIMIZED_BOTH) != 0) {
              f.setExtendedState(state & ~Frame.MAXIMIZED_BOTH);
            } else {
              f.setExtendedState(state | Frame.MAXIMIZED_BOTH);
            }
            return;
          }
        }
      }
    }
    @Override
    protected void showPopupMenu(MouseEvent ev) {
      // first select/deselect the row:
      int iRow = tblTasks.rowAtPoint(ev.getPoint());

      // Nur, wenn nicht selektiert, selektieren:
      if (!tblTasks.isRowSelected(iRow)) {
        if ((ev.getModifiers() & MouseEvent.CTRL_MASK) != 0) {
          // Control gedr\u00fcckt:
          // Zeile zur Selektion hinzuf\u00fcgen:
          tblTasks.addRowSelectionInterval(iRow, iRow);
        } else {
          // Sonst nur diese Zeile selektieren:
          tblTasks.setRowSelectionInterval(iRow, iRow);
        }
      } // if

      // enable/disable menu items
      final int iSelectedRow = this.tblTasks.getSelectedRow();
      final TimelimitTaskTableModel model = timelimittaskview.getTimelimitTaskTableModel();
      model.getTimelimitTask(iSelectedRow);

      // todo: there should be a better place for that...
      final boolean bPerformEnabled =
          existsRelatedObjectsFor(getSelectedTimelimitTasks(timelimittaskview));
      actPerformTask.setEnabled(bPerformEnabled);
      // this.popupTimelimitTasks.miPerform.setEnabled(bPerformEnabled);

      final boolean bFinished = areTasksCompleted(getSelectedTimelimitTasks(timelimittaskview));
      this.popupTimelimitTasks.miFinish.setState(bFinished);

      super.showPopupMenu(ev);
    }
Exemple #4
0
  public void mouseReleased(java.awt.event.MouseEvent e) {
    if (e.isPopupTrigger()) {
      doPopup(e);
      return;
    }
    if (org.nlogo.awt.Mouse.hasButton1(e)) {
      java.awt.Point p = e.getPoint();
      java.awt.Rectangle rect = this.getBounds();

      p.x += rect.x;
      p.y += rect.y;

      selectionRect = null;
      glassPane.setVisible(false);

      if (newWidget != null) {
        newWidget.selected(true);
        newWidget.foreground();
        newWidget.isNew(true);
        new org.nlogo.window.Events.EditWidgetEvent(null).raise(this);
        newWidget.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR));
        newWidget.isNew(false);
        newWidget = null;
      }
    }
  }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   FinderTableModel model = getDataModel();
   ICFSecurityISOTimezoneObj o =
       (ICFSecurityISOTimezoneObj) model.getValueAt(row, COLID_ROW_HEADER);
   if (o == null) {
     return;
   }
   JInternalFrame frame = swingSchema.getISOTimezoneFactory().newViewEditJInternalFrame(o);
   ((ICFSecuritySwingISOTimezoneJPanelCommon) frame).setPanelMode(CFJPanel.PanelMode.View);
   if (frame == null) {
     return;
   }
   Container cont = getParent();
   while ((cont != null) && (!(cont instanceof JInternalFrame))) {
     cont = cont.getParent();
   }
   if (cont != null) {
     JInternalFrame myInternalFrame = (JInternalFrame) cont;
     myInternalFrame.getDesktopPane().add(frame);
     frame.setVisible(true);
     frame.show();
   }
 }
    public void mouseMoved(MouseEvent e) {
      if (geoDisplayPopup != null) {
        geoDisplayPopup.hide();
      }

      String pointMessage = "";

      x = e.getX();
      y = e.getY();
      double minDist = -1;
      if (geoPoints == null || geoPoints.size() == 0) {
        return;
      }
      for (GeoPoint p : geoPoints) {
        double dist = p.distance(x, y);
        if (minDist > dist || minDist < 0) {
          pointMessage = p.getMessage();
          minDist = dist;
        }
      }
      if (minDist > 2.5) {
        return;
      }
      geoPanel = GeoPolygonPanel.this;
      message.setText(pointMessage);
      PopupFactory factory = PopupFactory.getSharedInstance();
      geoDisplayPopup =
          factory.getPopup(
              owner,
              message,
              (int) geoPanel.getLocationOnScreen().getX() + x,
              (int) geoPanel.getLocationOnScreen().getY() + y - 15);
      geoDisplayPopup.show();
    }
 public @Override void mouseExited(MouseEvent evt) {
   Object src = evt.getSource();
   if (src instanceof AbstractButton) {
     AbstractButton button = (AbstractButton) evt.getSource();
     removeButtonContentAreaAndBorder(button);
   }
 }
 private EditorMessageIconRenderer getIconRendererUnderMouse(MouseEvent e) {
   final int mouseX = e.getX();
   final int mouseY = e.getY();
   final EditorMessageIconRenderer[] theRenderer = new EditorMessageIconRenderer[] {null};
   myLineToRenderersMap.forEachEntry(
       new TIntObjectProcedure<List<IconRendererLayoutConstraint>>() {
         @Override
         public boolean execute(int y, List<IconRendererLayoutConstraint> layoutConstraints) {
           if (y <= mouseY && mouseY <= y + myMaxIconHeight) {
             for (IconRendererLayoutConstraint constraint : layoutConstraints) {
               int x = constraint.getX();
               if (y <= mouseY
                   && mouseY <= y + constraint.getIconRenderer().getIcon().getIconHeight()
                   && x <= mouseX
                   && mouseX <= x + constraint.getIconRenderer().getIcon().getIconWidth()) {
                 theRenderer[0] = constraint.getIconRenderer();
                 return false;
               }
             }
           }
           return true;
         }
       });
   return theRenderer[0];
 }
 public void mouseDragged(MouseEvent e) {
   middleX = (int) player.getX() + (int) player.get_spr_w() / 2;
   middleY = (int) player.getY() + (int) player.get_spr_h() / 2;
   angleX = ((e.getX() - middleX)) / 100.0f;
   angleY = ((e.getY() - middleY)) / 100.0f;
   angle = Math.atan2(angleY, angleX) * 180 / 3.14;
 }
Exemple #10
0
    /**
     * Continues dragging a piece.
     *
     * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
     */
    @Override
    public void mouseDragged(MouseEvent e) {
      int x;
      int y;

      if (pieceBeingDragged == null) return;
      // Don't allow drag outside board boundaries
      int maxX = board.columnToX(board.getColumns() - 1);
      int maxY = board.rowToY(board.getRows() - 1);
      x = e.getX() - board.getCellWidth() / 2;
      if (x < 0) {
        x = 0;
      } else {
        if (x > maxX) x = maxX;
      }
      y = e.getY() - board.getCellHeight() / 2;
      if (y < 0) {
        y = 0;
      } else {
        if (y > maxY) y = maxY;
      }
      pieceBeingDragged.x = x;
      pieceBeingDragged.y = y;
      // Track mouse movement
      pieceBeingDragged.setChanged();
      pieceBeingDragged.notifyObservers();
    }
  @Override
  public void itemClicked(VisualItem item, MouseEvent e) {

    if (!filterCheck(item)
        || v != item.getVisualization()
        || !UILib.isButtonPressed(e, button)
        || e.getClickCount() != ccount) {
      return;
    }

    if (e.isControlDown()) {
      if (focusedTupleSet.containsTuple(item)) {
        focusedTupleSet.removeTuple(item);
        if (item == curFocus) {
          curFocus = null;
          Iterator<VisualItem> focusedTuples = focusedTupleSet.tuples();
          while (focusedTuples.hasNext()) {
            curFocus = focusedTuples.next();
          }
        }
      } else {
        focusedTupleSet.addTuple(item);
        curFocus = item;
      }
    } else {
      focusedTupleSet.setTuple(item);
      curFocus = item;
    }

    runActivity(v);
  }
  public void eventDispatched(AWTEvent event) {
    if (!isAssertTrigger(event)) {
      return;
    }

    MouseEvent mouse = (MouseEvent) event;

    GuiComponent guiComponent = factory.find(mouse);

    if (guiComponent == null) {
      return;
    }

    assertContext.setGuiComponent(guiComponent);
    assertContext.setPoint(mouse.getPoint());

    JPopupMenu menu = dialogManager.newPopupMenu();

    for (Iterator iterator = actionManager.actions(); iterator.hasNext(); ) {
      AbstractAssert assertAction = (AbstractAssert) iterator.next();
      String actionId = (String) assertAction.getValue(AbstractAssert.ACTION_ID);

      ActionViewUtil.connectActionTo(assertAction, menu.add(actionId));
      assertAction.update();

      if (!guiComponent.isFindable()
          && AbstractAssert.COMPONENT_ASSERT == assertAction.getAssertType()) {
        assertAction.setEnabled(false);
      }
    }

    menu.setBorder(BorderFactory.createLineBorder(Color.blue, 5));
    menu.show(guiComponent.getSwingComponent(), mouse.getX(), mouse.getY());
  }
 public void mouseClicked(MouseEvent e) {
   //	Table => select
   if (e.getSource() instanceof JTable && e.getClickCount() > 1) {
     adaptee.m_changed = true;
     adaptee.dispose();
   }
 }
  public void mouseClicked(MouseEvent e) {

    if (!(e.getSource().getClass().getName()).equalsIgnoreCase("VisualItem")
        && !UILib.isButtonPressed(e, button1)) {
      if (gv.getDisplay().getCursor().getType() == (Cursor.DEFAULT_CURSOR)) {
        // release all focus and neighbour highlight
        TupleSet ts = vis.getGroup(Visualization.FOCUS_ITEMS);
        if (gv.getRecStatus() == 2 && gv.fromIndirect && (ts.getTupleCount() == 0) && !gv.fromAll)
          gv.showDirectGraph();

        ts.clear();
        vis.removeGroup("depthEdge");
        gv.releaseSearchFocus();
      }
    }

    if (UILib.isButtonPressed(e, button1) && e.getClickCount() == 1) {
      if (gv.getDisplay().getCursor().getName().equals("zoom")) admin.toggleZoom();
      else if (gv.getDisplay().getCursor().getName().equals("zoomout")) admin.toggleZoomOut();
      else if (gv.getDisplay().getCursor().getName().equals("zoomin")) admin.toggleZoomIn();
      else if (gv.getDisplay().getCursor().getName().equals("zoomout1")) admin.toggleZoomOut1();
      else if (gv.getDisplay().getCursor().getName().equals("zoomin1")) admin.toggleZoomIn1();
      else if (gv.getDisplay().getCursor().getName().equals("pan")) admin.togglePan();
    }
  }
 /** Handles mouse move events. The event is delegated to the currently active tool. */
 public void mouseMoved(MouseEvent e) {
   try {
     tool().mouseMove(e, e.getX(), e.getY());
   } catch (Throwable t) {
     handleMouseEventException(t);
   }
 }
Exemple #16
0
 /** This method cannot be called directly. */
 @Override
 public void mouseMoved(MouseEvent e) {
   synchronized (mouseLock) {
     mouseX = StdDraw.userX(e.getX());
     mouseY = StdDraw.userY(e.getY());
   }
 }
 /**
  * Used only on Mac OS, to remove key modifiers that are used to simulate mouse buttons 2 and 3.
  * Returns whether the event should be ignored.
  */
 private boolean pruneClickModifiers(AWTEvent event) {
   lastButton = 0;
   boolean ignoreEvent = false;
   if (event.getID() == MouseEvent.MOUSE_PRESSED) {
     MouseEvent me = (MouseEvent) event;
     int buttons = me.getModifiers() & (MouseEvent.BUTTON2_MASK | MouseEvent.BUTTON3_MASK);
     pruneButtonModifier = buttons != 0;
     lastButton = buttons;
   } else if (event.getID() == KeyEvent.KEY_RELEASED && pruneButtonModifier) {
     pruneButtonModifier = false;
     KeyEvent ke = (KeyEvent) event;
     int code = ke.getKeyCode();
     if ((code == KeyEvent.VK_CONTROL
             || code == KeyEvent.VK_ALT && (lastButton & MouseEvent.BUTTON2_MASK) != 0)
         || (code == KeyEvent.VK_META && (lastButton & MouseEvent.BUTTON3_MASK) != 0)) {
       if (steps.size() > 1) {
         Step step = (Step) steps.get(steps.size() - 2);
         if ((code == KeyEvent.VK_CONTROL && isKey(step, "VK_CONTROL", PRESS)
                 || (code == KeyEvent.VK_ALT && isKey(step, "VK_ALT", PRESS)))
             || (code == KeyEvent.VK_META && isKey(step, "VK_META", PRESS))) {
           // might be another one
           steps.remove(steps.size() - 2);
           pruneButtonModifier = true;
           ignoreEvent = true;
         }
       }
     }
   }
   return ignoreEvent;
 }
 /**
  * Manages mouse clicks
  *
  * @param e the event
  * @see javax.swing.text.DefaultCaret#mouseClicked(java.awt.event.MouseEvent)
  */
 public void mouseClicked(MouseEvent e) {
   if (SwingUtilities.isMiddleMouseButton(e) && e.getClickCount() == 1) {
     /** * PASTE USING MIDDLE BUTTON ** */
     JTextComponent c = (JTextComponent) e.getSource();
     if (c != null) {
       Toolkit tk = c.getToolkit();
       Clipboard buffer = tk.getSystemSelection();
       if (buffer != null) {
         Transferable trans = buffer.getContents(null);
         if (trans.isDataFlavorSupported(DataFlavor.stringFlavor)) {
           try {
             String pastedText = (String) trans.getTransferData(DataFlavor.stringFlavor);
             ((JTextPane) getConsole().getConfiguration().getInputCommandView())
                 .replaceSelection(pastedText);
           } catch (UnsupportedFlavorException e1) {
             e1.printStackTrace();
           } catch (IOException e1) {
             e1.printStackTrace();
           }
         }
       }
     }
   } else if (SwingUtilities.isLeftMouseButton(e) && e.getClickCount() == 1) {
     /** * SEND THE FOCUS TO THE INPUT COMMAND VIEW ** */
     ((JTextPane) getConsole().getConfiguration().getInputCommandView()).requestFocus();
     ((JTextPane) getConsole().getConfiguration().getInputCommandView())
         .getCaret()
         .setVisible(true);
   } else {
     /** * DELEGATE TO THE SYSTEM ** */
     super.mouseClicked(e);
   }
 }
 public void mouseMoved(MouseEvent e) {
   // check if the mouse is over something hot:
   // - a speed handle
   // - a rock
   tmp.setLocation(e.getX(), e.getY());
   panel.findHotDc(tmp, hot);
 }
 public void mouseDragged(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   boolean oldMouseOverButton = mMouseOverButton;
   if (mPressedButton != -1) mMouseOverButton = mRect[mPressedButton].contains(x, y);
   if (mMouseOverButton ^ oldMouseOverButton) repaint();
 }
Exemple #21
0
  public void mousePressed(java.awt.event.MouseEvent e) {
    if (e.isPopupTrigger()) {
      doPopup(e);
      return;
    }
    if (!org.nlogo.awt.Mouse.hasButton1(e)) {
      return;
    }

    // this is so the user can use action keys to control buttons
    // - ST 8/6/04,8/31/04
    this.requestFocus();

    java.awt.Point p = e.getPoint();
    java.awt.Rectangle rect = this.getBounds();

    p.x += rect.x;
    p.y += rect.y;

    if (!rect.contains(p)) {
      return;
    }
    unselectWidgets();
    startDragPoint = e.getPoint();
    if (widgetCreator == null) {
      return;
    }
    Widget widget = widgetCreator.getWidget();
    if (widget == null) {
      return;
    }
    addWidget(widget, e.getX(), e.getY(), true, false);
    revalidate();
  }
 // board panel clicked
 public void boardClicked(MouseEvent e) {
   System.out.println("Board clicked");
   // calculate y and x
   double x = e.getX() / supermarketView.CELLSIZEX;
   double y = e.getY() / supermarketView.CELLSIZEY;
   System.out.println("X = " + x + " Y = " + y);
 }
Exemple #23
0
  /** Shows popup with forward history entries */
  private void showForwardHistory(MouseEvent e) {

    JPopupMenu forwardMenu = new JPopupMenu("Forward History");

    if (historyModel == null) {
      return;
    }

    Locale locale = ((JHelp) getControl()).getModel().getHelpSet().getLocale();
    Enumeration items = historyModel.getForwardHistory().elements();
    JMenuItem mi = null;
    int index = historyModel.getIndex() + 1;
    // while(items.hasMoreElements()){
    for (int i = 0; items.hasMoreElements(); i++) {
      HelpModelEvent item = (HelpModelEvent) items.nextElement();
      if (item != null) {
        String title = item.getHistoryName();
        if (title == null) {
          title = HelpUtilities.getString(locale, "history.unknownTitle");
        }
        mi = new JMenuItem(title);
        // mi.setToolTipText(item.getURL().getPath());
        mi.addActionListener(new HistoryActionListener(i + index));
        forwardMenu.add(mi);
      }
    }
    // if(e.isPopupTrigger())
    forwardMenu.show(e.getComponent(), e.getX(), e.getY());
  }
 public void mouseClicked(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   int currentTabIndex = -1;
   int tabCount = tabPane.getTabCount();
   for (int i = 0; i < tabCount; i++) {
     if (rects[i].contains(x, y)) {
       currentTabIndex = i;
       break;
     } // if contains
   } // for i
   if (currentTabIndex >= 0) {
     Rectangle tabRect = rects[currentTabIndex];
     x = x - tabRect.x;
     y = y - tabRect.y;
     if ((x >= 5) && (x <= 15) && (y >= 5) && (y <= 15)) {
       try {
         tabbedPane.remove(currentTabIndex);
       } catch (Exception ex) {
         ex.printStackTrace();
       }
     } // if
   } // if currentTabIndex >= 0
   System.gc();
 } // mouseClicked
    public void mouseMoved(MouseEvent ev) {
      JRootPane root = getRootPane();

      if (root.getWindowDecorationStyle() == JRootPane.NONE) {
        return;
      }

      Window w = (Window) ev.getSource();

      Frame f = null;
      Dialog d = null;

      if (w instanceof Frame) {
        f = (Frame) w;
      } else if (w instanceof Dialog) {
        d = (Dialog) w;
      }

      // Update the cursor
      int cursor = getCursor(calculateCorner(w, ev.getX(), ev.getY()));

      if (cursor != 0
          && ((f != null && (f.isResizable() && (f.getExtendedState() & Frame.MAXIMIZED_BOTH) == 0))
              || (d != null && d.isResizable()))) {
        w.setCursor(Cursor.getPredefinedCursor(cursor));
      } else {
        w.setCursor(lastCursor);
      }
    }
Exemple #26
0
 @Override
 public void mouseReleased(MouseEvent e) {
   log.info("released: " + e);
   if (point1 != null && point2 != null) {
     if (draggedNode == null) {
       ZNode z = findZNodeAt(e.getPoint());
       if (z == null) {
         createSubNode(e.getPoint());
       } else dragged(z);
     } else if (e.getPoint().y >= display.getHeight() - 40) {
       final ZTask task = taskList.getTaskAt(e.getPoint().x, 20);
       if (task == null) {
         // TODO: show confirmation?
         synchronized (zNodes) {
           zNodes.remove(draggedNode);
         }
       } else task.add(draggedNode);
       draggedNode = null;
     } else {
       draggedNode.getLocation().setLocation(translateToZNodePoint(point2));
       updateSubLocations(draggedNode, true, draggedNode.getLocation());
       draggedNode = null;
     }
     point1 = point2 = null;
   }
 }
 public void mousePressed(MouseEvent e) {
   if (e.getButton() != MouseEvent.BUTTON1) {
     return;
   }
   if (e.getClickCount() != 2) {
     return;
   }
   JTable table = (JTable) e.getSource();
   Point p = e.getPoint();
   int row = table.rowAtPoint(p);
   if (row < 0) {
     return;
   }
   PickerTableModel model = getDataModel();
   ICFInternetISOCountryObj o =
       (ICFInternetISOCountryObj) model.getValueAt(row, COLID_ROW_HEADER);
   invokeWhenChosen.choseISOCountry(o);
   try {
     Container cont = getParent();
     while ((cont != null) && (!(cont instanceof JInternalFrame))) {
       cont = cont.getParent();
     }
     if (cont != null) {
       ((JInternalFrame) cont).setClosed(true);
     }
   } catch (Exception x) {
   }
 }
  @Override
  public void mouseMoved(final MouseEvent e) {
    if (coords.size() > 2) {
      if (justCreated) {
        coords.remove(coords.size() - 1);
        coords.remove(coords.size() - 1);
        coords.add(helper.toCoord(e.getX(), e.getY()));
        coords.add(helper.toCoord(e.getX(), e.getY()));
      } else {
        coords.remove(coords.size() - 1);
        coords.add(helper.toCoord(e.getX(), e.getY()));
      }

      erase = EditionHelper.createPolygon(coords);
      final Geometry line = EditionHelper.createLinearRing(coords);
      geometry =
          (multipolygon) ? EditionHelper.createMultiPolygon(subGeometries) : subGeometries.get(0);
      try {
        geometry = geometry.difference(erase);
      } catch (TopologyException ex) {
        LOGGER.log(Level.INFO, ex.getLocalizedMessage());
      }
      decoration.setGeometries(UnmodifiableArrayList.wrap(new Geometry[] {geometry, line}));
      return;
    }
    super.mouseMoved(e);
  }
  @Override
  public boolean handleDataClick(TrackClickEvent te) {
    MouseEvent e = te.getMouseEvent();
    Feature f = getFeatureAtMousePosition(te);

    // We allow any of these modifier keys for multi-select
    if (!e.isShiftDown() && !e.isControlDown() && !e.isMetaDown()) {
      clearSelectedExons();
    }

    boolean foundExon = false;
    if (f != null && f instanceof IGVFeature) {
      selectedFeature = (IGVFeature) f;
      double location = te.getFrame().getChromosomePosition(e.getX());
      if (selectedFeature.getExons() != null) {
        for (Exon exon : selectedFeature.getExons()) {
          if (location >= exon.getStart() && location < exon.getEnd()) {
            selectedExons.add(exon);
            foundExon = true;
            break;
          }
        }
      }
    }

    ((SelectableFeatureRenderer) getRenderer()).setSelectedExons(selectedExons);

    return foundExon;
  }
  /**
   * Mouse Listener Methods Handle double click on the getMulticastGroupConfigTable
   *
   * @param e
   */
  public void mouseClicked(MouseEvent e) {
    if (e.getClickCount() == 2) {
      JTable target = (JTable) e.getSource();

      int row = target.getSelectedRow();

      if (e.getSource() != this.multicastConnectivityPanel.getMulticastGroupConfigTable()) {
        System.err.println("Non standard table");
        return;
      }

      if (row < 0) {
        return;
      }

      int modelIndex = target.convertRowIndexToModel(row);

      MulticastGroupConfigModel model = (MulticastGroupConfigModel) target.getModel();

      MulticastChannelPairInfo info = model.getMulticastChannelPairInfo(modelIndex);

      chooseConfiguration();

      this.dispose();
    }

    return;
  }