예제 #1
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 onMouseClickGameStatus(MouseEvent mouseEvent) {
   GameStatus gameStatus = playerInfoBean.getGameStatus();
   if (gameStatus == GameStatus.NONE) {
     return;
   }
   if (mouseEvent.getButton() == MouseButton.PRIMARY && mouseEvent.getClickCount() == 2) {
     int uid = playerInfoBean.getGameUid();
     if (gameStatus == GameStatus.LOBBY || gameStatus == GameStatus.HOST) {
       GameInfoBean gameInfoBean = gameService.getByUid(uid);
       gamesController.onJoinGame(
           gameInfoBean, null, mouseEvent.getScreenX(), mouseEvent.getScreenY());
     } else if (gameStatus == GameStatus.PLAYING) {
       try {
         replayService.runLiveReplay(uid, playerInfoBean.getUsername());
       } catch (IOException e) {
         notificationService.addNotification(
             new ImmediateNotification(
                 i18n.get("errorTitle"),
                 i18n.get("replayCouldNotBeStarted.text"),
                 Severity.ERROR,
                 e,
                 singletonList(new ReportAction(i18n, reportingService, e))));
       }
     }
   }
 }
예제 #3
0
  @FXML
  private void Play(MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY) {
      if (j == 0) {
        listView.getSelectionModel().select(j);
        listView.getFocusModel().focus(j);
      }

      if (mp != null) {
        MediaPlayer.Status status = mp.getStatus();
        if (status == MediaPlayer.Status.UNKNOWN || status == MediaPlayer.Status.HALTED) {
          return;
        }
        if (status == MediaPlayer.Status.PAUSED
            || status == MediaPlayer.Status.READY
            || status == MediaPlayer.Status.STOPPED) {
          if (atEndOfMedia) {
            atEndOfMedia = false;
          }
          onPlay();
          mp.play();
          statusDisplay.toBack();
          play = true;

        } else {
          mp.pause();
          statusDisplay.toFront();
          play = false;
        }
      }
    }
  }
예제 #4
0
 @FXML
 private void gotoNP(MouseEvent event) {
   if (event.getButton() == MouseButton.PRIMARY) {
     if (go == false) {
       npView.setVisible(true);
       mView.toBack();
       timeProgress.setTextFill(Color.WHITE);
       Stage stage = (Stage) root.getScene().getWindow();
       stage.setResizable(true);
       btnPaFull.setImage(new Image("icon/Full_button/full.png"));
       go = true;
     } else {
       if (play == true) {
         Stage stage = (Stage) root.getScene().getWindow();
         if (full == false) {
           stage.setFullScreen(true);
           btnPaFull.setImage(new Image("icon/Full_button/full_off.png"));
           full = true;
         } else {
           stage.setFullScreen(false);
           btnPaFull.setImage(new Image("icon/Full_button/full.png"));
           full = false;
         }
       }
     }
   }
 }
예제 #5
0
  private void handleMouseEvent(MouseEvent me) {
    // Handle cursor
    final Scene scene = getScene();

    if (scene == null) {
      return;
    }

    // When another window is focused (just like the preview window),
    // we use default cursor
    if (scene.getWindow() != null && !scene.getWindow().isFocused()) {
      setCursor(Cursor.DEFAULT);
      return;
    }

    final LibraryListItem listItem = getItem();
    ILibraryItem item = null;

    if (listItem != null) {
      item = listItem.getLibItem();
    }

    boolean isSection = false;
    if (listItem != null && listItem.getSectionName() != null) {
      isSection = true;
    }

    if (me.getEventType() == MouseEvent.MOUSE_ENTERED) {
      if (isEmpty() || isSection) {
        setCursor(Cursor.DEFAULT);
      } else {
        setCursor(Cursor.OPEN_HAND);
      }
    } else if (me.getEventType() == MouseEvent.MOUSE_PRESSED) {
      if (isEmpty() || isSection) {
        setCursor(Cursor.DEFAULT);
      } else {
        setCursor(Cursor.CLOSED_HAND);
      }
    } else if (me.getEventType() == MouseEvent.MOUSE_RELEASED) {
      if (isEmpty() || isSection) {
        setCursor(Cursor.DEFAULT);
      } else {
        setCursor(Cursor.OPEN_HAND);
      }
    } else if (me.getEventType() == MouseEvent.MOUSE_EXITED) {
      setCursor(Cursor.DEFAULT);
    } else if (me.getEventType() == MouseEvent.MOUSE_CLICKED) {
      // On double click ask for addition of the drag able item on Content
      if (me.getClickCount() == 2 && me.getButton() == MouseButton.PRIMARY) {
        if (!isEmpty() && !isSection && item != null) {
          if (editorController.canPerformInsert(item)) {
            editorController.performInsert(item);
          }
        }
      }
    }
  }
