Search in sources :

Example 21 with Label

use of javafx.scene.control.Label in project SmartCity-Market by TechnionYP5777.

the class CustomerProductCellFormat method updateItem.

@Override
public void updateItem(CartProduct item, boolean empty) {
    super.updateItem(item, empty);
    if (item == null || empty) {
        setGraphic(null);
        setText(null);
        return;
    }
    HBox hbx = new HBox(280);
    // spacing = 5
    VBox vbx = new VBox(5);
    //vbox
    Label productName = new Label("Name: " + item.getCatalogProduct().getName());
    productName.getStyleClass().add("thisListLabel");
    //productName.setFont(new Font(20));
    Label productAmount = new Label("Amount: " + item.getTotalAmount());
    productAmount.getStyleClass().add("thisListLabel");
    //productAmount.setFont(new Font(20));
    Label productPrice = new Label("Price: " + Double.valueOf(item.getCatalogProduct().getPrice()) + " nis");
    productPrice.getStyleClass().add("thisListLabel");
    //productPrice.setFont(new Font(20));
    vbx.getChildren().addAll(productName, productAmount, productPrice);
    vbx.setAlignment(Pos.CENTER_LEFT);
    //image
    long itemBarcode = item.getCatalogProduct().getBarcode();
    URL imageUrl = null;
    try {
        imageUrl = new File("../Common/src/main/resources/ProductsPictures/" + itemBarcode + ".jpg").toURI().toURL();
    } catch (MalformedURLException e) {
        throw new RuntimeException();
    }
    Image image = new Image(imageUrl + "", 100, 100, true, false);
    ImageView productImage = new ImageView(image);
    hbx.setSpacing(230);
    hbx.getChildren().addAll(vbx, productImage);
    setGraphic(hbx);
}
Also used : HBox(javafx.scene.layout.HBox) MalformedURLException(java.net.MalformedURLException) Label(javafx.scene.control.Label) ImageView(javafx.scene.image.ImageView) Image(javafx.scene.image.Image) VBox(javafx.scene.layout.VBox) File(java.io.File) URL(java.net.URL)

Example 22 with Label

use of javafx.scene.control.Label in project Media-Library by The-Rain-Goddess.

the class ApplicationWindow method setDataTableClickEvents.

private void setDataTableClickEvents() {
    dataTable.setRowFactory(tv -> {
        TableRow<MediaFile> row = new TableRow<>();
        row.setOnMouseClicked(event -> {
            try {
                if (event.getButton() == MouseButton.SECONDARY) {
                    ContextMenu cMenu = new ContextMenu();
                    MenuItem remove = new MenuItem("Remove");
                    remove.setOnAction((ActionEvent ev) -> {
                        Main.getMasterData().remove(row.getItem().getUUID());
                        updateDataTable();
                        updateFileSystem();
                    });
                    cMenu.getItems().add(remove);
                    row.setOnContextMenuRequested(e -> cMenu.show(row, event.getScreenX(), event.getScreenY()));
                } else {
                    if (event.getClickCount() == 1) {
                        System.out.println("Clicked");
                        System.out.println(row.getItem());
                    } else if (event.getClickCount() == 2) {
                        System.out.println("Playing: \n" + row.getItem());
                        File mediaFile = new File(row.getItem().getLibraryFilePath());
                        Media mediaToPlay = new Media(mediaFile.toURI().toString());
                        artistLabel.setText(row.getItem().getArtistName() + " - " + row.getItem().getAlbumName());
                        songLabel.setText(row.getItem().getSongName());
                        player.stop();
                        player = new MediaPlayer(mediaToPlay);
                        player.setAutoPlay(true);
                        updatePlayer();
                    }
                }
            } catch (MediaException e) {
                Stage errorWindow = new Stage();
                VBox componentLayout = new VBox();
                Label errorLabel = new Label(e.getMessage());
                VBox.setMargin(errorLabel, new Insets(10, 10, 10, 10));
                componentLayout.getChildren().addAll(errorLabel);
                Scene scene = new Scene(componentLayout);
                errorWindow.setScene(scene);
                errorWindow.show();
            }
        });
        return row;
    });
}
Also used : MediaFile(com.negativevr.media_library.files.MediaFile) Insets(javafx.geometry.Insets) MediaException(javafx.scene.media.MediaException) ActionEvent(javafx.event.ActionEvent) Media(javafx.scene.media.Media) Label(javafx.scene.control.Label) ContextMenu(javafx.scene.control.ContextMenu) MenuItem(javafx.scene.control.MenuItem) Scene(javafx.scene.Scene) TableRow(javafx.scene.control.TableRow) Stage(javafx.stage.Stage) MediaFile(com.negativevr.media_library.files.MediaFile) File(java.io.File) VBox(javafx.scene.layout.VBox) MediaPlayer(javafx.scene.media.MediaPlayer)

