コード例 #1
0
      @Override
      public void mouseDragged(MouseEvent e) {
        if (!myDragging) return;
        MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, MyDivider.this);
        final ToolWindowAnchor anchor = myInfo.getAnchor();
        final Point point = event.getPoint();
        final Container windowPane = InternalDecorator.this.getParent();
        myLastPoint = SwingUtilities.convertPoint(MyDivider.this, point, windowPane);
        myLastPoint.x = Math.min(Math.max(myLastPoint.x, 0), windowPane.getWidth());
        myLastPoint.y = Math.min(Math.max(myLastPoint.y, 0), windowPane.getHeight());

        final Rectangle bounds = InternalDecorator.this.getBounds();
        if (anchor == ToolWindowAnchor.TOP) {
          InternalDecorator.this.setBounds(0, 0, bounds.width, myLastPoint.y);
        } else if (anchor == ToolWindowAnchor.LEFT) {
          InternalDecorator.this.setBounds(0, 0, myLastPoint.x, bounds.height);
        } else if (anchor == ToolWindowAnchor.BOTTOM) {
          InternalDecorator.this.setBounds(
              0, myLastPoint.y, bounds.width, windowPane.getHeight() - myLastPoint.y);
        } else if (anchor == ToolWindowAnchor.RIGHT) {
          InternalDecorator.this.setBounds(
              myLastPoint.x, 0, windowPane.getWidth() - myLastPoint.x, bounds.height);
        }
        InternalDecorator.this.validate();
        e.consume();
      }
コード例 #2
0
  @Override
  public void mouseMoved(MouseEvent e) {
    final MouseEvent event = SwingUtilities.convertMouseEvent(e.getComponent(), e, getParent());
    final boolean insideRec = getBounds().contains(event.getPoint());
    boolean buttonsNotPressed =
        (e.getModifiersEx()
                & (InputEvent.BUTTON1_DOWN_MASK
                    | InputEvent.BUTTON2_DOWN_MASK
                    | InputEvent.BUTTON3_DOWN_MASK))
            == 0;
    if (!myPopupIsShowing && insideRec && buttonsNotPressed) {
      showPopup(null, false);
    } else if (myPopupIsShowing && !insideRec) {
      final Component over =
          SwingUtilities.getDeepestComponentAt(e.getComponent(), e.getX(), e.getY());
      JPopupMenu popup = myUnderPopup.isShowing() ? myUnderPopup : myAbovePopup;
      if (over != null && popup.isShowing()) {
        final Rectangle rec = new Rectangle(popup.getLocationOnScreen(), popup.getSize());
        int delta = 15;
        rec.x -= delta;
        rec.width += delta * 2;
        rec.y -= delta;
        rec.height += delta * 2;

        final Point eventPoint = e.getPoint();
        SwingUtilities.convertPointToScreen(eventPoint, e.getComponent());

        if (rec.contains(eventPoint)) {
          return;
        }
      }

      closePopup();
    }
  }
コード例 #3
0
 public void mouseDragged(MouseEvent e) {
   graphContainer
       .getGraphControl()
       .dispatchEvent(
           SwingUtilities.convertMouseEvent(
               (Component) e.getSource(), e, graphContainer.getGraphControl()));
 }
コード例 #4
0
ファイル: BottomBar.java プロジェクト: fschaeck/MediathekView
    @Override
    public void mousePressed(MouseEvent e) {
      MouseEvent convertedEvent =
          SwingUtilities.convertMouseEvent(BottomBar.this.getComponent(), e, fSplitPane);

      fDelta = fSplitPane.getDividerLocation() - convertedEvent.getPoint().y;
    }
コード例 #5
0
ファイル: LocationTracker.java プロジェクト: rma93/greenfoot
 /**
  * Translate the event coordinates into those of the source sourceComponent of the
  * LocationTracker.
  */
 private MouseEvent translateEvent(MouseEvent e) {
   Component source = e.getComponent();
   if (source != sourceComponent) {
     e = SwingUtilities.convertMouseEvent(source, e, sourceComponent);
   }
   return e;
 }
