Beispiel #1
0
  @Override
  public void mouseDragged(MouseEvent e) {

    if (_mousedown != null && _up == null) {
      _display_offset[0] += e.getX() - _mousedown[0];
      _display_offset[1] += e.getY() - _mousedown[1];
      _mousedown = new int[] {e.getX(), e.getY()};
    }
    if (_up != null) {
      if (_up.getType() == BoardObject.type.ROAD) {
        if (((Road) _up).oneDown == false) {
          _up.setX(e.getX());
          _up.setY(e.getY());
        } else {
          ((Road) _up).setX2(e.getX());
          ((Road) _up).setY2(e.getY());
        }
      } else {
        _up.setX(e.getX() - _up.getW() / 2);
        _up.setY(e.getY() - _up.getH() / 2);
      }
    }

    repaint();
  }
Beispiel #2
0
private void Drop (MouseEvent ev)
    {
	switch (state) {
	case stateDrag:
	    state = stateIdle;
	    CheckResize ();
	    break;

	case stateCreate:
	    CGNode node = new CGNode (ev.getX(), ev.getY(), "something",
				      getFontMetrics (getFont()),
				      !curnode.IsConcept());
            curnode.AddChild (node, curarrow);
            node.SetParent (curnode, curarrow);
            ToBottom (curarrow);
            Add (node);

	    if (!node.IsConcept()) {
		int x = ev.getX() + node.Bbox().width + layoutXDist;
		CGNode node2 = new CGNode (x, ev.getY(), "something",
					   getFontMetrics (getFont()),
					   true);
		CGArrow arrow2 = new CGArrow (0, 0, 0, 0);
		node.AddChild (node2, arrow2);
		node2.SetParent (node, arrow2);
		Add (node2);
		Add (arrow2);
                ToBottom (arrow2);
	    }
            state = stateIdle;
            NotifyViewers();
            break;
	}
        ShowStatus (ev.getX(), ev.getY());
    }
Beispiel #3
0
 void dispatch() {
   synchronized (events) {
     if (mousemv != null) {
       mousepos = new Coord(mousemv.getX(), mousemv.getY());
       ui.mousemove(mousemv, mousepos);
       mousemv = null;
     }
     InputEvent e = null;
     while ((e = events.poll()) != null) {
       if (e instanceof MouseEvent) {
         MouseEvent me = (MouseEvent) e;
         if (me.getID() == MouseEvent.MOUSE_PRESSED) {
           ui.mousedown(me, new Coord(me.getX(), me.getY()), me.getButton());
         } else if (me.getID() == MouseEvent.MOUSE_RELEASED) {
           ui.mouseup(me, new Coord(me.getX(), me.getY()), me.getButton());
         } else if (me instanceof MouseWheelEvent) {
           ui.mousewheel(
               me, new Coord(me.getX(), me.getY()), ((MouseWheelEvent) me).getWheelRotation());
         }
       } else if (e instanceof KeyEvent) {
         KeyEvent ke = (KeyEvent) e;
         if (ke.getID() == KeyEvent.KEY_PRESSED) {
           ui.keydown(ke);
         } else if (ke.getID() == KeyEvent.KEY_RELEASED) {
           ui.keyup(ke);
         } else if (ke.getID() == KeyEvent.KEY_TYPED) {
           ui.type(ke);
         }
       }
       ui.lastevent = System.currentTimeMillis();
     }
   }
 }
  public void mousePressed(MouseEvent e) {
    System.out.println("mousePressed");
    Point1 p2;
    switch (toolFlag) {
      case 3: // 直线
        x = (int) e.getX();
        y = (int) e.getY();
        p2 = new Point1(x, y, c, toolFlag, con);
        paintInfo.addElement(p2);
        break;

      case 4: // 圆
        x = (int) e.getX();
        y = (int) e.getY();
        p2 = new Point1(x, y, c, toolFlag, con);
        paintInfo.addElement(p2);
        break;

      case 5: // 矩形
        x = (int) e.getX();
        y = (int) e.getY();
        p2 = new Point1(x, y, c, toolFlag, con);
        paintInfo.addElement(p2);
        break;

      default:
    }
  }
    public void mouseClicked(MouseEvent e) {
      int selRow = tree.getRowForLocation(e.getX(), e.getY());
      TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());

      if (e.getClickCount() == 2) {
        myDoubleClick(selRow, selPath);
      }
    }
