@Override public void start(Stage primaryStage) throws Exception { initApplicationDirs(); File dataDir = new File(applicationDataDir()); if (dataDir.exists()) { LoginWindow loginWindow = new LoginWindow(); loginWindow.displayLoginAndWait(); boolean isAuthenticated = SEAGridContext.getInstance().getAuthenticated(); if (isAuthenticated) { HomeWindow homeWindow = new HomeWindow(); Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); primaryStage.setX(bounds.getMinX()); primaryStage.setY(bounds.getMinY()); primaryStage.setWidth(bounds.getWidth()); primaryStage.setHeight(bounds.getHeight()); homeWindow.start(primaryStage); primaryStage.setOnCloseRequest( t -> { Platform.exit(); System.exit(0); }); } } else { SEAGridDialogHelper.showExceptionDialogAndWait( new Exception("Application Data Dir Does Not Exists"), "Application Data Dir Does Not Exists", null, "Application Data Dir Does Not Exists"); System.exit(0); } }
@Override public void start(Stage stage) { Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); stage.setWidth(bounds.getWidth()); stage.setHeight(bounds.getHeight()); stage.setResizable(false); new CellSocietyGUI(stage); }
private void setupStageLocation(Stage stage) { ObservableList<Screen> screens = Screen.getScreens(); Screen screen = screens.size() <= screenNumber ? Screen.getPrimary() : screens.get(screenNumber); Rectangle2D bounds = screen.getBounds(); boolean primary = screen.equals( Screen.getPrimary()); // WORKAROUND: this doesn't work nice in combination with full // screen, so this hack is used to prevent going fullscreen when // screen is not primary if (primary) { stage.setX(bounds.getMinX()); stage.setY(bounds.getMinY()); stage.setWidth(bounds.getWidth()); stage.setHeight(bounds.getHeight()); stage.setFullScreen(true); } else { stage.setX(bounds.getMinX()); stage.setY(bounds.getMinY()); stage.setWidth(bounds.getWidth()); stage.setHeight(bounds.getHeight()); stage.toFront(); } }
@Override protected void interpolate(double t) { final Rectangle2D viewport = new Rectangle2D( start.getMinX() + t * (end.getMinX() - start.getMinX()), start.getMinY() + t * (end.getMinY() - start.getMinY()), start.getWidth() + t * (end.getWidth() - start.getWidth()), start.getHeight() + t * (end.getHeight() - start.getHeight())); imageView.setViewport(viewport); }
private void showSplash( final Stage initStage, Task<?> task, InitCompletionHandler initCompletionHandler) { progressText.textProperty().bind(task.messageProperty()); loadProgress.progressProperty().bind(task.progressProperty()); task.stateProperty() .addListener( (observableValue, oldState, newState) -> { if (newState == Worker.State.SUCCEEDED) { loadProgress.progressProperty().unbind(); loadProgress.setProgress(1); initStage.toFront(); FadeTransition fadeSplash = new FadeTransition(Duration.seconds(1.2), splashLayout); fadeSplash.setFromValue(1.0); fadeSplash.setToValue(0.0); fadeSplash.setOnFinished(actionEvent -> initStage.hide()); fadeSplash.play(); initCompletionHandler.complete(); } // todo add code to gracefully handle other task states. }); Scene splashScene = new Scene(splashLayout); initStage.initStyle(StageStyle.UNDECORATED); final Rectangle2D bounds = Screen.getPrimary().getBounds(); initStage.setScene(splashScene); initStage.setX(bounds.getMinX() + bounds.getWidth() / 2 - SPLASH_WIDTH / 2); initStage.setY(bounds.getMinY() + bounds.getHeight() / 2 - SPLASH_HEIGHT / 2); initStage.show(); }
@Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle(Msg.get(this, "title")); primaryStage.setOpacity(Msg.get(this, "stage.opacity", Double::parseDouble, 1.0)); Group root = new Group(); Button btnHello = new Button(Msg.get(this, "btnHello.text")); root.getChildren().add(btnHello); Scene scene = new Scene( root, Msg.get(this, "scene.width", Integer::parseInt, 300), Msg.get(this, "scene.height", Integer::parseInt, 300)); primaryStage.setScene(scene); // primaryStage.sizeToScene(); primaryStage.setWidth(Msg.get(this, "stage.width", Integer::parseInt, 300)); primaryStage.setHeight(Msg.get(this, "stage.height", Integer::parseInt, 300)); primaryStage.show(); // Center the stage to window only after the stage has been shown Rectangle2D bounds = Screen.getPrimary().getVisualBounds(); double x = bounds.getMinX() + (bounds.getWidth() - primaryStage.getWidth()) / 2; double y = bounds.getMinY() + (bounds.getHeight() - primaryStage.getHeight()) / 2; // primaryStage.setX(x); primaryStage.setY(y); }
/** * maximized the given stage * * @param primaryStage */ public static void maximize(Stage primaryStage) { Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); primaryStage.setX(bounds.getMinX()); primaryStage.setY(bounds.getMinY()); primaryStage.setWidth(bounds.getWidth()); primaryStage.setHeight(bounds.getHeight()); }
@Override public void start(Stage primaryStage) { System.out.println("GUI.start()"); EnumPolicy.load(); EnumRegion.loadIcons(); // TODO: THIS WILL BE REMOVED WHEN PHASE HANDLING IS FULLY IMPLEMENTED MapController.setCurrentController(GamePhaseMapController.class); this.primaryStage = primaryStage; primaryStage.setTitle("Starvation Evasion"); // fills a list of all the product types // primaryStage.setMaxHeight(maxHeight); // primaryStage.setMinHeight(maxHeight); primaryStage.setResizable(true); Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); primaryStage.setX(bounds.getMinX()); primaryStage.setY(bounds.getMinY()); primaryStage.setWidth(bounds.getWidth()); primaryStage.setHeight(bounds.getHeight()); boxHeight = primaryStage.getWidth() / DraftLayout.ROWS; boxWidth = primaryStage.getWidth() / DraftLayout.COLS; // instantiate helper classes imageGetter = new ImageGetter(); popupManager = new PopupManager(this); graphManager = new GraphManager(this); // instantiate the DraftLayout draftLayout = new DraftLayout(this); votingLayout = new VotingLayout(this); // make a scene for displaying the game gameScene = new Scene(draftLayout); currentRoot = draftLayout; primaryStage.setScene(gameScene); primaryStage.show(); primaryStage.setOnCloseRequest( arg0 -> { if (client != null) client.shutdown(); Platform.exit(); }); initGame(); }
/** * Computes the actual scaling of an Image in an ImageView. If the preserveRatio property on the * ImageView is false the scaling has no meaning so NaN is returned. * * @return The scale factor of the image in relation to display coordinates */ public double computeActualScale() { if (!imageView.isPreserveRatio()) { actualScale = Double.NaN; } else if (doScaleRecompute) { Image localImage = imageView.getImage(); Rectangle2D localViewport = imageView.getViewport(); double w = 0; double h = 0; if (localViewport != null && localViewport.getWidth() > 0 && localViewport.getHeight() > 0) { w = localViewport.getWidth(); h = localViewport.getHeight(); } else if (localImage != null) { w = localImage.getWidth(); h = localImage.getHeight(); } double localFitWidth = imageView.getFitWidth(); double localFitHeight = imageView.getFitHeight(); if (w > 0 && h > 0 && (localFitWidth > 0 || localFitHeight > 0)) { if (localFitWidth <= 0 || (localFitHeight > 0 && localFitWidth * h > localFitHeight * w)) { w = w * localFitHeight / h; } else { w = localFitWidth; } actualScale = w / localImage.getWidth(); } doScaleRecompute = false; } return actualScale; }
public void start(Stage primaryStage) { try { screenBounds = Screen.getPrimary().getVisualBounds(); Group root = new Group(); Scene scene = new Scene(root, screenBounds.getWidth(), screenBounds.getHeight()); root.getChildren().add(new MainMenu(primaryStage).bigBox); scene.setFill(Color.WHITE); primaryStage.setScene(scene); primaryStage.initStyle(StageStyle.UNDECORATED); primaryStage.setFullScreen(true); primaryStage.show(); } catch (Exception e) { e.printStackTrace(); } }
@Override public void start(Stage stage) { StackPane root = new StackPane(); Rectangle2D visualBounds = Screen.getPrimary().getVisualBounds(); Scene scene = new Scene(root, visualBounds.getWidth(), visualBounds.getHeight()); stage .getIcons() .add(new Image(SamplePropertiesJavaFxPorts.class.getResourceAsStream("/icon.png"))); stage.setScene(scene); stage.show(); Label label = new Label(); root.getChildren().add(label); // Create a properties file PropertiesJavaFxPorts propertiesJavaFxPorts = new PropertiesJavaFxPorts("app.properties"); // Get value for "counter" key if exists String strCounter = propertiesJavaFxPorts.getProperty("counter"); if (strCounter == null) { strCounter = "0"; } int counter = Integer.valueOf(strCounter); counter++; strCounter = String.valueOf(counter); // Store new value for "counter" key in properties file propertiesJavaFxPorts.setProperty("counter", strCounter); label.setText("Counter = " + strCounter + "\n" + propertiesJavaFxPorts.getPath()); label.setWrapText(true); scene.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { switch (event.getCode()) { case ESCAPE: Platform.exit(); System.exit(0); break; } event.consume(); } }); }
/* */ public WCRectangle getScreenBounds(boolean paramBoolean) { /* 80 */ WebView localWebView = this.accessor.getView(); /* */ /* 82 */ Screen localScreen = Utils.getScreen(localWebView); /* 83 */ if (localScreen != null) { /* 84 */ Rectangle2D localRectangle2D = paramBoolean ? localScreen.getVisualBounds() : localScreen.getBounds(); /* */ /* 87 */ return new WCRectangle( (float) localRectangle2D.getMinX(), (float) localRectangle2D.getMinY(), (float) localRectangle2D.getWidth(), (float) localRectangle2D.getHeight()); /* */ } /* */ /* 91 */ return null; /* */ }
@Override public void start(Stage stage) throws Exception { Application.Parameters params = getParameters(); List<String> paramList = params.getUnnamed(); // Check for the existence of a proper API Key if (paramList.size() < 1 || !paramList.get(0).startsWith("-K")) { throw new IllegalStateException("Demo must be started with arguments [-K]<your-api-key>"); } PAFoxEatsDemoView view = new PAFoxEatsDemoView(this, params); Scene scene = new Scene(view, 900, 600, Color.WHITE); stage.setScene(scene); stage.show(); Rectangle2D primScreenBounds = Screen.getPrimary().getVisualBounds(); stage.setX((primScreenBounds.getWidth() - stage.getWidth()) / 2); stage.setY((primScreenBounds.getHeight() - stage.getHeight()) / 4); }
/** 最大化、最大化解除を行う */ public void toogleMaximized() { final Screen screen = Screen.getScreensForRectangle(stage.getX(), stage.getY(), 1, 1).get(0); if (maximized) { maximized = false; if (backupWindowBounds != null) { stage.setX(backupWindowBounds.getMinX()); stage.setY(backupWindowBounds.getMinY()); stage.setWidth(backupWindowBounds.getWidth()); stage.setHeight(backupWindowBounds.getHeight()); } } else { maximized = true; backupWindowBounds = new Rectangle2D(stage.getX(), stage.getY(), stage.getWidth(), stage.getHeight()); stage.setX(screen.getVisualBounds().getMinX()); stage.setY(screen.getVisualBounds().getMinY()); stage.setWidth(screen.getVisualBounds().getWidth()); stage.setHeight(screen.getVisualBounds().getHeight()); } }
public PrenotaViaggioView( Stage stage, PrenotaViaggioControl prenotaViaggioControl, GpMediator gpimpl) { this.prenotaViaggioControl = prenotaViaggioControl; this.gpMediator = gpimpl; gpimpl.addColleague(this); this.tg = new ToggleGroup(); this.gridCredential = new GridPane(); double percentageWidth = 0.50; double percentageHeight = 0.50; layout = new SplitPane(); layout.setPadding(new Insets(20, 0, 20, 20)); layout.setOrientation(Orientation.HORIZONTAL); Rectangle2D screenSize = Screen.getPrimary().getBounds(); percentageWidth *= screenSize.getWidth(); percentageHeight *= screenSize.getHeight(); sp1 = buildLeft(); ScrollPane scrollPane = new ScrollPane(); scrollPane.setContent(sp1); sp2 = new StackPane(); layout.getItems().addAll(scrollPane, sp2); layout.setDividerPositions(0.5f, 0.5f); this.scene = new Scene(layout, percentageWidth, percentageHeight); scene.getStylesheets().add("JMetroLightTheme.css"); stage.getIcons().add(new Image("icon.png")); stage.setTitle("Creazione Viaggio Gruppo"); stage.setScene(scene); stage.show(); }
@Override public void start(final Stage stage) { try { palco = stage; page = FXMLLoader.load(Login.class.getResource("../view/login/login.fxml")); cena = new Scene(page); stage.initStyle(StageStyle.UNDECORATED); stage.setX(windows.getMinX()); stage.setY(windows.getMinY()); stage.setWidth(windows.getWidth()); stage.setHeight(windows.getHeight()); stage.getIcons().addAll(new Image(Login.class.getResourceAsStream("icone.png"))); stage.setScene(cena); stage.show(); } catch (Exception ex) { System.out.println("Erro ao inicializar aplicação!" + ex); } }
@Override public void start(Stage primaryStage) throws Exception { try { screenSize = Screen.getPrimary().getVisualBounds(); width = screenSize.getWidth(); // gd.getDisplayMode().getWidth(); height = screenSize.getHeight(); // gd.getDisplayMode().getHeight(); } catch (Exception excep) { System.out.println("<----- Exception in Get Screen Size ----->"); excep.printStackTrace(); System.out.println("<---------->\n"); } try { dbCon = DriverManager.getConnection( "jdbc:mysql://192.168.1.6:3306/ale", "Root", "oqu#$XQgHFzDj@1MGg1G8"); estCon = true; } catch (SQLException sqlExcep) { System.out.println("<----- SQL Exception in Establishing Database Connection ----->"); sqlExcep.printStackTrace(); System.out.println("<---------->\n"); } xmlParser.generateUserInfo(); superUser = xmlParser.getSuperUser(); // ----------------------------------------------------------------------------------------------------> Top Panel Start closeBtn = new Button(""); closeBtn.getStyleClass().add("systemBtn"); closeBtn.setOnAction( e -> { systemClose(); }); minimizeBtn = new Button(""); minimizeBtn.getStyleClass().add("systemBtn"); minimizeBtn.setOnAction( e -> { primaryStage.setIconified(true); }); miscContainer = new HBox(); calcBtn = new Button(); calcBtn.getStyleClass().addAll("calcBtn"); calcBtn.setOnAction( e -> { calculator calculator = new calculator(); scientificCalculator scientificCalculator = new scientificCalculator(); calculator.start(calculatorName); }); miscContainer.getChildren().add(calcBtn); topPanel = new HBox(1); topPanel.getStyleClass().add("topPanel"); topPanel.setPrefWidth(width); topPanel.setAlignment(Pos.CENTER_RIGHT); topPanel.setPadding(new Insets(0, 0, 0, 0)); topPanel.getChildren().addAll(miscContainer, minimizeBtn, closeBtn); // ------------------------------------------------------------------------------------------------------> Top Panel End // ----------------------------------------------------------------------------------------------> Navigation Panel Start Line initDivider = new Line(); initDivider.setStartX(0.0f); initDivider.setEndX(205.0f); initDivider.setStroke(Color.GRAY); // <----- Dashboard -----> dashboardToolTip = new Tooltip("Dashboard"); dashboardBtn = new Button(""); dashboardBtn.getStyleClass().add("dashboardBtn"); dashboardBtn.setTooltip(dashboardToolTip); dashboardBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(dashBoardBase); }); // <----- Profile -----> profileToolTip = new Tooltip("Profile"); profileBtn = new Button(); profileBtn.getStyleClass().add("profileBtn"); profileBtn.setTooltip(profileToolTip); profileBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(profilePanel); }); // <----- Courses -----> courseToolTip = new Tooltip("Courses"); coursesBtn = new Button(""); coursesBtn.getStyleClass().add("coursesBtn"); coursesBtn.setTooltip(courseToolTip); coursesBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(coursesPanel); // miscContainer.getChildren().addAll(watchVidBtn); coursesPanel.setContent(coursesGridPanel); }); Line mainDivider = new Line(); mainDivider.setStartX(0.0f); mainDivider.setEndX(205.0f); mainDivider.setStroke(Color.GRAY); // <----- Simulations -----> simsToolTip = new Tooltip("Simulations"); simsBtn = new Button(); simsBtn.getStyleClass().add("simsBtn"); simsBtn.setTooltip(simsToolTip); simsBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(simsPanel); simsPanel.setContent(simsGridPanel); }); // <----- Text Editor -----> textEditorToolTip = new Tooltip("Text Editor"); textEditorBtn = new Button(); textEditorBtn.getStyleClass().add("textEditorBtn"); textEditorBtn.setTooltip(textEditorToolTip); textEditorBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(textEditorPanel); miscContainer.getChildren().addAll(saveDocBtn); }); Line toolsDivider = new Line(); toolsDivider.setStartX(0.0f); toolsDivider.setEndX(205.0f); toolsDivider.setStroke(Color.GRAY); // <----- Wolfram Alpha -----> wolframToolTip = new Tooltip("Wolfram Alpha"); wolframBtn = new Button(); wolframBtn.getStyleClass().add("wolframBtn"); wolframBtn.setTooltip(wolframToolTip); wolframBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(wolframPanel); }); // <----- Wikipedia -----> wikipediaToolTip = new Tooltip(); wikipediaBtn = new Button(); wikipediaBtn.getStyleClass().add("wikipediaBtn"); wikipediaBtn.setTooltip(wikipediaToolTip); wikipediaBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(wikipediaPanel); }); Line sitesDivider = new Line(); sitesDivider.setStartX(0.0f); sitesDivider.setEndX(205.0f); sitesDivider.setStroke(Color.GRAY); // <----- Settings -----> settingsToolTip = new Tooltip("Settings"); settingsBtn = new Button(); settingsBtn.getStyleClass().add("settingsBtn"); settingsBtn.setTooltip(settingsToolTip); settingsBtn.setOnAction( e -> { resetBtns(); rootPane.setCenter(settingsPanel); }); leftPanel = new VBox(0); // leftPanel.setPrefWidth(1); leftPanel.getStyleClass().add("leftPane"); leftPanel .getChildren() .addAll( initDivider, dashboardBtn, profileBtn, coursesBtn, mainDivider, simsBtn, textEditorBtn, toolsDivider, wolframBtn, wikipediaBtn, sitesDivider, settingsBtn); topPanel = new HBox(1); topPanel.getStyleClass().add("topPanel"); topPanel.setPrefWidth(width); topPanel.setAlignment(Pos.CENTER_RIGHT); topPanel.setPadding(new Insets(0, 0, 0, 0)); topPanel.getChildren().addAll(miscContainer, minimizeBtn, closeBtn); // ------------------------------------------------------------------------------------------------> Navigation Panel End // -----------------------------------------------------------------------------------------------> Dashboard Pane Start final WebView webVid = new WebView(); final WebEngine webVidEngine = webVid.getEngine(); webVid.setPrefHeight(860); webVid.setPrefWidth(width - 118); webVidEngine.loadContent(""); final NumberAxis xAxis = new NumberAxis(); final NumberAxis yAxis = new NumberAxis(); xAxis.setLabel("Day"); yAxis.setLabel("Score"); final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis); lineChart.setTitle("Line Chart"); XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>(); series.setName("My Data"); // populating the series with data series.getData().add(new XYChart.Data<Number, Number>(0.25, 36)); series.getData().add(new XYChart.Data<Number, Number>(1, 23)); series.getData().add(new XYChart.Data<Number, Number>(2, 114)); series.getData().add(new XYChart.Data<Number, Number>(3, 15)); series.getData().add(new XYChart.Data<Number, Number>(4, 124)); lineChart.getData().add(series); lineChart.setPrefWidth(400); lineChart.setPrefHeight(300); lineChart.setLegendVisible(false); chatRoomField = new TextField(); chatRoomField.getStyleClass().add("textField"); chatRoomField.setPromptText("Enter Chat Room"); chatRoomField.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ENTER) { chatRoom = chatRoomField.getText(); client.connect(messageArea, messageInputArea, superUser, chatRoom); } } }); messageArea = new TextArea(); messageArea.getStyleClass().add("textArea"); messageArea.setWrapText(true); messageArea.setPrefHeight(740); messageArea.setEditable(false); messageInputArea = new TextArea(); messageInputArea.getStyleClass().add("textArea"); messageInputArea.setWrapText(true); messageInputArea.setPrefHeight(100); messageInputArea.setPromptText("Enter Message"); messageInputArea.setOnKeyPressed( new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getCode() == KeyCode.ENTER) { client.send(messageArea, messageInputArea, superUser, chatRoom); event.consume(); } } }); chatBox = new VBox(); chatBox.setPrefWidth(250); chatBox.setMaxWidth(250); chatBox.getStyleClass().add("chatBox"); chatBox.getChildren().addAll(chatRoomField, messageArea, messageInputArea); // client.test(messageArea, messageInputArea); dashboardGridPanel = new GridPane(); dashboardGridPanel.getStyleClass().add("gridPane"); dashboardGridPanel.setVgap(5); dashboardGridPanel.setHgap(5); dashboardGridPanel.setGridLinesVisible(false); dashboardGridPanel.setPrefWidth(width - 430); dashboardGridPanel.setPrefHeight(860); dashboardGridPanel.setColumnIndex(lineChart, 0); dashboardGridPanel.setRowIndex(lineChart, 0); dashboardGridPanel.getChildren().addAll(lineChart); dashboardPanel = new ScrollPane(); dashboardPanel.getStyleClass().add("scrollPane"); dashboardPanel.setPrefWidth(width - 400); dashboardPanel.setPrefHeight(860); dashboardPanel.setContent(dashboardGridPanel); dashBoardBase = new HBox(); dashBoardBase.setPrefWidth(width - (leftPanel.getWidth() + chatBox.getWidth())); dashBoardBase.setPrefHeight(860); dashBoardBase.getChildren().addAll(dashboardPanel, chatBox); // -------------------------------------------------------------------------------------------------> Dashboard Pane End // -------------------------------------------------------------------------------------------------> Profile Pane Start profilePictureBtn = new Button(); profilePictureBtn.getStyleClass().addAll("profilePictureBtn"); String profileUserName = xmlParser.getSuperUser(); String profileEmail = xmlParser.getEmail(); String profileAge = xmlParser.getAge(); String profileSchool = xmlParser.getSchool(); String profileCountry = ""; String profileCity = ""; userNameLbl = new Label(profileUserName); userNameLbl.getStyleClass().add("profileLbl"); userNameLbl.setAlignment(Pos.CENTER); emailLbl = new Label(profileEmail); emailLbl.getStyleClass().add("profileLbl"); ageLbl = new Label(profileAge); ageLbl.getStyleClass().add("profileLbl"); schoolLbl = new Label(profileSchool); schoolLbl.getStyleClass().add("profileLbl"); profileGridPanel = new GridPane(); profileGridPanel.getStyleClass().add("gridPane"); profileGridPanel.setVgap(5); profileGridPanel.setHgap(5); profileGridPanel.setGridLinesVisible(false); profileGridPanel.setPrefWidth(width - 208); profileGridPanel.setPrefHeight(860); profileGridPanel.setAlignment(Pos.TOP_CENTER); profileGridPanel.setRowIndex(profilePictureBtn, 0); profileGridPanel.setColumnIndex(profilePictureBtn, 0); profileGridPanel.setRowIndex(userNameLbl, 1); profileGridPanel.setColumnIndex(userNameLbl, 0); profileGridPanel.setRowIndex(emailLbl, 2); profileGridPanel.setColumnIndex(emailLbl, 0); profileGridPanel.setRowIndex(ageLbl, 3); profileGridPanel.setColumnIndex(ageLbl, 0); profileGridPanel.setRowIndex(schoolLbl, 4); profileGridPanel.setColumnIndex(schoolLbl, 0); profileGridPanel .getChildren() .addAll(profilePictureBtn, userNameLbl, emailLbl, ageLbl, schoolLbl); profilePanel = new ScrollPane(); profilePanel.getStyleClass().add("scrollPane"); profilePanel.setContent(profileGridPanel); // ---------------------------------------------------------------------------------------------------> Profile Pane End // -------------------------------------------------------------------------------------------------> Courses Pane Start String course = ""; // Media media = new Media("media.mp4"); // mediaPlayer = new MediaPlayer(media); // mediaPlayer.setAutoPlay(true); // mediaView = new MediaView(mediaPlayer); watchVidBtn = new Button("Watch Video"); watchVidBtn.getStyleClass().add("btn"); watchVidBtn.setOnAction( e -> { // coursesPanel.setContent(mediaView); }); chemistryBtn = new Button(); chemistryBtn.getStyleClass().add("chemistryBtn"); chemistryBtn.setOnAction( e -> { displayCourse("chemistry"); }); physicsBtn = new Button(); physicsBtn.getStyleClass().add("physicsBtn"); physicsBtn.setOnAction( e -> { displayCourse("physics"); }); mathsBtn = new Button(); mathsBtn.getStyleClass().add("mathsBtn"); bioBtn = new Button(); bioBtn.getStyleClass().add("bioBtn"); bioBtn.setOnAction( e -> { rootPane.setCenter(biologyCourse.biologyPane()); }); // Course Web View try { courseView = new WebView(); courseWebEngine = courseView.getEngine(); courseView.setPrefHeight(860); courseView.setPrefWidth(width - 208); } catch (Exception excep) { System.out.println("<----- Exception in Course Web ----->"); excep.printStackTrace(); System.out.println("<---------->\n"); } coursesGridPanel = new GridPane(); coursesGridPanel.getStyleClass().add("gridPane"); coursesGridPanel.setVgap(5); coursesGridPanel.setHgap(5); coursesGridPanel.setGridLinesVisible(false); coursesGridPanel.setPrefWidth(width - 208); coursesGridPanel.setPrefHeight(860); coursesGridPanel.setRowIndex(chemistryBtn, 1); coursesGridPanel.setColumnIndex(chemistryBtn, 1); coursesGridPanel.setRowIndex(physicsBtn, 1); coursesGridPanel.setColumnIndex(physicsBtn, 2); coursesGridPanel.setRowIndex(mathsBtn, 1); coursesGridPanel.setColumnIndex(mathsBtn, 3); coursesGridPanel.setRowIndex(bioBtn, 1); coursesGridPanel.setColumnIndex(bioBtn, 4); coursesGridPanel.getChildren().addAll(chemistryBtn, physicsBtn, mathsBtn, bioBtn); coursesPanel = new ScrollPane(); coursesPanel.getStyleClass().add("scrollPane"); coursesPanel.setPrefWidth(width - 118); coursesPanel.setPrefHeight(860); coursesPanel.setContent(coursesGridPanel); // ---------------------------------------------------------------------------------------------------> Courses Pane End // ---------------------------------------------------------------------------------------------> Simulations Pane Start final WebView browser = new WebView(); final WebEngine webEngine = browser.getEngine(); browser.setPrefHeight(860); browser.setPrefWidth(width - 208); /* File phetImageFile = new File("img/styleDark/poweredByPHET.png"); String phetImageURL = phetImageFile.toURI().toURL().toString(); Image phetImage = new Image(phetImageURL, false); */ final ImageView phetImageView = new ImageView(); final Image phetImage = new Image(Main.class.getResourceAsStream("img/styleDark/poweredByPHET.png")); phetImageView.setImage(phetImage); Label motionLbl = new Label("Motion"); motionLbl.getStyleClass().add("lbl"); forcesAndMotionBtn = new Button(); forcesAndMotionBtn.getStyleClass().add("forcesAndMotionBtn"); forcesAndMotionBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/balancing-act/latest/balancing-act_en.html"); simsPanel.setContent(browser); }); balancingActBtn = new Button(); balancingActBtn.getStyleClass().add("balancingActBtn"); balancingActBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/balancing-act/latest/balancing-act_en.html"); simsPanel.setContent(browser); }); energySkateParkBtn = new Button(); energySkateParkBtn.getStyleClass().add("energySkateParkBtn"); energySkateParkBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/energy-skate-park-basics/latest/" + "energy-skate-park-basics_en.html"); simsPanel.setContent(browser); }); balloonsAndStaticElectricityBtn = new Button(); balloonsAndStaticElectricityBtn.getStyleClass().add("balloonsAndStaticElectricityBtn"); balloonsAndStaticElectricityBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/balloons-and-static-electricity/latest/" + "balloons-and-static-electricity_en.html"); simsPanel.setContent(browser); }); buildAnAtomBtn = new Button(); buildAnAtomBtn.getStyleClass().add("buildAnAtomBtn"); buildAnAtomBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/build-an-atom/latest/build-an-atom_en.html"); simsPanel.setContent(browser); }); colorVisionBtn = new Button(); colorVisionBtn.getStyleClass().add("colorVisionBtn"); colorVisionBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/color-vision/latest/color-vision_en.html"); simsPanel.setContent(browser); }); Label soundAndWavesLbl = new Label("Sound and Waves"); soundAndWavesLbl.getStyleClass().add("lbl"); wavesOnAStringBtn = new Button(); wavesOnAStringBtn.getStyleClass().add("wavesOnAStringBtn"); wavesOnAStringBtn.setOnAction( e -> { webEngine.load( "https://phet.colorado.edu/sims/html/wave-on-a-string/latest/wave-on-a-string_en.html"); simsPanel.setContent(browser); }); /* motionSimsFlowPane = new FlowPane(); motionSimsFlowPane.getStyleClass().add("flowPane"); motionSimsFlowPane.setVgap(5); motionSimsFlowPane.setHgap(5); motionSimsFlowPane.setAlignment(Pos.TOP_LEFT); motionSimsFlowPane.getChildren().addAll(forcesAndMotionBtn, balancingActBtn, energySkateParkBtn, buildAnAtomBtn, colorVisionBtn, wavesOnAStringBtn); soundAndWavesFlowPane = new FlowPane(); soundAndWavesFlowPane.getStyleClass().add("flowPane"); soundAndWavesFlowPane.setVgap(5); soundAndWavesFlowPane.setHgap(5); soundAndWavesFlowPane.setAlignment(Pos.TOP_LEFT); soundAndWavesFlowPane.getChildren().addAll(wavesOnAStringBtn); simsBox = new VBox(); simsBox.getStyleClass().add("vbox"); simsBox.setPrefHeight(height); simsBox.setPrefWidth(width); simsBox.getChildren().addAll(motionLbl, motionSimsFlowPane, soundAndWavesLbl, soundAndWavesFlowPane); */ simsGridPanel = new GridPane(); simsGridPanel.getStyleClass().add("gridPane"); simsGridPanel.setVgap(5); simsGridPanel.setHgap(5); simsGridPanel.setGridLinesVisible(false); simsGridPanel.setPrefWidth(width - 208); simsGridPanel.setPrefHeight(860); simsGridPanel.setRowIndex(phetImageView, 0); simsGridPanel.setColumnIndex(phetImageView, 4); simsGridPanel.setRowIndex(motionLbl, 0); simsGridPanel.setColumnIndex(motionLbl, 0); simsGridPanel.setRowIndex(forcesAndMotionBtn, 1); simsGridPanel.setColumnIndex(forcesAndMotionBtn, 0); simsGridPanel.setRowIndex(balancingActBtn, 1); simsGridPanel.setColumnIndex(balancingActBtn, 1); simsGridPanel.setRowIndex(energySkateParkBtn, 1); simsGridPanel.setColumnIndex(energySkateParkBtn, 2); simsGridPanel.setRowIndex(buildAnAtomBtn, 1); simsGridPanel.setColumnIndex(buildAnAtomBtn, 3); simsGridPanel.setRowIndex(colorVisionBtn, 1); simsGridPanel.setColumnIndex(colorVisionBtn, 4); simsGridPanel.setRowIndex(soundAndWavesLbl, 2); simsGridPanel.setColumnIndex(soundAndWavesLbl, 0); simsGridPanel.setColumnSpan(soundAndWavesLbl, 4); simsGridPanel.setRowIndex(wavesOnAStringBtn, 3); simsGridPanel.setColumnIndex(wavesOnAStringBtn, 0); simsGridPanel .getChildren() .addAll( phetImageView, motionLbl, forcesAndMotionBtn, balancingActBtn, energySkateParkBtn, buildAnAtomBtn, colorVisionBtn, soundAndWavesLbl, wavesOnAStringBtn); simsPanel = new ScrollPane(); simsPanel.getStyleClass().add("scrollPane"); simsPanel.setContent(simsGridPanel); // -----------------------------------------------------------------------------------------------> Simulations Pane End // ---------------------------------------------------------------------------------------------> Text Editor Pane Start htmlEditor = new HTMLEditor(); htmlEditor.setPrefHeight(860); htmlEditor.setPrefWidth(width - 208); // Prevents Scroll on Space Pressed htmlEditor.addEventFilter( KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { if (event.getEventType() == KeyEvent.KEY_PRESSED) { if (event.getCode() == KeyCode.SPACE) { event.consume(); } } } }); XWPFDocument document = new XWPFDocument(); XWPFParagraph tmpParagraph = document.createParagraph(); XWPFRun tmpRun = tmpParagraph.createRun(); saveDocBtn = new Button(); saveDocBtn.getStyleClass().add("btn"); saveDocBtn.setText("Save"); saveDocBtn.setOnAction( e -> { tmpRun.setText(tools.stripHTMLTags(htmlEditor.getHtmlText())); tmpRun.setFontSize(12); saveDocument(document, primaryStage); }); textEditorPanel = new ScrollPane(); textEditorPanel.getStyleClass().add("scrollPane"); textEditorPanel.setContent(htmlEditor); // -----------------------------------------------------------------------------------------------> Text Editor Pane End // -------------------------------------------------------------------------------------------------> Wolfram Pane Start Boolean wolframActive = false; try { final WebView wolframWeb = new WebView(); wolframWeb.getStyleClass().add("webView"); final WebEngine wolframWebEngine = wolframWeb.getEngine(); wolframWeb.setPrefHeight(860); wolframWeb.setPrefWidth(width - 208); if (wolframActive == false) { wolframWebEngine.load("http://www.wolframalpha.com/"); wolframActive = true; } wolframPanel = new ScrollPane(); wolframPanel.setContent(wolframWeb); } catch (Exception excep) { System.out.println("<----- Exception in Wolfram Alpha Web ----->"); excep.printStackTrace(); System.out.println("<---------->\n"); } // ---------------------------------------------------------------------------------------------------> Wolfram Pane End // ------------------------------------------------------------------------------------------------> Wikipedia Pane Start Boolean wikipediaActive = false; try { final WebView wikipediaWeb = new WebView(); wikipediaWeb.getStyleClass().add("scrollPane"); wikipediaWebEngine = wikipediaWeb.getEngine(); wikipediaWeb.setPrefHeight(860); wikipediaWeb.setPrefWidth(width - 208); if (wikipediaActive == false) { wikipediaWebEngine.load("https://en.wikipedia.org/wiki/Main_Page"); wikipediaActive = true; } wikipediaPanel = new ScrollPane(); wikipediaPanel.setContent(wikipediaWeb); } catch (Exception e) { e.printStackTrace(); } // --------------------------------------------------------------------------------------------------> Wikipedia Pane End // -------------------------------------------------------------------------------------------------> Settings Pane Start settingsGridPanel = new GridPane(); settingsGridPanel.getStyleClass().add("gridPane"); settingsGridPanel.setPrefWidth(width - 208); settingsGridPanel.setPrefHeight(height); settingsGridPanel.setVgap(5); settingsGridPanel.setHgap(5); settingsPanel = new ScrollPane(); settingsPanel.getStyleClass().add("scrollPane"); settingsPanel.setContent(settingsGridPanel); // ---------------------------------------------------------------------------------------------------> Settings Pane End rootPane = new BorderPane(); rootPane.setLeft(leftPanel); rootPane.setTop(topPanel); rootPane.setCenter(dashBoardBase); rootPane.getStyleClass().add("rootPane"); rootPane.getStylesheets().add(Main.class.getResource("css/styleDark.css").toExternalForm()); programWidth = primaryStage.getWidth(); programHeight = primaryStage.getHeight(); primaryStage.setTitle("ALE"); primaryStage.initStyle(StageStyle.UNDECORATED); primaryStage .getIcons() .add(new javafx.scene.image.Image(Main.class.getResourceAsStream("img/aleIcon.png"))); primaryStage.setScene(new Scene(rootPane, width, height)); primaryStage.show(); }
public void start(final Stage stage) { for (ConditionalFeature f : EnumSet.allOf(ConditionalFeature.class)) { System.err.println(f + ": " + Platform.isSupported(f)); } Rectangle2D screen = Screen.getPrimary().getVisualBounds(); final Random rand = new Random(); /* final Group starfield = new Group(); for(int i=0;i<66;i++) { int size = rand.nextInt(3)+1; if(size==3) { size = rand.nextInt(3)+1; } Circle circ = new Circle(rand.nextInt((int)screen.getWidth()), rand.nextInt(200+(int)screen.getHeight())-200, size); circ.setFill(Color.rgb(200,200,200+rand.nextInt(56))); circ.setTranslateZ(1+rand.nextInt(40)); starfield.getChildren().add(circ); } */ final List<Starfield> stars = new ArrayList<>(); for (int i = 0; i < 10; i++) { int sw = (int) screen.getWidth(), sh = (int) screen.getHeight(); Starfield sf = new Starfield(rand, -sw, -sh, 2 * sw, 2 * sh, rand.nextInt(30) + 10); sf.setTranslateZ(rand.nextInt(2000) + 50); stars.add(sf); } // final Starfield starfield2 = new Starfield(rand, -200, -200, (int)screen.getWidth(), // (int)screen.getHeight()+200, 40); final Ruleset1D rules = new Ruleset1D(new int[] {Colors.randomColor(rand), Colors.randomColor(rand)}); final Ruleset rules2 = new Rulespace1D(rules); // Rule rule = rules.random(rand).next(); Iterator<Rule> it = rules.iterator(); GridPane gridp = new GridPane(); int i = 0, j = 0; while (it.hasNext()) { Rule rule = it.next(); CA ca = new CA(rule, new RandomInitializer(), rand, 42, 100, 100); Plane plane = ca.createPlane(); ImageView imview = new ImageView(plane.toImage()); imview.setSmooth(true); imview.setFitWidth(30); imview.setPreserveRatio(true); gridp.add(imview, i, j); if (++i == 16) { i = 0; j++; } } // gridp.setScaleX(0.3); // gridp.setScaleY(0.3); // gridp.setPrefSize(100*3/3, 100*3/3); // gridp.setMaxSize(100*3/3, 100*3/3); final double XTRANS = screen.getWidth() / 2 - 30 * 16 / 2; final double YTRANS = screen.getHeight() / 2 - 30 * 16 / 2; // gridp.setTranslateX((screen.getWidth()/2+100*16/2)*0.3); // gridp.setTranslateX(0); gridp.setTranslateX(XTRANS); gridp.setTranslateY(YTRANS); // gridp.setAlignment(Pos.CENTER); Group grid = new Group(gridp); // grid.setTranslateX(0); // grid.setTranslateY(0); // gridp.relocate(-400, -400); // gridp.setTranslateX(-300); // gridp.setTranslateY(-150); /* final RotateTransition rt = new RotateTransition(Duration.millis(3000), gridp); rt.setByAngle(180); rt.setCycleCount(4); rt.setAutoReverse(true); */ // rt.setAutoReverse(false); /*` final BorderPane border = new BorderPane(); */ // Label title = new Label("EXPLORATIONS IN CELLULAR SPACES"); Label title = new Label("E X P L O R A T I O N S"); title.setFont(new Font("Helvetica Neue Condensed Bold", 36)); title.setTextFill(Color.WHITE); // Label title2 = new Label("IN CELLULAR SPACES"); Label title2 = new Label("EXPLORATIONS IN CELLULAR SPACES"); title2.setFont(new Font("Helvetica Neue Condensed Bold", 28)); title2.setTextFill(Color.WHITE); /*` title.setAlignment(Pos.CENTER); title.setContentDisplay(ContentDisplay.CENTER); title.setTextAlignment(TextAlignment.CENTER); */ final HBox toptitle = new HBox(); toptitle.setAlignment(Pos.CENTER); toptitle.getChildren().add(title); toptitle.setTranslateX(XTRANS); toptitle.setTranslateY(YTRANS - 36); final HBox btitle = new HBox(); btitle.setAlignment(Pos.CENTER); title2.setAlignment(Pos.CENTER); btitle.getChildren().add(title2); btitle.setTranslateX(XTRANS); // btitle.setTranslateX(screen.getWidth()/2-title2.getPrefWidth()/2); btitle.setTranslateY(YTRANS + 30 * 16); Group border = new Group(); // border.getChildren().add(toptitle); for (Starfield st : stars) { border.getChildren().add(st); } // border.getChildren().add(starfield2); border.getChildren().add(btitle); border.getChildren().add(grid); final List<TranslateTransition> tts = new ArrayList<>(); final TranslateTransition tt = new TranslateTransition(Duration.millis(6000), grid); tt.setByY(2000); tts.add(tt); for (Starfield sf : stars) { TranslateTransition st = new TranslateTransition(Duration.millis(6000), sf); st.setByY(200); st.setByZ(100 + rand.nextInt(100)); tts.add(st); } /* final TranslateTransition tt2 = new TranslateTransition(Duration.millis(6000), starfield1); tt2.setByY(200); tt2.setByZ(200); final TranslateTransition tt3 = new TranslateTransition(Duration.millis(6000), starfield2); tt3.setByY(300); tt3.setByZ(200); */ // final ParallelTransition infinite = new ParallelTransition(tt, tt2, tt3); final ParallelTransition infinite = new ParallelTransition(tts.toArray(new TranslateTransition[0])); final BorderPane ctrl = new BorderPane(); // ctrl.setPrefSize(200, 100); // ctrl.setMaxSize(200, 100); Label start = new Label("Start"); start.setTextFill(Color.WHITE); start.setFont(new Font("Helvetica", 28)); start.setAlignment(Pos.CENTER_LEFT); start.setContentDisplay(ContentDisplay.CENTER); start.setTranslateX(XTRANS + 30 * 16 + 100); start.setTranslateY(screen.getHeight() / 2); // start.setTranslateX(-400); Circle ico = new Circle(15); ico.setOnMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { FadeTransition ft = new FadeTransition(Duration.millis(500), ctrl); ft.setFromValue(1.0); ft.setToValue(0.0); FadeTransition tft = new FadeTransition(Duration.millis(500), btitle); tft.setFromValue(1.0); tft.setToValue(0.0); ParallelTransition pt = new ParallelTransition(ft, tft); // TranslateTransition fft = new TranslateTransition(Duration.millis(3000), border); // tt.setByY(2000); SequentialTransition st = new SequentialTransition(pt, infinite); st.setOnFinished( new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { State state = State.state().rules(rules2).random(new Rand()).size(400); Iterator<Rule> it = state.rules().random(state.random().create()); CA ca = new CA( it.next(), new RandomInitializer(), state.random().create(), 0, state.size(), state.size()); state.ca(ca); // final Futures futures = new Futures(rules2, new Rand()); final Controls controls = new Controls(state); // controls.setTranslateX(screen.getWidth()/2 - // futures.getPossibilityWidth()/2); // controls.setTranslateY(screen.getHeight()/2 - // futures.getPossiblityHeight()/2-20); // controls.setTranslateX(screen.getWidth()/2 - (3*200+2*10)/2); // controls.setTranslateY(screen.getHeight()/2 - (3*200+2*10)/2-20); for (Starfield sf : stars) { state.addListener(sf); // futures.addFutureListener(sf); } // futures.addFutureListener(starfield1); // futures.addFutureListener(starfield2); border.getChildren().remove(grid); border.getChildren().remove(btitle); // border.getChildren().add(futures); border.getChildren().add(controls); // futures.setTranslateX(screen.getWidth()/2 - futures.getPossibilityWidth()/2); // futures.setTranslateY(screen.getHeight()/2 - // futures.getPossiblityHeight()/2); // border.setCenter(futures); // border.setAlignment(futures, Pos.CENTER); } }); st.play(); } }); // Sphere ico = new Sphere(15); // ico.setDrawMode(DrawMode.LINE); ico.setFill(Color.rgb(10, 10, 10)); ico.setStroke(Color.WHITE); ico.setStrokeWidth(3); ico.setTranslateX(XTRANS + 30 * 16 + 100); ico.setTranslateY(screen.getHeight() / 2); // ctrl.setTop(ico); ctrl.setCenter(ico); /* border.setRight(ctrl); border.setMaxSize(800,600); border.setPrefSize(800,600); */ border.getChildren().add(ctrl); Group root = new Group(); root.getChildren().add(border); // root.setAutoSizeChildren(false); // root.setLayoutX(-400); // root.setLayoutY(-400); // Scene scene = new Scene(root, 1200, 1000); Scene scene = new Scene(root, 1280, 1024, true, SceneAntialiasing.DISABLED); scene.setFill(Color.BLACK); scene.setCamera(new PerspectiveCamera()); // set Stage boundaries to visible bounds of the main screen stage.setX(screen.getMinX()); stage.setY(screen.getMinY()); stage.setWidth(screen.getWidth()); stage.setHeight(screen.getHeight()); stage.setTitle("Explorations in Cellular Spaces"); stage.setScene(scene); stage.setResizable(false); // root.autosize(); // stage.sizeToScene(); stage.show(); }
private void shiftDock() { long now = System.currentTimeMillis(); Rectangle2D cfgBounds = Client.getConfiguredBounds(); // The bounds to work in int boundsSize = cfg.isVertical() ? (int) cfgBounds.getHeight() : (int) cfgBounds.getWidth(); // Total amount to slide int value = cfg.sizeProperty().get() - AUTOHIDE_TAB_OPPOSITE_SIZE; // How far along the timeline? float fac = Math.min(1f, 1f - ((float) (yEnd - now) / (float) AUTOHIDE_DURATION)); // The amount of movement so far float amt = fac * (float) value; // The amount to shrink the width (or height when vertical) of the // visible 'bar' float barSize = (float) boundsSize * fac; // If showing, reverse final boolean fhidden = hidden; if (!hidden) { amt = value - amt; barSize = (float) boundsSize - barSize; if (!pull.isVisible()) pull.setVisible(true); } // Reveal or hide the pull tab dockContent.setOpacity(hidden ? 1f - fac : fac); pull.setOpacity((hidden ? fac : 1f - fac) * 0.5f); Stage stage = getStage(); if (stage != null) { if (cfg.topProperty().get()) { getScene().getRoot().translateYProperty().set(-amt); stage.setHeight(cfg.sizeProperty().get() - amt + Client.DROP_SHADOW_SIZE); stage.setWidth(Math.max(AUTOHIDE_TAB_SIZE, cfgBounds.getWidth() - barSize)); stage.setX(cfgBounds.getMinX() + ((cfgBounds.getWidth() - stage.getWidth()) / 2f)); } else if (cfg.bottomProperty().get()) { stage.setY(cfgBounds.getMaxY() + amt); stage.setHeight(cfg.sizeProperty().get() - amt + Client.DROP_SHADOW_SIZE); stage.setWidth(Math.max(AUTOHIDE_TAB_SIZE, cfgBounds.getWidth() - barSize)); stage.setX(cfgBounds.getMinX() + ((cfgBounds.getWidth() - stage.getWidth()) / 2f)); } else if (cfg.leftProperty().get()) { getScene().getRoot().translateXProperty().set(-amt); stage.setWidth(cfg.sizeProperty().get() - amt); stage.setHeight(Math.max(AUTOHIDE_TAB_SIZE, cfgBounds.getHeight() - barSize)); stage.setY(cfgBounds.getMinY() + ((cfgBounds.getHeight() - stage.getHeight()) / 2f)); } else if (cfg.rightProperty().get()) { stage.setX(cfgBounds.getMaxX() + amt - cfg.sizeProperty().get()); stage.setWidth(cfg.sizeProperty().get() - amt); stage.setHeight(Math.max(AUTOHIDE_TAB_SIZE, cfgBounds.getHeight() - barSize)); stage.setY(cfgBounds.getMinY() + ((cfgBounds.getHeight() - stage.getHeight()) / 2f)); } else { throw new UnsupportedOperationException(); } } // The update or the sign in dialog may have been popped, so make sure // it is position correctly if (signInPopup != null && signInPopup.isShowing()) { signInPopup.sizeToScene(); } // If not fully hidden / revealed, play again if (now < yEnd) { dockHider.playFromStart(); } else { // Defer this as events may still be coming in Platform.runLater( new Runnable() { @Override public void run() { if (!fhidden && stage != null) { stage.requestFocus(); pull.setVisible(false); } hiding = false; } }); } }
public String getAsText() { if (null == getValue()) return null; Rectangle2D r = (Rectangle2D) getValue(); return r.getMinX() + ", " + r.getMinY() + ", " + r.getWidth() + ", " + r.getHeight(); }
@Override public void initialize(URL url, ResourceBundle rb) { loading.setVisible(false); checkTodos.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { boolean checked = ((CheckBox) t.getTarget()).isSelected(); for (Node node : servicos.getChildren()) { ((CheckBox) node).setSelected(checked); } } }); unidades.setItems(FXCollections.observableList(new ArrayList<ComboboxItem>())); unidades.setOnAction( new EventHandler() { @Override public void handle(Event t) { loading.setVisible(true); checkTodos.setSelected(false); ComboBox cb = (ComboBox) t.getTarget(); cb.getSelectionModel().selectedItemProperty(); ComboboxItem item = (ComboboxItem) cb.getSelectionModel().selectedItemProperty().getValue(); if (item != null && Integer.parseInt(item.getKey()) > 0) { unidadeAtual = Integer.parseInt(item.getKey()); updateServicos(main.getService().buscarServicos(unidadeAtual)); } loading.setVisible(false); } }); buscar.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { loading.setVisible(true); servicos.getChildren().clear(); unidadeAtual = 0; try { main.getService() .loadUrls( servidor.getText(), new Runnable() { @Override public void run() { updateUnidades(main.getService().buscarUnidades()); loading.setVisible(false); } }); } catch (Exception e) { loading.setVisible(false); } } }); salvar.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { loading.setVisible(true); try { List<Integer> idServicos = new ArrayList<Integer>(); for (Node node : servicos.getChildren()) { if (((CheckBox) node).isSelected()) { try { String id = node.getId().split("-")[1]; idServicos.add(Integer.parseInt(id)); } catch (Exception e) { } } } PainelConfig config = main.getConfig(); config.get(PainelConfig.KEY_SERVER).setValue(servidor.getText()); config.get(PainelConfig.KEY_UNIDADE, Integer.class).setValue(unidadeAtual); config .get(PainelConfig.KEY_SERVICOS, Integer[].class) .setValue(idServicos.toArray(new Integer[0])); // som e tema config.get(PainelConfig.KEY_SCREENSAVER_URL).setValue(videoUrl.getText()); config .get(PainelConfig.KEY_LANGUAGE) .setValue( ((ComboboxItem) language.getSelectionModel().getSelectedItem()).getKey()); config .get(PainelConfig.KEY_SOUND_VOICE, Boolean.class) .setValue(vocalizar.isSelected()); config.get(PainelConfig.KEY_COR_FUNDO).setValue(colorToHex(corFundo.getValue())); config .get(PainelConfig.KEY_COR_MENSAGEM) .setValue(colorToHex(corMensagem.getValue())); config.get(PainelConfig.KEY_COR_SENHA).setValue(colorToHex(corSenha.getValue())); config.get(PainelConfig.KEY_COR_GUICHE).setValue(colorToHex(corGuiche.getValue())); // screensaver layout config .get(PainelConfig.KEY_SCREENSAVER_LAYOUT, Integer.class) .setValue( Integer.parseInt(((RadioButton) svLayout.getSelectedToggle()).getText())); config.save(); main.getService().register(servidor.getText()); } catch (Exception e) { e.printStackTrace(); } loading.setVisible(false); } }); exibirPainel.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { main.getPainel().show(); } }); // language language.setItems(FXCollections.observableList(new ArrayList<ComboboxItem>())); SortedSet<String> keys = new TreeSet<String>(Main.locales.keySet()); for (String key : keys) { language.getItems().add(new ComboboxItem(key, Main.locales.get(key))); if (Locale.getDefault().getLanguage().equals(key)) { main.getConfig().get(PainelConfig.KEY_LANGUAGE).setValue(Locale.getDefault().getLanguage()); } } String defaultLang = main.getConfig().get(PainelConfig.KEY_LANGUAGE).getValue(); for (Object item : language.getItems()) { if (defaultLang.equals(((ComboboxItem) item).getKey())) { language.getSelectionModel().select(item); break; } } language.setOnAction( new EventHandler() { @Override public void handle(Event t) { ComboBox cb = (ComboBox) t.getTarget(); cb.getSelectionModel().selectedItemProperty(); ComboboxItem item = (ComboboxItem) cb.getSelectionModel().selectedItemProperty().getValue(); main.getConfig().get(PainelConfig.KEY_LANGUAGE).setValue(item.getKey()); } }); // video monitorId.setItems(FXCollections.observableList(new ArrayList<ComboboxItem>())); Integer defaultId = main.getConfig().get(PainelConfig.KEY_MONITOR_ID, Integer.class).getValue(); for (int i = 0; i < Screen.getScreens().size(); i++) { StringBuilder sb = new StringBuilder(); Rectangle2D b = Screen.getScreens().get(i).getBounds(); sb.append(i + 1) .append(" (") .append(b.getWidth()) .append(" x ") .append(b.getHeight()) .append(")"); ComboboxItem item = new ComboboxItem(i, sb.toString()); monitorId.getItems().add(item); if (defaultId.equals(i)) { monitorId.getSelectionModel().select(item); } } monitorId.setOnAction( new EventHandler() { @Override public void handle(Event t) { ComboBox cb = (ComboBox) t.getTarget(); cb.getSelectionModel().selectedItemProperty(); ComboboxItem item = (ComboboxItem) cb.getSelectionModel().selectedItemProperty().getValue(); Integer key = Integer.parseInt(item.getKey()); if (key >= 0 && key < Screen.getScreens().size()) { main.getConfig().get(PainelConfig.KEY_MONITOR_ID, Integer.class).setValue(key); } } }); // screen saver screenSaverTimeout.setItems(FXCollections.observableList(new ArrayList<ComboboxItem>())); Integer defaultTimeout = main.getConfig().get(PainelConfig.KEY_SCREENSAVER_TIMEOUT, Integer.class).getValue(); SortedSet<Integer> keys2 = new TreeSet<Integer>(Main.intervals.keySet()); for (Integer key : keys2) { ComboboxItem item = new ComboboxItem(key, Main.intervals.get(key)); screenSaverTimeout.getItems().add(item); if (defaultTimeout.equals(key)) { screenSaverTimeout.getSelectionModel().select(item); } } screenSaverTimeout.setOnAction( new EventHandler() { @Override public void handle(Event t) { ComboBox cb = (ComboBox) t.getTarget(); cb.getSelectionModel().selectedItemProperty(); ComboboxItem item = (ComboboxItem) cb.getSelectionModel().selectedItemProperty().getValue(); main.getConfig() .get(PainelConfig.KEY_SCREENSAVER_TIMEOUT, Integer.class) .setValue(Integer.parseInt(item.getKey())); } }); fileChooser.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { FileChooser fileChooser = new FileChooser(); fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("MP4", "*.mp4")); fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("AVI", "*.avi")); fileChooser.getExtensionFilters().add(new FileChooser.ExtensionFilter("HLS", "*.m3u8")); try { File file = fileChooser.showOpenDialog(null); videoUrl.setText(file.toURI().toString()); } catch (Exception e) { } } }); testVideo.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { try { String url = videoUrl.getText(); if (url != null && !url.isEmpty()) { if (tester != null) { tester.destroy(); } tester = new VideoTester(url.trim()); Stage painelStage = new Stage(); painelStage.initOwner(stage); painelStage.setOnCloseRequest( new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { tester.destroy(); } }); tester.start(painelStage); } } catch (Exception e) { e.printStackTrace(); } } }); // screesaver layout - marcando o padrao try { int id = main.getConfig().get(PainelConfig.KEY_SCREENSAVER_LAYOUT, Integer.class).getValue(); svLayout.getToggles().get(id - 1).setSelected(true); } catch (Exception e) { } // criando stage this.stage = new Stage(); stage.setTitle("Painel | Novo SGA"); stage.setScene(new Scene(getRoot())); // so esconde se suportar systray if (SystemTray.isSupported()) { final Controller self = this; stage.setOnCloseRequest( new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { self.stage.hide(); } }); } }
/** * Build an new JEConfig Login and main frame/stage * * @param primaryStage */ private void initGUI(Stage primaryStage) { Scene scene; LoginGlass login = new LoginGlass(primaryStage); AnchorPane jeconfigRoot = new AnchorPane(); AnchorPane.setTopAnchor(jeconfigRoot, 0.0); AnchorPane.setRightAnchor(jeconfigRoot, 0.0); AnchorPane.setLeftAnchor(jeconfigRoot, 0.0); AnchorPane.setBottomAnchor(jeconfigRoot, 0.0); Screen screen = Screen.getPrimary(); Rectangle2D bounds = screen.getVisualBounds(); login .getLoginStatus() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { if (newValue) { System.out.println("after request"); _mainDS = login.getDataSource(); ds = _mainDS; _currentUser = new User(ds); Platform.runLater( new Runnable() { @Override public void run() { FadeTransition ft = new FadeTransition(Duration.millis(1500), login); ft.setFromValue(1.0); ft.setToValue(0); ft.setCycleCount(1); ft.play(); } }); JEConfig.PROGRAMM_INFO.setJEVisAPI(ds.getInfo()); JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.commons.application.Info.INFO); JEConfig.PROGRAMM_INFO.addLibrary(org.jevis.application.Info.INFO); preLodedClasses = login.getAllClasses(); preLodedRootObjects = login.getRootObjects(); PluginManager pMan = new PluginManager(ds); GlobalToolBar toolbar = new GlobalToolBar(pMan); pMan.addPluginsByUserSetting(null); BorderPane border = new BorderPane(); VBox vbox = new VBox(); vbox.setStyle("-fx-background-color: black;"); // vbox.getChildren().addAll(new TopMenu(), // toolbar.ToolBarFactory()); vbox.getChildren().addAll(new TopMenu(), pMan.getToolbar()); border.setTop(vbox); border.setCenter(pMan.getView()); Statusbar statusBar = new Statusbar(ds); border.setBottom(statusBar); // Disable GUI is StatusBar note an disconnect border.disableProperty().bind(statusBar.connectedProperty.not()); Platform.runLater( new Runnable() { @Override public void run() { AnchorPane.setTopAnchor(border, 0.0); AnchorPane.setRightAnchor(border, 0.0); AnchorPane.setLeftAnchor(border, 0.0); AnchorPane.setBottomAnchor(border, 0.0); jeconfigRoot.getChildren().setAll(border); try { WelcomePage welcome = new WelcomePage(primaryStage, _config.getWelcomeURL()); } catch (URISyntaxException ex) { Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedURLException ex) { Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); } } }); } } }); AnchorPane.setTopAnchor(login, 0.0); AnchorPane.setRightAnchor(login, 0.0); AnchorPane.setLeftAnchor(login, 0.0); AnchorPane.setBottomAnchor(login, 0.0); scene = new Scene(jeconfigRoot, bounds.getWidth(), bounds.getHeight()); scene.getStylesheets().add("/styles/Styles.css"); primaryStage.getIcons().add(getImage("JEVisIconBlue.png")); primaryStage.setTitle("JEConfig"); primaryStage.setScene(scene); primaryStage.setMaximized(true); // maximize(primaryStage); primaryStage.show(); jeconfigRoot.getChildren().setAll(login); primaryStage .onCloseRequestProperty() .addListener( new ChangeListener<EventHandler<WindowEvent>>() { @Override public void changed( ObservableValue<? extends EventHandler<WindowEvent>> ov, EventHandler<WindowEvent> t, EventHandler<WindowEvent> t1) { try { System.out.println("Disconnect"); ds.disconnect(); } catch (JEVisException ex) { Logger.getLogger(JEConfig.class.getName()).log(Level.SEVERE, null, ex); } } }); }
/** Converts the given region into a {@link Bounds} object. */ public static Bounds bounds(Rectangle2D region) { return bounds(region.getMinX(), region.getMinY(), region.getWidth(), region.getHeight()); }
/* * Constructor for the MediaControl class. Accepts optional parameters from PWS. * Creates a visual control bar with a play/pause button, a stop button, and a * fullscreen button, which is overlayed onto the MediaPlayer. Also handles * entering into the fullscreen viewing mode. * * @param mp The MediaPlayer object instantiated by the VideoHandler class * @param width The PWS optional width for the MediaPlayer * @param height The PWS optional height for the MediaPlayer * @param loop The PWS optional loop value for the video * @param startTime The PWS optional startTime to delay the video starting to play * @param playDuration The PWS optional duration to play the video for */ public MediaControl( final MediaPlayer mp, Integer width, Integer height, Boolean loop, Integer startTime, Integer playDuration) { this.mp = mp; this.startTime = startTime; this.playDuration = playDuration; mediaView = new MediaView(mp); // Retrieve the size of the Screen bounds = Screen.getPrimary().getVisualBounds(); // Assign loop variable as necessary if (loop == null) { this.mpLoop = false; } else { this.mpLoop = loop; } // Set the MediaPlayer cycle count based on the value of loop setLoop(mpLoop); if (width != null && height != null) { // Set the height and width of the MediaPlayer based on the values this.mpWidth = width; this.mpHeight = height; mediaView.setPreserveRatio(false); mediaView.setFitWidth(mpWidth); mediaView.setFitHeight(mpHeight - 35); } else { // Set a default size of the MediaPlayer when no height and width are being indicated this.mpWidth = (int) (bounds.getWidth() / 2); this.mpHeight = (int) (bounds.getHeight() / 4); mediaView.setPreserveRatio(true); mediaView.setFitWidth(mpWidth); } if (startTime == null) { // Set start time to be 0 when no startTime is being indicated this.startTime = 0; new Thread(startTimerThread).start(); } else { // Start the startTimerThread based on the startTime indicated new Thread(startTimerThread).start(); } // A VBox that contains the MediaView and Control Panel of the MediaPlayer overallBox = new VBox(); overallBox.setMaxSize(mpWidth, mpHeight); mediaView.setFitHeight(mpHeight - 35); overallBox.getChildren().add(mediaView); // A HBox that contains all the Controls of the MediaPlayer mediaBar = new HBox(); mediaBar.setMaxWidth(mpWidth); mediaBar.setPadding(new Insets(5, 10, 5, 10)); try { // Get and load images for buttons on MediaControl bar. inputStream = new FileInputStream("../Resources/play.png"); playImage = new Image(inputStream); inputStream = new FileInputStream("../Resources/pause.png"); pauseImage = new Image(inputStream); inputStream = new FileInputStream("../Resources/stop.png"); stopImage = new Image(inputStream); inputStream = new FileInputStream("../Resources/fullscreen.png"); fullscreenImage = new Image(inputStream); } catch (FileNotFoundException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } // Handle the play button setPlayButton(); // Handle the stop button setStopButton(); // Handle the fullscreen button setFullScreenButton(); // Label to show the length of the video Label timeLabel = new Label(" Time: "); timeLabel.setTextFill(Color.WHITE); timeLabel.setMinWidth(Control.USE_PREF_SIZE); mediaBar.getChildren().add(timeLabel); // Handle the time slider setTimeSlider(); // Label to show the current time position of the video playTime = new Label(); playTime.setMinWidth(50); playTime.setTextFill(Color.WHITE); mediaBar.getChildren().add(playTime); // Label to show the current volume of the media Label volumeLabel = new Label(" Vol: "); volumeLabel.setTextFill(Color.WHITE); volumeLabel.setMinWidth(Control.USE_PREF_SIZE); mediaBar.getChildren().add(volumeLabel); // Handle the volume slider setVolumeSlider(); // Label for play time in full screen mode playTimeFS = new Label(); playTimeFS.setMinWidth(50); playTimeFS.setTextFill(Color.WHITE); // Add components to Control Panel during fullscreen mode fullscreenMediaBar = new HBox(); fullscreenMediaBar.getChildren().add(playButtonFS); fullscreenMediaBar.getChildren().add(timeSliderFS); fullscreenMediaBar.getChildren().add(playTimeFS); fullscreenMediaBar.setLayoutY(bounds.getHeight() - 20); // Add the mediaBar "box" to the overall MediaControl "bar" overallBox.getChildren().add(mediaBar); }
@Override /** Starts the application. */ public void start(final Stage primaryStage) { final EventManager eventManager = new EventManager(); final IdGenerator connectionIdGenerator = new IdGenerator(); try { final ConfigurationManager configurationManager = new ConfigurationManager(eventManager, connectionIdGenerator); // Load the main window FxmlUtils.setParentClass(getClass()); final FXMLLoader loader = FxmlUtils.createFxmlLoaderForProjectFile("MainWindow.fxml"); // Get the associated pane AnchorPane pane = (AnchorPane) loader.load(); final Rectangle2D primaryScreenBounds = Screen.getPrimary().getVisualBounds(); // Set scene width, height and style final double height = Math.min( UiProperties.getApplicationHeight(configurationManager), primaryScreenBounds.getHeight()); final double width = Math.min( UiProperties.getApplicationWidth(configurationManager), primaryScreenBounds.getWidth()); final Scene scene = new Scene(pane, width, height); scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm()); // Get the associated controller final MainController mainController = (MainController) loader.getController(); mainController.setEventManager(eventManager); mainController.setConfigurationManager(configurationManager); mainController.setSelectedPerspective( UiProperties.getApplicationPerspective(configurationManager)); mainController .getResizeMessagePaneMenu() .setSelected(UiProperties.getResizeMessagePane(configurationManager)); // Set the stage's properties primaryStage.setScene(scene); primaryStage.setMaximized(UiProperties.getApplicationMaximized(configurationManager)); // Initialise resources in the main controller mainController.setApplication(this); mainController.setStage(primaryStage); mainController.setLastHeight(height); mainController.setLastWidth(width); mainController.init(); final Image applicationIcon = new Image(getClass().getResourceAsStream("/images/mqtt-spy-logo.png")); primaryStage.getIcons().add(applicationIcon); // Show the main window primaryStage.show(); // Load the config file if specified final String noConfig = this.getParameters().getNamed().get(NO_CONFIGURATION_PARAMETER_NAME); final String configurationFileLocation = this.getParameters().getNamed().get(CONFIGURATION_PARAMETER_NAME); if (noConfig != null) { // Do nothing - no config wanted } else if (configurationFileLocation != null) { mainController.loadConfigurationFileAndShowErrorWhenApplicable( new File(configurationFileLocation)); } else { // If no configuration parameter is specified, use the user's home directory and the default // configuration file name mainController.loadDefaultConfigurationFile(); } } catch (Exception e) { LoggerFactory.getLogger(Main.class).error("Error while loading the main window", e); } }