@Override
  public void eventMouse(MouseEvent e) {
    if (!this.isVisible()) {
      this.state = NORMAL;
      return;
    }

    int button = e.getButton();
    boolean state = e.getState();
    Vec2i mouse = new Vec2i(e.getX(), e.getY());

    if (this.getBoundsDisp().contains(mouse)) {
      if (!state) {
        if (this.state == PRESSED && button == BUTTON_LEFT) {
          this.clicked = true;
          this.state = MOUSE_ON;
        }
        if (this.state == NORMAL) {
          this.state = MOUSE_ON;
        }
      } else if (button == BUTTON_LEFT) {
        this.state = PRESSED;
      }
    } else {
      this.state = NORMAL;
    }
  }
Ejemplo n.º 2
0
 private void kochPanelMouseDragged(MouseEvent event) {
   zoomTranslateX = zoomTranslateX + event.getX() - lastDragX;
   zoomTranslateY = zoomTranslateY + event.getY() - lastDragY;
   lastDragX = event.getX();
   lastDragY = event.getY();
   kochManager.drawEdges();
 }
Ejemplo n.º 3
0
 public void blankSquare(MouseEvent arg0) {
   if (arg0.getSource() == 0) {
     // checks to see if a square is properly blank without a number or a mine
     // fails test if square contains a value other than 0.
     assertEquals(arg0.getSource(), 0);
   }
 }
 protected int[] getCoordinates(GwtEvent<? extends EventHandler> event) {
   if (event instanceof TouchEvent) {
     return getPositionInTouch((TouchEvent<? extends EventHandler>) event);
   } else if (event instanceof MouseEvent) {
     MouseEvent<? extends EventHandler> me = (MouseEvent<? extends EventHandler>) event;
     return new int[] {me.getRelativeX(canvas.getElement()), me.getRelativeY(canvas.getElement())};
   }
   return null;
 }
Ejemplo n.º 5
0
 protected void spin(MouseEvent e) {
   int y = e.getY();
   int x = e.getX();
   double th = Math.atan((1.0 * y - radius) / (x - radius));
   int value = (int) (th / (2 * Math.PI) * (maxValue - minValue));
   if (x < radius) setValue(value + (maxValue - minValue) / 2 + minValue);
   else if (y < radius) setValue(value + maxValue);
   else setValue(value + minValue);
 }
Ejemplo n.º 6
0
  /**
   * Sets the fields of this MouseEvent to match the given MouseEvent.
   *
   * @param mouse
   * @param wheel
   * @param wheelDelta
   * @param isPageMove
   * @param when
   * @param lastWhen
   */
  protected void set(
      Mouse mouse, MouseWheel wheel, int wheelDelta, boolean isPageMove, long when, long lastWhen) {
    super.set(mouse, SubType.WHEEL_MOVED, wheel, when, lastWhen);

    this.wheelDelta = wheelDelta;
    this.isPageMove = isPageMove;
  }
Ejemplo n.º 7
0
 @FXML
 void seek(MouseEvent evt) {
   if (player != null) {
     Duration d = player.getMedia().getDuration();
     double millis = (evt.getX() / loadProgressBar.getWidth()) * d.toMillis();
     Duration s = new Duration(millis);
     player.seek(s);
   }
 }
 public static void openProducedItemDescription(
     final MouseEvent e, final RecipeView recipeView, final Window window) {
   if (e.getButton() != 3) {
     return;
   }
   final UICraftItemDetailMessage msg = new UICraftItemDetailMessage();
   msg.setParentWindowId((window == null) ? null : window.getElementMap().getId());
   msg.setItem(recipeView);
   Worker.getInstance().pushMessage(msg);
 }
Ejemplo n.º 9
0
    private int rightClicks() {
      int contextClicks = 0;

      for (int i = 0; i <= events.size(); i++) {
        MouseEvent event = events.get(i);
        MouseEvent nextEvent;

        if (events.size() == (i + 1)) {
          break;
        }

        nextEvent = events.get(i + 1);

        if (event.equals(new MouseEvent("mousedown", 2))
            && nextEvent.equals(new MouseEvent("mouseup", 2))) {
          contextClicks++;
        }
      }

      return contextClicks;
    }