Example 23 with Label

use of javafx.scene.control.Label in project Media-Library by The-Rain-Goddess.

the class ApplicationWindow method setupMediaPlayer.

//private Media Player accessors / mutators
private HBox setupMediaPlayer() {
    HBox mediaSlot = new HBox();
    VBox timeControls = new VBox();
    VBox timeBox = new VBox();
    HBox mediaControlBox = new HBox();
    HBox searchBox = new HBox();
    HBox fadeBox = new HBox(5);
    VBox volumeControls = new VBox(10);
    if (Main.getMasterDataAsList().size() != 0) {
        Path path = Paths.get(Main.getMasterDataAsList().get(0).getLibraryFilePath());
        Media media = new Media(path.toFile().toURI().toString());
        player = new MediaPlayer(media);
    } else {
    //player = new MediaPlayer(new Media(Paths.get("src/com/negativevr/media_library/res/init.mp3").toFile().toURI().toString()));
    }
    //player.setAutoPlay(true);
    MediaView mediaView = new MediaView();
    mediaView.setMediaPlayer(player);
    Image PlayButtonImage = new Image("com/negativevr/media_library/res/play.png");
    Image PauseButtonImage = new Image("com/negativevr/media_library/res/pause.png");
    ImageView imageViewPlay = new ImageView(PlayButtonImage);
    ImageView imageViewPause = new ImageView(PauseButtonImage);
    play = new Button();
    play.setGraphic(imageViewPlay);
    play.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent e) {
            updateValues();
            Status status = player.getStatus();
            if (status == Status.PAUSED || status == Status.READY || status == Status.UNKNOWN || status == Status.STOPPED) {
                player.play();
                play.setGraphic(imageViewPause);
            } else {
                player.pause();
                play.setGraphic(imageViewPlay);
            }
        }
    });
    reload = new Button();
    reload.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/reload.png")));
    reload.setOnAction((ActionEvent e) -> {
        player.seek(player.getStartTime());
    });
    skip = new Button();
    skip.setGraphic((new ImageView(new Image("com/negativevr/media_library/res/skip.png"))));
    skip.setOnAction((ActionEvent e) -> {
        player.seek(player.getStopTime());
    });
    previous = new Button();
    previous.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/previous.png")));
    next = new Button();
    next.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/next.png")));
    Button repeat = new Button();
    if (status == MediaStatus.REPEAT_NONE)
        repeat.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/repeat_none.png")));
    else if (status == MediaStatus.REPEAT_SINGLE)
        repeat.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/repeat_single.png")));
    repeat.setOnAction((ActionEvent e) -> {
        if (status == MediaStatus.REPEAT_SINGLE) {
            status = MediaStatus.REPEAT_NONE;
            repeat.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/repeat_none.png")));
        } else if (status == MediaStatus.REPEAT_NONE) {
            status = MediaStatus.REPEAT_SINGLE;
            repeat.setGraphic(new ImageView(new Image("com/negativevr/media_library/res/repeat_single.png")));
        }
    });
    timeSlider = new Slider();
    HBox.setHgrow(timeSlider, Priority.ALWAYS);
    timeSlider.setMinSize(100, 50);
    timeSlider.valueProperty().addListener(new InvalidationListener() {

        @Override
        public void invalidated(Observable ov) {
            if (timeSlider.isValueChanging()) {
                Duration duration = player.getMedia().getDuration();
                if (duration != null) {
                    player.seek(duration.multiply(timeSlider.getValue() / 100.0));
                }
                updateValues();
            }
        }
    });
    List<MediaFile> data = Main.getMasterDataAsList();
    if (data.size() != 0) {
        artistLabel = new Label(data.get(0).getArtistName() + " - " + data.get(0).getAlbumName());
        songLabel = new Label(data.get(0).getSongName());
    } else {
        artistLabel = new Label();
        songLabel = new Label();
    }
    player.currentTimeProperty().addListener(new InvalidationListener() {

        @Override
        public void invalidated(Observable ov) {
            updateValues();
        }
    });
    player.currentTimeProperty().addListener(new ChangeListener<Duration>() {

        @Override
        public void changed(ObservableValue<? extends Duration> arg0, Duration arg1, Duration arg2) {
            updateValues();
        }
    });
    time = new Label();
    time.setTextFill(Color.BLACK);
    player.setOnReady(() -> {
        duration = player.getMedia().getDuration();
        updateValues();
    });
    //volume control slider
    volumeSlider = new Slider(0, 1, 0);
    player.volumeProperty().bindBidirectional(volumeSlider.valueProperty());
    player.setVolume(0.5);
    //fade in time line
    final Timeline fadeInTimeline = new Timeline(new KeyFrame(FADE_DURATION, new KeyValue(player.volumeProperty(), 1.0)));
    //fade out timeline
    final Timeline fadeOutTimeline = new Timeline(new KeyFrame(FADE_DURATION, new KeyValue(player.volumeProperty(), 0.0)));
    //fade in button
    fadeIn = new Button("Fade In");
    fadeIn.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            fadeInTimeline.play();
        }
    });
    fadeIn.setMaxWidth(Double.MAX_VALUE);
    //fade out button
    fadeOut = new Button("Fade Out");
    fadeOut.setOnAction(new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent t) {
            fadeOutTimeline.play();
        }
    });
    fadeOut.setMaxWidth(Double.MAX_VALUE);
    player.setOnEndOfMedia(() -> {
        play.setGraphic(imageViewPlay);
        if (status == MediaStatus.REPEAT_NONE) {
            player.seek(new Duration(0));
            player.pause();
            play.setGraphic(imageViewPlay);
        } else if (status == MediaStatus.REPEAT_SINGLE) {
            player.seek(new Duration(0));
            player.play();
            play.setGraphic(imageViewPause);
        }
    });
    //volume cotrol box
    fadeBox.getChildren().addAll(fadeOut, fadeIn);
    fadeBox.setAlignment(Pos.CENTER);
    volumeControls.getChildren().setAll(new Label("Volume"), volumeSlider, fadeBox);
    volumeControls.setAlignment(Pos.CENTER);
    volumeControls.disableProperty().bind(Bindings.or(Bindings.equal(Timeline.Status.RUNNING, fadeInTimeline.statusProperty()), Bindings.equal(Timeline.Status.RUNNING, fadeOutTimeline.statusProperty())));
    timeControls.getChildren().addAll(songLabel, artistLabel, timeSlider);
    timeControls.setAlignment(Pos.CENTER);
    timeControls.setFillWidth(true);
    timeControls.setMinWidth(300);
    timeBox.getChildren().addAll(repeat, time);
    timeBox.setAlignment(Pos.CENTER);
    mediaControlBox.getChildren().addAll(previous, reload, play, skip, next);
    mediaControlBox.setAlignment(Pos.CENTER);
    searchBox.getChildren().addAll(new Label("Search"), search);
    searchBox.setAlignment(Pos.CENTER_RIGHT);
    mediaSlot.getChildren().addAll(mediaControlBox, timeBox, timeControls, volumeControls, mediaView, searchBox);
    mediaSlot.setSpacing(10);
    HBox.setHgrow(timeControls, Priority.ALWAYS);
    return mediaSlot;
}
Also used : HBox(javafx.scene.layout.HBox) KeyValue(javafx.animation.KeyValue) Slider(javafx.scene.control.Slider) ActionEvent(javafx.event.ActionEvent) Label(javafx.scene.control.Label) Image(javafx.scene.image.Image) MediaView(javafx.scene.media.MediaView) Button(javafx.scene.control.Button) MouseButton(javafx.scene.input.MouseButton) ImageView(javafx.scene.image.ImageView) Path(java.nio.file.Path) Status(javafx.scene.media.MediaPlayer.Status) MediaFile(com.negativevr.media_library.files.MediaFile) Media(javafx.scene.media.Media) Duration(javafx.util.Duration) Observable(javafx.beans.Observable) Timeline(javafx.animation.Timeline) InvalidationListener(javafx.beans.InvalidationListener) KeyFrame(javafx.animation.KeyFrame) VBox(javafx.scene.layout.VBox) MediaPlayer(javafx.scene.media.MediaPlayer)

