Пример #1
1
    @Override
    public void mouseDragged(MouseEvent e) {

      if (resizing) {
        config.width = widthStart + (resizeStart - e.getXOnScreen());
        if (config.width < 1) {
          config.width = 1;
        }
        configService.dispatch().configChanged();
      }

      if (dragging) {
        // Disable animation when dragging for better experience.
        editor.getScrollingModel().disableAnimation();

        editor
            .getScrollingModel()
            .scrollVertically(
                scrollStart + coords.pixelsToLines(e.getY() - mouseStart) * editor.getLineHeight());
        editor.getScrollingModel().enableAnimation();
      }
    }
Пример #2
0
  @Override
  public void mouseDragged(MouseEvent arg0) {
    if (dragging) {
      setDragTileLocation(new Point(arg0.getXOnScreen(), arg0.getYOnScreen()));

      // find drop target on world
      Point os = new Point(arg0.getXOnScreen(), arg0.getYOnScreen());
      SwingUtilities.convertPointFromScreen(os, parent.world);

      Component component =
          SwingUtilities.getDeepestComponentAt(parent.world, (int) os.getX(), (int) os.getY());

      if (component instanceof TileView) {
        // available drop target reached
        draggedOverTile = ((TileView) component);

        // change cursor symbol to drop target symbol
        Cursor cursor = DragSource.DefaultCopyDrop;
        draggedTile.setCursor(cursor);
      } else {
        draggedOverTile = null;

        // reset cursor symbol
        draggedTile.setCursor(null);
      }
    }
  }
        @Override
        public void mousePressed(MouseEvent arg0) {

          Random r = new Random();
          if (arg0.getButton() == 1) {
            if (arg0.getXOnScreen() + 30 < wymiar && arg0.getYOnScreen() < wymiar)
              plansza[arg0.getXOnScreen() - 30][arg0.getYOnScreen() - 60].color =
                  new Color(r.nextInt(255), r.nextInt(255), r.nextInt(255));
          } else {
            x = arg0.getXOnScreen() - 30;
            y = arg0.getYOnScreen() - 30;
          }
          canvas.repaint();
        }
Пример #4
0
  /** Déplacement du composant */
  @Override
  public void mouseDragged(MouseEvent e) {

    Point previous = getLocation();
    if (previousX == -1) {
      previousX = e.getXOnScreen();
      previousY = e.getYOnScreen();
    } else {
      int deltaX = -previousX + e.getXOnScreen();
      int deltaY = e.getYOnScreen() - previousY;
      setLocation(previous.x + deltaX, previous.y + deltaY);

      previousX = e.getXOnScreen();
      previousY = e.getYOnScreen();
    }
  }
Пример #5
0
 private void movebtMouseDragged(
     java.awt.event.MouseEvent evt) { // GEN-FIRST:event_movebtMouseDragged
   // TODO add your handling code here:
   int x = evt.getXOnScreen();
   int y = evt.getYOnScreen();
   this.setLocation(x - xmouse, y - ymouse);
 } // GEN-LAST:event_movebtMouseDragged
Пример #6
0
 @Override
 public void mousePressed(MouseEvent e) {
   // Set the point to start drawing the rectangle.
   initialX = e.getXOnScreen();
   initialY = e.getYOnScreen();
   repaint();
 }
Пример #7
0
 private void showPopup(MouseEvent evt, JComponent component) {
   hidePopup();
   popup = new JidePopup();
   popup.setOwner(this);
   popup.setDefaultFocusComponent(component);
   popup.getContentPane().add(component);
   popup.setAttachable(true);
   popup.setMovable(false);
   popup.showPopup(evt.getXOnScreen(), evt.getYOnScreen());
 }
Пример #8
0
 @Override
 public void mouseDragged(MouseEvent e) {
   if (this.mouseStartLocation != null) {
     Point offset =
         new Point(
             e.getXOnScreen() - this.mouseStartLocation.x,
             e.getYOnScreen() - this.mouseStartLocation.y);
     Point NmouseL = new Point(windowStartLocation.x + offset.x, windowStartLocation.y + offset.y);
     this.gui.setLocation(NmouseL);
   }
 }
 // <editor-fold desc="Mouse events">
 @Override
 public void mouseDragged(MouseEvent e) {
   try {
     Robot rbt = new Robot();
     int mousePromille = (int) (((e.getX() * 1.0) / getWidth()) * 1000);
     if (selectedThreshold != null) {
       if (mousePromille < dragMin) {
         rbt.mouseMove(e.getXOnScreen() + 1, e.getYOnScreen());
         return;
       }
       if (mousePromille > dragMax) {
         rbt.mouseMove(e.getXOnScreen() - 1, e.getYOnScreen());
         return;
       }
       selectedThreshold.setValuePromille((int) (((e.getX() * 1.0) / getWidth()) * 1000));
       repaint();
     }
   } catch (AWTException ex) {
     Logger.getLogger(ChannelSettingViewer.class.getName()).log(Level.SEVERE, null, ex);
   }
 }