예제 #6
0
 @FXML
 private void handleProgress(MouseEvent event) {
   if (event.getButton() == MouseButton.PRIMARY) {
     if (play = true) {
       mp.seek(
           Duration.seconds((mp.getTotalDuration().toSeconds() * timeSlider.getValue() / 100)));
     }
   }
 }
예제 #7
0
 @FXML
 private void evtMouseClick(MouseEvent evt) throws Exception {
   if (evt.getButton() == MouseButton.SECONDARY) {
     showContextMenu(evt.getX(), evt.getY());
     evt.consume();
   } else if (contextMenu != null) {
     contextMenu.hide();
   }
 }
예제 #8
0
 @FXML
 private void Foward(MouseEvent event) {
   if (event.getButton() == MouseButton.PRIMARY) {
     statusDisplay.toBack();
     if (j == fileList.size() - 1) {
       listView.getSelectionModel().selectFirst();
     } else {
       listView.getSelectionModel().selectNext();
     }
   }
 }
예제 #9
0
 @FXML
 private void Stop(MouseEvent event) {
   if (event.getButton() == MouseButton.PRIMARY) {
     if (mp != null) {
       mp.stop();
       playButton.setImage(new Image("icon/PlayPause_button/play.png"));
       mp.seek(mp.getStartTime());
       play = false;
     }
   }
 }
예제 #10
0
 @FXML
 private void Previous(MouseEvent event) {
   if (event.getButton() == MouseButton.PRIMARY) {
     statusDisplay.toBack();
     if (j == 0) {
       listView.getSelectionModel().selectLast();
     } else {
       listView.getSelectionModel().selectPrevious();
     }
   }
 }
예제 #11
0
 @FXML
 private void setVolume(MouseEvent event) {
   if (event.getButton() == MouseButton.PRIMARY) {
     if (play = true) {
       if (mute == false) {
         mp.setVolume(0.0);
         mute = true;
       } else {
         mp.setVolume(1.0);
         mute = false;
       }
     }
   }
 }
예제 #12
0
 public void startGame(MouseEvent e) {
   if (e.getButton().equals(MouseButton.PRIMARY)) {
     stage.close();
     EscapeNewPangea game = new EscapeNewPangea();
     Scene scene = game.initialize();
     stage.setScene(scene);
     stage.show();
     KeyFrame frame = game.start();
     Timeline animation = new Timeline();
     animation.setCycleCount(Animation.INDEFINITE);
     animation.getKeyFrames().add(frame);
     animation.play();
   }
 }
예제 #13
0
  @FXML
  private void gotoMain(MouseEvent event) {
    if (event.getButton() == MouseButton.PRIMARY) {
      btnPaFull.setImage(new Image("icon/Go_button/goNP.png"));
      timeProgress.setTextFill(Color.BLACK);
      Stage stage = (Stage) root.getScene().getWindow();
      if (stage.isFullScreen() == true) {
        stage.setFullScreen(false);
      }

      mView.setVisible(true);
      npView.toBack();
      stage.setResizable(false);
      go = false;
    }
  }
  /**
   * Click and Hold to make window draggable
   *
   * @param event
   */
  public void handleAppMouseClick_Hold(MouseEvent event) {

    Stage stage = OnlineQuizzingApp.getInstance().getStage();

    xOffset = event.getSceneX();
    yOffset = event.getSceneY();

    if (event.getButton().equals(MouseButton.PRIMARY)) {
      if (event.getClickCount() == 2) {
        if (stage.isFullScreen()) {
          stage.setFullScreen(false);
        } else {
          stage.setFullScreen(true);
        }
      }
    }
  }
