private void createMasterPane() { webView = new WebView(); webViewAnchorPane = new AnchorPane(webView); AnchorPane.setBottomAnchor(webView, 0.0); AnchorPane.setTopAnchor(webView, 0.0); AnchorPane.setLeftAnchor(webView, 0.0); AnchorPane.setRightAnchor(webView, 0.0); webEngine = webView.getEngine(); dialog = Dialogs.create().lightweight().modal().owner(webView); // locals = new LocalJSObject(webEngine); // globals = GlobalJSObject.getGlobalJSObject(webEngine); javaScriptHelpers = new BurpKitBridge(webEngine); originalUserAgent = webEngine.getUserAgent(); webEngine.setJavaScriptEnabled(true); webEngine.setOnAlert(this::handleAlert); webEngine.setOnError(this::handleError); webEngine.setConfirmHandler(param -> true); webEngine.getLoadWorker().stateProperty().addListener(this::workerStateChanged); createToolBar(); createStatusBar(); webEngine.load("about:blank"); masterPane = new BorderPane(); masterPane.setTop(toolBar); masterPane.setCenter(webViewAnchorPane); masterPane.setBottom(statusBar); }
public void displayPane() throws IOException { addStationsToCB(); paneTop.getColumnConstraints().add(new ColumnConstraints(60)); paneTop.getColumnConstraints().add(new ColumnConstraints(200)); paneTop.getColumnConstraints().add(new ColumnConstraints(100)); paneBot.getColumnConstraints().add(new ColumnConstraints(60)); paneBot.getColumnConstraints().add(new ColumnConstraints(200)); paneBot.getColumnConstraints().add(new ColumnConstraints(100)); paneCenter.getColumnConstraints().add(new ColumnConstraints(300)); paneTop.setPadding(new Insets(10, 10, 10, 10)); paneTop.setAlignment(Pos.CENTER); paneTop.setHgap(5); paneTop.setVgap(5); paneBot.setPadding(new Insets(10, 10, 10, 10)); paneBot.setAlignment(Pos.CENTER); paneBot.setHgap(5); paneBot.setVgap(5); paneTop.add(new Label("Station :"), 0, 0); paneTop.add(cbStations, 1, 0); paneTop.add(btOpen, 2, 0); paneBot.add(new Label("Quantity :"), 0, 0); paneBot.add(cbQuantity, 1, 0); paneBot.add(btShow, 2, 0); paneTop.setHalignment(btOpen, HPos.RIGHT); paneBot.setHalignment(btShow, HPos.RIGHT); paneCenter.setHgap(5); paneCenter.setVgap(5); paneCenter.setAlignment(Pos.CENTER); sp.setContent(paneCenter); sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS); bp.setMargin(sp, new Insets(20, 50, 40, 50)); bp.setTop(paneTop); bp.setCenter(sp); bp.setBottom(paneBot); btOpen.setOnAction( e -> { try { open(); } catch (IOException er) { er.printStackTrace(); } }); btShow.setOnAction(e -> showGraph()); }
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(); }
@Override public void start(Stage primaryStage) throws Exception { /* create the menu (for the top of the user interface) */ Menu fileMenu = new Menu("File"); MenuItem newMenuItem = new MenuItem("New", imageFile("images/new.png")); newMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+N")); fileMenu.getItems().add(newMenuItem); fileMenu.getItems().add(new SeparatorMenuItem()); fileMenu.getItems().add(new MenuItem("Open...", imageFile("images/open.png"))); fileMenu.getItems().add(new SeparatorMenuItem()); MenuItem saveMenuItem = new MenuItem("Save", imageFile("images/save.png")); fileMenu.getItems().add(saveMenuItem); MenuItem saveAsMenuItem = new MenuItem("Save As...", imageFile("images/save_as.png")); fileMenu.getItems().add(saveAsMenuItem); fileMenu.getItems().add(new SeparatorMenuItem()); MenuItem exitMenuItem = new MenuItem("Exit", imageFile("images/exit.png")); fileMenu.getItems().add(exitMenuItem); exitMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+Q")); exitMenuItem.setOnAction(e -> System.exit(0)); Menu editMenu = new Menu("Edit"); editMenu.getItems().add(new MenuItem("Cut", imageFile("images/cut.png"))); editMenu.getItems().add(new MenuItem("Copy", imageFile("images/copy.png"))); editMenu.getItems().add(new MenuItem("Paste", imageFile("images/paste.png"))); Menu helpMenu = new Menu("Help"); helpMenu.getItems().add(new MenuItem("About...", imageFile("images/about.png"))); helpMenu.getItems().add(new SeparatorMenuItem()); helpMenu.getItems().add(new MenuItem("Help...", imageFile("images/help.png"))); MenuBar menuBar = new MenuBar(); menuBar.getMenus().add(fileMenu); menuBar.getMenus().add(editMenu); menuBar.getMenus().add(helpMenu); primaryStage.setTitle("Lab08"); // grid contains all of the textfeilds, labels , buttons, ect.. GridPane grid = new GridPane(); // the tableview puts all of our data into a exel like format TableView<StudentRecord> table = new TableView<>(); table.setItems(DataSource.getAllMarks()); table.setEditable(true); TableColumn<StudentRecord, String> IDColumn = null; IDColumn = new TableColumn<>("SID"); IDColumn.setMinWidth(100); // the thing in quotes is what it will search for in the StudentRecords.java (MAKE SURE THERE IS // A GET FUNCTION FOR THAT VARIBALE) IDColumn.setCellValueFactory(new PropertyValueFactory<>("ID")); TableColumn<StudentRecord, Double> AssignmentColumn = null; AssignmentColumn = new TableColumn<>("Assignment"); AssignmentColumn.setMinWidth(100); AssignmentColumn.setCellValueFactory(new PropertyValueFactory<>("Assign")); TableColumn<StudentRecord, Float> MidtermColumn = null; MidtermColumn = new TableColumn<>("Midterm"); MidtermColumn.setMinWidth(100); MidtermColumn.setCellValueFactory(new PropertyValueFactory<>("Midterm")); TableColumn<StudentRecord, Float> FinalColumn = null; FinalColumn = new TableColumn<>("Final Exam"); FinalColumn.setMinWidth(100); FinalColumn.setCellValueFactory(new PropertyValueFactory<>("Final")); TableColumn<StudentRecord, String> GradeColumn = null; GradeColumn = new TableColumn<>("Letter Grade"); GradeColumn.setMinWidth(100); GradeColumn.setCellValueFactory(new PropertyValueFactory<>("Grade")); table.getColumns().add(IDColumn); table.getColumns().add(AssignmentColumn); table.getColumns().add(MidtermColumn); table.getColumns().add(FinalColumn); table.getColumns().add(GradeColumn); Label IDLabel = new Label("SID:"); grid.add(IDLabel, 0, 0); TextField IDField = new TextField(); IDField.setPromptText("SID"); grid.add(IDField, 1, 0); Label AssignLabel = new Label("Assignments:"); grid.add(AssignLabel, 2, 0); TextField AssignField = new TextField(); AssignField.setPromptText("Assignment"); grid.add(AssignField, 3, 0); Label MidLabel = new Label("Midterm:"); grid.add(MidLabel, 0, 1); TextField midField = new TextField(); midField.setPromptText("Midterm"); grid.add(midField, 1, 1); Label FinalLabel = new Label("Final:"); grid.add(FinalLabel, 2, 1); TextField FinalField = new TextField(); FinalField.setPromptText("Final"); grid.add(FinalField, 3, 1); Button AddButton = new Button("Add"); AddButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { char Grade; String SID = IDField.getText(); Float Assignment = Float.parseFloat(AssignField.getText()); Float Midterm = Float.parseFloat(midField.getText()); Float Final = Float.parseFloat(FinalField.getText()); table.getItems().add(new StudentRecord(SID, Assignment, Midterm, Final)); IDField.setText(""); AssignField.setText(""); midField.setText(""); FinalField.setText(""); } }); grid.add(AddButton, 0, 2); layout = new BorderPane(); layout.setTop(menuBar); layout.setCenter(table); layout.setBottom(grid); Scene scene = new Scene(layout); grid.setPadding(new Insets(10, 10, 10, 10)); grid.setVgap(10); grid.setHgap(10); primaryStage.setScene(scene); primaryStage.show(); }
@Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("JavaFX Demo"); /* create the menu (for the top of the user interface) */ Menu fileMenu = new Menu("File"); MenuItem newMenuItem = new MenuItem("New", imageFile("images/new.png")); newMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+N")); fileMenu.getItems().add(newMenuItem); fileMenu.getItems().add(new SeparatorMenuItem()); fileMenu.getItems().add(new MenuItem("Open...", imageFile("images/open.png"))); fileMenu.getItems().add(new SeparatorMenuItem()); fileMenu.getItems().add(new MenuItem("Save", imageFile("images/save.png"))); fileMenu.getItems().add(new MenuItem("Save As...", imageFile("images/save_as.png"))); fileMenu.getItems().add(new SeparatorMenuItem()); MenuItem exitMenuItem = new MenuItem("Exit", imageFile("images/exit.png")); fileMenu.getItems().add(exitMenuItem); exitMenuItem.setAccelerator(KeyCombination.keyCombination("Ctrl+Q")); exitMenuItem.setOnAction(e -> System.exit(0)); Menu editMenu = new Menu("Edit"); editMenu.getItems().add(new MenuItem("Cut", imageFile("images/cut.png"))); editMenu.getItems().add(new MenuItem("Copy", imageFile("images/copy.png"))); editMenu.getItems().add(new MenuItem("Paste", imageFile("images/paste.png"))); Menu helpMenu = new Menu("Help"); helpMenu.getItems().add(new MenuItem("About...", imageFile("images/about.png"))); helpMenu.getItems().add(new SeparatorMenuItem()); helpMenu.getItems().add(new MenuItem("Help...", imageFile("images/help.png"))); MenuBar menuBar = new MenuBar(); menuBar.getMenus().add(fileMenu); menuBar.getMenus().add(editMenu); menuBar.getMenus().add(helpMenu); /* create the table (for the center of the user interface) */ table = new TableView<>(); table.setItems(DataSource.getAllStudents()); table.setEditable(true); /* create the table's columns */ TableColumn<Student, Integer> sidColumn = null; sidColumn = new TableColumn<>("SID"); sidColumn.setMinWidth(100); sidColumn.setCellValueFactory(new PropertyValueFactory<>("sid")); TableColumn<Student, String> firstNameColumn = null; firstNameColumn = new TableColumn<>("First Name"); firstNameColumn.setMinWidth(200); firstNameColumn.setCellValueFactory(new PropertyValueFactory<>("firstName")); firstNameColumn.setCellFactory(TextFieldTableCell.<Student>forTableColumn()); firstNameColumn.setOnEditCommit( (CellEditEvent<Student, String> event) -> { ((Student) event.getTableView().getItems().get(event.getTablePosition().getRow())) .setFirstName(event.getNewValue()); }); TableColumn<Student, String> lastNameColumn = null; lastNameColumn = new TableColumn<>("Last Name"); lastNameColumn.setMinWidth(200); lastNameColumn.setCellValueFactory(new PropertyValueFactory<>("lastName")); lastNameColumn.setCellFactory(TextFieldTableCell.<Student>forTableColumn()); lastNameColumn.setOnEditCommit( (CellEditEvent<Student, String> event) -> { ((Student) event.getTableView().getItems().get(event.getTablePosition().getRow())) .setLastName(event.getNewValue()); }); TableColumn<Student, Double> gpaColumn = null; gpaColumn = new TableColumn<>("GPA"); gpaColumn.setMinWidth(100); gpaColumn.setCellValueFactory(new PropertyValueFactory<>("gpa")); table.getColumns().add(sidColumn); table.getColumns().add(lastNameColumn); table.getColumns().add(firstNameColumn); table.getColumns().add(gpaColumn); /* create an edit form (for the bottom of the user interface) */ GridPane editArea = new GridPane(); editArea.setPadding(new Insets(10, 10, 10, 10)); editArea.setVgap(10); editArea.setHgap(10); Label sidLabel = new Label("SID:"); editArea.add(sidLabel, 0, 0); TextField sidField = new TextField(); sidField.setPromptText("SID"); editArea.add(sidField, 1, 0); Label fnameLabel = new Label("First name:"); editArea.add(fnameLabel, 0, 1); TextField fnameField = new TextField(); fnameField.setPromptText("First Name"); editArea.add(fnameField, 1, 1); Label lnameLabel = new Label("Last name:"); editArea.add(lnameLabel, 0, 2); TextField lnameField = new TextField(); lnameField.setPromptText("Last Name"); editArea.add(lnameField, 1, 2); Label gpaLabel = new Label("GPA:"); editArea.add(gpaLabel, 0, 3); TextField gpaField = new TextField(); gpaField.setPromptText("GPA"); editArea.add(gpaField, 1, 3); Button addButton = new Button("Add"); addButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent e) { int sid = Integer.parseInt(sidField.getText()); String firstName = fnameField.getText(); String lastName = lnameField.getText(); double gpa = Double.parseDouble(gpaField.getText()); table.getItems().add(new Student(sid, firstName, lastName, gpa)); sidField.setText(""); fnameField.setText(""); lnameField.setText(""); gpaField.setText(""); } }); editArea.add(addButton, 1, 4); /* arrange all components in the main user interface */ layout = new BorderPane(); layout.setTop(menuBar); layout.setCenter(table); layout.setBottom(editArea); Scene scene = new Scene(layout, 600, 600); primaryStage.setScene(scene); primaryStage.show(); }
/** * Draws the MapMaker screen and displays it to the user * * @param primaryStage the stage to show it in * @throws Exception */ public void drawScreen(Stage primaryStage) throws Exception { // Create the base BorderPane for the whole window BorderPane borderPane = new BorderPane(); borderPane.setStyle("-fx-background-color: papayawhip"); // Add some instructions to the user String text = "Instructions:\n" + "1. Click on the map component that you would like to place in the map\n" + "2. Click on the place in the map where you want to place the component\n" + "3. Repeat until you built the map you want!\n" + "4. Hit the 'Save' button when you are done"; Label instructions = new Label(text); instructions.setFont(Font.font("Arial", FontWeight.BOLD, 12)); instructions.setPadding(new Insets(5, 5, 5, 5)); borderPane.setTop(instructions); // Create the blank Map Pane mapPane = new Pane(); Map map = new Map(width, height); MapGridGUIDecorator mapGridGUIDecorator = new MapGridGUIDecorator(map.getGrid()); ResizeFactor rf = ResizeFactor.getSuggestedResizeFactor(width, height); mapGridGUIDecorator.setResizeFactor(rf); GridPane mapGridPane = mapGridGUIDecorator.drawComponents(); mapGridPane.setPadding(new Insets(0, 0, 5, 5)); mapPane.getChildren().add(mapGridPane); borderPane.setCenter(mapPane); MapMakerController.setCurrentFocused(ComponentType.NOTHING); VBox sideComponents = new VBox(); /* Add "Components" label */ Label componentsLabel = new Label("Components"); componentsLabel.setFont(Font.font("Arial", FontWeight.EXTRA_BOLD, 14)); componentsLabel.setPadding(new Insets(15, 5, 0, 20)); sideComponents.getChildren().add(componentsLabel); /* Add Intersection square image */ VBox intersectionPane = new VBox(); Label intersectionLabel = new Label("Intersection"); intersectionLabel.setPadding(new Insets(5, 5, 0, 30)); intersectionLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12)); Image intersectionImg = new Image("IntersectionX.png", 60, 60, true, false); intersectionImgView = new ImageView(intersectionImg); StackPane intersectionStackPane = new StackPane(intersectionImgView); intersectionStackPane.setPadding(new Insets(0, 10, 10, 10)); intersectionPane.getChildren().add(intersectionLabel); intersectionPane.getChildren().add(intersectionStackPane); sideComponents.getChildren().add(intersectionPane); /* Add RoadNS square image */ VBox roadNSPane = new VBox(); Label roadNSLabel = new Label("Road (North-South)"); roadNSLabel.setPadding(new Insets(5, 5, 0, 15)); roadNSLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12)); Image roadNSImg = new Image("RoadBackgroundNS.png", 60, 60, true, false); roadNSImgView = new ImageView(roadNSImg); StackPane roadNSStackPane = new StackPane(roadNSImgView); roadNSStackPane.setPadding(new Insets(0, 10, 10, 10)); roadNSPane.getChildren().add(roadNSLabel); roadNSPane.getChildren().add(roadNSStackPane); sideComponents.getChildren().add(roadNSPane); /* Add RoadEW square image */ VBox roadEWPane = new VBox(); Label roadEWLabel = new Label("Road (East-West)"); roadEWLabel.setPadding(new Insets(5, 5, 0, 15)); roadEWLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12)); Image roadEWImg = new Image("RoadBackgroundEW.png", 60, 60, true, false); roadEWImgView = new ImageView(roadEWImg); StackPane roadEWStackPane = new StackPane(roadEWImgView); roadEWStackPane.setPadding(new Insets(0, 10, 10, 10)); roadEWPane.getChildren().add(roadEWLabel); roadEWPane.getChildren().add(roadEWStackPane); sideComponents.getChildren().add(roadEWPane); /* Add Grass square image to empty out cells */ VBox grassPane = new VBox(); Label grassLabel = new Label("Grass (clear square)"); grassLabel.setPadding(new Insets(5, 5, 0, 15)); grassLabel.setFont(Font.font("Arial", FontWeight.SEMI_BOLD, 12)); Image grassImg = new Image("Grass.png", 60, 60, true, false); grassImgView = new ImageView(grassImg); StackPane grassStackPane = new StackPane(grassImgView); grassStackPane.setPadding(new Insets(0, 10, 10, 10)); grassPane.getChildren().add(grassLabel); grassPane.getChildren().add(grassStackPane); sideComponents.getChildren().add(grassPane); /* Add Save, Reset buttons */ VBox buttonsPane = new VBox(); buttonsPane.setPadding(new Insets(0, 0, 0, 10)); Label toolsLabel = new Label("Tools"); toolsLabel.setFont(Font.font("Arial", FontWeight.EXTRA_BOLD, 14)); toolsLabel.setPadding(new Insets(15, 5, 5, 35)); buttonsPane.getChildren().add(toolsLabel); Insets padding = new Insets(0, 0, 5, 0); Button saveButton = new Button("Save Map"); StackPane saveButtonPane = new StackPane(saveButton); saveButtonPane.setPadding(padding); saveButton.setStyle("-fx-base:Gold"); saveButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13)); buttonsPane.getChildren().add(saveButtonPane); Button resetButton = new Button("Reset Map"); resetButton.setStyle("-fx-base:Gold"); resetButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13)); StackPane resetButtonPane = new StackPane(resetButton); resetButtonPane.setPadding(padding); buttonsPane.getChildren().add(resetButtonPane); Button backButton = new Button("Go Back"); backButton.setStyle("-fx-base:Gold"); backButton.setFont(Font.font("System Bold Italic", FontWeight.BOLD, 13)); StackPane backButtonPane = new StackPane(backButton); backButtonPane.setPadding(padding); buttonsPane.getChildren().add(backButtonPane); sideComponents.getChildren().add(buttonsPane); Ticker.start(); /* Add click processing for Map grid squares */ for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { Node current = getNodeFromIndex(i, j, mapGridPane); final int x = j; final int y = i; current.setOnMouseClicked( (MouseEvent click) -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.MAP_SQUARE); current.requestFocus(); }); current .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { ComponentType previous = MapMakerController.getPreviousFocused(); if (previous == ComponentType.INTERSECTION) { addIntersection( x, y, map, mapGridGUIDecorator, mapGridPane, intersectionImgView); } else if (previous == ComponentType.ROADNS) { addRoadNS(x, y, map, mapGridGUIDecorator, mapGridPane, roadNSImgView); } else if (previous == ComponentType.ROADEW) { addRoadEW(x, y, map, mapGridGUIDecorator, mapGridPane, roadEWImgView); } else if (previous == ComponentType.GRASS) { addGrass(x, y, map, mapGridGUIDecorator, mapGridPane, grassImgView); } }); } } /* Add intersection icon click processing */ DropShadow ds = new DropShadow(15, Color.BLUE); intersectionImgView.setOnMouseClicked( click -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.INTERSECTION); intersectionImgView.requestFocus(); }); intersectionImgView .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) intersectionImgView.setEffect(ds); else intersectionImgView.setEffect(null); }); /* Add roadNS icon click processing */ roadNSImgView.setOnMouseClicked( click -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.ROADNS); roadNSImgView.requestFocus(); }); roadNSImgView .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) roadNSImgView.setEffect(ds); else roadNSImgView.setEffect(null); }); /* Add roadEW icon click processing */ roadEWImgView.setOnMouseClicked( click -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.ROADEW); roadEWImgView.requestFocus(); }); roadEWImgView .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) roadEWImgView.setEffect(ds); else roadEWImgView.setEffect(null); }); /* Add grass icon click processing */ grassImgView.setOnMouseClicked( click -> { MapMakerController.setPreviousFocused(MapMakerController.getCurrentFocused()); MapMakerController.setCurrentFocused(ComponentType.GRASS); grassImgView.requestFocus(); }); grassImgView .focusedProperty() .addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { if (newValue) grassImgView.setEffect(ds); else grassImgView.setEffect(null); }); /* Add save button functionality */ saveButton.setOnMouseClicked( click -> { TextInputDialog nameDialog = new TextInputDialog(); nameDialog.setTitle("Save Map"); nameDialog.setHeaderText( "Please provide a name for your map (no spaces or special characters).\nSaved maps go into the /maps directory of your working directory."); nameDialog.setContentText("File name"); Button btOk = (Button) nameDialog.getDialogPane().lookupButton(ButtonType.OK); TextField textfield = nameDialog.getEditor(); Platform.runLater(() -> textfield.requestFocus()); btOk.setDisable(true); textfield .textProperty() .addListener( ((observable, oldValue, newValue) -> { btOk.setDisable(newValue.trim().isEmpty()); })); Optional<String> result = nameDialog.showAndWait(); result.ifPresent( name -> { name = name.concat(".map"); try { Map finalMap = buildAndSaveMap(map); finalMap.saveMap(name); goBack(primaryStage); } catch (Exception e) { e.printStackTrace(); } }); }); resetButton.setOnMouseClicked( click -> { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { Component component = map.getAtLocation(new Coordinate(x, y)); if (component instanceof Road || component instanceof Intersection) { addGrass(x, y, map, mapGridGUIDecorator, mapGridPane, grassImgView); } } } }); backButton.setOnMouseClicked( click -> { try { goBack(primaryStage); } catch (Exception e) { e.printStackTrace(); } }); borderPane.setRight(sideComponents); Scene scene = new Scene(borderPane); primaryStage.setScene(scene); primaryStage.centerOnScreen(); primaryStage.setResizable(false); }
@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 entryView(Object object) { getChildren().clear(); getStylesheets().add("css/entryView.css"); giveNode(object); BorderPane mainpane = new BorderPane(); BorderPane centerpane = new BorderPane(); BorderPane bottompane = new BorderPane(); GridPane divgrid = new GridPane(); GridPane maingrid = new GridPane(); Label emptylab = new Label(); Label divlab = new Label(); VBox options = new VBox(); VBox tlist = new VBox(); Button ok = new Button("ok"); Periods periods = new Periods(); TList loadteacher = new TList(); DatePicker date = new DatePicker(); BorderPane datepane = new BorderPane(); BorderPane nextpane = new BorderPane(); Button next = new Button("next"); options.setId("options"); tlist.setId("tlist"); divgrid.setId("divgrid"); bottompane.setId("bottompane"); periods.setId("period"); divlab.setId("divlabel"); datepane.setId("datepane"); nextpane.setId("nextpane"); emptylab.setPrefHeight(100); bottompane.setStyle("-fx-background-color:#ecf0f1;"); StringConverter converter = new StringConverter<LocalDate>() { DateTimeFormatter dateFormatter = DateTimeFormatter.ofPattern("dd-MM-yyyy"); @Override public String toString(LocalDate date) { if (date != null) { return dateFormatter.format(date); } else { return ""; } } @Override public LocalDate fromString(String string) { if (string != null && !string.isEmpty()) { return LocalDate.parse(string, dateFormatter); } else { return null; } } }; date.setConverter(converter); date.setPromptText("dd-MM-yyyy".toLowerCase()); date.setValue(LocalDate.now()); maingrid = div.loadDiv(); list = (ListView) div.takelist(); periods.period(); list.getSelectionModel().select(0); divlab.setText((String) list.getItems().get(0)); list.setOnMouseClicked( e -> { divlab.setText((String) list.getSelectionModel().getSelectedItem()); periods.getChildren().clear(); periods.period(); }); final Node node = maingrid.getChildren().get(0); Platform.runLater( new Runnable() { @Override public void run() { node.requestFocus(); } }); next.setOnAction( e -> { // list.getSelectionModel().getSelectedIndex()+1 list.getSelectionModel().select(list.getSelectionModel().getSelectedIndex() + 1); divlab.setText((String) list.getSelectionModel().getSelectedItem()); }); nextpane.setRight(next); datepane.setRight(date); options.getChildren().clear(); options.getChildren().add(maingrid); divgrid.setHgap(5); // divgrid.add(emptylab, 0, 1); divgrid.add(datepane, 1, 0); divgrid.add(divlab, 0, 2); divgrid.add(periods, 1, 2); divgrid.add(nextpane, 1, 3); divgrid.setAlignment(Pos.TOP_CENTER); mainpane.setCenter(centerpane); mainpane.setLeft(options); mainpane.setRight(loadteacher); centerpane.setCenter(divgrid); centerpane.setBottom(bottompane); bottompane.setRight(ok); addCloseButton cb = new addCloseButton(); cb.addxb(1); setTop(cb); setCenter(mainpane); }