@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();
      }
  @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
    @Override
    public void mousePressed(MouseEvent e) {
      MouseEvent convertedEvent =
          SwingUtilities.convertMouseEvent(BottomBar.this.getComponent(), e, fSplitPane);

      fDelta = fSplitPane.getDividerLocation() - convertedEvent.getPoint().y;
    }
Пример #5
0
 /**
  * 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;
 }
    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
 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));
 }
 /* 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;
 }
 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
 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
    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
 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
 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));
 }
 // 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
 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
 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
  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
 private void dispatchMouseEvent(MouseEvent e) {
   parent.dispatchEvent(SwingUtilities.convertMouseEvent(e.getComponent(), e, parent));
 }
 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
 public void mouseDragged(MouseEvent e) {
   if (mouseAdapter != null) {
     mouseAdapter.mouseDragged(e.getX(), e.getY(), cv);
   }
   graphPanel.dispatchEvent(SwingUtilities.convertMouseEvent(this, e, graphPanel));
 }
Пример #24
0
 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);
 }
 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;
 }