Example 24 with Label

use of javafx.scene.control.Label in project aima-java by aimacode.

the class ConnectFourApp method createRootPane.

@Override
public Pane createRootPane() {
    model = new ConnectFourModel();
    BorderPane root = new BorderPane();
    ToolBar toolBar = new ToolBar();
    toolBar.setStyle("-fx-background-color: rgb(0, 0, 200)");
    clearBtn = new Button("Clear");
    clearBtn.setOnAction(ev -> model.initGame());
    strategyCombo = new ComboBox<>();
    strategyCombo.getItems().addAll("Iterative Deepening Alpha-Beta", "Advanced Alpha-Beta");
    strategyCombo.getSelectionModel().select(0);
    timeCombo = new ComboBox<>();
    timeCombo.getItems().addAll("2sec", "4sec", "6sec", "8sec");
    timeCombo.getSelectionModel().select(1);
    proposeBtn = new Button("Propose Move");
    proposeBtn.setOnAction(ev -> model.proposeMove((timeCombo.getSelectionModel().getSelectedIndex() + 1) * 2, strategyCombo.getSelectionModel().getSelectedIndex()));
    toolBar.getItems().addAll(clearBtn, new Separator(), strategyCombo, timeCombo, proposeBtn);
    root.setTop(toolBar);
    final int rows = model.getRows();
    final int cols = model.getCols();
    BorderPane boardPane = new BorderPane();
    ColumnConstraints colCons = new ColumnConstraints();
    colCons.setPercentWidth(100.0 / cols);
    GridPane btnPane = new GridPane();
    GridPane diskPane = new GridPane();
    btnPane.setHgap(10);
    btnPane.setPadding(new Insets(10, 10, 0, 10));
    btnPane.setStyle("-fx-background-color: rgb(0, 50, 255)");
    diskPane.setPadding(new Insets(10, 10, 10, 10));
    diskPane.setStyle("-fx-background-color: rgb(0, 50, 255)");
    colBtns = new Button[cols];
    for (int i = 0; i < cols; i++) {
        Button colBtn = new Button("" + (i + 1));
        colBtn.setId("" + (i + 1));
        colBtn.setMaxWidth(Double.MAX_VALUE);
        colBtn.setOnAction(ev -> {
            String id = ((Button) ev.getSource()).getId();
            int col = Integer.parseInt(id);
            model.makeMove(col - 1);
        });
        colBtns[i] = colBtn;
        btnPane.add(colBtn, i, 0);
        GridPane.setHalignment(colBtn, HPos.CENTER);
        btnPane.getColumnConstraints().add(colCons);
        diskPane.getColumnConstraints().add(colCons);
    }
    boardPane.setTop(btnPane);
    diskPane.setMinSize(0, 0);
    diskPane.setPrefSize(cols * 100, rows * 100);
    RowConstraints rowCons = new RowConstraints();
    rowCons.setPercentHeight(100.0 / rows);
    for (int i = 0; i < rows; i++) diskPane.getRowConstraints().add(rowCons);
    disks = new Circle[rows * cols];
    for (int i = 0; i < rows * cols; i++) {
        Circle disk = new Circle(30);
        disk.radiusProperty().bind(Bindings.min(Bindings.divide(diskPane.widthProperty(), cols * 3), Bindings.divide(diskPane.heightProperty(), rows * 3)));
        disks[i] = disk;
        diskPane.add(disk, i % cols, i / cols);
        GridPane.setHalignment(disk, HPos.CENTER);
    }
    boardPane.setCenter(diskPane);
    root.setCenter(boardPane);
    statusBar = new Label();
    statusBar.setMaxWidth(Double.MAX_VALUE);
    statusBar.setStyle("-fx-background-color: rgb(0, 0, 200); -fx-font-size: 20");
    root.setBottom(statusBar);
    model.addObserver(this::update);
    return root;
}
Also used : Circle(javafx.scene.shape.Circle) BorderPane(javafx.scene.layout.BorderPane) GridPane(javafx.scene.layout.GridPane) Insets(javafx.geometry.Insets) ColumnConstraints(javafx.scene.layout.ColumnConstraints) Label(javafx.scene.control.Label) RowConstraints(javafx.scene.layout.RowConstraints) Button(javafx.scene.control.Button) ToolBar(javafx.scene.control.ToolBar) Separator(javafx.scene.control.Separator)