예제 #15
0
 @FXML
 private void Repeat(MouseEvent event) {
   if (event.getButton() == MouseButton.PRIMARY) {
     repeat++;
     switch (repeat) {
       case 1:
         mp.setCycleCount(MediaPlayer.INDEFINITE);
         repeatButton.setImage(new Image("icon/Replay_button/replay_one.png"));
         break;
       case 2:
         mp.setCycleCount(0);
         repeatButton.setImage(new Image("icon/Replay_button/replay_all.png"));
         break;
       case 3:
         repeat = 0;
         repeatButton.setImage(new Image("icon/Replay_button/replay.png"));
         break;
     }
   }
 }
예제 #16
0
 void showContextMenu(MouseEvent e) {
   if (MouseButton.SECONDARY != e.getButton()) {
     return;
   }
   getContextMenu().show(canvas, e.getScreenX(), e.getScreenY());
 }
예제 #17
0
 private boolean isDoubleClick(MouseEvent e) {
   return e.getButton() == MouseButton.PRIMARY && e.getClickCount() == 2;
 }
예제 #18
0
  @Override
  public void handle(MouseEvent event) {
    if (event.getEventType() == MouseEvent.MOUSE_PRESSED) {
      if (dockNode.isFloating()
          && event.getClickCount() == 2
          && event.getButton() == MouseButton.PRIMARY) {
        dockNode.setMaximized(!dockNode.isMaximized());
      } else {
        // drag detected is used in place of mouse pressed so there is some threshold for the
        // dragging which is determined by the default drag detection threshold
        dragStart = new Point2D(event.getX(), event.getY());
      }
    } else if (event.getEventType() == MouseEvent.DRAG_DETECTED) {
      if (!dockNode.isFloating()) {
        // if we are not using a custom title bar and the user
        // is not forcing the default one for floating and
        // the dock node does have native window decorations
        // then we need to offset the stage position by
        // the height of this title bar
        if (!dockNode.isCustomTitleBar() && dockNode.isDecorated()) {
          dockNode.setFloating(true, new Point2D(0, DockTitleBar.this.getHeight()));
        } else {
          dockNode.setFloating(true);
        }

        // TODO: Find a better solution.
        // Temporary work around for nodes losing the drag event when removed from
        // the scene graph.
        // A possible alternative is to use "ghost" panes in the DockPane layout
        // while making DockNode simply an overlay stage that is always shown.
        // However since flickering when popping out was already eliminated that would
        // be overkill and is not a suitable solution for native decorations.
        // Bug report open: https://bugs.openjdk.java.net/browse/JDK-8133335
        DockPane dockPane = this.getDockNode().getDockPane();
        if (dockPane != null) {
          dockPane.addEventFilter(MouseEvent.MOUSE_DRAGGED, this);
          dockPane.addEventFilter(MouseEvent.MOUSE_RELEASED, this);
        }
      } else if (dockNode.isMaximized()) {
        double ratioX = event.getX() / this.getDockNode().getWidth();
        double ratioY = event.getY() / this.getDockNode().getHeight();

        // Please note that setMaximized is ruined by width and height changes occurring on the
        // stage and there is currently a bug report filed for this though I did not give them an
        // accurate test case which I should and wish I would have. This was causing issues in the
        // original release requiring maximized behavior to be implemented manually by saving the
        // restored bounds. The problem was that the resize functionality in DockNode.java was
        // executing at the same time canceling the maximized change.
        // https://bugs.openjdk.java.net/browse/JDK-8133334

        // restore/minimize the window after we have obtained its dimensions
        dockNode.setMaximized(false);

        // scale the drag start location by our restored dimensions
        dragStart = new Point2D(ratioX * dockNode.getWidth(), ratioY * dockNode.getHeight());
      }
      dragging = true;
      event.consume();
    } else if (event.getEventType() == MouseEvent.MOUSE_DRAGGED) {
      if (dockNode.isFloating()
          && event.getClickCount() == 2
          && event.getButton() == MouseButton.PRIMARY) {
        event.setDragDetect(false);
        event.consume();
        return;
      }

      if (!dragging) return;

      Stage stage = dockNode.getStage();
      Insets insetsDelta = this.getDockNode().getBorderPane().getInsets();

      // dragging this way makes the interface more responsive in the event
      // the system is lagging as is the case with most current JavaFX
      // implementations on Linux
      stage.setX(event.getScreenX() - dragStart.getX() - insetsDelta.getLeft());
      stage.setY(event.getScreenY() - dragStart.getY() - insetsDelta.getTop());

      // TODO: change the pick result by adding a copyForPick()
      DockEvent dockEnterEvent =
          new DockEvent(
              this,
              DockEvent.NULL_SOURCE_TARGET,
              DockEvent.DOCK_ENTER,
              event.getX(),
              event.getY(),
              event.getScreenX(),
              event.getScreenY(),
              null);
      DockEvent dockOverEvent =
          new DockEvent(
              this,
              DockEvent.NULL_SOURCE_TARGET,
              DockEvent.DOCK_OVER,
              event.getX(),
              event.getY(),
              event.getScreenX(),
              event.getScreenY(),
              null);
      DockEvent dockExitEvent =
          new DockEvent(
              this,
              DockEvent.NULL_SOURCE_TARGET,
              DockEvent.DOCK_EXIT,
              event.getX(),
              event.getY(),
              event.getScreenX(),
              event.getScreenY(),
              null);

      EventTask eventTask =
          new EventTask() {
            @Override
            public void run(Node node, Node dragNode) {
              executions++;

              if (dragNode != node) {
                Event.fireEvent(node, dockEnterEvent.copyFor(DockTitleBar.this, node));

                if (dragNode != null) {
                  // fire the dock exit first so listeners
                  // can actually keep track of the node we
                  // are currently over and know when we
                  // aren't over any which DOCK_OVER
                  // does not provide
                  Event.fireEvent(dragNode, dockExitEvent.copyFor(DockTitleBar.this, dragNode));
                }

                dragNodes.put(node.getScene().getWindow(), node);
              }
              Event.fireEvent(node, dockOverEvent.copyFor(DockTitleBar.this, node));
            }
          };

      this.pickEventTarget(
          new Point2D(event.getScreenX(), event.getScreenY()), eventTask, dockExitEvent);
    } else if (event.getEventType() == MouseEvent.MOUSE_RELEASED) {
      dragging = false;

      DockEvent dockReleasedEvent =
          new DockEvent(
              this,
              DockEvent.NULL_SOURCE_TARGET,
              DockEvent.DOCK_RELEASED,
              event.getX(),
              event.getY(),
              event.getScreenX(),
              event.getScreenY(),
              null,
              this.getDockNode());

      EventTask eventTask =
          new EventTask() {
            @Override
            public void run(Node node, Node dragNode) {
              executions++;
              if (dragNode != node) {
                Event.fireEvent(node, dockReleasedEvent.copyFor(DockTitleBar.this, node));
              }
              Event.fireEvent(node, dockReleasedEvent.copyFor(DockTitleBar.this, node));
            }
          };

      this.pickEventTarget(new Point2D(event.getScreenX(), event.getScreenY()), eventTask, null);

      dragNodes.clear();

      // Remove temporary event handler for bug mentioned above.
      DockPane dockPane = this.getDockNode().getDockPane();
      if (dockPane != null) {
        dockPane.removeEventFilter(MouseEvent.MOUSE_DRAGGED, this);
        dockPane.removeEventFilter(MouseEvent.MOUSE_RELEASED, this);
      }
    }
  }
 @FXML
 void onUsernameClicked(MouseEvent mouseEvent) {
   if (mouseEvent.getButton() == MouseButton.PRIMARY && mouseEvent.getClickCount() == 2) {
     chatController.openPrivateMessageTabForUser(playerInfoBean.getUsername());
   }
 }