Example #1
0
    /** Invoked when a mouse button has been released on a component. */
    public void mouseReleased(java.awt.event.MouseEvent e) {
      if ((checkClick) && hadDrag) {
        int dx = startX - e.getX();
        int dy = startY - e.getY();
        long cTime = e.getWhen();
        if ((dx * dx + dy * dy < MAX_DISP) && (cTime - startTime) < CLICK_TIME) {
          // our drag was short! dispatch a CLICK event.
          //
          MouseEvent click =
              new MouseEvent(
                  e.getComponent(),
                  MouseEvent.MOUSE_CLICKED,
                  e.getWhen(),
                  e.getModifiers(), // modifiers
                  e.getX(),
                  e.getY(),
                  e.getClickCount(),
                  e.isPopupTrigger());

          fakeClickTime = click.getWhen();
          handleMouseClicked(click);
        }
      }
      checkClick = false;
      hadDrag = false;

      selectInteractor(e);
      if (interactor != null) {
        interactor.mouseReleased(e);
        deselectInteractor();
      } else if (eventDispatcher != null) {
        dispatchMouseReleased(e);
      }
    }
  /**
   * Converts the specified mouse event's screen point from WebView coordinates to Windows
   * coordinates, and returns a new event who's screen point is in Windows coordinates, with the
   * origin at the upper left corner of the WebView window.
   *
   * @param e The event to convert.
   * @return A new mouse event in the Windows coordinate system.
   */
  protected MouseEvent convertToWindows(MouseEvent e) {
    int x = e.getX();
    int y = e.getY();

    // Translate OpenGL screen coordinates to Windows by moving the Y origin from the lower left
    // corner to
    // the upper left corner and flipping the direction of the Y axis.
    y = this.frameSize.height - y;

    if (e instanceof MouseWheelEvent) {
      return new MouseWheelEvent(
          (Component) e.getSource(),
          e.getID(),
          e.getWhen(),
          e.getModifiers(),
          x,
          y,
          e.getClickCount(),
          e.isPopupTrigger(),
          ((MouseWheelEvent) e).getScrollType(),
          ((MouseWheelEvent) e).getScrollAmount(),
          ((MouseWheelEvent) e).getWheelRotation());
    } else {
      return new MouseEvent(
          (Component) e.getSource(),
          e.getID(),
          e.getWhen(),
          e.getModifiers(),
          x,
          y,
          e.getClickCount(),
          e.isPopupTrigger(),
          e.getButton());
    }
  }
 public boolean shouldSelectCell(EventObject anEvent) {
   if (editorComponent != null
       && anEvent instanceof MouseEvent
       && ((MouseEvent) anEvent).getID() == MouseEvent.MOUSE_PRESSED) {
     Component dispatchComponent = SwingUtilities.getDeepestComponentAt(editorComponent, 3, 3);
     MouseEvent e = (MouseEvent) anEvent;
     MouseEvent e2 =
         new MouseEvent(
             dispatchComponent,
             MouseEvent.MOUSE_RELEASED,
             e.getWhen() + 100000,
             e.getModifiers(),
             3,
             3,
             e.getClickCount(),
             e.isPopupTrigger());
     dispatchComponent.dispatchEvent(e2);
     e2 =
         new MouseEvent(
             dispatchComponent,
             MouseEvent.MOUSE_CLICKED,
             e.getWhen() + 100001,
             e.getModifiers(),
             3,
             3,
             1,
             e.isPopupTrigger());
     dispatchComponent.dispatchEvent(e2);
   }
   return false;
 }
Example #4
0
  public void mouseClicked(MouseEvent e) {
    if (e.getWhen() - lastClick < 500) {
      toggle();
      invalidate();
      vp.container.frame.validate();
    }

    lastClick = e.getWhen();
  }
