Search in sources :

Example 36 with AnchorPane

use of javafx.scene.layout.AnchorPane in project Gargoyle by callakrsos.

the class CaptureScreenController method initialize.

@FXML
public void initialize() {
    itemHandler = new CaptureItemHandler(this);
    flowItems.getChildren().addAll(itemHandler.getItems());
    anchorBoard = new AnchorPane();
    //아이템 카운트 수를 핸들링하는 이벤트 리스너
    anchorBoard.getChildren().addListener((ListChangeListener) c -> {
        if (c.next()) {
            if (c.wasAdded()) {
                int addedSize = c.getAddedSize();
                itemCount.add(addedSize);
            } else if (c.wasRemoved()) {
                itemCount.subtract(c.getRemovedSize());
            }
        }
    });
    spPic.setContent(anchorBoard);
    anchorBoard.setOnScroll(ev -> {
        if (ev.isControlDown()) {
            if (ev.getDeltaY() > 0) {
                scaleDeltaX.set(scaleDeltaX.get() + 0.1);
                scaleDeltaY.set(scaleDeltaY.get() + 0.1);
                scale.setX(scaleDeltaX.get());
                scale.setY(scaleDeltaY.get());
                scale.setPivotX(ev.getX());
                scale.setPivotY(ev.getY());
            } else {
                double value = scaleDeltaX.get() - 0.1;
                double value2 = scaleDeltaY.get() - 0.1;
                if (value < 0)
                    return;
                if (value2 < 0)
                    return;
                scaleDeltaX.set(value);
                scaleDeltaY.set(value2);
                scale.setX(scaleDeltaX.get());
                scale.setY(scaleDeltaY.get());
                scale.setPivotX(ev.getX());
                scale.setPivotY(ev.getY());
            }
            lblStatus.setText(String.format(STATUS_FORMAT, scaleDeltaX.get(), ev.getX(), ev.getY(), itemCount.get()));
        }
    });
    anchorBoard.setOnMouseMoved(ev -> {
        lblStatus.setText(String.format(STATUS_FORMAT, scaleDeltaX.get(), ev.getX(), ev.getY(), itemCount.get()));
    });
}
Also used : Label(javafx.scene.control.Label) Node(javafx.scene.Node) FXMLController(com.kyj.fx.voeditor.visual.framework.annotation.FXMLController) FXCollections(javafx.collections.FXCollections) DoubleProperty(javafx.beans.property.DoubleProperty) FileInputStream(java.io.FileInputStream) IntegerProperty(javafx.beans.property.IntegerProperty) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) FXML(javafx.fxml.FXML) ScrollPane(javafx.scene.control.ScrollPane) ListChangeListener(javafx.collections.ListChangeListener) FlowPane(javafx.scene.layout.FlowPane) AnchorPane(javafx.scene.layout.AnchorPane) ImageView(javafx.scene.image.ImageView) Map(java.util.Map) FileUtil(com.kyj.fx.voeditor.visual.util.FileUtil) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) Scale(javafx.scene.transform.Scale) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) Point2D(javafx.geometry.Point2D) Image(javafx.scene.image.Image) AnchorPane(javafx.scene.layout.AnchorPane) FXML(javafx.fxml.FXML)

Example 37 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)

Example 38 with AnchorPane

use of javafx.scene.layout.AnchorPane in project Gargoyle by callakrsos.

the class PropertyChangeExam method start.

