private void kochPanelMouseDragged(MouseEvent event) { zoomTranslateX = zoomTranslateX + event.getX() - lastDragX; zoomTranslateY = zoomTranslateY + event.getY() - lastDragY; lastDragX = event.getX(); lastDragY = event.getY(); kochManager.drawEdges(); }
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(); } }
@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; } }
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); }
@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); } }
private void kochPanelMousePressed(MouseEvent event) { startPressedX = event.getX(); startPressedY = event.getY(); lastDragX = event.getX(); lastDragY = event.getY(); }