Example #5
0
 public static void move(int x, int y) {
   Component target = getTarget();
   MouseEvent last = null;
   for (MouseEvent me : createPath(target, MousePathGenerator.generatePath(x, y))) {
     Client.getMouse().sendEvent(me);
     long lag = Math.max(0, mouseSpeed - 2 + new Random().nextInt(4));
     if (last != null) lag = me.getWhen() - last.getWhen();
     sleep(lag);
   }
   currentPath = new MouseEvent[] {};
 }
Example #6
0
  /**
   * Called to process events. Mouse events will be rewritten to indicate the position in the
   * document clicked, instead of the position of the panel.
   *
   * @param event to process.
   */
  protected void processEvent(AWTEvent event) {
    try {
      if (event instanceof MouseEvent) {
        final Point scrollPosition = getScrollPosition();

        if (scrollPosition != null) {
          final MouseEvent mouseEvent = (MouseEvent) event;
          event =
              new MouseEvent(
                  (Component) mouseEvent.getSource(),
                  mouseEvent.getID(),
                  mouseEvent.getWhen(),
                  mouseEvent.getModifiers(),
                  mouseEvent.getX() + scrollPosition.x,
                  mouseEvent.getY() + scrollPosition.y,
                  mouseEvent.getClickCount(),
                  mouseEvent.isPopupTrigger());
        }
      }
    } catch (final Throwable exp) {
      exp.printStackTrace(DjVuOptions.err);
      System.gc();
    }

    super.processEvent(event);
  }
 /** Overriden to pass events on to the tree if the editor does not want to start editing. */
 public boolean editCellAt(int row, int column, EventObject e) {
   if (!super.editCellAt(row, column, e)) {
     if (e instanceof MouseEvent) {
       for (int counter = getColumnCount() - 1; counter >= 0; counter--) {
         if (getColumnClass(counter) == TreeTableModel.class) {
           MouseEvent me = (MouseEvent) e;
           MouseEvent newME =
               new MouseEvent(
                   tree,
                   me.getID(),
                   me.getWhen(),
                   me.getModifiers(),
                   me.getX() - getCellRect(0, counter, true).x,
                   me.getY(),
                   me.getClickCount(),
                   me.isPopupTrigger());
           tree.dispatchEvent(newME);
           break;
         }
       }
     }
     return false;
   }
   return true;
 }
 @Override
 public void mousePressed(MouseEvent e) {
   JXTree tree = (JXTree) e.getComponent();
   Point mousePoint = e.getPoint();
   int labelRow = tree.getRowForLocation(mousePoint.x, mousePoint.y);
   // default selection
   if (labelRow >= 0) return;
   int row = tree.getClosestRowForLocation(mousePoint.x, mousePoint.y);
   Rectangle bounds = tree.getRowBounds(row);
   if (bounds == null) {
     row = -1;
   } else {
     if ((bounds.y + bounds.height < mousePoint.y) || bounds.x > mousePoint.x) {
       row = -1;
     }
   }
   // no hit
   if (row < 0) return;
   tree.dispatchEvent(
       new MouseEvent(
           tree,
           e.getID(),
           e.getWhen(),
           e.getModifiers(),
           bounds.x + bounds.width - 2,
           mousePoint.y,
           e.getClickCount(),
           e.isPopupTrigger(),
           e.getButton()));
 }
Example #9
0
    public void mouseClicked(MouseEvent e) {
      // 左ボタンの場合
      if (SwingUtilities.isLeftMouseButton(e)) {

        // クリック間隔算出
        long interSec = (e.getWhen() - lastClickedTime);
        lastClickedTime = e.getWhen();

        // ダブルクリックの場合(クリック間隔280ミリ秒以内)
        if (interSec <= 280) {

          // 拡大処理
          fromPos = toPos = null;
          initMass();
          repaint();
        }
      }
    }
 private MouseEvent createEnterExitEvent(Component c, int eventId, MouseEvent mouseEvent) {
   return new MouseEvent(
       c,
       eventId,
       mouseEvent.getWhen(),
       0,
       mouseEvent.getX(),
       mouseEvent.getY(),
       0,
       false,
       MouseEvent.NOBUTTON);
 }