Пример #10
0
  @Override
  public void mouseDragged(MouseEvent e) {
    // Get the current point where the mouse is dragged at.
    finalX = e.getXOnScreen();
    finalY = e.getYOnScreen();
    // Behind the initial point? Nope.
    if (finalX < initialX || finalY < initialY) {
      finalX = 0;
      finalY = 0;
    }

    clearCanvas = true;
    repaint();
  }
Пример #11
0
  @Override
  public void mousePressed(MouseEvent arg0) {
    dragging = true;
    offset = new Point(arg0.getX(), arg0.getY());
    TileView orig = (TileView) arg0.getSource();
    draggedTile = orig.clone();

    // Drag tile size
    draggedTile.setSize(orig.getSize());

    parent.layeredPane.add(
        draggedTile, parent.layeredPane.getComponentCountInLayer(JLayeredPane.DRAG_LAYER));

    setDragTileLocation(new Point(arg0.getXOnScreen(), arg0.getYOnScreen()));
  }
Пример #12
0
    public void set(MouseEvent e, SAMRecord sr) {
      if (sr == null) return;
      StringBuffer text = new StringBuffer();
      text.append("<html>");

      if (sr != null) {
        text.append(
            MessageManager.getString("shortreadtrack.name") + " " + sr.getReadName() + "<br/>");
        text.append(
            MessageManager.getString("shortreadtrack.len") + " " + sr.getReadLength() + "<br/>");
        text.append(
            MessageManager.getString("shortreadtrack.cigar") + " " + sr.getCigarString() + "<br/>");
        text.append(
            MessageManager.getString("shortreadtrack.sequence")
                + " "
                + rerun(sr.getReadString())
                + "<br/>");
        text.append(
            MessageManager.getString("shortreadtrack.paired")
                + " "
                + sr.getReadPairedFlag()
                + "<br/>");
        if (sr.getReadPairedFlag()) {
          if (!sr.getMateUnmappedFlag())
            text.append(
                MessageManager.getString("shortreadtrack.mate")
                    + " "
                    + sr.getMateReferenceName()
                    + ":"
                    + sr.getMateAlignmentStart()
                    + "<br/>");
          else text.append(MessageManager.getString("shortreadtrack.mate_missing") + "<br/>");
          text.append(
              MessageManager.getString("shortreadtrack.second") + " " + sr.getFirstOfPairFlag());
        }
        // text.append("<br/>");
      }
      text.append("</html>");
      if (!text.toString().equals(floater.getText())) {
        floater.setText(text.toString());
        this.pack();
      }
      setLocation(e.getXOnScreen() + 5, e.getYOnScreen() + 5);

      if (!isVisible()) {
        setVisible(true);
      }
    }
 void forwardEventToParent(MouseEvent e) {
   getParent()
       .dispatchEvent(
           new MouseEvent(
               getParent(),
               e.getID(),
               e.getWhen(),
               e.getModifiers(),
               e.getX(),
               e.getY(),
               e.getXOnScreen(),
               e.getYOnScreen(),
               e.getClickCount(),
               e.isPopupTrigger(),
               MouseEvent.NOBUTTON));
 }
Пример #14
0
 /**
  * Check for user's action
  *
  * @param event
  */
 public void mousePressed(MouseEvent event) {
   if (event.getButton() == MouseEvent.BUTTON3
       || (event.isControlDown() == true && event.getButton() == MouseEvent.BUTTON1)) {
     conversationToRemove =
         listPane.getUserWrapper(listPane.getClickedIndex()).getConversation();
     rightClickMenu.show(listPane, event.getX() + 5, event.getYOnScreen());
     rightClickMenu.setLocation(event.getXOnScreen(), event.getYOnScreen());
   } else if (event.getButton() == MouseEvent.BUTTON1) {
     controller.setTypingState(1); // set to the default typing state
     // before
     rightClickMenu.setVisible(false);
     // switching
     controller.changeConversation(
         listPane.getUserWrapper(listPane.getClickedIndex()).getConversation());
   }
   return;
 }
Пример #15
0
 public void mouseClicked(MouseEvent e) {
   MouseEvent transfer =
       new MouseEvent(
           this,
           e.getID(),
           e.getWhen(),
           e.getModifiers(),
           e.getX(),
           e.getY(),
           e.getXOnScreen(),
           e.getYOnScreen(),
           e.getClickCount(),
           e.isPopupTrigger(),
           e.getButton());
   for (MouseListener l : getMouseListeners()) {
     l.mouseClicked(transfer);
   }
 }