Beispiel #6
0
  @Override
  public final void mouseDragged(final MouseEvent e) {
    if (!SwingUtilities.isLeftMouseButton(e)) return;

    // selection mode
    select(e.getPoint(), false);
    final int y = Math.max(20, Math.min(e.getY(), getHeight() - 20));
    if (y != e.getY()) scroll.pos(scroll.pos() + e.getY() - y);
  }
 public void mouseMoved(MouseEvent e) {
   if (isEnabled()) {
     setXY(
         ((double) e.getX() - (double) getWidth() / (double) 2)
             / ((double) (getWidth() + 1) / 2.0),
         -((double) e.getY() - (double) getHeight() / (double) 2)
             / ((double) (getHeight() + 1) / 2.0));
     face.setEmotion(p, a, d, e.getX(), e.getY());
   }
   paint();
 }
 /** Handles mouse down events. The event is delegated to the currently active tool. */
 public void mousePressed(MouseEvent e) {
   try {
     requestFocus(); // JDK1.1
     Point p = constrainPoint(new Point(e.getX(), e.getY()));
     setLastClick(new Point(e.getX(), e.getY()));
     tool().mouseDown(e, p.x, p.y);
     checkDamage();
   } catch (Throwable t) {
     handleMouseEventException(t);
   }
 }
  @Override
  public void mouseReleased(MouseEvent evt) {
    dragLocation = new Point(evt.getX(), evt.getY());
    multicaster.trackEnd(anchor, dragLocation, evt.getModifiersEx(), getView());

    // Note: we must not fire "Tool Done" in this method, because then we can not
    // listen to keyboard events for the handle.

    Rectangle r = new Rectangle(anchor.x, anchor.y, 0, 0);
    r.add(evt.getX(), evt.getY());
    maybeFireBoundsInvalidated(r);
    dragLocation = null;
  }
Beispiel #10
0
private void Drag (MouseEvent ev)
    {
	switch (state) {
	case stateDrag:
            curnode.Move (ev.getX() - dragx, ev.getY() - dragy);
            dragx = ev.getX();
            dragy = ev.getY();
	    break;

	case stateCreate:
	    curarrow.MoveHeadTo (ev.getX(), ev.getY());
	    break;
        }
    }
Beispiel #11
0
private void MenuPopup (MouseEvent ev, CGNode node)
    {
	if (!node.IsConcept())
	    return;

	String menuname = (String)menumap.get (node.GetType(true));
	if (menuname == null)
	    return;
	Hashtable templates = (Hashtable)menus.get (menuname);
	if (templates == null)
	    return;

	if( popup != null )
	  remove( popup );

	popup = new PopupMenu( menuname );
	
        Enumeration e = templates.keys();
        while (e.hasMoreElements()) {
            String key = (String)e.nextElement();
	    MenuItem mi = new MenuItem( key );
	    mi.setActionCommand( key );
	    mi.addActionListener( this );
	    popup.add( mi );
        }
        curnode = node;

	this.add( popup );

	popup.show( this, ev.getX(), ev.getY() );
    }
Beispiel #12
0
 private void maybeShowGroupPopup(MouseEvent e, JIDStatusGroup jidStatusGroup) {
   if (e.isPopupTrigger()) {
     currentJIDStatusGroup = jidStatusGroup;
     currentGroup = jidStatusGroup.getName();
     groupPopupMenu.show(e.getComponent(), e.getX(), e.getY());
   }
 }