Example #11
0
    public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) {
      MouseReleasedEvent obj = (MouseReleasedEvent) object;
      java.awt.event.MouseEvent src = obj.getSourceEvent();

      serializer.serialize(buffer, src.getButton());
      serializer.serialize(buffer, src.getClickCount());
      serializer.serialize(buffer, src.getX());
      serializer.serialize(buffer, src.getY());
      serializer.serialize(buffer, src.getID());
      serializer.serialize(buffer, src.getModifiersEx());
      serializer.serialize(buffer, src.getWhen());
    }
Example #12
0
 @Override
 public void mouseClicked(MouseEvent me) {
   if (windowWidth == 0 || windowHeight == 0) return; // no display window yet
   mouseClickX =
       (stretchToFit
           ? (int) (0.5 + me.getX() * bufferSize.width / (double) windowWidth)
           : me.getX() - paintAtX);
   mouseClickY =
       (stretchToFit
           ? (int) (0.5 + me.getY() * bufferSize.height / (double) windowHeight)
           : me.getY() - paintAtY);
   mouseClickTime = me.getWhen();
 }
 public static MouseEvent convertMouseEvent(
     final Component source, final MouseEvent event, final Component destination) {
   Point convertedPoint = convertPoint(source, event.getPoint(), destination);
   return new MouseEvent(
       (destination != null) ? destination : source,
       event.getID(),
       event.getWhen(),
       event.getModifiersEx(),
       convertedPoint.x,
       convertedPoint.y,
       event.getClickCount(),
       event.isPopupTrigger(),
       event.getButton());
 }
Example #14
0
  private MouseEvent translate(MouseEvent e) {
    int x = (int) (e.getX() / scale);
    int y = (int) (e.getY() / scale);

    return new MouseEvent(
        (Component) e.getSource(),
        e.getID(),
        e.getWhen(),
        e.getModifiers(),
        x,
        y,
        e.getClickCount(),
        e.isPopupTrigger(),
        e.getButton());
  }
Example #15
0
 /**
  * Create a MapMouseEvent from a MapMouseMode that is distributing the event and the original
  * MouseEvent delivered from a source component, most likely a MapBean.
  */
 public MapMouseEvent(MapMouseMode mode, MouseEvent me) {
   super(
       (Component) me.getSource(),
       me.getID(),
       me.getWhen(),
       me.getModifiers(),
       me.getX(),
       me.getY(),
       me.getClickCount(),
       me.isPopupTrigger());
   if (me.getSource() instanceof MapBean) {
     map = (MapBean) me.getSource();
   }
   mapMouseMode = mode;
 }
