Search in sources :

Example 11 with AnchorPane

use of javafx.scene.layout.AnchorPane in project JFoenix by jfoenixadmin.

the class PopupDemo method start.

@Override
public void start(Stage primaryStage) throws Exception {
    JFXHamburger show = new JFXHamburger();
    show.setPadding(new Insets(10, 5, 10, 5));
    JFXRippler r = new JFXRippler(show, RipplerMask.CIRCLE, RipplerPos.BACK);
    JFXListView<Label> list = new JFXListView<Label>();
    for (int i = 1; i < 5; i++) list.getItems().add(new Label("Item " + i));
    AnchorPane container = new AnchorPane();
    container.getChildren().add(r);
    AnchorPane.setLeftAnchor(r, 200.0);
    AnchorPane.setTopAnchor(r, 210.0);
    StackPane main = new StackPane();
    main.getChildren().add(container);
    JFXPopup popup = new JFXPopup(list);
    r.setOnMouseClicked((e) -> popup.show(r, PopupVPosition.TOP, PopupHPosition.LEFT));
    final Scene scene = new Scene(main, 800, 800);
    scene.getStylesheets().add(PopupDemo.class.getResource("/resources/css/jfoenix-components.css").toExternalForm());
    primaryStage.setTitle("JFX Popup Demo");
    primaryStage.setScene(scene);
    primaryStage.setResizable(false);
    primaryStage.show();
}
Also used : JFXPopup(com.jfoenix.controls.JFXPopup) Insets(javafx.geometry.Insets) JFXRippler(com.jfoenix.controls.JFXRippler) JFXHamburger(com.jfoenix.controls.JFXHamburger) JFXListView(com.jfoenix.controls.JFXListView) Label(javafx.scene.control.Label) Scene(javafx.scene.Scene) AnchorPane(javafx.scene.layout.AnchorPane) StackPane(javafx.scene.layout.StackPane)

Example 12 with AnchorPane

use of javafx.scene.layout.AnchorPane in project NumberMagic by MaslEberl.

the class main_screen method showPersonOverview.

/**
     * Shows the person overview inside the root layout.
     */