コード例 #6
0
    public boolean isEnabled(@NotNull final Project project, final AnActionEvent event) {
      if (!myHandler.isEnabled(project)) return false;

      Editor editor = event.getData(PlatformDataKeys.EDITOR);
      if (editor == null) return false;

      InputEvent inputEvent = event.getInputEvent();
      if (inputEvent instanceof MouseEvent && inputEvent.isAltDown()) {
        MouseEvent mouseEvent = (MouseEvent) inputEvent;
        Component component =
            SwingUtilities.getDeepestComponentAt(
                mouseEvent.getComponent(), mouseEvent.getX(), mouseEvent.getY());
        if (SwingUtilities.isDescendingFrom(component, editor.getComponent())) {
          MouseEvent convertedEvent =
              SwingUtilities.convertMouseEvent(mouseEvent.getComponent(), mouseEvent, component);
          EditorMouseEventArea area = editor.getMouseEventArea(convertedEvent);
          if (area != EditorMouseEventArea.EDITING_AREA) {
            return false;
          }
        }
      } else {
        if (StringUtil.isEmptyOrSpaces(editor.getSelectionModel().getSelectedText())) {
          return false;
        }
      }

      return true;
    }
コード例 #7
0
ファイル: ChannelView.java プロジェクト: usgs/xmax
 public void mousePressed(MouseEvent e) {
   mousePressX = e.getX();
   mousePressY = e.getY();
   graphPanel
       .getScaleMode()
       .init(
           graphs,
           (graphPanel.getOverlayState() == true) || (graphPanel.getSelectState() == true)
               ? graphPanel.getCurrentChannelShowSet()
               : graphPanel.getChannelShowSet(),
           graphPanel.getTimeRange(),
           graphPanel.getMeanState(),
           getHeight());
   // one-button mouse Mac OSX behaviour emulation
   if (e.getButton() == MouseEvent.BUTTON1) {
     if (e.isShiftDown()) {
       button = MouseEvent.BUTTON2;
     } else if (e.isControlDown()) {
       button = MouseEvent.BUTTON3;
     } else {
       button = MouseEvent.BUTTON1;
     }
   } else {
     button = e.getButton();
   }
   graphPanel.dispatchEvent(SwingUtilities.convertMouseEvent(this, e, graphPanel));
 }
コード例 #8
0
 /* Repost event to dispatchComponent */
 private boolean repostEvent(MouseEvent e) {
   if (dispatchComponent == null) {
     return false;
   }
   MouseEvent editorMouseEvent = SwingUtilities.convertMouseEvent(grid, e, dispatchComponent);
   dispatchComponent.dispatchEvent(editorMouseEvent);
   return true;
 }
コード例 #9
0
 private boolean repostEvent(MouseEvent e) {
   // Check for isEditing() in case another event has
   // caused the editor to be removed. See bug #4306499.
   if (dispatchComponent == null || !isEditing()) {
     return false;
   }
   MouseEvent e2 = SwingUtilities.convertMouseEvent(JListMutable.this, e, dispatchComponent);
   dispatchComponent.dispatchEvent(e2);
   return true;
 }
コード例 #10
0
ファイル: BottomBar.java プロジェクト: fschaeck/MediathekView
 public void mouseDragged(MouseEvent e) {
   MouseEvent convertedEvent =
       SwingUtilities.convertMouseEvent(BottomBar.this.getComponent(), e, fSplitPane);
   int newLocation = convertedEvent.getPoint().y + fDelta;
   // bound newLocation between the minimum and maximum divider locations.
   int boundedNewLocation =
       Math.max(
           fSplitPane.getMinimumDividerLocation(),
           Math.min(newLocation, fSplitPane.getMaximumDividerLocation()));
   fSplitPane.setDividerLocation(boundedNewLocation);
 }
コード例 #11
0
ファイル: CPanel.java プロジェクト: Chabernac/p2pmessenger
    private void redispatch(MouseEvent e) {

      setGlassPane(false);
      Point thePoint =
          SwingUtilities.convertPoint(myRootFrame.getGlassPane(), e.getX(), e.getY(), myRootFrame);
      Component theComponent =
          SwingUtilities.getDeepestComponentAt(myRootFrame, thePoint.x, thePoint.y);

      MouseEvent theEvt =
          SwingUtilities.convertMouseEvent(myRootFrame.getGlassPane(), e, theComponent);
      logger.debug(
          "Redispatching mouse event to component: " + theComponent.getClass() + e.isConsumed());
      theComponent.dispatchEvent(theEvt);

      Point theLocalPoint =
          SwingUtilities.convertPoint(myRootFrame.getGlassPane(), e.getX(), e.getY(), CPanel.this);
      if (contains(theLocalPoint))
        dispatchEvent(SwingUtilities.convertMouseEvent(myRootFrame.getGlassPane(), e, CPanel.this));

      setGlassPane(true);
    }
