@Override public void initialize(URL location, ResourceBundle resources) { ImageView backImgBtnLayout = createImageBtnLayout( Constants.BACK_IMAGE_PATH, Constants.BACK_IMAGE_WIDTH, Constants.BACK_IMAGE_HEIGHT); backBtn.setGraphic(backImgBtnLayout); ImageView addImgBtnLayout = createImageBtnLayout( Constants.ADD_BUTTON_IMAGE_PATH, Constants.ADD_IMAGE_WIDTH, Constants.ADD_IMAGE_HEIGHT); addButton.setGraphic(addImgBtnLayout); cancelBtn.setOnAction( event -> { showWindow(true, false); setTitle(Constants.CHARACTER_SCENE_HEADER.toUpperCase()); }); levelField.setEditable(false); classBox.setItems( FXCollections.observableArrayList( "Guardin", "Assassin", "Archmage", "Necromancer", "Prophet", "Shaman", "Druid", "Ranger")); characterRaceBox.setItems( FXCollections.observableArrayList( "Human", "Gnome", "Dwarf", "Elf", "Eladin", "Tiefling", "Deva", "Goliath")); }
/** * Called whenever the status of the {@link Timeline} changes. When fired, the buttons in the * controls panel are enabled/disabled accordingly. */ @Override public void changed(ObservableValue<? extends Status> arg0, Status oldStatus, Status newStatus) { if (newStatus == Status.RUNNING) { playButton.setGraphic(pauseImage); } else { playButton.setGraphic(playImage); } if (newStatus == Status.STOPPED) { stopButton.setDisable(true); } else { stopButton.setDisable(false); } }
private void gamePicture() throws FileNotFoundException { ImageView coloredBoxImg = new ImageView(new Image(new FileInputStream("lib/" + selectedGame + ".png"))); coloredBoxImg.setFitHeight(gamePicture.getPrefHeight() - 25); coloredBoxImg.setFitWidth(gamePicture.getPrefWidth() - 25); gamePicture.setGraphic(coloredBoxImg); gamePicture.setStyle(buttonStyle); }
private void instanciateWidgets() { eventHandler = new DocumentConfigurationScreenEventHandler(this); btnAddFromFS = new Button(properties.getProperty("add_from_hard_drive")); btnAddFromFS.setPrefSize(300, 80); btnAddFromFS.setOnAction(eventHandler); Image i = new Image(getClass().getResourceAsStream(properties.getProperty("ico_library_root"))); ImageView iv = new ImageView(i); iv.setSmooth(true); iv.setFitWidth(64); iv.setFitHeight(64); btnAddFromFS.setGraphic(iv); btnAddFromScanner = new Button(properties.getProperty("add_scan")); btnAddFromScanner.setPrefSize(300, 80); btnAddFromScanner.setOnAction(eventHandler); Image i2 = new Image(getClass().getResourceAsStream(properties.getProperty("ico_scan"))); ImageView iv2 = new ImageView(i2); iv2.setSmooth(true); iv2.setFitWidth(64); iv2.setFitHeight(64); btnAddFromScanner.setGraphic(iv2); docInfoEditor = new DocumentInfoEditor(); docInfoEditor.getEventHandler().addDocumentInfoEditorListener(eventHandler); btnSubmit = new Button(properties.getProperty("save")); btnSubmit.setPrefSize(250, 80); btnSubmit.setOnAction(eventHandler); Image i3 = new Image(getClass().getResourceAsStream(properties.getProperty("ico_save"))); ImageView iv3 = new ImageView(i3); iv3.setSmooth(true); iv3.setFitWidth(64); iv3.setFitHeight(64); btnSubmit.setGraphic(iv3); btnSubmit.setDisable(true); documentPreviewer = new DocumentPreviewer(this); documentPreviewer.getEventHandler().addDocumentPreviewListener(eventHandler); documentPreviewer.setEditionMode(true); }
public ModuleFooterPane() { this.getStyleClass().addAll(Style.CLOSE_FOOTER.css()); failed.setGraphic(AwesomeDude.createIconLabel(AwesomeIcon.TIMES_CIRCLE)); failed.getStyleClass().addAll("pdfsam-footer-button", "pdfsam-footer-failed-button"); failed.setVisible(false); failed.setOnAction(e -> eventStudio().broadcast(new ShowStageRequest(), "LogStage")); failed.setTooltip(new Tooltip(DefaultI18nContext.getInstance().i18n("Task execution failed"))); open.setVisible(false); bar.setPrefWidth(280); }
@Override public void start(Stage primaryStage) { // Text Button Button btnText = new Button(); btnText.setText("Button!"); btnText.setTextFill(Color.web("red")); btnText.setFont(new Font("Verdana", 15)); // Image Text Button Button btnTextImage = new Button(); btnTextImage.setText("Check"); btnTextImage.setFont(Font.font(20)); btnTextImage.setPrefSize(150, 100); Image imgCheck = new Image("file:resources/images/check.png"); btnTextImage.setGraphic(new ImageView(imgCheck)); // Image Button Button btnRight = new Button(); Image imgRight = new Image("file:resources/images/button_right.png"); btnRight.setGraphic(new ImageView(imgRight)); Button btnLeft = new Button(); Image imgLeft = new Image("file:resources/images/button_left.png"); btnLeft.setGraphic(new ImageView(imgLeft)); HBox hBoxFirst = new HBox(25); hBoxFirst.getChildren().addAll(btnText, btnTextImage); HBox hBoxSecond = new HBox(10); hBoxSecond.getChildren().addAll(btnLeft, btnRight); VBox vBox = new VBox(20); vBox.getChildren().addAll(hBoxFirst, hBoxSecond); vBox.setPadding(new Insets(20, 20, 20, 20)); StackPane layout = new StackPane(vBox); Scene scene = new Scene(layout, 300, 180); primaryStage.setTitle("Sample 03. Button"); primaryStage.setScene(scene); primaryStage.show(); }
@FXML void toggleState() { if (tweenBlock) return; tweenBlock = true; if (isPlaying) { stateButton.setGraphic(imagePlay); pause( () -> { tweenBlock = false; }); } else { if (currentTrack != null) { stateButton.setGraphic(imagePause); resume( () -> { tweenBlock = false; }); } } }
private void configureButtons() { // Restaurant button restaurantButton.setGraphic(restaurantIMV); restaurantButton.setStyle("-fx-background-color: transparent"); // reservations button reservationsButton.setGraphic(reservationsIMV); reservationsButton.setStyle("-fx-background-color: transparent"); // customers button customersButton.setGraphic(customersIMV); customersButton.setStyle("-fx-background-color: transparent"); // employees button employeesButton.setGraphic(employeesIMV); employeesButton.setStyle("-fx-background-color: transparent"); // rating button ratingButton.setGraphic(ratingIMV); ratingButton.setStyle("-fx-background-color: transparent"); // archive button archiveButton.setGraphic(archiveIMV); archiveButton.setStyle("-fx-background-color: transparent"); }
/** Initializes the controller. */ @FXML private void initialize() { closeButton.setGraphic(new FontAwesomeIconView(FontAwesomeIcon.TIMES)); try { licenseTextArea.setText( new String( Files.readAllBytes( Paths.get(SmartRace.class.getResource("/licenses/gnu_gpl_v3.txt").getPath())))); } catch (IOException ex) { log.error(ex.getMessage(), ex); } }
private Button createCharacterBtn(String imgPath, double imgWidth, double imgHeight) { Button characterBtn = new Button(); characterBtn.setMaxWidth(400.0d); characterBtn.setMaxHeight(100.0d); characterBtn.setMinWidth(400.0d); characterBtn.setMinHeight(100.0d); characterBtn.setTextAlignment(TextAlignment.LEFT); ImageView avatarImgBtnLayout = createImageBtnLayout(imgPath, imgWidth, imgHeight); characterBtn.setGraphic(avatarImgBtnLayout); return characterBtn; }
@FXML private void customersButtonClicked(ActionEvent event) { configureButtons(); customersButton.setGraphic(customersSelectedIMV); // Clear old content contentPane.getChildren().clear(); titleLabel.setText("Customer Information"); ScrollPane scrollPane = new ScrollPane(); contentPane.getChildren().add(scrollPane); VBox box = new VBox(); box.setSpacing(10); box.setAlignment(Pos.TOP_CENTER); box.setPrefWidth(900); // set up for ALL CUSTOMERS Text cHeader = new Text("All Customers"); cHeader.setFont(new Font("System", 24)); ObservableList<Customer> data = FXCollections.observableArrayList(operation.getAllCustomers()); TableView cTable = new TableView(); TableColumn cfnCol = new TableColumn("First Name"); cfnCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); TableColumn clnCol = new TableColumn("Last Name"); clnCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); TableColumn cEmailCol = new TableColumn("Email"); cEmailCol.setCellValueFactory(new PropertyValueFactory<>("email")); TableColumn cUpdatedAtCol = new TableColumn("Updated At"); cUpdatedAtCol.setCellValueFactory(new PropertyValueFactory<>("updatedAt")); TableColumn cDiscountCol = new TableColumn("Discount"); cDiscountCol.setCellValueFactory(new PropertyValueFactory<>("discount")); cTable.getColumns().addAll(cfnCol, clnCol, cEmailCol, cUpdatedAtCol, cDiscountCol); cTable.setItems(data); cTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); box.getChildren().addAll(cHeader, cTable); scrollPane.setContent(box); }
/* * Function that creates a stop button, adds the relevant event handlers for it, * and adds the button to the MediaControl bar. */ void setStopButton() { // Create a stop button Button stopButton = new Button(); stopButton.setGraphic(new ImageView(stopImage)); stopButton.setOnAction( new EventHandler<ActionEvent>() { // ActionHandler for play button. public void handle(ActionEvent e) { // Media is stopped so set the play image for the "stop" button mp.stop(); atEndOfMedia = true; playButton.setGraphic(new ImageView(playImage)); playButtonFS.setGraphic(new ImageView(playImage)); } }); // Add the stop button to the MediaControl bar mediaBar.getChildren().add(stopButton); }
// Layouti default constructor, koos back nupuga public Layout(Pane pane) { soundOffOnButton.setGraphic(soundOnImage); setContent(pane); showBackButton(); }
public MediaControl(final MediaPlayer mp) { this.mp = mp; setStyle("-fx-background-color: #bfc2c7;"); // TODO: Use css file mediaView = new MediaView(mp); Pane mvPane = new Pane() {}; mvPane.getChildren().add(mediaView); mvPane.setStyle("-fx-background-color: black;"); // TODO: Use css file setCenter(mvPane); mediaBar = new HBox(); mediaBar.setPadding(new Insets(5, 10, 5, 10)); mediaBar.setAlignment(Pos.CENTER_LEFT); BorderPane.setAlignment(mediaBar, Pos.CENTER); final Button playButton = new Button(); playButton.setGraphic(imageViewPlay); playButton.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { updateValues(); Status status = mp.getStatus(); if (status == Status.UNKNOWN || status == Status.HALTED) { // don't do anything in these states return; } if (status == Status.PAUSED || status == Status.READY || status == Status.STOPPED) { // rewind the movie if we're sitting at the end if (atEndOfMedia) { mp.seek(mp.getStartTime()); atEndOfMedia = false; playButton.setGraphic(imageViewPlay); // playButton.setText(">"); updateValues(); } mp.play(); playButton.setGraphic(imageViewPause); // playButton.setText("||"); } else { mp.pause(); } } }); mp.currentTimeProperty() .addListener( new ChangeListener<Duration>() { @Override public void changed( ObservableValue<? extends Duration> observable, Duration oldValue, Duration newValue) { updateValues(); } }); mp.setOnPlaying( new Runnable() { public void run() { // System.out.println("onPlaying"); if (stopRequested) { mp.pause(); stopRequested = false; } else { playButton.setGraphic(imageViewPause); // playButton.setText("||"); } } }); mp.setOnPaused( new Runnable() { public void run() { // System.out.println("onPaused"); playButton.setGraphic(imageViewPlay); // playButton.setText("||"); } }); mp.setOnReady( new Runnable() { public void run() { duration = mp.getMedia().getDuration(); updateValues(); } }); mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1); mp.setOnEndOfMedia( new Runnable() { public void run() { if (!repeat) { playButton.setGraphic(imageViewPlay); // playButton.setText(">"); stopRequested = true; atEndOfMedia = true; } } }); mediaBar.getChildren().add(playButton); // Add spacer Label spacer = new Label(" "); mediaBar.getChildren().add(spacer); // Time label Label timeLabel = new Label("Time: "); timeLabel.setMinWidth(Control.USE_PREF_SIZE); mediaBar.getChildren().add(timeLabel); // Time slider timeSlider = new Slider(); HBox.setHgrow(timeSlider, Priority.ALWAYS); timeSlider.setMinWidth(50); timeSlider.setMaxWidth(Double.MAX_VALUE); timeSlider .valueProperty() .addListener( new InvalidationListener() { public void invalidated(Observable ov) { if (timeSlider.isValueChanging()) { // multiply duration by percentage calculated by slider position if (duration != null) { mp.seek(duration.multiply(timeSlider.getValue() / 100.0)); } updateValues(); } } }); mediaBar.getChildren().add(timeSlider); // Play label playTime = new Label(); playTime.setPrefWidth(130); playTime.setMinWidth(50); mediaBar.getChildren().add(playTime); // Volume label Label volumeLabel = new Label("Vol: "); volumeLabel.setMinWidth(Control.USE_PREF_SIZE); mediaBar.getChildren().add(volumeLabel); // Volume slider volumeSlider = new Slider(); volumeSlider.setPrefWidth(70); volumeSlider.setMaxWidth(Region.USE_PREF_SIZE); volumeSlider.setMinWidth(30); volumeSlider .valueProperty() .addListener( new InvalidationListener() { public void invalidated(Observable ov) {} }); volumeSlider .valueProperty() .addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { if (volumeSlider.isValueChanging()) { mp.setVolume(volumeSlider.getValue() / 100.0); } } }); mediaBar.getChildren().add(volumeSlider); setBottom(mediaBar); }
public MediaControl(final MediaPlayer mp) { this.mp = mp; setStyle("-fx-background-color: #bfc2c7;"); // TODO: Use css file mediaView = new MediaView(mp); mvPane = new Pane(); mvPane.getChildren().add(mediaView); mvPane.setStyle("-fx-background-color: black;"); // TODO: Use css file setCenter(mvPane); mediaBar = new HBox(5.0); mediaBar.setPadding(new Insets(5, 10, 5, 10)); mediaBar.setAlignment(Pos.CENTER_LEFT); BorderPane.setAlignment(mediaBar, Pos.CENTER); final Button playButton = ButtonBuilder.create().minWidth(Control.USE_PREF_SIZE).build(); playButton.setGraphic(imageViewPlay); playButton.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { updateValues(); MediaPlayer.Status status = mp.getStatus(); if (status == MediaPlayer.Status.UNKNOWN || status == MediaPlayer.Status.HALTED) { // don't do anything in these states return; } if (status == MediaPlayer.Status.PAUSED || status == MediaPlayer.Status.READY || status == MediaPlayer.Status.STOPPED) { // rewind the movie if we're sitting at the end if (atEndOfMedia) { mp.seek(mp.getStartTime()); atEndOfMedia = false; playButton.setGraphic(imageViewPlay); // playButton.setText(">"); updateValues(); } mp.play(); playButton.setGraphic(imageViewPause); // playButton.setText("||"); } else { mp.pause(); } } }); mp.currentTimeProperty() .addListener( new ChangeListener<Duration>() { @Override public void changed( ObservableValue<? extends Duration> observable, Duration oldValue, Duration newValue) { updateValues(); } }); mp.setOnPlaying( new Runnable() { public void run() { if (stopRequested) { mp.pause(); stopRequested = false; } else { playButton.setGraphic(imageViewPause); // playButton.setText("||"); } } }); mp.setOnPaused( new Runnable() { public void run() { playButton.setGraphic(imageViewPlay); // playButton.setText("||"); } }); mp.setOnReady( new Runnable() { public void run() { duration = mp.getMedia().getDuration(); updateValues(); } }); mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1); mp.setOnEndOfMedia( new Runnable() { public void run() { if (!repeat) { playButton.setGraphic(imageViewPlay); // playButton.setText(">"); stopRequested = true; atEndOfMedia = true; } } }); mediaBar.getChildren().add(playButton); // Time label Label timeLabel = new Label("Time"); timeLabel.setMinWidth(Control.USE_PREF_SIZE); mediaBar.getChildren().add(timeLabel); // Time slider timeSlider = SliderBuilder.create().minWidth(30).maxWidth(Double.MAX_VALUE).build(); HBox.setHgrow(timeSlider, Priority.ALWAYS); timeSlider .valueProperty() .addListener( new InvalidationListener() { public void invalidated(Observable ov) { if (timeSlider.isValueChanging()) { // multiply duration by percentage calculated by slider position if (duration != null) { mp.seek(duration.multiply(timeSlider.getValue() / 100.0)); } updateValues(); } } }); mediaBar.getChildren().add(timeSlider); // Play label playTime = LabelBuilder.create() // .prefWidth(130) .minWidth(Control.USE_PREF_SIZE) .build(); mediaBar.getChildren().add(playTime); // Fullscreen button Button buttonFullScreen = ButtonBuilder.create().text("Full Screen").minWidth(Control.USE_PREF_SIZE).build(); buttonFullScreen.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { if (!fullScreen) { newStage = new Stage(); newStage .fullScreenProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed( ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) { onFullScreen(); } }); final BorderPane borderPane = new BorderPane() { @Override protected void layoutChildren() { if (mediaView != null && getBottom() != null) { mediaView.setFitWidth(getWidth()); mediaView.setFitHeight(getHeight() - getBottom().prefHeight(-1)); } super.layoutChildren(); if (mediaView != null) { mediaView.setTranslateX( (((Pane) getCenter()).getWidth() - mediaView.prefWidth(-1)) / 2); mediaView.setTranslateY( (((Pane) getCenter()).getHeight() - mediaView.prefHeight(-1)) / 2); } }; }; setCenter(null); setBottom(null); borderPane.setCenter(mvPane); borderPane.setBottom(mediaBar); Scene newScene = new Scene(borderPane); newStage.setScene(newScene); // Workaround for disposing stage when exit fullscreen newStage.setX(-100000); newStage.setY(-100000); newStage.setFullScreen(true); fullScreen = true; newStage.show(); } else { // toggle FullScreen fullScreen = false; newStage.setFullScreen(false); } } }); mediaBar.getChildren().add(buttonFullScreen); // Volume label Label volumeLabel = new Label("Vol"); volumeLabel.setMinWidth(Control.USE_PREF_SIZE); mediaBar.getChildren().add(volumeLabel); // Volume slider volumeSlider = SliderBuilder.create().prefWidth(70).minWidth(30).maxWidth(Region.USE_PREF_SIZE).build(); volumeSlider .valueProperty() .addListener( new InvalidationListener() { public void invalidated(Observable ov) {} }); volumeSlider .valueProperty() .addListener( new ChangeListener<Number>() { @Override public void changed( ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { if (volumeSlider.isValueChanging()) { mp.setVolume(volumeSlider.getValue() / 100.0); } } }); mediaBar.getChildren().add(volumeSlider); setBottom(mediaBar); }
public MasterGUI(Stage stage) { parentStage = stage; // JsonHelpExtractor ujextractor = new JsonHelpExtractor(); // HashMap<String,String> dataSetTab_tooltipHelp = // ujextractor.extractToolTipFile("TestJson.json"); // HashMap<String, ExtensiveHelp> dataSetTab_extensiveHelp = // ujextractor.extractExtensiveHelpFile("DataSetExtensiveHelp.json"); // final HelpDataStore dataSetTab_HelpStore = new // HelpDataStore("DataSetTab",dataSetTab_tooltipHelp,dataSetTab_extensiveHelp); // ujextractor.writeExtensiveHelpFile("C:\\Users\\user\\Desktop\\ExtensiveSectionTest.json"); experiment = new Experiment(); tabPane = new TabPane(); final Tab tab1 = new DataSetTab(parentStage, experiment); tab1.setText("Dataset"); final Tab tab2 = new PreprocessingTab(parentStage, experiment); tab2.setText("Preprocessing"); final Tab tab3 = new FeatureSelectionTab(parentStage, experiment); tab3.setText("Feature Selection"); final Tab tab4 = new AlgorithmTab(parentStage, experiment); tab4.setText("Preference Learning Methods"); tabPane.tabClosingPolicyProperty().set(TabPane.TabClosingPolicy.UNAVAILABLE); tabPane.getTabs().addAll(tab1, tab2, tab3, tab4); BorderPane bottomPane = new BorderPane(); final Button btnBack = new Button(); btnBack.setPrefSize(200, 20); btnBack.setVisible(false); Label lblBackBtn = new Label("BACK"); ImageView imgViewBkBtn = new ImageView(new Image(DataSetTab.class.getResourceAsStream("bkButton.png"))); BorderPane backBtnInnerBPane = new BorderPane(); backBtnInnerBPane.setLeft(imgViewBkBtn); backBtnInnerBPane.setCenter(lblBackBtn); btnBack.setGraphic(backBtnInnerBPane); btnBack.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { if (tabPane.getSelectionModel().getSelectedIndex() > 0) { tabPane .selectionModelProperty() .get() .select(tabPane.selectionModelProperty().get().getSelectedIndex() - 1); } } }); final Button btnNext = new Button(); btnNext.setPrefSize(200, 20); Label lblNextBtn = new Label("NEXT"); ImageView imgViewNextBtn = new ImageView(new Image(DataSetTab.class.getResourceAsStream("nxtButton.png"))); BorderPane nextBtnInnerBPane = new BorderPane(); nextBtnInnerBPane.setCenter(lblNextBtn); nextBtnInnerBPane.setRight(imgViewNextBtn); btnNext.setGraphic(nextBtnInnerBPane); btnNext.disableProperty().bind(this.experiment.isReadyToUseDataSetProperty().not()); tabPane.selectionModelProperty(); btnNext.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { if (!tab4.selectedProperty().get()) { tabPane .selectionModelProperty() .get() .select(tabPane.selectionModelProperty().get().getSelectedIndex() + 1); } else if (tab4.selectedProperty().get()) { // Perform safety checks. boolean allClear = true; int numOfIgnoredFeatures = 0; boolean[] tmpIgArr = experiment.ignoredFeaturesProperty().get(); for (int i = 0; i < tmpIgArr.length; i++) { if (tmpIgArr[i]) { numOfIgnoredFeatures++; } } if (numOfIgnoredFeatures == experiment.dataSetProperty().get().getNumberOfFeatures()) { // You must include at least one feature. ModalPopup notification = new ModalPopup(); notification.show( new Label("ERROR: You must include at least one feature from the dataset."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } else if (experiment.featureSelectionProperty().get() != null) { if (experiment.featureSelectionProperty().get() instanceof NBest) { NBest castNBest = (NBest) experiment.featureSelectionProperty().get(); int numOfUserIncludedFeatures = (experiment.dataSetProperty().get().getNumberOfFeatures() - numOfIgnoredFeatures); if (castNBest.getN() > numOfUserIncludedFeatures) { // N val should always be less than or equal to the number of user included // features. ModalPopup notification = new ModalPopup(); notification.show( new Label( "ERROR: N-Best N value cannot be greater than the number of included features. \n Current N Value = " + castNBest.getN() + " \n Current Num of Included Features = " + numOfUserIncludedFeatures), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 600, false); allClear = false; } } if (experiment.algorithmForFeatureSelectionProperty().get() == null) { // You cannot select a feature selection type without stating an algorithm. ModalPopup notification = new ModalPopup(); notification.show( new Label( "ERROR: You must state an algorithm to work with " + experiment.featureSelectionProperty().get().getFSelName() + "."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } if (experiment.algorithmForFeatureSelectionProperty().get() != null) { if (experiment.algorithmForFeatureSelectionProperty().get() instanceof PLNeuroEvolution) { PLNeuroEvolution castPLNE = (PLNeuroEvolution) experiment.algorithmForFeatureSelectionProperty().get(); PLNeuroEvolutionConfigurator neConfig = castPLNE.getConfigurator(); GeneticAlgorithmConfigurator gaConfig = neConfig.getGeneticAlgorithmConfigurator(); if (gaConfig.getNumberOfParents() > gaConfig.getPopulationSize()) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "GA ERROR: The number of parents is greater than the GA population size."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } if (gaConfig.getElitSize() > gaConfig.getPopulationSize()) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "GA ERROR: The elitism size is greater than the GA population size."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } if (experiment.algorithmProperty().get() instanceof PLRankSvm) { PLRankSvm castPLRS = (PLRankSvm) experiment.algorithmProperty().get(); PLRankSvmConfigurator svmConfig = castPLRS.getConfigurator(); if ((svmConfig.gammaRequired()) && (svmConfig.getGamma() == 0)) { ModalPopup notification = new ModalPopup(); notification.show( new Label("SVM ERROR: Gamma cannot be set to 0."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } if (svmConfig.degreeRequired()) { try { Integer.parseInt(svmConfig.getDegreeTextboxContents()); } catch (Exception NumberFormatException) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "SVM ERROR: Invalid Degree value \\" + svmConfig.getDegreeTextboxContents() + "\\" + "."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } if (svmConfig.betaRequired()) { try { Integer.parseInt(svmConfig.getBetaTextboxContents()); } catch (Exception NumberFormatException) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "SVM ERROR: Invalid Beta value \\" + svmConfig.getBetaTextboxContents() + "\\" + "."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } } } if (experiment.algorithmProperty().get() instanceof PLNeuroEvolution) { PLNeuroEvolution castPLNE = (PLNeuroEvolution) experiment.algorithmProperty().get(); PLNeuroEvolutionConfigurator neConfig = castPLNE.getConfigurator(); GeneticAlgorithmConfigurator gaConfig = neConfig.getGeneticAlgorithmConfigurator(); int numParents = gaConfig.getNumberOfParents(); int popSize = gaConfig.getPopulationSize(); if (numParents > popSize) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "GA ERROR: The number of parents is greater than the GA population size."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } if (gaConfig.getElitSize() > gaConfig.getPopulationSize()) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "GA ERROR: The elitism size is greater than the GA population size."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } if (experiment.algorithmProperty().get() instanceof PLRankSvm) { PLRankSvm castPLRS = (PLRankSvm) experiment.algorithmProperty().get(); PLRankSvmConfigurator svmConfig = castPLRS.getConfigurator(); if ((svmConfig.gammaRequired()) && (svmConfig.getGamma() == 0)) { ModalPopup notification = new ModalPopup(); notification.show( new Label("SVM ERROR: Gamma cannot be set to 0."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } if (svmConfig.degreeRequired()) { try { Integer.parseInt(svmConfig.getDegreeTextboxContents()); } catch (Exception NumberFormatException) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "SVM ERROR: Invalid Degree value \\" + svmConfig.getDegreeTextboxContents() + "\\" + "."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } if (svmConfig.betaRequired()) { try { Integer.parseInt(svmConfig.getBetaTextboxContents()); } catch (Exception NumberFormatException) { ModalPopup notification = new ModalPopup(); notification.show( new Label( "SVM ERROR: Invalid Beta value \\" + svmConfig.getBetaTextboxContents() + "\\" + "."), parentStage.getScene().getRoot(), null, new Button("OK"), 200, 550, false); allClear = false; } } } if (allClear) { Execution e = new Execution(experiment); e.show(parentStage); } } } }); tab4.selectedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) { if (t1) { Label lblNextBtn = new Label("RUN EXPERIMENT"); ImageView imgViewNextBtn = new ImageView( new Image( DataSetTab.class.getResourceAsStream("runExperimentButton.png"))); BorderPane nextBtnInnerBPane = new BorderPane(); nextBtnInnerBPane.setCenter(lblNextBtn); nextBtnInnerBPane.setRight(imgViewNextBtn); btnNext.setGraphic(nextBtnInnerBPane); } else { Label lblNextBtn = new Label("NEXT"); ImageView imgViewNextBtn = new ImageView( new Image(DataSetTab.class.getResourceAsStream("nxtButton.png"))); BorderPane nextBtnInnerBPane = new BorderPane(); nextBtnInnerBPane.setCenter(lblNextBtn); nextBtnInnerBPane.setRight(imgViewNextBtn); btnNext.setGraphic(nextBtnInnerBPane); } } }); tab1.selectedProperty() .addListener( new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> ov, Boolean t, Boolean t1) { if (t1) { btnBack.setVisible(false); btnNext.setVisible(true); } else { btnBack.setVisible(true); } } }); Button helpButton = new Button(); helpButton.setVisible(true); helpButton.setGraphic( new ImageView(new Image(DataSetTab.class.getResourceAsStream("helpButton.png")))); helpButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { if (tab1.selectedProperty().get()) { Tab1Help h = new Tab1Help(); h.show(parentStage.getScene().getRoot(), null); } else if (tab2.selectedProperty().get()) { Tab2Help h = new Tab2Help(); h.show(parentStage.getScene().getRoot(), null); } else if (tab3.selectedProperty().get()) { Tab3Help h = new Tab3Help(); h.show(parentStage.getScene().getRoot(), null); } else if (tab4.selectedProperty().get()) { Tab4Help h = new Tab4Help(); h.show(parentStage.getScene().getRoot(), null); } } }); /*helpButton.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent t) { if (tab1.selectedProperty().get()) { ArrayList<String> itemsToInclude = new ArrayList<String>(); itemsToInclude.add("Loading a dataset"); itemsToInclude.add("Button: Import Object File"); itemsToInclude.add("Button: Import Ranking File"); String reqHTML = dataSetTab_HelpStore.constructHtml(itemsToInclude); HelpPopup hPopup = new HelpPopup(reqHTML); hPopup.show(parentStage.getScene().getRoot(), null); //Tab1Help h = new Tab1Help(); //h.show(parentStage.getScene().getRoot(), null); } if (tab2.selectedProperty().get()) { Tab2Help h = new Tab2Help(); h.show(parentStage.getScene().getRoot(), null); } } });*/ // helpButton.visibleProperty().bind(tab1.selectedProperty().or(tab2.selectedProperty())); HBox navBtnBox = new HBox(10); navBtnBox.getChildren().addAll(btnBack, btnNext); bottomPane.setPadding(new Insets(10, 10, 10, 10)); bottomPane.setStyle("-fx-background-color: #336699;"); bottomPane.setLeft(helpButton); bottomPane.setRight(navBtnBox); this.setCenter(tabPane); this.setBottom(bottomPane); disableTabs(new ArrayList<Integer>(Arrays.asList(1, 2, 3))); }
@FXML private void reservationsButtonClicked(ActionEvent event) { configureButtons(); reservationsButton.setGraphic(reservationsSelectedIMV); // Clear the content of contentPane contentPane.getChildren().clear(); // Set title titleLabel.setText("Reservations"); // Make box for weekly availability and reservations VBox box = new VBox(); box.setSpacing(10); box.setAlignment(Pos.TOP_CENTER); box.setPrefWidth(900); // box for availability VBox abox = new VBox(); box.setSpacing(10); box.setAlignment(Pos.TOP_CENTER); box.setPrefWidth(900); // box for reservations VBox resbox = new VBox(); box.setSpacing(10); box.setAlignment(Pos.TOP_CENTER); box.setPrefWidth(900); // set up for weekly table availability Text aHeader = new Text("Tables still available"); aHeader.setFont(new Font("System", 24)); TableView aTable = new TableView(); TableColumn aDateCol = new TableColumn("Date"); aDateCol.setCellValueFactory(new PropertyValueFactory<>("date")); TableColumn tablesCol = new TableColumn("Tables Available"); tablesCol.setCellValueFactory(new PropertyValueFactory<>("tablesAvailable")); // add table and title to availability box abox.getChildren().addAll(aHeader, aTable); abox.setSpacing(5); // set width for all cols aDateCol.setMinWidth(100); tablesCol.setMinWidth(100); aTable.getColumns().addAll(aDateCol, tablesCol); // Populate data to the table view operation.callDates(); ObservableList<Availability> adata = FXCollections.observableArrayList(operation.getWeeklyAvailability()); aTable.setItems(adata); aTable.setMaxHeight(235); aTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); // set up for reservations Text resHeader = new Text("All Reservations"); resHeader.setFont(new Font("System", 24)); TableView resTable = new TableView(); TableColumn firstNameCol = new TableColumn("First Name"); firstNameCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); TableColumn lastNameCol = new TableColumn("Last Name"); lastNameCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); TableColumn tidCol = new TableColumn("tID"); tidCol.setCellValueFactory(new PropertyValueFactory<>("tID")); TableColumn partySizeCol = new TableColumn("Party Size"); partySizeCol.setCellValueFactory(new PropertyValueFactory<>("partySize")); TableColumn seatsCol = new TableColumn("Seats"); seatsCol.setCellValueFactory(new PropertyValueFactory<>("seats")); TableColumn dateCol = new TableColumn("Reservation Date"); dateCol.setCellValueFactory(new PropertyValueFactory<>("reservationDate")); // set width for all cols firstNameCol.setMinWidth(100); lastNameCol.setMinWidth(100); tidCol.setMinWidth(100); partySizeCol.setMinWidth(100); seatsCol.setMinWidth(100); dateCol.setMinWidth(300); // add table and title to availability box ScrollPane scrollPane = new ScrollPane(); scrollPane.setContent(resTable); scrollPane.setFitToWidth(true); resbox.getChildren().addAll(resHeader, scrollPane); resbox.setSpacing(5); resTable .getColumns() .addAll(firstNameCol, lastNameCol, tidCol, partySizeCol, seatsCol, dateCol); // Populate data to the table view ObservableList<ReservationInfo> resdata = FXCollections.observableArrayList(operation.getAllReservations()); resTable.setItems(resdata); resTable.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); // add table view to content pane box.getChildren().addAll(abox, resbox); contentPane.getChildren().add(box); }
@FXML private void archiveButtonClicked(ActionEvent event) { configureButtons(); archiveButton.setGraphic(archiveSelectedIMV); // clear old content contentPane.getChildren().clear(); // ask for archive date titleLabel.setText("Archiving"); // create text and textfield VBox mainBox = new VBox(); mainBox.setSpacing(20); mainBox.setAlignment(Pos.CENTER); HBox box = new HBox(); contentPane.getChildren().add(mainBox); box.setSpacing(5); box.setAlignment(Pos.CENTER); Label dateLabel = new Label("Cut Off Date:"); dateLabel.setFont(new Font("System", 24)); TextField dateTF = new TextField(); dateTF.setPromptText("YYYY-MM-DD"); Label errorLabel = new Label(); errorLabel.setTextFill(Paint.valueOf("#f5515f")); errorLabel.setFont(new Font("System", 14)); Button confirmButton = new Button("Confirm"); confirmButton.setStyle( "-fx-background-color: #e63347;" + "-fx-background-radius: 7;" + "-fx-text-fill: white"); confirmButton.setPrefSize(130, 40); confirmButton.setOnAction( e -> { if (dateTF.getText() != null) { String cutoffDate = dateTF.getText().trim(); if (cutoffDate.length() > 10) { errorLabel.setText("Too long"); return; } else if (!isDate(cutoffDate)) { errorLabel.setText("Wrong date format"); return; } boolean success = operation.archive(cutoffDate); if (success) { // set up content contentPane.getChildren().clear(); TableView table = new TableView(); TableColumn fnCol = new TableColumn("First Name"); fnCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); TableColumn lnCol = new TableColumn("Last Name"); lnCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); TableColumn emailCol = new TableColumn("Email"); emailCol.setCellValueFactory(new PropertyValueFactory<>("email")); TableColumn lvCol = new TableColumn("Updated At"); lvCol.setCellValueFactory(new PropertyValueFactory<>("updatedAt")); TableColumn discountCol = new TableColumn("Discount"); discountCol.setCellValueFactory(new PropertyValueFactory<>("discount")); table.getColumns().addAll(fnCol, lnCol, emailCol, lvCol, discountCol); ObservableList<Customer> data = FXCollections.observableArrayList(operation.getArchivedCustomers()); table.setItems(data); contentPane.getChildren().add(table); titleLabel.setText("Archived Customers"); } else { titleLabel.setText("Can't archive"); return; } } else { errorLabel.setText("Please enter a date"); return; } }); box.getChildren().addAll(dateLabel, dateTF, errorLabel); mainBox.getChildren().addAll(box, confirmButton); }
@Override public void start(Stage primaryStage) { primaryStage.setTitle("OpenBot"); primaryStage.setResizable(false); GridPane grid = new GridPane(); grid.setAlignment(Pos.CENTER_LEFT); grid.setHgap(10); grid.setVgap(10); grid.setPadding(new Insets(25, 25, 25, 25)); Label scenetitle = new Label("Move Joints"); scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20)); grid.add(scenetitle, 2, 0, 5, 1); Image imgRight = new Image("images/arrowRight.png"); Image imgLeft = new Image("images/arrowLeft.png"); Button baseLeft = new Button(); baseLeft.setGraphic(new ImageView(imgLeft)); HBox hbbaseLeft = new HBox(10); hbbaseLeft.setAlignment(Pos.CENTER_LEFT); hbbaseLeft.getChildren().add(baseLeft); grid.add(hbbaseLeft, 0, 1); Label baseLabel = new Label("BASE"); grid.add(baseLabel, 5, 1); Button baseRight = new Button(); baseRight.setGraphic(new ImageView(imgRight)); HBox hbbaseRight = new HBox(10); hbbaseRight.setAlignment(Pos.CENTER_RIGHT); hbbaseRight.getChildren().add(baseRight); grid.add(hbbaseRight, 7, 1); TextField baseText = new TextField(); baseText.setPromptText("Base angle"); grid.add(baseText, 8, 1); Button shoulderLeft = new Button(); shoulderLeft.setGraphic(new ImageView(imgLeft)); HBox hbshoulderLeft = new HBox(10); hbshoulderLeft.setAlignment(Pos.CENTER_LEFT); hbshoulderLeft.getChildren().add(shoulderLeft); grid.add(hbshoulderLeft, 0, 2); Label shoulderLabel = new Label("SHOULDER"); grid.add(shoulderLabel, 5, 2); Button shoulderRight = new Button(); shoulderRight.setGraphic(new ImageView(imgRight)); HBox hbshoulderRight = new HBox(10); hbshoulderRight.setAlignment(Pos.CENTER_RIGHT); hbshoulderRight.getChildren().add(shoulderRight); grid.add(hbshoulderRight, 7, 2); TextField shoulderText = new TextField(); shoulderText.setPromptText("Shoulder angle"); grid.add(shoulderText, 8, 2); Button elbowLeft = new Button(); elbowLeft.setGraphic(new ImageView(imgLeft)); HBox hbelbowLeft = new HBox(10); hbelbowLeft.setAlignment(Pos.CENTER_LEFT); hbelbowLeft.getChildren().add(elbowLeft); grid.add(hbelbowLeft, 0, 3); Label elbowLabel = new Label("ELBOW"); grid.add(elbowLabel, 5, 3); Button elbowRight = new Button(); elbowRight.setGraphic(new ImageView(imgRight)); HBox hbelbowRight = new HBox(10); hbelbowRight.setAlignment(Pos.CENTER_RIGHT); hbelbowRight.getChildren().add(elbowRight); grid.add(hbelbowRight, 7, 3); TextField elbowText = new TextField(); elbowText.setPromptText("Elbow angle"); grid.add(elbowText, 8, 3); Button wrist1Left = new Button(); wrist1Left.setGraphic(new ImageView(imgLeft)); HBox hbwrist1Left = new HBox(10); hbwrist1Left.setAlignment(Pos.CENTER_LEFT); hbwrist1Left.getChildren().add(wrist1Left); grid.add(hbwrist1Left, 0, 4); Label wrist1Label = new Label("WRIST 1"); grid.add(wrist1Label, 5, 4); Button wrist1Right = new Button(); wrist1Right.setGraphic(new ImageView(imgRight)); HBox hbwrist1Right = new HBox(10); hbwrist1Right.setAlignment(Pos.CENTER_RIGHT); hbwrist1Right.getChildren().add(wrist1Right); grid.add(hbwrist1Right, 7, 4); TextField wrist1Text = new TextField(); wrist1Text.setPromptText("Wrist 1 angle"); grid.add(wrist1Text, 8, 4); Button wrist2Left = new Button(); wrist2Left.setGraphic(new ImageView(imgLeft)); HBox hbwrist2Left = new HBox(10); hbwrist2Left.setAlignment(Pos.CENTER_LEFT); hbwrist2Left.getChildren().add(wrist2Left); grid.add(hbwrist2Left, 0, 5); Label wrist2Label = new Label("WRIST 2"); grid.add(wrist2Label, 5, 5); Button wrist2Right = new Button(); wrist2Right.setGraphic(new ImageView(imgRight)); HBox hbwrist2Right = new HBox(10); hbwrist2Right.setAlignment(Pos.CENTER_RIGHT); hbwrist2Right.getChildren().add(wrist2Right); grid.add(hbwrist2Right, 7, 5); TextField wrist2Text = new TextField(); wrist2Text.setPromptText("Wrist 2 angle"); grid.add(wrist2Text, 8, 5); Button wrist3Left = new Button(); wrist3Left.setGraphic(new ImageView(imgLeft)); HBox hbwrist3Left = new HBox(10); hbwrist3Left.setAlignment(Pos.CENTER_LEFT); hbwrist3Left.getChildren().add(wrist3Left); grid.add(hbwrist3Left, 0, 6); Label wrist3Label = new Label("WRIST 3"); grid.add(wrist3Label, 5, 6); Button wrist3Right = new Button(); wrist3Right.setGraphic(new ImageView(imgRight)); HBox hbwrist3Right = new HBox(10); hbwrist3Right.setAlignment(Pos.CENTER_RIGHT); hbwrist3Right.getChildren().add(wrist3Right); grid.add(hbwrist3Right, 7, 6); TextField wrist3Text = new TextField(); wrist3Text.setPromptText("Wrist 3 angle"); grid.add(wrist3Text, 8, 6); Button sendAllAnglesButton = new Button("Send All Angles"); grid.add(sendAllAnglesButton, 8, 7); sendAllAnglesButton.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(baseText.getText()); if (currentValue != -1) { client.moveBaseHorizontalTo(currentValue); } currentValue = parseInt(shoulderText.getText()); if (currentValue != -1) { client.moveShoulderTo(currentValue); } currentValue = parseInt(elbowText.getText()); if (currentValue != -1) { client.moveElbowTo(currentValue); } currentValue = parseInt(wrist1Text.getText()); if (currentValue != -1) { client.moveWristOneTo(currentValue); } currentValue = parseInt(wrist2Text.getText()); if (currentValue != -1) { client.moveWristTwoTo(currentValue); } currentValue = parseInt(wrist3Text.getText()); if (currentValue != -1) { client.moveWristThreeTo(currentValue); } } }); baseLeft.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(baseText.getText()); if (currentValue != -1) { int targetValue = currentValue - 1; baseText.setText(String.valueOf(targetValue)); client.moveBaseHorizontalTo(targetValue); } } }); baseRight.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(baseText.getText()); if (currentValue != -1) { int targetValue = currentValue + 1; baseText.setText(String.valueOf(targetValue)); client.moveBaseHorizontalTo(targetValue); } } }); shoulderLeft.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(shoulderText.getText()); if (currentValue != -1) { int targetValue = currentValue - 1; shoulderText.setText(String.valueOf(targetValue)); client.moveShoulderTo(targetValue); } } }); shoulderRight.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(shoulderText.getText()); if (currentValue != -1) { int targetValue = currentValue + 1; shoulderText.setText(String.valueOf(targetValue)); client.moveShoulderTo(targetValue); } } }); elbowLeft.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(elbowText.getText()); if (currentValue != -1) { int targetValue = currentValue - 1; elbowText.setText(String.valueOf(targetValue)); client.moveElbowTo(targetValue); } } }); elbowRight.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(elbowText.getText()); if (currentValue != -1) { int targetValue = currentValue + 1; elbowText.setText(String.valueOf(targetValue)); client.moveElbowTo(targetValue); } } }); wrist1Left.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(wrist1Text.getText()); if (currentValue != -1) { int targetValue = currentValue - 1; wrist1Text.setText(String.valueOf(targetValue)); client.moveWristOneTo(targetValue); } } }); wrist1Right.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(wrist1Text.getText()); if (currentValue != -1) { int targetValue = currentValue + 1; wrist1Text.setText(String.valueOf(targetValue)); client.moveWristOneTo(targetValue); } } }); wrist2Left.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(wrist2Text.getText()); if (currentValue != -1) { int targetValue = currentValue - 1; wrist2Text.setText(String.valueOf(targetValue)); client.moveWristTwoTo(targetValue); } } }); wrist2Right.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(wrist2Text.getText()); if (currentValue != -1) { int targetValue = currentValue + 1; wrist2Text.setText(String.valueOf(targetValue)); client.moveWristTwoTo(targetValue); } } }); wrist3Left.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(wrist3Text.getText()); if (currentValue != -1) { int targetValue = currentValue - 1; wrist3Text.setText(String.valueOf(targetValue)); client.moveWristThreeTo(targetValue); } } }); wrist3Right.setOnAction( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { int currentValue = parseInt(wrist3Text.getText()); if (currentValue != -1) { int targetValue = currentValue + 1; wrist3Text.setText(String.valueOf(targetValue)); client.moveWristThreeTo(targetValue); } } }); Label scenetitle2 = new Label("Enter Angle"); scenetitle2.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20)); grid.add(scenetitle2, 8, 0, 5, 1); Label scenetitle3 = new Label("Tool Position"); scenetitle3.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20)); grid.add(scenetitle3, 10, 0, 5, 1); String xValue = "360.0"; grid.add(x, 11, 1); x.setText("X : " + xValue); String yValue = "360.0"; grid.add(y, 11, 2); y.setText("Y : " + yValue); String zValue = "360.0"; grid.add(z, 11, 3); z.setText("Z : " + zValue); String rxValue = "360.0"; grid.add(rx, 11, 4); rx.setText("RX : " + rxValue); String ryValue = "360.0"; grid.add(ry, 11, 5); ry.setText("RY : " + ryValue); String rzValue = "360.0"; grid.add(rz, 11, 6); rz.setText("RZ : " + rzValue); // Scene Scene scene = new Scene(grid, 700, 600); primaryStage.setScene(scene); primaryStage.show(); primaryStage.setOnCloseRequest( new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent event) { client.killClient(); } }); Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA); StyleManager.getInstance() .addUserAgentStylesheet( this.getClass().getResource("/resources/styleSheet.css").toExternalForm()); }
@Override public void start(Stage stage) throws Exception { // ----------MENU---------- MenuBar menuBar = new MenuBar(); Menu menuFile = new Menu("File"); MenuItem menuItemPurchase = new MenuItem("New Purchase"); MenuItem menuItemStore = new MenuItem("New Store"); MenuItem menuItemCategory = new MenuItem("New Category"); MenuItem menuItemExit = new MenuItem("Exit"); menuFile.getItems().addAll(menuItemPurchase, menuItemStore, menuItemCategory, menuItemExit); Menu menuHelp = new Menu("Help"); menuBar.getMenus().addAll(menuFile, menuHelp); // ----------TOOLBAR---------- ToolBar toolBar = new ToolBar(); Button buttonPurchase = new Button(); Button buttonStore = new Button(); Button buttonCategory = new Button(); buttonPurchase.setGraphic(new ImageView("/pictures/purchase.png")); buttonStore.setGraphic(new ImageView("/pictures/store.png")); buttonCategory.setGraphic(new ImageView("/pictures/category.png")); toolBar.getItems().addAll(buttonPurchase, buttonStore, buttonCategory); buttonStore.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent actionEvent) { Stage stage = new Stage(); try { new StoreWindows().start(stage); } catch (Exception e) { e.printStackTrace(); } } }); // ----------WORKSPACE---------- GridPane gridPane = new GridPane(); gridPane.setAlignment(Pos.CENTER); gridPane.setVgap(10); gridPane.setHgap(10); gridPane.setPadding(new Insets(0, 25, 25, 0)); Label storeLabel = new Label("Store: "); storeLabel.setId("simpleLabel"); gridPane.add(storeLabel, 0, 1); final ComboBox<String> stores = new ComboBox<String>(); gridPane.add(stores, 1, 1); Label categoryLabel = new Label("Category: "); categoryLabel.setId("simpleLabel"); gridPane.add(categoryLabel, 2, 1); final ComboBox<String> categories = new ComboBox<String>(); gridPane.add(categories, 3, 1); Button bCount = new Button("Count"); HBox hBox = new HBox(10); hBox.setAlignment(Pos.BOTTOM_RIGHT); hBox.getChildren().add(bCount); gridPane.add(hBox, 4, 1); FlowPane flowPane1 = new FlowPane(); flowPane1.setAlignment(Pos.CENTER); flowPane1.setPadding(new Insets(10, 25, 25, 10)); final Text spentTitle = new Text("SPENT: "); spentTitle.setId("headline"); flowPane1.getChildren().add(spentTitle); // ----------DATABASE---------- Label statusLabel = new Label(); DaoFactory daoFactory = new MySQLDaoFactory(); try { Connection connection = daoFactory.getConnection(); statusLabel.setText("Database connection: success"); StoreDao storeDao = new MySQLStoreDao(connection); ArrayList<Store> storeList = (ArrayList) storeDao.getStores(); for (Store store : storeList) { stores.getItems().add(store.getName()); } CategoryDao categoryDao = new MySQLCategoryDao(connection); ArrayList<Category> categoryList = (ArrayList) categoryDao.getCategories(); for (Category category : categoryList) { categories.getItems().add(category.getTitle()); } } catch (SQLException e) { statusLabel.setText("Database connection: failed"); } FlowPane footer = new FlowPane(); footer.setPadding(new Insets(10, 10, 10, 10)); footer.getChildren().add(statusLabel); bCount.setOnAction( new EventHandler<ActionEvent>() { public void handle(ActionEvent actionEvent) { try { PurchaseDao purchaseDao = new MySQLPurchaseDao(new MySQLDaoFactory().getConnection()); spentTitle.setText( "SPENT: " + purchaseDao.showSpent(stores.getValue(), categories.getValue())); } catch (SQLException e) { e.printStackTrace(); } } }); // ----------VIEW---------- Scene scene = new Scene(new VBox(), 800, 600); scene.getStylesheets().add("css/style.css"); ((VBox) scene.getRoot()).getChildren().addAll(menuBar, toolBar, gridPane, flowPane1, footer); stage.setScene(scene); stage.setTitle("Cash Organizer"); stage.getIcons().add(new Image("pictures/icon.png")); stage.show(); }
public SerieInfo(final Serie serie) { // TODO Auto-generated constructor stub GridPane grid = new GridPane(); FlowPane flow = new FlowPane(Orientation.HORIZONTAL); flow.setAlignment(Pos.TOP_LEFT); flow.setHgap(40); DropShadow dropShadow = new DropShadow(); dropShadow.setOffsetX(10); dropShadow.setOffsetY(10); dropShadow.setColor(Color.rgb(50, 50, 50, 0.7)); Label poster = new Label(); String style_inner = "-fx-font: Gill Sans;" + "-fx-font-family: Gill Sans;" + "-fx-effect: dropshadow(one-pass-box, black, 8, 0, 4, 4);"; poster.setStyle(style_inner); final Label star = new Label(); Image stella = new Image("img/greentick.png", 35, 35, true, true, true); star.setGraphic(new ImageView(stella)); star.setVisible(false); ImageView image = new ImageView(serie.getPoster()); poster.setGraphic(image); TextArea text = new TextArea(); text.setPrefSize(600, 160); text.setText(serie.getOverview()); text.setWrapText(true); text.setEditable(false); /* * text.setStyle("-fx-text-fill: black;"+ "-fx-font: Gill Sans;"+ * "-fx-font-size: 13;" + "-fx-height:400"); */ text.setStyle(LABEL_STYLE); String name = null; if (serie.getNome().length() > 16) { name = serie.getNome().substring(0, 15); name = name.concat("..."); } else { name = serie.getNome(); } Label nome = new Label(name); nome.setTextFill(Color.BLACK); nome.setFont(Font.font("Helvetica", 28)); final Button btn = new Button(" Add "); ImageView imageview = new ImageView(new Image("img/add.png", 12, 12, true, true, true)); btn.setGraphic(imageview); btn.setContentDisplay(ContentDisplay.LEFT); /* * String buttonCss = SerieInfo.class.getResource("CustomButton.css") * .toExternalForm(); btn.getStylesheets().add(buttonCss); */ btn.getStyleClass().add("custom-browse"); btn.setCursor(Cursor.HAND); btn.setTextFill(Color.WHITE); btn.addEventHandler( MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { star.setVisible(true); if (Preferiti.getInstance().addToPreferiti(serie) == false) { /* * new MyDialog(Guiseries2.stage, * Modality.APPLICATION_MODAL, "Warning!", serie); */ } else { btn.setDisable(true); btn.setText(" Added "); btn.setGraphic(null); // torrent... DaemonManager manager = new DaemonManager(); Search search = new Search( serie, manager, "ENG", new SearchListener() { @Override public void SearchListener() { Platform.runLater( new Runnable() { @Override public void run() { boolean compare = false; for (int i = 0; i < serie.getStagioni().size(); i++) { for (int j = 0; j < serie.getStagioni().get(i).getEpisodiStagione().size(); j++) { compare = false; if ((serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent() != null)) { for (int k = (1 + j); k < serie .getStagioni() .get(i) .getEpisodiStagione() .size(); k++) { if (serie .getStagioni() .get(i) .getEpisodiStagione() .get(k) .getTorrent() != null) { if (serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent() .getName() .equals( serie .getStagioni() .get(i) .getEpisodiStagione() .get(k) .getTorrent() .getName())) { compare = true; } } } if (compare == false) { TorrentSeriesElement.getInstance() .addToTorrents( serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent()); if ((TorrentSeriesElement.getInstance() .torrents .indexOf( serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent()) % 2) == 0) { TabDownload.mainDownload .getChildren() .add( TabDownload.addTorrentEvenToDownloadTab( serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent())); } else { TabDownload.mainDownload .getChildren() .add( TabDownload.addTorrentOddToDownloadTab( serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent())); } System.out.println( serie .getStagioni() .get(i) .getEpisodiStagione() .get(j) .getTorrent() .getName()); } } } } try { FilmistaDb.getInstance().addSeriesToFilmistaDb(serie); } catch (ClassNotFoundException e1) { // TODO Auto-generated // catch // block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated // catch // block e1.printStackTrace(); } catch (SQLException e1) { // TODO Auto-generated // catch // block e1.printStackTrace(); } TabPreferiti.updateTab(); } }); } }); } } }); flow.getChildren().add(btn); flow.getChildren().add(nome); if (Preferiti.getInstance().series.contains(serie) == true) { btn.setText(" Added "); btn.setDisable(true); star.setVisible(true); btn.setGraphic(null); } grid.setHgap(25); grid.setVgap(15); grid.add(poster, 0, 0, 1, 2); grid.add(flow, 1, 0); FlowPane paneStar = new FlowPane(Orientation.HORIZONTAL); paneStar.setAlignment(Pos.TOP_RIGHT); paneStar.getChildren().add(star); grid.add(paneStar, 2, 0, 1, 1); grid.add(text, 1, 1, 2, 1); grid.getColumnConstraints().add(0, new ColumnConstraints()); grid.getColumnConstraints().add(1, new ColumnConstraints()); grid.getColumnConstraints().add(2, new ColumnConstraints(150)); // grid.setGridLinesVisible(true); grid.setHgrow(text, Priority.ALWAYS); grid.setVgrow(poster, Priority.ALWAYS); grid.setPadding(new Insets(25, 25, 25, 25)); this.setCenter(grid); String customCss = SerieInfo.class.getResource("CustomBorder.css").toExternalForm(); this.getStylesheets().add(customCss); this.getStyleClass().add("custom-border"); }
@FXML private void employeesButtonClicked(ActionEvent event) { configureButtons(); employeesButton.setGraphic(employeesSelectedIMV); // Clear old content contentPane.getChildren().clear(); titleLabel.setText("Employees"); // 2 horizontal boxes for All Employees and Employees are Customers HBox hbox = new HBox(); hbox.setSpacing(5); // 2 vboxes for each hbox VBox leftBox = new VBox(); VBox rightBox = new VBox(); // Set up All employees ObservableList<Employee> data = FXCollections.observableArrayList(operation.getAllEmployees()); TableView table = new TableView(); // Add title for all employees Text leftTitle = new Text("All Employees"); leftTitle.setFont(new Font("System", 24)); // add left table and title to left box leftBox.getChildren().addAll(leftTitle, table); leftBox.setSpacing(5); TableColumn efnCol = new TableColumn("First Name"); efnCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); TableColumn elnCol = new TableColumn("Last Name"); elnCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); TableColumn epositionCol = new TableColumn("Position"); epositionCol.setCellValueFactory(new PropertyValueFactory<>("position")); TableColumn eemailCol = new TableColumn("Email"); eemailCol.setCellValueFactory(new PropertyValueFactory<>("email")); TableColumn elastworkedCol = new TableColumn("Last Worked"); elastworkedCol.setCellValueFactory(new PropertyValueFactory<>("lastWorked")); table.getColumns().addAll(efnCol, elnCol, epositionCol, eemailCol, elastworkedCol); table.setItems(data); table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY); // Set up for employees and also customers ObservableList<Employee> rightData = FXCollections.observableArrayList(operation.getEmployeesWhoAreCustomers()); TableView rightTable = new TableView(); // Add title for all employees Text rightTitle = new Text("Employees Are Customers"); rightTitle.setFont(new Font("System", 24)); TableColumn RfnCol = new TableColumn("First Name"); RfnCol.setCellValueFactory(new PropertyValueFactory<>("firstName")); TableColumn RlnCol = new TableColumn("Last Name"); RlnCol.setCellValueFactory(new PropertyValueFactory<>("lastName")); TableColumn RpositionCol = new TableColumn("Position"); RpositionCol.setCellValueFactory(new PropertyValueFactory<>("position")); TableColumn RemailCol = new TableColumn("Email"); RemailCol.setCellValueFactory(new PropertyValueFactory<>("email")); TableColumn RlastworkedCol = new TableColumn("Last Worked"); RlastworkedCol.setCellValueFactory(new PropertyValueFactory<>("lastWorked")); rightTable.getColumns().addAll(RfnCol, RlnCol, RpositionCol, RemailCol, RlastworkedCol); rightTable.setItems(rightData); // add right table to the right box rightBox.getChildren().addAll(rightTitle, rightTable); rightBox.setSpacing(5); hbox.getChildren().addAll(leftBox, rightBox); hbox.setSpacing(10); hbox.setAlignment(Pos.CENTER); // add hbox to content pane contentPane.getChildren().add(hbox); }
/* * Function that creates a play button, adds the relevant event handlers for it, * and adds it to the appropiate media control bar. Done for both normal view mode * and fullscreen mode. */ void setPlayButton() { // Create a play button. playButton = new Button(); playButton.setGraphic(new ImageView(playImage)); playButton.setOnAction( new EventHandler<ActionEvent>() { // ActionHandler for play button. public void handle(ActionEvent e) { updateValues(); Status status = mp.getStatus(); // Check for bad status's. if (status == Status.UNKNOWN || status == Status.HALTED) { System.out.println("Player is in a bad or unknown state, can't play."); return; } // Check for accepted status's. if (status == Status.PAUSED || status == Status.READY || status == Status.STOPPED) { // Rewind the video if it's at the end if (atEndOfMedia) { mp.seek(mp.getStartTime()); atEndOfMedia = false; playButton.setGraphic(new ImageView(playImage)); updateValues(); } // Set video to play again and set pause image for button mp.play(); playButton.setGraphic(new ImageView(pauseImage)); } else { // Pause the media and set play image for button mp.pause(); playButton.setGraphic(new ImageView(playImage)); } } }); // Play/Pause Button in fullscreen mode playButtonFS = new Button(); playButtonFS.setGraphic(new ImageView(playImage)); playButtonFS.setOnAction( new EventHandler<ActionEvent>() { // ActionHandler for play button in fullscreen mode. public void handle(ActionEvent e) { updateValues(); Status status = mp.getStatus(); // Check for bad status's if (status == Status.UNKNOWN || status == Status.HALTED) { System.out.println("Player is in a bad or unknown state, can't play."); return; } // Check for acceptable status's if (status == Status.PAUSED || status == Status.READY || status == Status.STOPPED) { // rewind the movie if we're sitting at the end if (atEndOfMedia) { mp.seek(mp.getStartTime()); atEndOfMedia = false; playButtonFS.setGraphic(new ImageView(playImage)); updateValues(); } // Set video to play again and set pause image for button mp.play(); playButtonFS.setGraphic(new ImageView(pauseImage)); } else { // Pause the media and set play image for button mp.pause(); playButtonFS.setGraphic(new ImageView(playImage)); } } }); // Whenever there's a change in duration of the MediaPlayer, update the Time Label and Slider // Position mp.currentTimeProperty() .addListener( new ChangeListener<Duration>() { @Override public void changed( ObservableValue<? extends Duration> observableValue, Duration duration, Duration current) { updateValues(); } }); // Media is playing so set appropiate playButton image mp.setOnPlaying( new Runnable() { public void run() { if (stopRequested) { // If a media stop has been requested in the meantime, pause the media. mp.pause(); stopRequested = false; } else { // Otherwise set the pause image for the "play" button playButton.setGraphic(new ImageView(pauseImage)); playButtonFS.setGraphic(new ImageView(pauseImage)); } } }); // Media is paused so set appropiate playButton image mp.setOnPaused( new Runnable() { public void run() { // Set the play image for the "play" button playButton.setGraphic(new ImageView(playImage)); playButtonFS.setGraphic(new ImageView(playImage)); } }); // Media is stopped so set appropiate playButton image mp.setOnStopped( new Runnable() { public void run() { // Media has stopped so display the play image for the "play" button mp.setStopTime(Duration.INDEFINITE); atEndOfMedia = true; playButton.setGraphic(new ImageView(playImage)); playButtonFS.setGraphic(new ImageView(playImage)); } }); // Media is ready so get the total duration of the Media and update the Time Label mp.setOnReady( new Runnable() { public void run() { duration = mp.getMedia().getDuration(); updateValues(); } }); // Media has finished playing so set appropiate playButton image & handle loops mp.setOnEndOfMedia( new Runnable() { public void run() { if (!mpLoop) { // If loop not set then stop media and display play image for "play" button playButton.setGraphic(new ImageView(playImage)); playButtonFS.setGraphic(new ImageView(playImage)); atEndOfMedia = true; mp.stop(); } // Otherwise go back to the requested start time of the media mp.seek(mp.getStartTime()); } }); // Media is repeating so set appropiate playButton image mp.setOnRepeat( new Runnable() { public void run() { // Display the pause image for the "play" button atEndOfMedia = false; playButton.setGraphic(new ImageView(pauseImage)); playButtonFS.setGraphic(new ImageView(pauseImage)); } }); // Add the play button to the MediaControl bar. mediaBar.getChildren().add(playButton); }
/* * Function that creates a fullscreen button, adds the relevant event handlers, and * adds it to the MediaControl bar. Also handles nice fade transitions when the mouse * is moved/clicked. */ void setFullScreenButton() { // Create a fullscreen button Button fullscreenButton = new Button(); fullscreenButton.setGraphic(new ImageView(fullscreenImage)); // Create a new stage for the fullscreen mode stageFS = new Stage(); fullscreenButton.setOnAction( new EventHandler<ActionEvent>() { // ActionHandler for play button. public void handle(ActionEvent e) { // Hide the current MediaView object mediaView.setVisible(false); // Create a new group in the active window Node source = (Node) e.getSource(); stage = (Stage) source.getScene().getWindow(); final Group root = new Group(); // Create a new MediaView based on the same Media settings MediaView mediaViewFS = new MediaView(mp); mediaViewFS.setFitWidth(bounds.getWidth()); mediaViewFS.setPreserveRatio(true); mediaViewFS.setLayoutY((bounds.getHeight() - mediaViewFS.getFitHeight()) / 7); // Add the new MediaView to the new group root.getChildren().add(mediaViewFS); // Add the Play button for fullscreen and the Slider bar root.getChildren().add(fullscreenMediaBar); // Create a new scene for fullscreen mode final Scene scene = new Scene(root, bounds.getWidth(), bounds.getHeight(), Color.BLACK); // Set up the stage for fullscreen mode stageFS.setScene(scene); stageFS.setFullScreen(true); stageFS.show(); // Toggle Play and Pause when the user click on the window root.setOnMouseClicked( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { if (mp.getStatus() == Status.PLAYING) { // If already playing pause the video mp.pause(); } else { // If already paused play the video mp.play(); } } }); // Animation for the Control Panel in fullscreen mode fadeTransition = new FadeTransition(Duration.millis(3000), fullscreenMediaBar); fadeTransition.setFromValue(1.0); fadeTransition.setToValue(0.0); // Play the fade transition if the mouse is moved on the screen & show control bar scene.setOnMouseMoved( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { fullscreenMediaBar.setDisable(false); scene.setCursor(Cursor.DEFAULT); fadeTransition.play(); } }); // Hide the control bar when fade transition finishes fadeTransition.setOnFinished( new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { fullscreenMediaBar.setDisable(true); scene.setCursor(Cursor.NONE); } }); // If the mouse moves into the control bar stop the fade transition fullscreenMediaBar.setOnMouseEntered( new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent mouseEvent) { fadeTransition.stop(); } }); // Exit Fullscreen mode and return to the main Window is ESC key pressed stageFS.addEventFilter( KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { @Override public void handle(KeyEvent event) { // Check for ESC key only! if (event.getCode() == KeyCode.ESCAPE) { // Close fullscreen mode and return to previous view stageFS.close(); mediaView.setVisible(true); stage.setFullScreen(true); stage.getScene().setCursor(Cursor.HAND); stage.show(); } } }); } }); // Add the full screen button to the MediaControl bar mediaBar.getChildren().add(fullscreenButton); }
@FXML private void ratingButtonClicked(ActionEvent event) throws SQLException { configureButtons(); ratingButton.setGraphic(ratingSelectedIMV); // clear old content contentPane.getChildren().clear(); // set up titleLabel.setText("Rating and Feedback"); // rating box HBox ratingBox = new HBox(); ratingBox.setAlignment(Pos.CENTER); ratingBox.setSpacing(20); ratingBox.setPadding(new Insets(10, 0, 10, 0)); // Rating label Label ratingTitle = new Label("Average Rating: "); ratingTitle.setFont(new Font("System", 24)); // 5 stars String yellowStarURL = "Graphics/StarYellow.png"; String blankStarURL = "Graphics/StarBlank.png"; ImageView starBlank1 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); ImageView starBlank2 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); ImageView starBlank3 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); ImageView starBlank4 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); ImageView starBlank5 = new ImageView(new Image(getClass().getResourceAsStream("Graphics/StarBlank.png"))); Button star1 = new Button(); star1.setGraphic(starBlank1); star1.setStyle("-fx-background-color: transparent"); Button star2 = new Button(); star2.setGraphic(starBlank2); star2.setStyle("-fx-background-color: transparent"); Button star3 = new Button(); star3.setGraphic(starBlank3); star3.setStyle("-fx-background-color: transparent"); Button star4 = new Button(); star4.setGraphic(starBlank4); star4.setStyle("-fx-background-color: transparent"); Button star5 = new Button(); star5.setGraphic(starBlank5); star5.setStyle("-fx-background-color: transparent"); // get average rating double avgRating = 0; try { avgRating = operation.getAverageRating(); } catch (SQLException e) { e.printStackTrace(); ratingTitle.setText("Error! Can't get average rating"); } Button[] buttonlist = new Button[5]; buttonlist[0] = star1; buttonlist[1] = star2; buttonlist[2] = star3; buttonlist[3] = star4; buttonlist[4] = star5; for (int i = 0; i < Math.floor(avgRating); i++) { ImageView image = new ImageView(new Image(getClass().getResourceAsStream(yellowStarURL))); buttonlist[i].setGraphic(image); } // feedback box VBox feedBackBox = new VBox(); feedBackBox.setAlignment(Pos.CENTER); feedBackBox.setSpacing(20); // Feedback title Label feedBackLabel = new Label("Feedback:"); feedBackLabel.setFont(new Font("System", 24)); // get feedback string String feedback = ""; ArrayList<Rating> list = operation.getRatingsAndFeedbacks(); for (Rating r : list) { feedback += r.getFeedback() + "\n\n"; } Text feedbackText = new Text(feedback); feedbackText.setFont(new Font("System", 14)); ScrollPane scrollPane = new ScrollPane(); scrollPane.setContent(feedbackText); // Add children nodes to appropriate boxes ratingBox.getChildren().addAll(ratingTitle, star1, star2, star3, star4, star5); feedBackBox.getChildren().addAll(feedBackLabel, scrollPane); // main box VBox mainBox = new VBox(); mainBox.setSpacing(40); mainBox.getChildren().addAll(ratingBox, feedBackBox); contentPane.getChildren().add(mainBox); }
@FXML void playTrack(Track t) { if (tweenBlock) return; tweenBlock = true; stop( () -> { currentPlaylist = (Playlist) playlistsView.getSelectionModel().getSelectedItem(); currentTrack = t; if (player != null) { player.dispose(); } if (t == null) { return; } timeUpdate = 9; if (currentPlaylist != null) { Tray.announce("[" + currentPlaylist.getTitle() + "] " + t.getTitle()); } Platform.runLater( () -> { infoLabel.setText(res.getString("playing_offline") + t.getTitle()); log.info("Playing offline: " + t.getTitle()); }); try { Media media = new Media(Cache.getContent(t).toURI().toString()); player = new MediaPlayer(media); player.setVolume(Settings.currentVolume); player.play(); } catch (MediaException ex) { Platform.runLater( () -> { infoLabel.setText( String.format(res.getString("cant_play_offline_not_exist"), t.getTitle())); log.error("Can't play: seems that track does not exist - " + t.getTitle()); }); } if (player != null) { pushToPlayStack(getSelectedPlaylist(), t); player.setOnEndOfMedia( () -> { String mode = Settings.currentMode; if (mode.equals(Settings.MODE_NEXT)) { playNext(); } else if (mode.equals(Settings.MODE_RANDOM)) { playRandom(); } else if (mode.equals(Settings.MODE_SAME)) { playSame(); } }); } Platform.runLater( () -> { isPlaying = true; tweenBlock = false; titleLabel.setText(t.getTitle()); stateButton.setGraphic(imagePause); }); }); }
private void setImage(Button play, String pathToImage) { Image icon = new Image(getClass().getResourceAsStream(pathToImage)); play.setGraphic(new ImageView(icon)); }
private Button createCommandLinksButton(ButtonType buttonType) { // look up the CommandLinkButtonType for the given ButtonType CommandLinksButtonType commandLink = typeMap.getOrDefault(buttonType, new CommandLinksButtonType(buttonType)); // put the content inside a button final Button button = new Button(); button.getStyleClass().addAll("command-link-button"); // $NON-NLS-1$ button.setMaxHeight(Double.MAX_VALUE); button.setMaxWidth(Double.MAX_VALUE); button.setAlignment(Pos.CENTER_LEFT); final ButtonData buttonData = buttonType.getButtonData(); button.setDefaultButton(buttonData != null && buttonData.isDefaultButton()); button.setOnAction(ae -> setResult(buttonType)); final Label titleLabel = new Label(commandLink.getButtonType().getText()); titleLabel .minWidthProperty() .bind( new DoubleBinding() { { bind(titleLabel.prefWidthProperty()); } @Override protected double computeValue() { return titleLabel.getPrefWidth() + 400; } }); titleLabel.getStyleClass().addAll("line-1"); // $NON-NLS-1$ titleLabel.setWrapText(true); titleLabel.setAlignment(Pos.TOP_LEFT); GridPane.setVgrow(titleLabel, Priority.NEVER); Label messageLabel = new Label(commandLink.getLongText()); messageLabel.getStyleClass().addAll("line-2"); // $NON-NLS-1$ messageLabel.setWrapText(true); messageLabel.setAlignment(Pos.TOP_LEFT); messageLabel.setMaxHeight(Double.MAX_VALUE); GridPane.setVgrow(messageLabel, Priority.SOMETIMES); Node commandLinkImage = commandLink.getGraphic(); Node view = commandLinkImage == null ? new ImageView( CommandLinksDialog.class.getResource("arrow-green-right.png").toExternalForm()) : //$NON-NLS-1$ commandLinkImage; Pane graphicContainer = new Pane(view); graphicContainer.getStyleClass().add("graphic-container"); // $NON-NLS-1$ GridPane.setValignment(graphicContainer, VPos.TOP); GridPane.setMargin(graphicContainer, new Insets(0, 10, 0, 0)); GridPane grid = new GridPane(); grid.minWidthProperty().bind(titleLabel.prefWidthProperty()); grid.setMaxHeight(Double.MAX_VALUE); grid.setMaxWidth(Double.MAX_VALUE); grid.getStyleClass().add("container"); // $NON-NLS-1$ grid.add(graphicContainer, 0, 0, 1, 2); grid.add(titleLabel, 1, 0); grid.add(messageLabel, 1, 1); button.setGraphic(grid); button.minWidthProperty().bind(titleLabel.prefWidthProperty()); if (commandLink.isHidden) { button.setVisible(false); button.setPrefHeight(1); } return button; }
@Override public void initialize(URL location, ResourceBundle resources) { AppController.instance = this; this.res = resources; ObservableList<String> modeItems = FXCollections.observableArrayList( Settings.MODE_NEXT, Settings.MODE_RANDOM, Settings.MODE_SAME); modeList.setItems(modeItems); modeList.getSelectionModel().select(Settings.currentMode); modeList .valueProperty() .addListener( (ObservableValue ov, Object oldVal, Object newVal) -> { Settings.currentMode = (String) newVal; }); setupPlaylistsView(); setupPlaylistsContextMenu(); setupTracksView(); tracksView.setContextMenu(tracksContextMenu); tracksView.setOnContextMenuRequested( (ContextMenuEvent evt) -> { setupTracksContextMenu(); evt.consume(); }); tracksView .getSelectionModel() .selectedItemProperty() .addListener( (ObservableValue observable, Object oldValue, Object newValue) -> { Settings.lastTrackId = newValue != null ? ((Track) newValue).getId() : null; }); playlistsView .getSelectionModel() .selectedItemProperty() .addListener( (ObservableValue observable, Object oldValue, Object newValue) -> { loadSelectedPlaylist(); Settings.lastPlaylistId = newValue != null ? ((Playlist) newValue).getId() : null; searching = false; searchText.setText(StringUtils.EMPTY); }); volumeSlider.setCursor(Cursor.HAND); volumeSlider .valueProperty() .addListener( (ObservableValue<? extends Number> ov, Number oldVal, Number newVal) -> { if (player != null) { player.setVolume(newVal.doubleValue()); } Settings.currentVolume = newVal.doubleValue(); volumeLabel.setText( String.valueOf((int) Math.ceil(newVal.doubleValue() * 100)) + "%"); }); volumeSlider.setValue(Settings.currentVolume); imagePlay = new ImageView(new Image(getClass().getResourceAsStream("/images/button_play.png"))); imagePlay.setScaleX(0.40); imagePlay.setScaleY(0.40); imagePause = new ImageView(new Image(getClass().getResourceAsStream("/images/button_pause.png"))); imagePause.setScaleX(0.5); imagePause.setScaleY(0.5); imageSettings = new ImageView(new Image(getClass().getResourceAsStream("/images/settings.png"))); imageSettings.setScaleX(0.5); imageSettings.setScaleY(0.5); imageUpdate = new ImageView(new Image(getClass().getResourceAsStream("/images/refresh.png"))); imageUpdate.setScaleX(0.5); imageUpdate.setScaleY(0.5); imageAdd = new ImageView(new Image(getClass().getResourceAsStream("/images/add.png"))); imageAdd.setScaleX(0.5); imageAdd.setScaleY(0.5); imageRename = new ImageView(new Image(getClass().getResourceAsStream("/images/rename.png"))); imageRename.setScaleX(0.5); imageRename.setScaleY(0.5); imageDelete = new ImageView(new Image(getClass().getResourceAsStream("/images/delete.png"))); imageDelete.setScaleX(0.5); imageDelete.setScaleY(0.5); stateButton.setGraphic(imagePlay); settingsButton.setGraphic(imageSettings); refreshButton.setGraphic(imageUpdate); refreshButton.setTooltip(new Tooltip(res.getString("tooltip_sync"))); addButton.setGraphic(imageAdd); addButton.setOnAction((evt) -> createOfflinePlaylist()); addButton.setTooltip(new Tooltip(res.getString("tooltip_add_offline"))); renameButton.setGraphic(imageRename); renameButton.setOnAction(evt -> renamePlaylist()); renameButton.setTooltip(new Tooltip(res.getString("rename_playlist"))); deleteButton.setGraphic(imageDelete); deleteButton.setOnAction(evt -> deletePlaylist()); deleteButton.setTooltip(new Tooltip(res.getString("delete_playlist"))); loadProgressBar.setCursor(Cursor.HAND); volumeSlider.setCursor(Cursor.HAND); updatePlaylists(); if (Settings.lastPlaylistId != null) { currentPlaylist = ((ObservableList<Playlist>) playlistsView.getItems()) .stream() .filter((playlist) -> playlist.getId().equals(Settings.lastPlaylistId)) .findFirst() .orElse(null); playlistsView.getSelectionModel().select(currentPlaylist); playlistsView.scrollTo(currentPlaylist); Platform.runLater( () -> { if (Settings.lastTrackId != null) { currentTrack = ((ObservableList<Track>) tracksView.getItems()) .stream() .filter((track) -> track.getId().equals(Settings.lastTrackId)) .findFirst() .orElse(null); tracksView.getSelectionModel().select(currentTrack); tracksView.scrollTo(currentTrack); } }); } new Timer() .scheduleAtFixedRate( new TimerTask() { @Override public void run() { updatePlayProgress(); } }, 100, 100); setupTracksContextMenu(); setupShortcuts(); Platform.runLater( () -> { tracksView.requestFocus(); }); }
/** Constructs the profile grid pane */ private ProfileSettings() { // Setting the style sheet this.getStylesheets() .add(this.getClass().getResource("css/profile_settings.css").toExternalForm()); this.getStyleClass().add("grid"); // Library Settings musicLibrarySettings_Label = new Label("Music Library"); musicLibrarySettings_Label.setId("LabelBig"); musicLibraryPath_Label = new Label("Path to Library:"); musicLibraryPath_Label.setId("LabelSmall"); orderingMode_Label = new Label("Ordering Mode:"); musicLibraryPath = new TextField(""); musicLibraryPath.setEditable(false); orderingMode_Label = new Label("Ordering Mode"); orderingMode_Label.setId("LabelSmall"); orderingMode = new ChoiceBox<String>(); orderingMode.setItems(FXCollections.observableArrayList(AAA, AA, GAA)); chooseDirToMusicLibrary = new Button(); chooseDirToMusicLibrary.setId("OpenFolderButton"); chooseDirToMusicLibrary.setGraphic( new ImageView(PropertiesUtils.getProperty(IconProperties.OPEN_FOLDER_IMPORT))); chooseDirToMusicLibrary.setOnAction(getButtonSetLibraryEventHandler()); CenterGridPane.setConstraints(musicLibrarySettings_Label, 0, 0, 3, 1); CenterGridPane.setConstraints(musicLibraryPath_Label, 0, 1, 1, 1); CenterGridPane.setConstraints(musicLibraryPath, 1, 1, 1, 1); CenterGridPane.setConstraints(chooseDirToMusicLibrary, 2, 1, 1, 1); CenterGridPane.setConstraints(orderingMode_Label, 0, 2, 1, 1); CenterGridPane.setConstraints(orderingMode, 1, 2, 3, 1); // Import Settings importSettings_Label = new Label("Import Settings"); importSettings_Label.setId("LabelBig"); keepFiles_Label = new Label("Keep original files:"); keepFiles_Label.setId("LabelSmall"); keepFiles = new RadioButton(); justTagFiles_Label = new Label("Just tag files:"); justTagFiles_Label.setId("LabelSmall"); justTagFiles = new RadioButton(); CenterGridPane.setConstraints(importSettings_Label, 0, 4, 3, 1); CenterGridPane.setConstraints(keepFiles_Label, 0, 5, 1, 1); CenterGridPane.setConstraints(keepFiles, 1, 5, 1, 1); CenterGridPane.setConstraints(justTagFiles_Label, 0, 6, 1, 1); CenterGridPane.setConstraints(justTagFiles, 1, 6, 1, 1); // Playlist export settings playlistSettings_Label = new Label("Playlist Export Settings"); playlistSettings_Label.setId("LabelBig"); playListExport_Label = new Label("Playlist Export"); playListExport_Label.setId("LabelSmall"); playListExport = new RadioButton(); playListName_Label = new Label("Playlist-Name:"); playListName_Label.setId("LabelSmall"); playListName = new TextField(); playListExportPath_Label = new Label("Export Directory"); playListExportPath_Label.setId("LabelSmall"); playListExportPath = new TextField(""); playListExportPath.setEditable(false); chooseDirToExportPlayList = new Button(); chooseDirToExportPlayList.setId("OpenFolderButton"); chooseDirToExportPlayList.setGraphic( new ImageView(PropertiesUtils.getProperty(IconProperties.OPEN_FOLDER_IMPORT))); chooseDirToExportPlayList.setOnAction(getButtonSetPlayListDirEventHandler()); playListHeader = new Label("Playlist Header-Language"); playListHeaderMode = new ChoiceBox<String>(); playListHeaderMode.setItems(FXCollections.observableArrayList(germanHeader, englishHeader)); CenterGridPane.setConstraints(playlistSettings_Label, 0, 8, 3, 1); CenterGridPane.setConstraints(playListExport_Label, 0, 9, 1, 1); CenterGridPane.setConstraints(playListExport, 1, 9, 1, 1); CenterGridPane.setConstraints(playListName_Label, 0, 10, 1, 1); CenterGridPane.setConstraints(playListName, 1, 10, 1, 1); CenterGridPane.setConstraints(playListExportPath_Label, 0, 11, 1, 1); CenterGridPane.setConstraints(playListExportPath, 1, 11, 1, 1); CenterGridPane.setConstraints(chooseDirToExportPlayList, 2, 11, 1, 1); CenterGridPane.setConstraints(playListHeader, 0, 12, 1, 1); CenterGridPane.setConstraints(playListHeaderMode, 1, 12, 1, 1); /** Restore and apply button */ applyButton = new Button("Apply"); applyButton.setOnAction(getButtonApplyEventHandler()); restoreButton = new Button("Restore"); restoreButton.setOnAction(getButtonRestoreEventHandler()); CenterGridPane.setConstraints(restoreButton, 1, 13, 1, 1, HPos.RIGHT, VPos.CENTER); CenterGridPane.setConstraints(applyButton, 2, 13, 1, 1); this.getChildren() .addAll( musicLibrarySettings_Label, musicLibraryPath_Label, musicLibraryPath, chooseDirToMusicLibrary, orderingMode_Label, orderingMode, importSettings_Label, keepFiles_Label, keepFiles, justTagFiles_Label, justTagFiles, playlistSettings_Label, playListExport_Label, playListExport, playListName_Label, playListName, playListExportPath_Label, playListExportPath, chooseDirToExportPlayList, restoreButton, applyButton, playListHeader, playListHeaderMode); /** Reading the properties and adding them to the pane */ readProperties(); }