public void showPersonOverview() {
    try {
        // Load person overview.
        FXMLLoader loader = new FXMLLoader();
        loader.setLocation(main_screen.class.getResource("haupt_scene.fxml"));
        AnchorPane personOverview = (AnchorPane) loader.load();
        // Set person overview into the center of root layout.
        rootLayout.setCenter(personOverview);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader) AnchorPane(javafx.scene.layout.AnchorPane)

Example 13 with AnchorPane

use of javafx.scene.layout.AnchorPane in project Media-Library by The-Rain-Goddess.

the class ApplicationWindow method start.

@Override
public void start(Stage rootStage) throws Exception {
    AnchorPane componentWindow = new AnchorPane();
    VBox componentLayout = new VBox();
    BorderPane tableDisplay = new BorderPane();
    search = new TextField();
    //set main window size
    componentWindow.setMinHeight(WINDOW_MIN_HEIGHT);
    componentWindow.setMinWidth(WINDOW_MIN_WIDTH);
    //align dataTable
    tableDisplay.setRight(setupMediaDataTable());
    tableDisplay.setLeft(setupMediaFileBrowser());
    tableDisplay.setTop(setupMediaPlayer());
    ;
    VBox.setMargin(tableDisplay, new Insets(10, 10, 10, 10));
    componentLayout.getChildren().addAll(setupMenuBar(), tableDisplay);
    //add componentLayout to Window
    componentWindow.getChildren().addAll(componentLayout);
    //Create the scene and add the parent container to it
    Scene scene = new Scene(componentWindow, WINDOW_MIN_WIDTH, WINDOW_MIN_HEIGHT);
    //Add the Scene to the Stage
    rootStage.setScene(scene);
    rootStage.getIcons().add(new Image(this.getClass().getResourceAsStream("media_library.png")));
    rootStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) Insets(javafx.geometry.Insets) TextField(javafx.scene.control.TextField) Scene(javafx.scene.Scene) Image(javafx.scene.image.Image) AnchorPane(javafx.scene.layout.AnchorPane) VBox(javafx.scene.layout.VBox)

Example 14 with AnchorPane

use of javafx.scene.layout.AnchorPane in project bitsquare by bitsquare.

the class MainView method initialize.

@Override
protected void initialize() {
    MainView.rootContainer = this.root;
    ToggleButton marketButton = new NavButton(MarketView.class, "Market");
    ToggleButton buyButton = new NavButton(BuyOfferView.class, "Buy BTC");
    ToggleButton sellButton = new NavButton(SellOfferView.class, "Sell BTC");
    ToggleButton portfolioButton = new NavButton(PortfolioView.class, "Portfolio");
    ToggleButton fundsButton = new NavButton(FundsView.class, "Funds");
    ToggleButton disputesButton = new NavButton(DisputesView.class, "Support");
    ToggleButton settingsButton = new NavButton(SettingsView.class, "Settings");
    ToggleButton accountButton = new NavButton(AccountView.class, "Account");
    Pane portfolioButtonHolder = new Pane(portfolioButton);
    Pane disputesButtonHolder = new Pane(disputesButton);
    HBox leftNavPane = new HBox(marketButton, buyButton, sellButton, portfolioButtonHolder, fundsButton, disputesButtonHolder) {

        {
            setLeftAnchor(this, 10d);
            setTopAnchor(this, 0d);
        }
    };
    Tuple3<ComboBox<PriceFeedComboBoxItem>, Label, VBox> marketPriceBox = getMarketPriceBox("Market price");
    ComboBox<PriceFeedComboBoxItem> priceComboBox = marketPriceBox.first;
    priceComboBox.getSelectionModel().selectedItemProperty().addListener((observable, oldValue, newValue) -> {
        model.setPriceFeedComboBoxItem(newValue);
    });
    ChangeListener<PriceFeedComboBoxItem> selectedPriceFeedItemListender = (observable, oldValue, newValue) -> {
        if (newValue != null)
            priceComboBox.getSelectionModel().select(newValue);
    };
    model.selectedPriceFeedComboBoxItemProperty.addListener(selectedPriceFeedItemListender);
    priceComboBox.setItems(model.priceFeedComboBoxItems);
    marketPriceBox.second.textProperty().bind(createStringBinding(() -> {
        PriceFeedService.Type type = model.typeProperty.get();
        return type != null ? "Market price (" + type.name + ")" : "";
    }, model.marketPriceCurrencyCode, model.typeProperty));
    HBox.setMargin(marketPriceBox.third, new Insets(0, 0, 0, 0));
    Tuple2<TextField, VBox> availableBalanceBox = getBalanceBox("Available balance");
    availableBalanceBox.first.textProperty().bind(model.availableBalance);
    Tuple2<TextField, VBox> reservedBalanceBox = getBalanceBox("Reserved in offers");
    reservedBalanceBox.first.textProperty().bind(model.reservedBalance);
    Tuple2<TextField, VBox> lockedBalanceBox = getBalanceBox("Locked in trades");
    lockedBalanceBox.first.textProperty().bind(model.lockedBalance);
    HBox rightNavPane = new HBox(marketPriceBox.third, availableBalanceBox.second, reservedBalanceBox.second, lockedBalanceBox.second, settingsButton, accountButton) {

        {
            setRightAnchor(this, 10d);
            setTopAnchor(this, 0d);
        }
    };
    root.widthProperty().addListener((observable, oldValue, newValue) -> {
        double w = (double) newValue;
        if (w > 0) {
            leftNavPane.setSpacing(w >= 1080 ? 10 : 5);
            rightNavPane.setSpacing(w >= 1080 ? 10 : 5);
        }
    });
    AnchorPane contentContainer = new AnchorPane() {

        {
            setId("content-pane");
            setLeftAnchor(this, 0d);
            setRightAnchor(this, 0d);
            setTopAnchor(this, 60d);
            setBottomAnchor(this, 10d);
        }
    };
    AnchorPane applicationContainer = new AnchorPane(leftNavPane, rightNavPane, contentContainer) {

        {
            setId("content-pane");
        }
    };
    BorderPane baseApplicationContainer = new BorderPane(applicationContainer) {

        {
            setId("base-content-container");
        }
    };
    baseApplicationContainer.setBottom(createFooter());
    setupNotificationIcon(portfolioButtonHolder);
    setupDisputesIcon(disputesButtonHolder);
    navigation.addListener(viewPath -> {
        if (viewPath.size() != 2 || viewPath.indexOf(MainView.class) != 0)
            return;
        Class<? extends View> viewClass = viewPath.tip();
        View view = viewLoader.load(viewClass);
        contentContainer.getChildren().setAll(view.getRoot());
        navButtons.getToggles().stream().filter(toggle -> toggle instanceof NavButton).filter(button -> viewClass == ((NavButton) button).viewClass).findFirst().orElseThrow(() -> new BitsquareException("No button matching %s found", viewClass)).setSelected(true);
    });
    VBox splashScreen = createSplashScreen();
    root.getChildren().addAll(baseApplicationContainer, splashScreen);
    model.showAppScreen.addListener((ov, oldValue, newValue) -> {
        if (newValue) {
            navigation.navigateToPreviousVisitedView();
            if (!persistedFilesCorrupted.isEmpty()) {
                if (persistedFilesCorrupted.size() > 1 || !persistedFilesCorrupted.get(0).equals("Navigation")) {
                    // show warning that some files has been corrupted
                    new Popup().warning("We detected incompatible data base files!\n\n" + "Those database file(s) are not compatible with our current code base:" + "\n" + persistedFilesCorrupted.toString() + "\n\nWe made a backup of the corrupted file(s) and applied the default values to a new " + "database version." + "\n\nThe backup is located at:\n[you local app data directory]/db/backup_of_corrupted_data.\n\n" + "Please check if you have the latest version of Bitsquare installed.\n" + "You can download it at:\nhttps://github.com/bitsquare/bitsquare/releases\n\n" + "Please restart the application.").closeButtonText("Shut down").onClose(BitsquareApp.shutDownHandler::run).show();
                } else {
                    log.debug("We detected incompatible data base file for Navigation. That is a minor issue happening with refactoring of UI classes " + "and we don't display a warning popup to the user.");
                }
            }
            transitions.fadeOutAndRemove(splashScreen, 1500, actionEvent -> disposeSplashScreen());
        }
    });
    // Delay a bit to give time for rendering the splash screen
    UserThread.execute(model::start);
}
Also used : Pos(javafx.geometry.Pos) PriceFeedService(io.bitsquare.btc.pricefeed.PriceFeedService) Popup(io.bitsquare.gui.main.overlays.popups.Popup) MarketView(io.bitsquare.gui.main.market.MarketView) javafx.scene.layout(javafx.scene.layout) javafx.scene.control(javafx.scene.control) LoggerFactory(org.slf4j.LoggerFactory) BitsquareApp(io.bitsquare.app.BitsquareApp) Tuple2(io.bitsquare.common.util.Tuple2) Transitions(io.bitsquare.gui.util.Transitions) FundsView(io.bitsquare.gui.main.funds.FundsView) GUIUtil(io.bitsquare.gui.util.GUIUtil) Inject(javax.inject.Inject) DevFlags(io.bitsquare.app.DevFlags) Insets(javafx.geometry.Insets) Navigation(io.bitsquare.gui.Navigation) SettingsView(io.bitsquare.gui.main.settings.SettingsView) TextAlignment(javafx.scene.text.TextAlignment) Named(javax.inject.Named) BSFormatter(io.bitsquare.gui.util.BSFormatter) Color(javafx.scene.paint.Color) Logger(org.slf4j.Logger) UserThread(io.bitsquare.common.UserThread) BuyOfferView(io.bitsquare.gui.main.offer.BuyOfferView) BitsquareException(io.bitsquare.BitsquareException) DropShadow(javafx.scene.effect.DropShadow) DisputesView(io.bitsquare.gui.main.disputes.DisputesView) io.bitsquare.gui.common.view(io.bitsquare.gui.common.view) PortfolioView(io.bitsquare.gui.main.portfolio.PortfolioView) List(java.util.List) Bindings.createStringBinding(javafx.beans.binding.Bindings.createStringBinding) Tuple3(io.bitsquare.common.util.Tuple3) AnchorPane(javafx.scene.layout.AnchorPane) ImageView(javafx.scene.image.ImageView) BusyAnimation(io.bitsquare.gui.components.BusyAnimation) SellOfferView(io.bitsquare.gui.main.offer.SellOfferView) ChangeListener(javafx.beans.value.ChangeListener) AccountView(io.bitsquare.gui.main.account.AccountView) Insets(javafx.geometry.Insets) BitsquareApp(io.bitsquare.app.BitsquareApp) Popup(io.bitsquare.gui.main.overlays.popups.Popup) AnchorPane(javafx.scene.layout.AnchorPane) AnchorPane(javafx.scene.layout.AnchorPane) MarketView(io.bitsquare.gui.main.market.MarketView) FundsView(io.bitsquare.gui.main.funds.FundsView) SettingsView(io.bitsquare.gui.main.settings.SettingsView) BuyOfferView(io.bitsquare.gui.main.offer.BuyOfferView) DisputesView(io.bitsquare.gui.main.disputes.DisputesView) PortfolioView(io.bitsquare.gui.main.portfolio.PortfolioView) ImageView(javafx.scene.image.ImageView) SellOfferView(io.bitsquare.gui.main.offer.SellOfferView) AccountView(io.bitsquare.gui.main.account.AccountView) BitsquareException(io.bitsquare.BitsquareException)

Example 15 with AnchorPane

use of javafx.scene.layout.AnchorPane in project bitsquare by bitsquare.

the class PreferencesView method initializeDisplayCurrencies.

///////////////////////////////////////////////////////////////////////////////////////////
// Initialize
///////////////////////////////////////////////////////////////////////////////////////////
private void initializeDisplayCurrencies() {
    TitledGroupBg titledGroupBg = addTitledGroupBg(root, gridRow, 3, "Currencies in market price feed list");
    GridPane.setColumnSpan(titledGroupBg, 4);
    preferredTradeCurrencyComboBox = addLabelComboBox(root, gridRow, "Preferred currency:", Layout.FIRST_ROW_DISTANCE).second;
    preferredTradeCurrencyComboBox.setConverter(new StringConverter<TradeCurrency>() {

        @Override
        public String toString(TradeCurrency tradeCurrency) {
            // http://boschista.deviantart.com/journal/Cool-ASCII-Symbols-214218618
            return tradeCurrency.getDisplayPrefix() + tradeCurrency.getNameAndCode();
        }

        @Override
        public TradeCurrency fromString(String s) {
            return null;
        }
    });
    Tuple2<Label, ListView> fiatTuple = addLabelListView(root, ++gridRow, "Display national currencies:");
    GridPane.setValignment(fiatTuple.first, VPos.TOP);
    fiatCurrenciesListView = fiatTuple.second;
    fiatCurrenciesListView.setMinHeight(2 * Layout.LIST_ROW_HEIGHT + 2);
    fiatCurrenciesListView.setMaxHeight(6 * Layout.LIST_ROW_HEIGHT + 2);
    Label placeholder = new Label("There are no national currencies selected");
    placeholder.setWrapText(true);
    fiatCurrenciesListView.setPlaceholder(placeholder);
    fiatCurrenciesListView.setCellFactory(new Callback<ListView<FiatCurrency>, ListCell<FiatCurrency>>() {

        @Override
        public ListCell<FiatCurrency> call(ListView<FiatCurrency> list) {
            return new ListCell<FiatCurrency>() {

                final Label label = new Label();

                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);

                final Button removeButton = new Button("", icon);

                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final FiatCurrency item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(item.getNameAndCode());
                        removeButton.setOnAction(e -> {
                            if (item.equals(preferences.getPreferredTradeCurrency())) {
                                new Popup().warning("You cannot remove your selected preferred display currency").show();
                            } else {
                                preferences.removeFiatCurrency(item);
                                if (!allFiatCurrencies.contains(item))
                                    allFiatCurrencies.add(item);
                            }
                        });
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                        removeButton.setOnAction(null);
                    }
                }
            };
        }
    });
    Tuple2<Label, ListView> cryptoCurrenciesTuple = addLabelListView(root, gridRow, "Display altcoins:");
    GridPane.setValignment(cryptoCurrenciesTuple.first, VPos.TOP);
    GridPane.setMargin(cryptoCurrenciesTuple.first, new Insets(0, 0, 0, 20));
    cryptoCurrenciesListView = cryptoCurrenciesTuple.second;
    GridPane.setColumnIndex(cryptoCurrenciesTuple.first, 2);
    GridPane.setColumnIndex(cryptoCurrenciesListView, 3);
    cryptoCurrenciesListView.setMinHeight(2 * Layout.LIST_ROW_HEIGHT + 2);
    cryptoCurrenciesListView.setMaxHeight(6 * Layout.LIST_ROW_HEIGHT + 2);
    placeholder = new Label("There are no altcoins selected");
    placeholder.setWrapText(true);
    cryptoCurrenciesListView.setPlaceholder(placeholder);
    cryptoCurrenciesListView.setCellFactory(new Callback<ListView<CryptoCurrency>, ListCell<CryptoCurrency>>() {

        @Override
        public ListCell<CryptoCurrency> call(ListView<CryptoCurrency> list) {
            return new ListCell<CryptoCurrency>() {

                final Label label = new Label();

                final ImageView icon = ImageUtil.getImageViewById(ImageUtil.REMOVE_ICON);

                final Button removeButton = new Button("", icon);

                final AnchorPane pane = new AnchorPane(label, removeButton);

                {
                    label.setLayoutY(5);
                    removeButton.setId("icon-button");
                    AnchorPane.setRightAnchor(removeButton, 0d);
                }

                @Override
                public void updateItem(final CryptoCurrency item, boolean empty) {
                    super.updateItem(item, empty);
                    if (item != null && !empty) {
                        label.setText(item.getNameAndCode());
                        removeButton.setOnAction(e -> {
                            if (item.equals(preferences.getPreferredTradeCurrency())) {
                                new Popup().warning("You cannot remove your selected preferred display currency").show();
                            } else {
                                preferences.removeCryptoCurrency(item);
                                if (!allCryptoCurrencies.contains(item))
                                    allCryptoCurrencies.add(item);
                            }
                        });
                        setGraphic(pane);
                    } else {
                        setGraphic(null);
                        removeButton.setOnAction(null);
                    }
                }
            };
        }
    });
    fiatCurrenciesComboBox = addLabelComboBox(root, ++gridRow).second;
    fiatCurrenciesComboBox.setPromptText("Add national currency");
    fiatCurrenciesComboBox.setConverter(new StringConverter<FiatCurrency>() {

        @Override
        public String toString(FiatCurrency tradeCurrency) {
            return tradeCurrency.getNameAndCode();
        }

        @Override
        public FiatCurrency fromString(String s) {
            return null;
        }
    });
    Tuple2<Label, ComboBox> labelComboBoxTuple2 = addLabelComboBox(root, gridRow);
    cryptoCurrenciesComboBox = labelComboBoxTuple2.second;
    GridPane.setColumnIndex(cryptoCurrenciesComboBox, 3);
    cryptoCurrenciesComboBox.setPromptText("Add altcoin");
    cryptoCurrenciesComboBox.setConverter(new StringConverter<CryptoCurrency>() {

        @Override
        public String toString(CryptoCurrency tradeCurrency) {
            return tradeCurrency.getNameAndCode();
        }

        @Override
        public CryptoCurrency fromString(String s) {
            return null;
        }
    });
}
Also used : Popup(io.bitsquare.gui.main.overlays.popups.Popup) Arrays(java.util.Arrays) io.bitsquare.locale(io.bitsquare.locale) javafx.scene.control(javafx.scene.control) FXCollections(javafx.collections.FXCollections) Tuple2(io.bitsquare.common.util.Tuple2) Inject(javax.inject.Inject) Insets(javafx.geometry.Insets) Layout(io.bitsquare.gui.util.Layout) VPos(javafx.geometry.VPos) Callback(javafx.util.Callback) GridPane(javafx.scene.layout.GridPane) BSFormatter(io.bitsquare.gui.util.BSFormatter) Activatable(io.bitsquare.gui.common.model.Activatable) InputTextField(io.bitsquare.gui.components.InputTextField) BlockChainExplorer(io.bitsquare.user.BlockChainExplorer) UserThread(io.bitsquare.common.UserThread) ImageUtil(io.bitsquare.gui.util.ImageUtil) StringConverter(javafx.util.StringConverter) ActivatableViewAndModel(io.bitsquare.gui.common.view.ActivatableViewAndModel) Collectors(java.util.stream.Collectors) TimeUnit(java.util.concurrent.TimeUnit) Preferences(io.bitsquare.user.Preferences) FormBuilder(io.bitsquare.gui.util.FormBuilder) AnchorPane(javafx.scene.layout.AnchorPane) ImageView(javafx.scene.image.ImageView) ObservableList(javafx.collections.ObservableList) FxmlView(io.bitsquare.gui.common.view.FxmlView) ChangeListener(javafx.beans.value.ChangeListener) NotNull(org.jetbrains.annotations.NotNull) TitledGroupBg(io.bitsquare.gui.components.TitledGroupBg) Insets(javafx.geometry.Insets) Popup(io.bitsquare.gui.main.overlays.popups.Popup) ImageView(javafx.scene.image.ImageView) AnchorPane(javafx.scene.layout.AnchorPane) TitledGroupBg(io.bitsquare.gui.components.TitledGroupBg)

Aggregations

AnchorPane (javafx.scene.layout.AnchorPane)18 Scene (javafx.scene.Scene)7 ImageView (javafx.scene.image.ImageView)7 Popup (io.bitsquare.gui.main.overlays.popups.Popup)6 UserThread (io.bitsquare.common.UserThread)5 Tuple2 (io.bitsquare.common.util.Tuple2)5 ChangeListener (javafx.beans.value.ChangeListener)5 Inject (javax.inject.Inject)5 ActivatableViewAndModel (io.bitsquare.gui.common.view.ActivatableViewAndModel)4 FxmlView (io.bitsquare.gui.common.view.FxmlView)4 BSFormatter (io.bitsquare.gui.util.BSFormatter)4 Insets (javafx.geometry.Insets)4 javafx.scene.control (javafx.scene.control)4 Label (javafx.scene.control.Label)4 Tuple3 (io.bitsquare.common.util.Tuple3)3 TitledGroupBg (io.bitsquare.gui.components.TitledGroupBg)3 FormBuilder (io.bitsquare.gui.util.FormBuilder)3 ImageUtil (io.bitsquare.gui.util.ImageUtil)3 Layout (io.bitsquare.gui.util.Layout)3 VPos (javafx.geometry.VPos)3