Example #16
0
    /** Invoked when a mouse button has been pressed on a component. */
    public void mousePressed(MouseEvent e) {
      startX = e.getX();
      startY = e.getY();
      startTime = e.getWhen();

      checkClick = true;

      selectInteractor(e);
      if (interactor != null) {
        interactor.mousePressed(e);
        deselectInteractor();
      } else if (eventDispatcher != null) {
        dispatchMousePressed(e);
      }
    }
  private boolean showToolTipByMouseMove(final MouseEvent e, final double width) {
    MouseEvent me = e;

    Set<RangeHighlighter> highlighters = new THashSet<RangeHighlighter>();

    getNearestHighlighters(this, me, width, highlighters);
    getNearestHighlighters(
        (MarkupModelEx) myEditor.getDocument().getMarkupModel(getEditor().getProject()),
        me,
        width,
        highlighters);

    if (highlighters.isEmpty()) return false;

    int minDelta = Integer.MAX_VALUE;
    int y = e.getY();

    for (RangeHighlighter each : highlighters) {
      ProperTextRange range = offsetToYPosition(each.getStartOffset(), each.getEndOffset());
      int eachStartY = range.getStartOffset();
      int eachEndY = range.getEndOffset();
      int eachY = eachStartY + (eachEndY - eachStartY) / 2;
      if (Math.abs(e.getY() - eachY) < minDelta) {
        y = eachY;
      }
    }

    me =
        new MouseEvent(
            (Component) e.getSource(),
            e.getID(),
            e.getWhen(),
            e.getModifiers(),
            e.getX(),
            y + 1,
            e.getClickCount(),
            e.isPopupTrigger());

    TooltipRenderer bigRenderer = myTooltipRendererProvider.calcTooltipRenderer(highlighters);
    if (bigRenderer != null) {
      showTooltip(
          me,
          bigRenderer,
          new HintHint(me).setAwtTooltip(true).setPreferredPosition(Balloon.Position.atLeft));
      return true;
    }
    return false;
  }
 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));
 }
 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);
   }
 }
  /**
   * Convenience method to handle mouse events.
   *
   * @param me the mouse event
   */
  private void dispatchEvent(MouseEvent me) {
    // determine whether border needs to be repainted, e.g. to reflect mouse-over changes
    boolean doRepaint = false;
    int id = me.getID();
    if ((id == MouseEvent.MOUSE_ENTERED) || (id == MouseEvent.MOUSE_MOVED) && !hovering) {
      if (rect.contains(me.getX(), me.getY())) {
        hovering = true;
        id = MouseEvent.MOUSE_ENTERED;
        doRepaint = true;
      }
    } else if ((id == MouseEvent.MOUSE_EXITED) || (id == MouseEvent.MOUSE_MOVED) && hovering) {
      if (!rect.contains(me.getX(), me.getY())) {
        hovering = false;
        id = MouseEvent.MOUSE_EXITED;
        doRepaint = true;
      }
    } else {
      if (rect.contains(me.getX(), me.getY())) {
        doRepaint = true;
      }
    }

    if (doRepaint) {
      // repaint the border's component
      Point pt = me.getPoint();
      pt.translate(-offset, 0);
      comp.setBounds(rect);
      comp.dispatchEvent(
          new MouseEvent(
              comp,
              id,
              me.getWhen(),
              me.getModifiers(),
              pt.x,
              pt.y,
              me.getClickCount(),
              me.isPopupTrigger(),
              me.getButton()));
      // repaint the enclosed container if invalidated
      if (!comp.isValid()) {
        container.repaint();
      }
    }
  }
 private void dispatchEvent(MouseEvent me) {
   if (rect != null && rect.contains(me.getX(), me.getY())) {
     Point pt = me.getPoint();
     pt.translate(-offset, 0);
     comp.setBounds(rect);
     comp.dispatchEvent(
         new MouseEvent(
             comp,
             me.getID(),
             me.getWhen(),
             me.getModifiers(),
             pt.x,
             pt.y,
             me.getClickCount(),
             me.isPopupTrigger(),
             me.getButton()));
     if (!comp.isValid()) container.repaint();
   }
 }
Example #22
0
  /**
   * The code in this method is copy and pasted from source code to the same method in
   * javax.swing.JTable, except for one value change on one line. If you'd like to see the change,
   * please read the source code below.
   *
   * @param event the mouse event we're reacting to
   */
  public String getToolTipText(MouseEvent event) {
    String tip = null;
    Point p = event.getPoint();

    // Locate the renderer under the event location
    int hitColumnIndex = columnAtPoint(p);
    int hitRowIndex = rowAtPoint(p);

    if ((hitColumnIndex != -1) && (hitRowIndex != -1)) {
      TableCellRenderer renderer = getCellRenderer(hitRowIndex, hitColumnIndex);
      Component component = prepareRenderer(renderer, hitRowIndex, hitColumnIndex);

      // Now have to see if the component is a JComponent before
      // getting the tip
      if (component instanceof JComponent) {
        // Convert the event to the renderer's coordinate system
        Rectangle cellRect = getCellRect(hitRowIndex, hitColumnIndex, false);
        // HERE IS THE MODIFICATION FROM javax.swing.JTable:
        // p.translate(-cellRect.x, -cellRect.y);
        p.translate(-cellRect.x, 0);

        // END OF MODIFICATION
        MouseEvent newEvent =
            new MouseEvent(
                component,
                event.getID(),
                event.getWhen(),
                event.getModifiers(),
                p.x,
                p.y,
                event.getClickCount(),
                event.isPopupTrigger());

        tip = ((JComponent) component).getToolTipText(newEvent);
      }
    }

    // No tip from the renderer get our own tip
    if (tip == null) tip = getToolTipText();

    return tip;
  }