コード例 #12
0
ファイル: ChannelView.java プロジェクト: usgs/xmax
 public void mouseMoved(MouseEvent e) {
   int x = e.getX();
   int y = e.getY();
   graphPanel.cvMouseMoved = true;
   if ((button != MouseEvent.NOBUTTON) && (e.isControlDown() || e.isShiftDown())) {
     mouseDragged(e);
   } else {
     if (mouseAdapter != null) {
       mouseAdapter.mouseMoved(x, y, cv);
     }
     graphPanel.dispatchEvent(SwingUtilities.convertMouseEvent(this, e, graphPanel));
   }
 }
コード例 #13
0
 public static JComponent getDeepest(JComponent outermostContainer, MouseEvent mouseEvent) {
   JComponent result;
   Assert.notNull(outermostContainer);
   Assert.notNull(mouseEvent);
   MouseEvent localizedMouseEvent =
       SwingUtilities.convertMouseEvent(mouseEvent.getComponent(), mouseEvent, outermostContainer);
   result =
       (JComponent)
           SwingUtilities.getDeepestComponentAt(
               outermostContainer,
               localizedMouseEvent.getPoint().x,
               localizedMouseEvent.getPoint().y);
   return result;
 }
コード例 #14
0
ファイル: ChannelView.java プロジェクト: usgs/xmax
 public void mouseClicked(MouseEvent e) {
   int clickedX = e.getX();
   int clickedY = e.getY();
   if (e.getButton() == MouseEvent.BUTTON1) {
     if (mouseAdapter != null) {
       mouseAdapter.mouseClickedButton1(clickedX, clickedY, cv);
     }
     lastClickedY = clickedY;
     lastClickedX = clickedX;
   } else if (e.getButton() == MouseEvent.BUTTON3) {
     if (mouseAdapter != null) {
       mouseAdapter.mouseClickedButton3(clickedX, clickedY, cv);
     }
   }
   graphPanel.dispatchEvent(SwingUtilities.convertMouseEvent(this, e, graphPanel));
 }
コード例 #15
0
 // Event forwarding. We need it if user does press-and-drag gesture for opening popup and
 // choosing item there.
 // It works in JComboBox, here we provide the same behavior
 private void dispatchEventToPopup(MouseEvent e) {
   if (myPopup != null && myPopup.isVisible()) {
     JComponent content = myPopup.getContent();
     Rectangle rectangle = content.getBounds();
     Point location = rectangle.getLocation();
     SwingUtilities.convertPointToScreen(location, content);
     Point eventPoint = e.getLocationOnScreen();
     rectangle.setLocation(location);
     if (rectangle.contains(eventPoint)) {
       MouseEvent event =
           SwingUtilities.convertMouseEvent(e.getComponent(), e, myPopup.getContent());
       Component component =
           SwingUtilities.getDeepestComponentAt(content, event.getX(), event.getY());
       if (component != null) component.dispatchEvent(event);
     }
   }
 }
コード例 #16
0
ファイル: ChannelView.java プロジェクト: usgs/xmax
 public void mouseReleased(MouseEvent e) {
   if (button != MouseEvent.NOBUTTON
       && ((mousePressX != e.getX()) || (mousePressY != e.getY()))) {
     if (button == MouseEvent.BUTTON3
         || (button == MouseEvent.BUTTON1 && e.isControlDown() == true)) {
       if (mouseAdapter != null) {
         mouseAdapter.mouseReleasedButton3(e.getX(), e.getY(), cv);
       }
     } else if (e.getButton() == MouseEvent.BUTTON1) {
       if (mouseAdapter != null) {
         mouseAdapter.mouseReleasedButton1(e.getX(), e.getY(), cv);
       }
     }
   }
   button = MouseEvent.NOBUTTON;
   graphPanel.dispatchEvent(SwingUtilities.convertMouseEvent(this, e, graphPanel));
 }