Ejemplo n.º 10
0
 private void kochPanelMouseClicked(MouseEvent event) {
   if (Math.abs(event.getX() - startPressedX) < 1.0
       && Math.abs(event.getY() - startPressedY) < 1.0) {
     double originalPointClickedX = (event.getX() - zoomTranslateX) / zoom;
     double originalPointClickedY = (event.getY() - zoomTranslateY) / zoom;
     if (event.getButton() == MouseButton.PRIMARY) {
       zoom *= 2.0;
     } else if (event.getButton() == MouseButton.SECONDARY) {
       zoom /= 2.0;
     }
     zoomTranslateX = (int) (event.getX() - originalPointClickedX * zoom);
     zoomTranslateY = (int) (event.getY() - originalPointClickedY * zoom);
     kochManager.drawEdges();
   }
 }
  @FXML
  void dragDetected(MouseEvent event) {
    /* drag was detected, start drag-and-drop gesture*/

    /* allow any transfer mode */
    Dragboard db = imageView.startDragAndDrop(TransferMode.ANY);

    /* put a string on dragboard */
    ClipboardContent content = new ClipboardContent();
    content.putImage(imageView.getImage());
    db.setContent(content);

    event.consume();
  }
 public static void openProducedItemDescription(
     final MouseEvent e, final AbstractCraftHarvestElement element, final Window window) {
   if (e.getButton() != 3) {
     return;
   }
   final AbstractReferenceItem referenceItem =
       ReferenceItemManager.getInstance().getReferenceItem(element.getItemId());
   if (referenceItem == null) {
     return;
   }
   final Item item = new Item(referenceItem.getId());
   item.initializeWithReferenceItem(referenceItem);
   final UIItemDetailMessage msg = new UIItemDetailMessage();
   msg.setId(16415);
   msg.setParentWindowId((window == null) ? null : window.getElementMap().getId());
   msg.setItem(item);
   Worker.getInstance().pushMessage(msg);
 }
 /** Fixes pick block */
 @SubscribeEvent(priority = EventPriority.HIGHEST)
 public void replacePickBlock(MouseEvent event) {
   if (event.buttonstate) {
     Minecraft mc = FMLClientHandler.instance().getClient();
     if (mc.thePlayer != null) {
       if (event.button - 100 == mc.gameSettings.keyBindPickBlock.getKeyCode()) {
         event.setCanceled(true);
         if (!((IBattlePlayer) mc.thePlayer).isBattlemode()) {
           boolean isCreative = mc.thePlayer.capabilities.isCreativeMode;
           ItemStack stack = getItemFromPointedAt(mc.objectMouseOver, mc.thePlayer);
           if (stack != null) {
             int k = -1;
             ItemStack temp;
             for (int slot = 0; slot < MAIN_INV; slot++) {
               temp = mc.thePlayer.inventory.getStackInSlot(slot);
               if (temp != null
                   && stack.isItemEqual(temp)
                   && ItemStack.areItemStackTagsEqual(stack, temp)) {
                 k = slot;
                 break;
               }
             }
             if (isCreative && k == -1) {
               k = mc.thePlayer.inventory.getFirstEmptyStack();
               if (k < 0 || k >= MAIN_INV) {
                 k = mc.thePlayer.inventory.currentItem;
               }
             }
             if (k >= 0 && k < MAIN_INV) {
               mc.thePlayer.inventory.currentItem = k;
               Battlegear.packetHandler.sendPacketToServer(
                   new PickBlockPacket(stack, k).generatePacket());
             }
           }
         }
       }
     }
   }
 }
Ejemplo n.º 14
0
 private void kochPanelMousePressed(MouseEvent event) {
   startPressedX = event.getX();
   startPressedY = event.getY();
   lastDragX = event.getX();
   lastDragY = event.getY();
 }
Ejemplo n.º 15
0
 private Point getMousePosition(MouseEvent event) {
   int x = event.getRelativeX(this.canvas.getElement());
   int y = event.getRelativeY(this.canvas.getElement());
   return new Point(x, y);
 }
Ejemplo n.º 16
0
 /** @see IFigure#handleMouseReleased(MouseEvent) */
 public void handleMouseReleased(MouseEvent event) {
   Iterator iter = eventListeners.getListeners(MouseListener.class);
   while (!event.isConsumed() && iter.hasNext())
     ((MouseListener) iter.next()).mouseReleased(event);
 }
Ejemplo n.º 17
0
 @FXML
 public void tracksViewMouseClicked(MouseEvent evt) {
   if (evt.getClickCount() == 2) {
     playSelectedTrack();
   }
 }