Example #23
0
  protected MouseEvent getTranslatedMouseEvent(MouseEvent evt, Rectangle cellRect) {
    Point location = new Point(evt.getPoint());
    location.translate(-cellRect.x, -cellRect.y);

    Component component =
        SwingUtilities.getAncestorOfClass(GanttTable.class, evt.getComponent()) != null
            ? SwingUtilities.getAncestorOfClass(GanttTable.class, evt.getComponent())
            : evt.getComponent();
    return location != null
        ? new MouseEvent(
            component,
            evt.getID(),
            evt.getWhen(),
            evt.getModifiers(),
            location.x,
            location.y,
            evt.getClickCount(),
            evt.isPopupTrigger(),
            evt.getButton())
        : null;
  }
Example #24
0
  /**
   * Re-dispatches glass pane mouse events only in case they occur on the security panel.
   *
   * @param glassPane the glass pane
   * @param e the mouse event in question
   */
  private void redispatchMouseEvent(Component glassPane, MouseEvent e) {
    Point glassPanePoint = e.getPoint();

    Point securityPanelPoint =
        SwingUtilities.convertPoint(glassPane, glassPanePoint, securityPanel);

    Component component;
    Point componentPoint;

    if (securityPanelPoint.y > 0) {
      component = securityPanel;
      componentPoint = securityPanelPoint;
    } else {
      Container contentPane =
          callRenderer.getCallContainer().getCallWindow().getFrame().getContentPane();

      Point containerPoint = SwingUtilities.convertPoint(glassPane, glassPanePoint, contentPane);

      component =
          SwingUtilities.getDeepestComponentAt(contentPane, containerPoint.x, containerPoint.y);

      componentPoint = SwingUtilities.convertPoint(contentPane, glassPanePoint, component);
    }

    if (component != null)
      component.dispatchEvent(
          new MouseEvent(
              component,
              e.getID(),
              e.getWhen(),
              e.getModifiers(),
              componentPoint.x,
              componentPoint.y,
              e.getClickCount(),
              e.isPopupTrigger()));

    e.consume();
  }
  private void dispatchEvent(MouseEvent me) {

    if (rect != null && box != null && rect.contains(me.getX(), me.getY())) {
      Point pt = me.getPoint();
      pt.translate(0, 0);
      box.setBounds(rect);
      box.dispatchEvent(
          new MouseEvent(
              box,
              me.getID(),
              me.getWhen(),
              me.getModifiers(),
              pt.x,
              pt.y,
              me.getClickCount(),
              me.isPopupTrigger(),
              me.getButton()));

      if (!box.isValid()) {
        repaint();
      }
    }
  }