コード例 #17
0
    public void mousePressed(MouseEvent e) {
      // Selects to create a handler for resizing
      if (!graph.isCellSelected(cell)) {
        graphContainer.selectCellForEvent(cell, e);
      }

      // Initiates a resize event in the handler
      mxCellHandler handler = graphContainer.getSelectionCellsHandler().getHandler(cell);

      if (handler != null) {
        // Starts the resize at index 7 (bottom right)
        handler.start(
            SwingUtilities.convertMouseEvent(
                (Component) e.getSource(), e, graphContainer.getGraphControl()),
            index);
        e.consume();
      }
    }
コード例 #18
0
ファイル: HannoiTower.java プロジェクト: Eric-aihua/practise
 public void mouseDragged(MouseEvent e) {
   Disk disk = null;
   int x, y;
   if (e.getSource() instanceof Disk) {
     move = true;
     disk = (Disk) e.getSource();
     e = SwingUtilities.convertMouseEvent(disk, e, this);
   }
   if (e.getSource() == this) {
     if (move && (disk != null)) {
       x = e.getX();
       y = e.getY();
       if (disk.isPressed() == false) {
         disk.setLocation(x - disk.getWidth() / 2, y - disk.getHeight() / 2);
       } else {
         System.out.println("locked");
       }
     }
   }
 }
コード例 #19
0
ファイル: LoadMacroMenu.java プロジェクト: bzhoek/tn5250j
  private static void doOptionsPopup(MouseEvent e, SessionPanel session) {

    Action action;

    JPopupMenu j = new JPopupMenu("Macro Options");
    action =
        new AbstractAction(
            LangTool.getString("popup.delete") + " " + ((JMenuItem) e.getSource()).getText()) {
          private static final long serialVersionUID = 1L;

          public void actionPerformed(ActionEvent e) {
            StringBuffer macro = new StringBuffer(((JMenuItem) e.getSource()).getText());
            macro.delete(0, LangTool.getString("popup.delete").length() + 1);
            Macronizer.removeMacroByName(macro.toString());
          }
        };

    j.add(action);

    final SessionPanel ses = session;
    action =
        new AbstractAction(
            LangTool.getString("popup.execute") + " " + ((JMenuItem) e.getSource()).getText()) {
          private static final long serialVersionUID = 1L;

          public void actionPerformed(ActionEvent e) {
            StringBuffer macro = new StringBuffer(((JMenuItem) e.getSource()).getText());
            macro.delete(0, LangTool.getString("popup.execute").length() + 1);
            Macronizer.invoke(macro.toString(), ses);
          }
        };

    j.add(action);
    MouseEvent et = SwingUtilities.convertMouseEvent((JMenuItem) e.getSource(), e, session);
    GUIGraphicsUtils.positionPopup(session, j, et.getX(), et.getY());
  }
コード例 #20
0
ファイル: TabControl.java プロジェクト: JIoJIaJIu/myrobotlab
 private void dispatchMouseEvent(MouseEvent e) {
   parent.dispatchEvent(SwingUtilities.convertMouseEvent(e.getComponent(), e, parent));
 }
コード例 #21
0
 private MouseEvent getTargetEvent(MouseEvent e) {
   return SwingUtilities.convertMouseEvent(e.getComponent(), e, this);
 }
コード例 #22
0
 private void dispatchEvent(MouseEvent me) {
   Component src = me.getComponent();
   comp.dispatchEvent(SwingUtilities.convertMouseEvent(src, me, comp));
   src.repaint();
 }
コード例 #23
0
ファイル: ChannelView.java プロジェクト: usgs/xmax
 public void mouseDragged(MouseEvent e) {
   if (mouseAdapter != null) {
     mouseAdapter.mouseDragged(e.getX(), e.getY(), cv);
   }
   graphPanel.dispatchEvent(SwingUtilities.convertMouseEvent(this, e, graphPanel));
 }