Пример #16
0
  @Override
  public void mouseClicked(MouseEvent arg0) { // add or delete a cell when mouse is clicked
    // translate mouse position to viewport area and register that a new Organism has been spawned
    // in the viewport.agents array
    int x = arg0.getXOnScreen() - this.getX();
    int y = arg0.getYOnScreen() - this.getY(); // -30 to accommodate the ribbon

    if (!arg0.isControlDown()) { // add a cell
      viewport
          .agents[((int) Math.ceil(((double) x / (double) viewport.scale))) - 1][
          ((int) Math.ceil(((double) y / (double) viewport.scale))) - 1]
          .setAlive(true);
    } else if (arg0.isControlDown()) { // delete a cell
      viewport
          .agents[((int) Math.ceil(((double) x / (double) viewport.scale))) - 1][
          ((int) Math.ceil(((double) y / (double) viewport.scale))) - 1]
          .setAlive(false); // undo a life
    }
  }
Пример #17
0
    @Override
    public void mousePressed(MouseEvent e) {
      if (!dragging && inResizeGutter(e.getX())) {
        resizing = true;
      } else if (!resizing) {
        dragging = true;
      }

      if (resizing) {
        resizeStart = e.getXOnScreen();
        widthStart = config.width;
      }

      if (dragging) {
        Rectangle visibleArea = editor.getScrollingModel().getVisibleArea();
        int firstVisibleLine = getMapYFromEditorY((int) visibleArea.getMinY());
        int height =
            coords.linesToPixels(
                (int) ((visibleArea.getMaxY() - visibleArea.getMinY()) / editor.getLineHeight()));

        int panelY = e.getY() - getY();

        if (config.jumpOnMouseDown
            && (panelY <= firstVisibleLine || panelY >= (firstVisibleLine + height))) {
          editor.getScrollingModel().disableAnimation();
          editor
              .getScrollingModel()
              .scrollTo(
                  editor.offsetToLogicalPosition(
                      coords.screenSpaceToOffset(e.getY(), config.percentageBasedClick)),
                  ScrollType.CENTER);
          editor.getScrollingModel().enableAnimation();
        }

        scrollStart = editor.getScrollingModel().getVerticalScrollOffset();
        mouseStart = e.getY();
      }
    }
Пример #18
0
  protected void createNewQuickMenu(java.awt.event.MouseEvent evt) {
    initializeComponents();

    popupMenu.setLocation(evt.getXOnScreen(), evt.getYOnScreen());
    quickUndo.setEnabled(notepad.undoManager.canUndo());
    quickRedo.setEnabled(notepad.undoManager.canRedo());
    quickCut.setEnabled(notepad.bigEdit.getSelectedText() != null);
    quickCopy.setEnabled(notepad.bigEdit.getSelectedText() != null);
    quickSelectAll.setEnabled(notepad.bigEdit.getText().length() != 0);
    String data = null;
    try {
      data =
          (String)
              Toolkit.getDefaultToolkit() //
                  .getSystemClipboard()
                  .getData(DataFlavor.stringFlavor);
    } catch (UnsupportedFlavorException | IOException ex) {
      System.err.println("Clipboard error. " + ex);
    }
    quickPaste.setEnabled(data != null);
    quickSwap.setEnabled(data != null & notepad.bigEdit.getSelectedText() != null);

    displayQuickMenuGUI();
  }
Пример #19
0
    public void set(MouseEvent e, ShortReadInsertion sri) {
      if (sri == null) return;
      StringBuffer text = new StringBuffer();
      text.append("<html>");

      if (sri != null) {
        text.append(MessageManager.getString("shortreadtrack.insertion") + " ");
        byte[] bases = sri.esr.getReadBases();
        for (int i = sri.start; i < sri.start + sri.len; i++) {
          text.append((char) bases[i]);
        }
        text.append("<br/>");
      }
      text.append("</html>");
      if (!text.toString().equals(floater.getText())) {
        floater.setText(text.toString());
        this.pack();
      }
      setLocation(e.getXOnScreen() + 5, e.getYOnScreen() + 5);

      if (!isVisible()) {
        setVisible(true);
      }
    }
Пример #20
0
 // **************eventos********************
 protected void mouseArrastrandose(MouseEvent evt) {
   evt.getComponent().setLocation(evt.getXOnScreen() - xi, evt.getYOnScreen() - yi);
 }
Пример #21
0
 @Override
 public void mouseDragged(MouseEvent e) {
   if ((e.getModifiersEx() & 0x400) != 0)
     setLocation(e.getXOnScreen() - this.dragGripX, e.getYOnScreen() - this.dragGripY);
 }