Beispiel #13
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);
      }
    }
  }
 /** 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);
   }
 }
 public void mouseMoved(MouseEvent e) {
   // if (ij==null) return;
   int sx = e.getX();
   int sy = e.getY();
   int ox = offScreenX(sx);
   int oy = offScreenY(sy);
   flags = e.getModifiers();
   setCursor(sx, sy, ox, oy);
   IJ.setInputEvent(e);
   Roi roi = imp.getRoi();
   if (roi != null
       && (roi.getType() == Roi.POLYGON
           || roi.getType() == Roi.POLYLINE
           || roi.getType() == Roi.ANGLE)
       && roi.getState() == roi.CONSTRUCTING) {
     PolygonRoi pRoi = (PolygonRoi) roi;
     pRoi.handleMouseMove(ox, oy);
   } else {
     if (ox < imageWidth && oy < imageHeight) {
       ImageWindow win = imp.getWindow();
       // Cursor must move at least 12 pixels before text
       // displayed using IJ.showStatus() is overwritten.
       if ((sx - sx2) * (sx - sx2) + (sy - sy2) * (sy - sy2) > 144) showCursorStatus = true;
       if (win != null && showCursorStatus) win.mouseMoved(ox, oy);
     } else IJ.showStatus("");
   }
 }
  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();
    }
  }
 @Override
 public void mousePressed(MouseEvent evt) {
   // handle.mousePressed(evt);
   anchor = new Point(evt.getX(), evt.getY());
   multicaster.trackStart(anchor, evt.getModifiersEx(), getView());
   clearHoverHandles();
 }
  /**
   * 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());
    }
  }
Beispiel #19
0
 static void handleMouseDragged(MouseEvent e) {
   DrawObject L = new DrawObject();
   L.scribbleX = e.getX();
   L.scribbleY = e.getY();
   L.scribbleNum = currentScribbleNum;
   scribbles.add(L);
   drawArea.repaint();
 }
 @Override
 public void mouseClicked(MouseEvent evt) {
   if (evt.getClickCount() == 2) {
     multicaster.trackDoubleClick(
         new Point(evt.getX(), evt.getY()), evt.getModifiersEx(), getView());
   }
   evt.consume();
 }
Beispiel #21
0
 private Location findloc(MouseEvent e) {
   int i, x = e.getX(), y = e.getY();
   if (button.contains(x, y)) return button;
   for (i = 0; i < NUM_LOCATIONS; i++) {
     if (locs[i].contains(x, y)) return locs[i];
   }
   return null;
 }
 /** Handles mouse drag events. The event is delegated to the currently active tool. */
 public void mouseDragged(MouseEvent e) {
   try {
     Point p = constrainPoint(new Point(e.getX(), e.getY()));
     tool().mouseDrag(e, p.x, p.y);
     checkDamage();
   } catch (Throwable t) {
     handleMouseEventException(t);
   }
 }
 public void mouseDragged(MouseEvent e) {
   mx = e.getX();
   my = e.getY();
   // Buttons
   pauseClicked();
   resumeClicked();
   musicClicked();
   menuClicked();
 }
Beispiel #24
0
 public void mousePressed(MouseEvent e) {
   int x = e.getX(), y = e.getY();
   pressX = lastX = x;
   pressY = lastY = y;
   first = findFigureElement(x, y);
   if (first == null) {
     point1 = addPoint(x, y);
   }
 }
Beispiel #25
0
  public void mouseReleased(MouseEvent e) {
    System.out.println("mouseReleased");
    Point1 p3;
    switch (toolFlag) {
      case 0: // 画笔
        paintInfo.addElement(cutflag);
        break;

      case 1: // eraser
        paintInfo.addElement(cutflag);
        break;

      case 3: // 直线
        x = (int) e.getX();
        y = (int) e.getY();
        p3 = new Point1(x, y, c, toolFlag, con);
        paintInfo.addElement(p3);
        paintInfo.addElement(cutflag);
        repaint();
        break;

      case 4: // 圆
        x = (int) e.getX();
        y = (int) e.getY();
        p3 = new Point1(x, y, c, toolFlag, con);
        paintInfo.addElement(p3);
        paintInfo.addElement(cutflag);
        repaint();
        break;

      case 5: // 矩形
        x = (int) e.getX();
        y = (int) e.getY();
        p3 = new Point1(x, y, c, toolFlag, con);
        paintInfo.addElement(p3);
        paintInfo.addElement(cutflag);
        repaint();
        break;

      default:
    }
  }
Beispiel #26
0
  public String getToolTipText(MouseEvent ev) {
    if (ev == null) return null;
    TreePath path = getPathForLocation(ev.getX(), ev.getY());
    if (path != null) {
      JIDStatus jidStatus = null;
      Object o = path.getLastPathComponent();
      if (o instanceof PrimaryJIDStatus) {
        jidStatus = ((PrimaryJIDStatus) o).getJIDPrimaryStatus();
      }
      if (o instanceof JIDStatus) {
        jidStatus = ((JIDStatus) o);
      } else {
        return null;
      }
      String statusMsg;
      if (jidStatus.getStatus() != null) {
        statusMsg =
            I18N.gettext("main.main.statusmenu.Status_message:")
                + " "
                + jidStatus.getStatus()
                + "</p><p>";
      } else {
        statusMsg = "";
      }

      String waitingStatus = jidStatus.getWaiting();
      if (jidStatus.getWaiting() != null) {
        waitingStatus =
            "<p>"
                + I18N.gettext("main.main.roster.Waiting_Status:")
                + " "
                + jidStatus.getWaiting()
                + "</p>";
      } else {
        waitingStatus = "";
      }
      return "<HTML><P>"
          + I18N.gettext("main.main.roster.Status:")
          + " "
          + Presence.toLongShow(jidStatus.getShow())
          + "</p><p>"
          + statusMsg
          + "JID: "
          + jidStatus.getCompleteJID()
          + "</p><p>"
          + I18N.gettext("main.main.roster.Subscription:")
          + " "
          + jidStatus.getSubscription()
          + "</p>"
          + waitingStatus
          + "</p></HTML>";
    }
    return null;
  }
    private void maybeShowPopup(MouseEvent e) {

      if (e.isPopupTrigger()) {
        popup = new JPopupMenu();
        CalendarCardPanel cc = new CalendarCardPanel(ClientContext.getEventColorTable());
        cc.addPropertyChangeListener(CalendarCardPanel.PICKED_DATE, this);
        cc.setCalendarRange(new int[] {-12, 0});
        popup.insert(cc, 0);
        popup.show(e.getComponent(), e.getX(), e.getY());
      }
    }