コード例 #24
0
ファイル: HannoiTower.java プロジェクト: Eric-aihua/practise
 public void mouseReleased(MouseEvent e) {
   Disk disk = null;
   move = false;
   Rectangle rect = null;
   int x = 0, y = 0;
   boolean containPoint = false;
   int px = 0, py = 0;
   int endI = 0;
   if (e.getSource() instanceof Disk) {
     /* contain point */
     disk = (Disk) e.getSource();
     e = SwingUtilities.convertMouseEvent(disk, e, this);
     x = e.getX();
     y = e.getY();
     rect = disk.getBounds();
     for (int i = 0; i < points.length; i++) {
       px = points[i].getX();
       py = points[i].getY();
       if (rect.contains(px, py)) {
         endI = i;
         containPoint = true;
       }
     }
     if (disk != null && containPoint) {
       /* contain point */
       if ((px != startX) && (py != startY)) {
         System.out.println("px  py" + px + "  " + py + "  x,  y" + x + "  " + y);
         if (points[endI].isHavaDisk()) {
           /* point hava disk */
           System.out.println("------------------startI" + strarTowerPoint);
           System.out.println("------------------endI" + endI);
           System.out.println(endI + "---------point hava disk----------");
           disk.setLocation(startX, startY);
         } else {
           if (endI == diskNum - 1 || endI == diskNum * 2 - 1 || endI == diskNum * 3 - 1) {
             /* to botton */
             points[endI].putDisk(disk, this);
             System.out.println("------------------startI" + strarTowerPoint);
             System.out.println("------------------endI" + endI);
             System.out.println("********to botton put**********************");
             points[strarTowerPoint].setHavaDisk(false);
             if (strarTowerPoint != diskNum - 1
                 || strarTowerPoint != diskNum * 2 - 1
                 || strarTowerPoint != diskNum * 3 - 1) {
               /*
                * not
                * from
                * botton
                */
               (points[strarTowerPoint + 1].getDisk()).setPressed(false);
               points[strarTowerPoint].setHavaDisk(false);
             } else {
               points[strarTowerPoint].setHavaDisk(false);
             }
           } else {
             /* not to botton */
             if (points[endI + 1].isHavaDisk()) {
               /*
                * next have
                * disk
                */
               Disk tempDisk = points[endI + 1].getDisk();
               if ((tempDisk.getNum() - disk.getNum()) >= 1) {
                 /*
                  * bigger
                  * than
                  * points[EndI+1]
                  */
                 points[endI].putDisk(disk, this);
                 System.out.println("------------------startI" + strarTowerPoint);
                 System.out.println("------------------endI" + endI);
                 System.out.println(
                     "********not to botton and next hava disk put**********************");
                 points[strarTowerPoint].setHavaDisk(false);
                 System.out.println("#################" + points[strarTowerPoint].isHavaDisk());
                 System.out.println("#################" + points[endI].isHavaDisk());
                 if (strarTowerPoint != diskNum - 1
                     || strarTowerPoint != diskNum * 2 - 1
                     || strarTowerPoint != diskNum * 3 - 1) {
                   (points[strarTowerPoint].getDisk()).setPressed(false);
                   points[strarTowerPoint].setHavaDisk(false);
                   tempDisk.setPressed(true);
                 } else {
                   points[strarTowerPoint].setHavaDisk(false);
                   // points[endI].setHavaDisk(true);
                   tempDisk.setPressed(true);
                 }
               } else {
                 /* small than points[EndI+1] */
                 System.out.println("----------small---------");
                 disk.setLocation(startX, startY);
               }
             } else {
               /* next not have disk */
               int minMoveNum = ((endI / diskNum) + 1) * diskNum;
               for (int j = endI + 1; j < minMoveNum; j++) {
                 if (points[j].isHavaDisk()) {}
               }
               System.out.println("---------next not have disk----------");
               disk.setLocation(startX, startY);
             }
           }
         }
       }
     }
     if (disk != null && !containPoint) {
       /* not contain point */
       System.out.println("---------not contain point----------");
       disk.setLocation(startX, startY);
     }
   }
 }
コード例 #25
0
 /**
  * @param aEvent
  * @return
  */
 protected final MouseEvent convertEvent(final MouseEvent aEvent) {
   JComponent view = SwingComponentUtils.getDeepestComponentAt(aEvent);
   return SwingUtilities.convertMouseEvent(aEvent.getComponent(), aEvent, view);
 }
コード例 #26
0
 boolean isInDragZone(MouseEvent e) {
   final Point p = SwingUtilities.convertMouseEvent(e.getComponent(), e, this).getPoint();
   return Math.abs(myInfo.getAnchor().isHorizontal() ? p.y : p.x) < 6;
 }