@Override
public void start(Stage primaryStage) throws Exception {
    TextArea textArea = new TextArea("");
    Button button = new Button("ssss");
    button.setStyle("-fx-base: red;");
    button.setFont(new Font(55));
    Button button2 = new Button("ssss2");
    // button2.textProperty().bind(button.textProperty());
    // button2.styleProperty().bind(button.styleProperty());
    // button2.getStyleClass().addAll(button.getStyleClass());
    propertyCopy2(button, button2);
    //
    // button.setVisible(false);
    // propertyCopy(button, button2);
    // List<CssMetaData<? extends Styleable, ?>> cssMetaData =
    // button.getCssMetaData();
    // cssMetaData.forEach(cssMeta -> {
    // String property = cssMeta.getProperty();
    // System.out.print(property);
    // try {
    // String ss = String.valueOf(cssMeta.getInitialValue(null));
    //
    // System.out.println(" : " + ss);
    // } catch (NullPointerException e) {
    //
    // }
    //
    // });
    // button.setStyle(button.getStyle());
    // button2.styleProperty().set(button.getStyle());
    // button2.setSkin(button.getSkin());
    // button2.getCssMetaData().clear();
    // button2.getCssMetaData().addAll(button.getControlCssMetaData());
    // button2.fire();
    //
    // ExpressionHelper.fireValueChangedEvent(helper);
    // button2.getCssMetaData().addAll(button.getControlCssMetaData());
    // button2.textProperty().bind(button.textProperty());
    // button2.styleProperty().bind(button.styleProperty());
    // button2.visibleProperty().bind(button.visibleProperty());
    // button2.disableProperty().bind(button.disableProperty());
    // button2.fontProperty().bind(button.fontProperty());
    textArea.textProperty().addListener(new ChangeListener<String>() {

        @Override
        public void changed(ObservableValue<? extends String> oba, String oldval, String newval) {
            button.setStyle(newval);
            button2.setStyle(newval);
        }
    });
    AnchorPane root = new AnchorPane(new HBox(textArea, button, button2));
    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.show();
}
Also used : HBox(javafx.scene.layout.HBox) TextArea(javafx.scene.control.TextArea) Button(javafx.scene.control.Button) Scene(javafx.scene.Scene) AnchorPane(javafx.scene.layout.AnchorPane) Font(javafx.scene.text.Font)

Example 39 with AnchorPane

use of javafx.scene.layout.AnchorPane in project graphysica by Graphysica.

the class MainApp method start.

@Override
public void start(Stage stage) throws Exception {
    panneauPrincipal = new AnchorPane();
    initialiserPanneau();
    Scene scene = new Scene(panneauPrincipal);
    LOGGER.debug("");
    scene.getStylesheets().add("/styles/Styles.css");
    stage.setTitle("Graphysica");
    stage.setScene(scene);
    stage.show();
// showDialog();
}
Also used : Scene(javafx.scene.Scene) AnchorPane(javafx.scene.layout.AnchorPane)

Example 40 with AnchorPane

use of javafx.scene.layout.AnchorPane in project arquivoProject by fader-azevedo.

the class DBConnector method backtoMenu.

public void backtoMenu(AnchorPane pane) {
    FXMLLoader fxmlLoader = new FXMLLoader();
    try {
        fxmlLoader.load(getClass().getResource("/view/Menu.fxml").openStream());
        AnchorPane root = fxmlLoader.getRoot();
        pane.getChildren().clear();
        pane.getChildren().add(root);
        pane.setStyle("-fx-border-color:transparent;");
    } catch (IOException ex) {
        Logger.getLogger(DBConnector.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader) AnchorPane(javafx.scene.layout.AnchorPane)

Aggregations

AnchorPane (javafx.scene.layout.AnchorPane)66 IOException (java.io.IOException)26 Scene (javafx.scene.Scene)23 FXMLLoader (javafx.fxml.FXMLLoader)22 ChangeListener (javafx.beans.value.ChangeListener)18 Label (javafx.scene.control.Label)16 ImageView (javafx.scene.image.ImageView)16 FXML (javafx.fxml.FXML)15 Insets (javafx.geometry.Insets)15 Pane (javafx.scene.layout.Pane)14 URL (java.net.URL)13 GridPane (javafx.scene.layout.GridPane)12 Inject (javax.inject.Inject)12 JFXButton (com.jfoenix.controls.JFXButton)11 ResourceBundle (java.util.ResourceBundle)11 KeyFrame (javafx.animation.KeyFrame)11 Timeline (javafx.animation.Timeline)11 Initializable (javafx.fxml.Initializable)11 Duration (javafx.util.Duration)11 Button (javafx.scene.control.Button)10