Example 25 with Label

use of javafx.scene.control.Label in project aima-java by aimacode.

the class SimulationPaneBuilder method getResultFor.

/**
	 * Adds a toolbar, a state view, and a status label to the provided pane and returns
	 * a controller class instance. The toolbar contains combo boxes to control parameter settings
	 * and buttons for simulation control. The controller class instance handles user events and provides
	 * access to user settings (parameter settings, simulation speed, status text, ...).
	 */
public SimulationPaneCtrl getResultFor(BorderPane pane) {
    List<ComboBox<String>> combos = new ArrayList<>();
    parameters.add(createSimSpeedParam());
    for (Parameter param : parameters) {
        ComboBox<String> combo = new ComboBox<>();
        combo.setId(param.getName());
        combo.getItems().addAll(param.getValueNames());
        combo.getSelectionModel().select(param.getDefaultValueIndex());
        combos.add(combo);
    }
    Button simBtn = new Button();
    Node[] tools = new Node[combos.size() + 2];
    for (int i = 0; i < combos.size() - 1; i++) tools[i] = combos.get(i);
    tools[combos.size() - 1] = new Separator();
    tools[combos.size() + 0] = combos.get(combos.size() - 1);
    tools[combos.size() + 1] = simBtn;
    ToolBar toolBar = new ToolBar(tools);
    Label statusLabel = new Label();
    statusLabel.setMaxWidth(Double.MAX_VALUE);
    statusLabel.setAlignment(Pos.CENTER);
    statusLabel.setFont(Font.font(16));
    pane.setTop(toolBar);
    if (stateView.isPresent()) {
        if (stateView.get() instanceof Canvas) {
            // make canvas resizable
            Canvas canvas = (Canvas) stateView.get();
            Pane canvasPane = new Pane();
            canvasPane.getChildren().add(canvas);
            canvas.widthProperty().bind(canvasPane.widthProperty());
            canvas.heightProperty().bind(canvasPane.heightProperty());
            pane.setCenter(canvasPane);
            pane.setStyle("-fx-background-color: white");
        } else
            pane.setCenter(stateView.get());
    }
    pane.setBottom(statusLabel);
    if (!initMethod.isPresent())
        throw new IllegalStateException("No initialization method defined.");
    if (!simMethod.isPresent())
        throw new IllegalStateException("No simulation method defined.");
    return new SimulationPaneCtrl(parameters, combos, initMethod.get(), simMethod.get(), simBtn, statusLabel);
}
Also used : ComboBox(javafx.scene.control.ComboBox) Node(javafx.scene.Node) Canvas(javafx.scene.canvas.Canvas) ArrayList(java.util.ArrayList) Label(javafx.scene.control.Label) BorderPane(javafx.scene.layout.BorderPane) Pane(javafx.scene.layout.Pane) Button(javafx.scene.control.Button) ToolBar(javafx.scene.control.ToolBar) Separator(javafx.scene.control.Separator)

Aggregations

Label (javafx.scene.control.Label)138 Insets (javafx.geometry.Insets)47 Button (javafx.scene.control.Button)38 Scene (javafx.scene.Scene)26 HBox (javafx.scene.layout.HBox)26 VBox (javafx.scene.layout.VBox)25 GridPane (javafx.scene.layout.GridPane)20 TextField (javafx.scene.control.TextField)19 BorderPane (javafx.scene.layout.BorderPane)19 Node (javafx.scene.Node)17 ImageView (javafx.scene.image.ImageView)13 ArrayList (java.util.ArrayList)12 InputTextField (io.bitsquare.gui.components.InputTextField)11 List (java.util.List)11 Tooltip (javafx.scene.control.Tooltip)11 Stage (javafx.stage.Stage)11 Map (java.util.Map)9 ObservableList (javafx.collections.ObservableList)9 Image (javafx.scene.image.Image)9 StackPane (javafx.scene.layout.StackPane)9