Esempio n. 1
0
  @Override
  public final void mousePressed(final MouseEvent e) {
    if (!isEnabled() || !isFocusable()) return;

    requestFocusInWindow();
    cursor(true);

    if (SwingUtilities.isMiddleMouseButton(e)) copy();

    final boolean marking = e.isShiftDown();
    final boolean nomark = !text.marked();
    if (SwingUtilities.isLeftMouseButton(e)) {
      final int c = e.getClickCount();
      if (c == 1) {
        // selection mode
        if (marking && nomark) text.startMark();
        rend.select(scroll.pos(), e.getPoint(), marking);
      } else if (c == 2) {
        text.selectWord();
      } else {
        text.selectLine();
      }
    } else if (nomark) {
      rend.select(scroll.pos(), e.getPoint(), false);
    }
  }
 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 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;
          }
        }
      }
    }
Esempio n. 4
0
 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();
 }
 /** 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);
   }
 }
  @Override
  public void mouseMoved(MouseEvent e) {
    Component source = e.getComponent();
    Point location = e.getPoint();
    direction = 0;

    if (location.x < dragInsets.left) direction += WEST;

    if (location.x > source.getWidth() - dragInsets.right - 1) direction += EAST;

    if (location.y < dragInsets.top) direction += NORTH;

    if (location.y > source.getHeight() - dragInsets.bottom - 1) direction += SOUTH;

    //  Mouse is no longer over a resizable border

    if (direction == 0) {
      source.setCursor(sourceCursor);
    } else // use the appropriate resizable cursor
    {
      int cursorType = cursors.get(direction);
      Cursor cursor = Cursor.getPredefinedCursor(cursorType);
      source.setCursor(cursor);
    }
  }
Esempio n. 7
0
 private void onMouseUp(MouseEvent e) {
   if (hasMotionListener()) {
     changeSelectedPoint(e.getX(), e.getY());
     removeMotionListener();
   }
   updateAll();
 }
Esempio n. 8
0
  public void processFolderPanelMouseEvent(MouseEvent mouseevent) {
    switch (mouseevent.getID()) {
      case 501:
        if (mouseevent.getClickCount() == 2 && !dragged) {
          visitDocument(mouseevent.isShiftDown());
          return;
        }
        // fall through

      case 502:
        ListItem listitem = hotCanvas.getSelectedItem();
        if (listitem != null && (listitem instanceof Bookmark)) {
          Bookmark bookmark = (Bookmark) listitem;
          Webmark webmark = bookmark.getWebmark();
          String s = webmark.getURL();
          frm.setMessage(s);
        } else {
          frm.setMessage("");
        }
        redispatchEvent(mouseevent);
        dragged = false;
        return;

      case 506:
        redispatchEvent(mouseevent);
        dragged = true;
        return;

      default:
        return;
    }
  }
Esempio n. 9
0
 public void mouseDragged(MouseEvent e) {
   if (isEnabled()) {
     // System.out.println("LinkTool::mouseDragged");
     if (e.getSource() instanceof ONLGraphic)
       buttonAction.setIntermediate(e.getPoint(), (ONLGraphic) e.getSource());
   }
 }
Esempio n. 10
0
  public void action(int eventType, MouseEvent e) {
    switch (eventType) {
      case GeDyn.eEvent_MB1Down:
        dyn.comp.setColorInverse(1);
        dyn.repaintNow = true;
        break;
      case GeDyn.eEvent_MB1Up:
        dyn.comp.setColorInverse(0);
        dyn.repaintNow = true;
        break;
      case GeDyn.eEvent_MB3Press:
        if (refObject.startsWith("!")) {
          // Name of an attribute that contains the objid of the reference object
          CdhrObjid reto = dyn.en.gdh.getObjectInfoObjid(refObject.substring(1));

          if (reto.oddSts() && !reto.objid.isNull()) {
            CdhrString rets = dyn.en.gdh.objidToName(reto.objid, Cdh.mName_volumeStrict);
            System.out.println("str: " + rets.str + " " + rets.getSts());
            if (rets.oddSts() && !rets.str.equals(""))
              new JopMethodsMenu(
                  dyn.session,
                  rets.str,
                  JopUtility.GRAPH,
                  (Component) dyn.comp,
                  e.getX(),
                  e.getY());
          }
        } else {
          new JopMethodsMenu(
              dyn.session, refObject, JopUtility.GRAPH, (Component) dyn.comp, e.getX(), e.getY());
        }
        break;
    }
  }
Esempio n. 11
0
  public void mouseClicked(MouseEvent e) {
    int x;
    int y;

    e.consume();

    if (mouseEventsEnabled) {

      x = Math.round(e.getX() / scale);
      y = Math.round(e.getY() / scale);

      // allow for the canvas margin
      y -= margin;

      // System.out.println("Mouse Click: (" + x + ", " + y + ")");

      if (e.getClickCount() < 2) {
        if (nativeSelectItem(x, y)) {
          parentFTAFrame.updateFrame();
        }
      } else {
        if (nativeSelectItem(x, y)) {
          parentFTAFrame.updateFrame();
        }

        editSelected();
        parentFTAFrame.updateFrame();
      }

      if (focusEventsEnabled) {
        // tell the main Canvas to point to this coordinate
        parentFTAFrame.setCanvasFocus(x, y);
      }
    }
  }
Esempio n. 12
0
  public void mouseDragged(MouseEvent evt) {
    Graphics g = canvas.getGraphics();
    g.setColor(color);

    if (type == 0) {
      g.setXORMode(canvas.getBackground());
      g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y);
      end = evt.getPoint();
      g.drawRect(start.x, start.y, end.x - start.x, end.y - start.y);
    } else if (type == 1) {
      int radius;

      g.setXORMode(canvas.getBackground());

      radius = (int) Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));

      g.drawOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius);
      end = evt.getPoint();

      radius = (int) Math.sqrt(Math.pow(end.x - start.x, 2) + Math.pow(end.y - start.y, 2));

      g.drawOval(start.x - radius, start.y - radius, 2 * radius, 2 * radius);
    } else if (type == 2) {
      g.setXORMode(canvas.getBackground());
      g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y);
      end = evt.getPoint();
      g.drawOval(start.x, start.y, end.x - start.x, end.y - start.y);
    }
  }
Esempio n. 13
0
  public void mousePressed(MouseEvent e) {
    this.mousePoint = e.getPoint();

    Object topObject = null;
    PickedObjectList pickedObjects = this.wwd.getObjectsAtCurrentPosition();
    if (pickedObjects != null) topObject = pickedObjects.getTopObject();

    if (topObject instanceof ControlPointMarker) {
      this.activeControlPoint = (ControlPointMarker) topObject;
      this.activeAction = this.activeControlPoint.getType();

      setShowAnnotation(true);
      updateAnnotation(this.activeControlPoint.getPosition());

      // update controlPointIndex;
      int i = 0;
      for (Marker controlPoint : this.controlPoints) {
        if (controlPoint.equals(topObject)) break;
        i++;
      }
      this.activeControlPointIndex = i;
      e.consume();
    } else if (topObject == this.getPolygon()) {
      this.activeAction = MOVE_POLYGON_ACTION;

      // set the shape to be the "active control point"
      this.activeControlPointIndex = -1;

      setShowAnnotation(true);
      updateAnnotation(this.polygon.getReferencePosition());
      e.consume();
    }
  }
 public static void checkClickedModifiersTest(int testModifier, MouseEvent event) {
   int[] curStandardModifiers = getStandardArray(testModifier);
   int[] curStandardExModifiers = getStandardExArray(testModifier);
   //        int index = (button - 4)*3 + 2;
   int button = event.getButton();
   int modifiers = event.getModifiers();
   int modifiersEx = event.getModifiersEx();
   int index = (button - 1) * 3 + 2;
   dumpValues(
       button, modifiers, curStandardModifiers[index], modifiersEx, curStandardExModifiers[index]);
   if (modifiers != curStandardModifiers[index]) {
     if (debug) {
       System.out.println("Test failed :  Clicked. modifiers != modifiersStandard");
     } else {
       throw new RuntimeException("Test failed :  Clicked. modifiers != modifiersStandard");
     }
   }
   if (modifiersEx != curStandardExModifiers[index]) {
     if (debug) {
       System.out.println("Test failed :  Clicked. modifiersEx != curStandardExModifiers");
     } else {
       throw new RuntimeException("Test failed :  Clicked. modifiersEx != curStandardExModifiers");
     }
   }
   HashMap<String, String> paramStringElements = tokenizeParamString(event.paramString());
   checkButton(paramStringElements, button);
   checkModifiers(testModifier, paramStringElements, button);
   checkExtModifiersOnReleaseClick(testModifier, paramStringElements, button);
 }
Esempio n. 15
0
  public void leftMouseReleased(MouseEvent e) {
    double x = e.getX();
    double y = e.getY();

    // If no start vertex selected or start vertex is virtual, do nothing
    if (startVertex == null || startVertex.isVirtual()) {
      displayFrame.controlFrame.updateDisplays(true);
      return;
    }
    endVertex =
        getSelectedVertex(
            x, y, displayFrame.getMainDiagramPanel(), displayFrame.getFreeVertexPanel());
    // If no end vertex selected, still do nothing
    if (endVertex == null) {
      displayFrame.controlFrame.updateDisplays(true);
      return;
    }
    // If mouse pressed and released within the same vertex, print vertex label
    if (endVertex == startVertex) {
      canCreateEdge = false;
      startVertex.setSelected(!startVertex.isSelected());
      displayFrame.controlFrame.updateDisplays(true);
      return;
    } else {
      addNewEdge();
    }
  }
Esempio n. 16
0
  @Override
  public final void mousePressed(final MouseEvent e) {
    if (!isEnabled() || !isFocusable()) return;

    requestFocusInWindow();
    caret(true);

    if (SwingUtilities.isMiddleMouseButton(e)) copy();

    final boolean shift = e.isShiftDown();
    final boolean selected = editor.selected();
    if (SwingUtilities.isLeftMouseButton(e)) {
      final int c = e.getClickCount();
      if (c == 1) {
        // selection mode
        if (shift) editor.startSelection(true);
        select(e.getPoint(), !shift);
      } else if (c == 2) {
        editor.selectWord();
      } else {
        editor.selectLine();
      }
    } else if (!selected) {
      select(e.getPoint(), true);
    }
  }
Esempio n. 17
0
 public void mouseReleased(MouseEvent e) {
   if (gameover) return;
   if (!blown) {
     if (started == false) {
       started = true;
       processActionEvent(new ActionEvent(this, START_TIMER, "MineSweeper"));
     }
     if (!xy2index(e.getX(), e.getY())) return;
     if (right_clicked) {
       if (hidden[cr][cc]) {
         flagged[cr][cc] = !flagged[cr][cc];
         processActionEvent(
             new ActionEvent(this, SQUARE_FLAGGED * (!flagged[cr][cc] ? 1 : -1), "MineSweeper"));
       }
     } else {
       if (hidden[cr][cc] && !flagged[cr][cc]) hidden[cr][cc] = false;
       if (!flagged[cr][cc] && field[cr][cc] == -1) {
         blown = true;
         started = false;
         processActionEvent(new ActionEvent(this, GAME_LOST, "MineSweeper"));
         paint(getGraphics());
         return;
       }
       if (field[cr][cc] == 0) showNeighbours(cr, cc, false);
     }
     drawBlock(buffG, cr, cc, status(cr, cc));
     paint(getGraphics());
     if ((gameover = is_game_over())) end_game();
   }
 }
Esempio n. 18
0
    public void mousePressed(MouseEvent e) {
      if (e.getButton() == e.BUTTON3) {
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(2);
        int index = list.locationToIndex(e.getPoint());
        GetImageFile gif = new GetImageFile(files[index]);

        JTextArea area =
            new JTextArea(
                "File: "
                    + gif.getImageString()
                    + "\n"
                    + "Score: "
                    + nf.format(scores[index])
                    + "\n"
                    + "Pairs: "
                    + nrpairs[index]);
        area.setEditable(false);
        area.setBorder(BorderFactory.createLineBorder(Color.black));
        area.setFont(new Font("times", Font.PLAIN, 12));
        PopupFactory factory = PopupFactory.getSharedInstance();
        popup =
            factory.getPopup(
                null,
                area,
                (int) e.getComponent().getLocationOnScreen().getX() + e.getX() + 25,
                (int) e.getComponent().getLocationOnScreen().getY() + e.getY());
        popup.show();
      }
    }
  @Override
  public void mousePressed(MouseEvent e) {
    //	The mouseMoved event continually updates this variable

    if (direction == 0) return;

    //  Setup for resizing. All future dragging calculations are done based
    //  on the original bounds of the component and mouse pressed location.

    resizing = true;

    Component source = e.getComponent();
    pressed = e.getPoint();
    SwingUtilities.convertPointToScreen(pressed, source);
    bounds = source.getBounds();

    //  Making sure autoscrolls is false will allow for smoother resizing
    //  of components

    if (source instanceof JComponent) {
      JComponent jc = (JComponent) source;
      autoscrolls = jc.getAutoscrolls();
      jc.setAutoscrolls(false);
    }
  }
    public void mouseClicked(MouseEvent e) {
      JTableHeader h = (JTableHeader) e.getSource();
      TableColumnModel columnModel = h.getColumnModel();
      int viewColumn = columnModel.getColumnIndexAtX(e.getX());
      int column = columnModel.getColumn(viewColumn).getModelIndex();
      if (column != -1) {
        sorting_column = column;

        // 0 == priority icon column
        // 4 == priority text column
        if (column == 0) sorting_column = 4;

        if (e.isControlDown()) sorting_column = -1;
        else opposite = !opposite;

        TaskTable treetable = ((TaskTable) h.getTable());

        // java.util.Collection expanded = treetable.getExpandedTreeNodes();

        treetable.tableChanged();
        // treetable.setExpandedTreeNodes(expanded);
        // h.updateUI();
        h.resizeAndRepaint();
      }
    }
Esempio n. 21
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;
   }
 }
 // Die Methoden des Interface MouseMotionListener implementieren
 public void mouseDragged(MouseEvent e) {
   // Die Koordinaten des Mausklicks lesen
   int x = e.getX();
   int y = e.getY();
   // und mit der Maus malen
   g.fillRect(x, y, 3, 3);
 }
 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
  @Override
  public void mouseMoved(MouseEvent evt) {
    Point point = evt.getPoint();
    updateCursor(editor.findView((Container) evt.getSource()), point);
    DrawingView view = editor.findView((Container) evt.getSource());
    updateCursor(view, point);
    if (view == null || editor.getActiveView() != view) {
      clearHoverHandles();
    } else {
      // Search first, if one of the selected figures contains
      // the current mouse location. Only then search for other
      // figures. This search sequence is consistent with the
      // search sequence of the SelectionTool.
      Figure figure = null;
      Point2D.Double p = view.viewToDrawing(point);
      for (Figure f : view.getSelectedFigures()) {
        if (f.contains(p)) {
          figure = f;
        }
      }
      if (figure == null) {
        figure = view.findFigure(point);
        Drawing drawing = view.getDrawing();
        while (figure != null && !figure.isSelectable()) {
          figure = drawing.findFigureBehind(p, figure);
        }
      }

      updateHoverHandles(view, figure);
    }
  }
Esempio n. 25
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());
  }
 @Override
 public void mousePressed(MouseEvent evt) {
   // handle.mousePressed(evt);
   anchor = new Point(evt.getX(), evt.getY());
   multicaster.trackStart(anchor, evt.getModifiersEx(), getView());
   clearHoverHandles();
 }
Esempio n. 27
0
    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);
      }
    }
    private void adjustFocusAndSelection(MouseEvent e) {
      if (shouldIgnore(e)) {
        return;
      }

      Point p = e.getPoint();
      int row = grid.rowAtPoint(p);
      int column = grid.columnAtPoint(p);

      // The autoscroller can generate drag events outside range.
      if ((column == -1) || (row == -1)) {
        System.err.println("Out of bounds");
        return;
      }

      if (grid.editCellAt(row, column, e)) {
        setDispatchComponent(e);
        repostEvent(e);
      } else {
        grid.requestFocus();
      }

      GridCellEditor editor = grid.getCurrentCellEditor();
      if (editor == null || editor.shouldSelectCell(e)) {
        // Update selection model
        setValueIsAdjusting(true);
        grid.changeSelection(row, column, e.isControlDown(), e.isShiftDown());
      }
    }
 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) {
   }
 }
 private void dispatchMouseEvent(MouseEvent event) {
   MouseListener[] mouseListeners = event.getComponent().getMouseListeners();
   for (MouseListener listener : mouseListeners) {
     // skip all ToolTipManager's related listeners
     if (!listener.getClass().getName().startsWith("javax.swing.ToolTipManager")) {
       switch (event.getID()) {
         case MouseEvent.MOUSE_PRESSED:
           listener.mousePressed(event);
           break;
         case MouseEvent.MOUSE_RELEASED:
           listener.mouseReleased(event);
           break;
         case MouseEvent.MOUSE_CLICKED:
           listener.mouseClicked(event);
           break;
         case MouseEvent.MOUSE_EXITED:
           listener.mouseExited(event);
           break;
         case MouseEvent.MOUSE_ENTERED:
           listener.mouseEntered(event);
           break;
         default:
           throw new AssertionError();
       }
     }
   }
 }