Example #26
0
    /**
     * Overridden to return false, and if the event is a mouse event it is forwarded to the tree.
     *
     * <p>The behavior for this is debatable, and should really be offered as a property. By
     * returning false, all keyboard actions are implemented in terms of the table. By returning
     * true, the tree would get a chance to do something with the keyboard events. For the most part
     * this is ok. But for certain keys, such as left/right, the tree will expand/collapse where as
     * the table focus should really move to a different column. Page up/down should also be
     * implemented in terms of the table. By returning false this also has the added benefit that
     * clicking outside of the bounds of the tree node, but still in the tree column will select the
     * row, whereas if this returned true that wouldn't be the case.
     *
     * <p>By returning false we are also enforcing the policy that the tree will never be editable
     * (at least by a key sequence).
     *
     * @see TableCellEditor
     */
    @Override
    public boolean isCellEditable(EventObject e) {
      if (e instanceof MouseEvent) {
        for (int counter = getColumnCount() - 1; counter >= 0; counter--) {
          if (getColumnClass(counter) == TreeTableModel.class) {
            final MouseEvent me = (MouseEvent) e;
            final MouseEvent newME =
                new MouseEvent(
                    tree,
                    me.getID(),
                    me.getWhen(),
                    me.getModifiers(),
                    me.getX() - getCellRect(0, counter, true).x,
                    me.getY(),
                    me.getClickCount(),
                    me.isPopupTrigger());
            tree.dispatchEvent(newME);
            break;
          }
        }
      }

      return false;
    }
Example #27
0
 /** Invoked when the mouse has been clicked on a component. */
 public void mouseClicked(MouseEvent e) {
   // Supress mouse click if we generated a
   // fake click with the same time stamp.
   if (fakeClickTime != e.getWhen()) handleMouseClicked(e);
 }