Beispiel #28
0
  private int[] setUpNearest(MouseEvent e) {

    int mousex = e.getX() - _display_offset[0];
    int mousey = e.getY() - _display_offset[1];

    int i = 0;
    int j;

    j = (int) Math.round((mousey - hextop) * 1.0 / intervalUp);

    if ((j % 2 + (rings - 1) % 2) == 0 || (((j - 1) % 2 + (rings) % 2) == 0)) {
      int glob = 1;
      for (i = 0;
          (Math.floor((i + 1) / 2) * radius + Math.floor(i / 2) * radius * 2)
              < mousex - hexleft - radius / 2;
          i++) glob += (((i % 2) == 0) ? 1 : 3);

      double dx =
          (Math.floor((i + 1) / 2) * radius + Math.floor(i / 2) * radius * 2)
              - (mousex - hexleft - radius / 2);

      if ((i % 2) == 1 && dx > radius / 2) {
        i = i - 1;
        glob -= 1;
      } else if ((i % 2) == 0 && dx > radius) {
        i = i - 1;
        glob -= 3;
      }

      i = glob;

    } else {
      int glob = 0;
      for (i = 0;
          (Math.floor((i + 1) / 2) * radius * 2 + Math.floor(i / 2) * radius) < mousex - hexleft;
          i++) glob += (((i % 2) == 0) ? 3 : 1);

      double dx =
          (Math.floor((i + 1) / 2) * radius * 2 + Math.floor(i / 2) * radius) - (mousex - hexleft);

      if ((i % 2) == 0 && dx > radius / 2) {
        i = i - 1;
        glob -= 1;
      } else if ((i % 2) == 1 && dx > radius) {
        i = i - 1;
        glob -= 3;
      }

      i = glob;
    }

    return new int[] {i, j};
  }
Beispiel #29
0
 public void mousePressed(MouseEvent e) {
   if (e.getButton() == 3 && !(currentTool instanceof CursorTool)) {
     setTool(cursorTool, cursorButton);
   } else {
     Point p = new Point(e.getX(), e.getY());
     WorkingView.this.getTool().mouseDown(p.x, p.y, e);
   }
   if (currentTool instanceof ArrowTool || currentTool instanceof TextBoxTool) {
     setTool(cursorTool, cursorButton);
   }
   board.requestFocus();
 }
Beispiel #30
0
 static void handleMouseClick(MouseEvent e) {
   double midX = (maxX + minX) / 2;
   double midXDist = midX - minX;
   double midY = (maxY + minY) / 2;
   double midYDist = midY - minY;
   // See if any of the navigation icons were under the mouse.
   if (withinBounds(e.getX(), e.getY(), D.width - 20, D.width - 15, 10, 20)) {
     // Plus.
     setXYRange(minX, midX, minY, midY);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 20, D.width - 15, 40, 50)) {
     // Minus.
     setXYRange(minX, 2 * maxX, minY, 2 * maxY);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 75, D.width - 65, 0, 20)) {
     //
     setXYRange(minX, maxX, minY + midYDist, maxY + midYDist);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 75, D.width - 65, 30, 50)) {
     //
     setXYRange(minX, maxX, minY - midYDist, maxY - midYDist);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 65, D.width - 45, 20, 30)) {
     //
     setXYRange(minX + midXDist, maxX + midXDist, minY, maxY);
   } else if (withinBounds(e.getX(), e.getY(), D.width - 95, D.width - 75, 20, 30)) {
     //
     setXYRange(minX - midXDist, maxX - midXDist, minY, maxY);
   }
   drawArea.repaint();
 }