Пример #22
0
 protected void mousePresionado(MouseEvent evt) {
   xi = evt.getXOnScreen() - evt.getComponent().getX();
   yi = evt.getYOnScreen() - evt.getComponent().getY();
 }
  /**
   * When a MenuElement receives an event from a MouseListener, it should never process the event
   * directly. Instead all MenuElements should call this method with the event.
   *
   * @param event a MouseEvent object
   */
  public void processMouseEvent(MouseEvent event) {
    int screenX, screenY;
    Point p;
    int i, c, j, d;
    Component mc;
    Rectangle r2;
    int cWidth, cHeight;
    MenuElement menuElement;
    MenuElement subElements[];
    MenuElement path[];
    Vector<MenuElement> tmp;
    int selectionSize;
    p = event.getPoint();

    Component source = event.getComponent();

    if ((source != null) && !source.isShowing()) {
      // This can happen if a mouseReleased removes the
      // containing component -- bug 4146684
      return;
    }

    int type = event.getID();
    int modifiers = event.getModifiers();
    // 4188027: drag enter/exit added in JDK 1.1.7A, JDK1.2
    if ((type == MouseEvent.MOUSE_ENTERED || type == MouseEvent.MOUSE_EXITED)
        && ((modifiers
                & (InputEvent.BUTTON1_MASK | InputEvent.BUTTON2_MASK | InputEvent.BUTTON3_MASK))
            != 0)) {
      return;
    }

    if (source != null) {
      SwingUtilities.convertPointToScreen(p, source);
    }

    screenX = p.x;
    screenY = p.y;

    tmp = (Vector<MenuElement>) selection.clone();
    selectionSize = tmp.size();
    boolean success = false;
    for (i = selectionSize - 1; i >= 0 && success == false; i--) {
      menuElement = (MenuElement) tmp.elementAt(i);
      subElements = menuElement.getSubElements();

      path = null;
      for (j = 0, d = subElements.length; j < d && success == false; j++) {
        if (subElements[j] == null) continue;
        mc = subElements[j].getComponent();
        if (!mc.isShowing()) continue;
        if (mc instanceof JComponent) {
          cWidth = mc.getWidth();
          cHeight = mc.getHeight();
        } else {
          r2 = mc.getBounds();
          cWidth = r2.width;
          cHeight = r2.height;
        }
        p.x = screenX;
        p.y = screenY;
        SwingUtilities.convertPointFromScreen(p, mc);

        /**
         * Send the event to visible menu element if menu element currently in the selected path or
         * contains the event location
         */
        if ((p.x >= 0 && p.x < cWidth && p.y >= 0 && p.y < cHeight)) {
          int k;
          if (path == null) {
            path = new MenuElement[i + 2];
            for (k = 0; k <= i; k++) path[k] = (MenuElement) tmp.elementAt(k);
          }
          path[i + 1] = subElements[j];
          MenuElement currentSelection[] = getSelectedPath();

          // Enter/exit detection -- needs tuning...
          if (currentSelection[currentSelection.length - 1] != path[i + 1]
              && (currentSelection.length < 2
                  || currentSelection[currentSelection.length - 2] != path[i + 1])) {
            Component oldMC = currentSelection[currentSelection.length - 1].getComponent();

            MouseEvent exitEvent =
                new MouseEvent(
                    oldMC,
                    MouseEvent.MOUSE_EXITED,
                    event.getWhen(),
                    event.getModifiers(),
                    p.x,
                    p.y,
                    event.getXOnScreen(),
                    event.getYOnScreen(),
                    event.getClickCount(),
                    event.isPopupTrigger(),
                    MouseEvent.NOBUTTON);
            currentSelection[currentSelection.length - 1].processMouseEvent(exitEvent, path, this);

            MouseEvent enterEvent =
                new MouseEvent(
                    mc,
                    MouseEvent.MOUSE_ENTERED,
                    event.getWhen(),
                    event.getModifiers(),
                    p.x,
                    p.y,
                    event.getXOnScreen(),
                    event.getYOnScreen(),
                    event.getClickCount(),
                    event.isPopupTrigger(),
                    MouseEvent.NOBUTTON);
            subElements[j].processMouseEvent(enterEvent, path, this);
          }
          MouseEvent mouseEvent =
              new MouseEvent(
                  mc,
                  event.getID(),
                  event.getWhen(),
                  event.getModifiers(),
                  p.x,
                  p.y,
                  event.getXOnScreen(),
                  event.getYOnScreen(),
                  event.getClickCount(),
                  event.isPopupTrigger(),
                  MouseEvent.NOBUTTON);
          subElements[j].processMouseEvent(mouseEvent, path, this);
          success = true;
          event.consume();
        }
      }
    }
  }