Example #28
0
  /**
   * Converts a new event to an old one (used for compatibility). If the new event cannot be
   * converted (because no old equivalent exists) then this returns null.
   *
   * <p>Note: this method is here instead of in each individual new event class in java.awt.event
   * because we don't want to make it public and it needs to be called from java.awt.
   */
  Event convertToOld() {
    Object src = getSource();
    int newid = id;

    switch (id) {
      case KeyEvent.KEY_PRESSED:
      case KeyEvent.KEY_RELEASED:
        KeyEvent ke = (KeyEvent) this;
        if (ke.isActionKey()) {
          newid = (id == KeyEvent.KEY_PRESSED ? Event.KEY_ACTION : Event.KEY_ACTION_RELEASE);
        }
        int keyCode = ke.getKeyCode();
        if (keyCode == KeyEvent.VK_SHIFT
            || keyCode == KeyEvent.VK_CONTROL
            || keyCode == KeyEvent.VK_ALT) {
          return null; // suppress modifier keys in old event model.
        }
        // no mask for button1 existed in old Event - strip it out
        return new Event(
            src,
            ke.getWhen(),
            newid,
            0,
            0,
            Event.getOldEventKey(ke),
            (ke.getModifiers() & ~InputEvent.BUTTON1_MASK));

      case MouseEvent.MOUSE_PRESSED:
      case MouseEvent.MOUSE_RELEASED:
      case MouseEvent.MOUSE_MOVED:
      case MouseEvent.MOUSE_DRAGGED:
      case MouseEvent.MOUSE_ENTERED:
      case MouseEvent.MOUSE_EXITED:
        MouseEvent me = (MouseEvent) this;
        // no mask for button1 existed in old Event - strip it out
        Event olde =
            new Event(
                src,
                me.getWhen(),
                newid,
                me.getX(),
                me.getY(),
                0,
                (me.getModifiers() & ~InputEvent.BUTTON1_MASK));
        olde.clickCount = me.getClickCount();
        return olde;

      case FocusEvent.FOCUS_GAINED:
        return new Event(src, Event.GOT_FOCUS, null);

      case FocusEvent.FOCUS_LOST:
        return new Event(src, Event.LOST_FOCUS, null);

      case WindowEvent.WINDOW_CLOSING:
      case WindowEvent.WINDOW_ICONIFIED:
      case WindowEvent.WINDOW_DEICONIFIED:
        return new Event(src, newid, null);

      case ComponentEvent.COMPONENT_MOVED:
        if (src instanceof Frame || src instanceof Dialog) {
          Point p = ((Component) src).getLocation();
          return new Event(src, 0, Event.WINDOW_MOVED, p.x, p.y, 0, 0);
        }
        break;

      case ActionEvent.ACTION_PERFORMED:
        ActionEvent ae = (ActionEvent) this;
        String cmd;
        if (src instanceof Button) {
          cmd = ((Button) src).getLabel();
        } else if (src instanceof MenuItem) {
          cmd = ((MenuItem) src).getLabel();
        } else {
          cmd = ae.getActionCommand();
        }
        return new Event(src, 0, newid, 0, 0, 0, ae.getModifiers(), cmd);

      case ItemEvent.ITEM_STATE_CHANGED:
        ItemEvent ie = (ItemEvent) this;
        Object arg;
        if (src instanceof List) {
          newid =
              (ie.getStateChange() == ItemEvent.SELECTED ? Event.LIST_SELECT : Event.LIST_DESELECT);
          arg = ie.getItem();
        } else {
          newid = Event.ACTION_EVENT;
          if (src instanceof Choice) {
            arg = ie.getItem();

          } else { // Checkbox
            arg = new Boolean(ie.getStateChange() == ItemEvent.SELECTED);
          }
        }
        return new Event(src, newid, arg);

      case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
        AdjustmentEvent aje = (AdjustmentEvent) this;
        switch (aje.getAdjustmentType()) {
          case AdjustmentEvent.UNIT_INCREMENT:
            newid = Event.SCROLL_LINE_DOWN;
            break;
          case AdjustmentEvent.UNIT_DECREMENT:
            newid = Event.SCROLL_LINE_UP;
            break;
          case AdjustmentEvent.BLOCK_INCREMENT:
            newid = Event.SCROLL_PAGE_DOWN;
            break;
          case AdjustmentEvent.BLOCK_DECREMENT:
            newid = Event.SCROLL_PAGE_UP;
            break;
          case AdjustmentEvent.TRACK:
            if (aje.getValueIsAdjusting()) {
              newid = Event.SCROLL_ABSOLUTE;
            } else {
              newid = Event.SCROLL_END;
            }
            break;
          default:
            return null;
        }
        return new Event(src, newid, new Integer(aje.getValue()));

      default:
    }
    return null;
  }
  /**
   * This method gets called when user performs a mouse click. It decodes whether it is a single
   * click or part of a multiple click (double click, triple click etc.) and inserts appropriate
   * command to the current editor.
   *
   * @param e a MouseEvent describing the mouse click.
   */
  public void mouseClicked(MouseEvent e) {
    if (enabled && !readOnly) {
      if (timer != null && timer.isRunning()) {
        timer.stop();
      }
      if (enableMouseClicks) {
        int count = 1;
        MouseEvent e2;

        long lastEventTime = e.getWhen();

        // This cycle is to determine multiple clicks like double click, triple click etc.
        // We go through the vector of events and check whether there are events corresponding to
        // multiple clicks.
        for (int i = 0; i < events.size() && events.get(i) instanceof MouseEvent; i++) {
          e2 = (MouseEvent) events.get(i);

          // The events are considered to be a multiple click when:
          // 1. Coordinates are equal
          // 2. Modifiers are equal
          // 3. Button is equal
          // 4. Delay between two subsequent clicks is lower than given number of miliseconds
          if (e2.getX() == e.getX()
              && e2.getY() == e.getY()
              && e2.getModifiers() == e.getModifiers()
              && (lastEventTime - e2.getWhen() < mouseMultiDelay)
              && e.getButton() == e2.getButton()
              && e2.getID() == e.getID()) {
            count++;
            lastEventTime = e2.getWhen();
          } else {
            break;
          }
        }

        // Generate the command string
        String s = "Mouse " + MouseCommand.MOUSE_CLICK;

        // Insert the button identifier if other than left button was pressed
        if (e.getButton() != MouseEvent.BUTTON1) {
          s += " " + MouseCommand.PARAM_BUTTON_SHORT + "=" + parser.buttonToString(e.getButton());
        }

        // Insert modifiers if there are any
        String modifiers = parser.modifiersToString(e.getModifiers());
        if (modifiers.length() > 0) {
          s += " " + MouseCommand.PARAM_MODIFIER + "=" + modifiers;
        }

        // Generate the count parameter
        if (count > 1) {
          s += " " + MouseCommand.PARAM_COUNT + "=" + count;
        }

        // This will determine whether this click is preceded by a mouse
        // move command with the same coordinates.
        // It will be replaced if yes.
        boolean replaceLastMove = false;
        //                if (enableMouseMoves) {
        //                    if (events.size() > 0 && events.get(events.size() - 1) instanceof
        // MouseEvent) {
        //                        MouseEvent me = (MouseEvent) events.get(events.size() - 1);
        //                        if (me.getID() == MouseEvent.MOUSE_MOVED && e.getX() == me.getX()
        // && e.getY() == me.getY()) {
        //                            replaceLastMove = true;
        //                        }
        //                    }
        //                }

        // Generate coordinates
        s += " " + MouseCommand.PARAM_TO + "=" + parser.pointToString(e.getPoint());

        // Insert the command to the current editor
        insertLine(s, count > 1 || replaceLastMove, true, false);
        dragInProgress = false;
      }
      insertEvent(e);
    }
  }
    private MouseEvent transformMouseEvent(MouseEvent event) {
      if (event == null) {
        throw new IllegalArgumentException("MouseEvent is null");
      }
      MouseEvent newEvent;
      if (event instanceof MouseWheelEvent) {
        MouseWheelEvent mouseWheelEvent = (MouseWheelEvent) event;
        newEvent =
            new MouseWheelEvent(
                mouseWheelEvent.getComponent(),
                mouseWheelEvent.getID(),
                mouseWheelEvent.getWhen(),
                mouseWheelEvent.getModifiers(),
                mouseWheelEvent.getX(),
                mouseWheelEvent.getY(),
                mouseWheelEvent.getClickCount(),
                mouseWheelEvent.isPopupTrigger(),
                mouseWheelEvent.getScrollType(),
                mouseWheelEvent.getScrollAmount(),
                mouseWheelEvent.getWheelRotation());
      } else {
        newEvent =
            new MouseEvent(
                event.getComponent(),
                event.getID(),
                event.getWhen(),
                event.getModifiers(),
                event.getX(),
                event.getY(),
                event.getClickCount(),
                event.isPopupTrigger(),
                event.getButton());
      }
      if (view != null && at.getDeterminant() != 0) {
        Rectangle viewBounds = getTransformedSize();
        Insets insets = JXTransformer.this.getInsets();
        int xgap = (getWidth() - (viewBounds.width + insets.left + insets.right)) / 2;
        int ygap = (getHeight() - (viewBounds.height + insets.top + insets.bottom)) / 2;

        double x = newEvent.getX() + viewBounds.getX() - insets.left;
        double y = newEvent.getY() + viewBounds.getY() - insets.top;
        Point2D p = new Point2D.Double(x - xgap, y - ygap);

        Point2D tp;
        try {
          tp = at.inverseTransform(p, null);
        } catch (NoninvertibleTransformException ex) {
          // can't happen, we check it before
          throw new AssertionError("NoninvertibleTransformException");
        }
        // Use transformed coordinates to get the current component
        mouseCurrentComponent =
            SwingUtilities.getDeepestComponentAt(view, (int) tp.getX(), (int) tp.getY());
        if (mouseCurrentComponent == null) {
          mouseCurrentComponent = JXTransformer.this;
        }
        Component tempComponent = mouseCurrentComponent;
        if (mouseDraggedComponent != null) {
          tempComponent = mouseDraggedComponent;
        }

        Point point =
            SwingUtilities.convertPoint(view, (int) tp.getX(), (int) tp.getY(), tempComponent);
        newEvent.setSource(tempComponent);
        newEvent.translatePoint(point.x - event.getX(), point.y - event.getY());
      }
      return newEvent;
    }