Search in sources :

Example 26 with HBox

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

the class CodeAnalysisJavaTextArea method initialize.

@FXML
public void initialize() {
    choMethod = new ChoiceBox<>();
    choMethod.setConverter(new StringConverter<SourceAnalysisDVO>() {

        @Override
        public String toString(SourceAnalysisDVO d) {
            return d.getMethodName();
        }

        @Override
        public SourceAnalysisDVO fromString(String string) {
            return null;
        }
    });
    // jdk1.8.73이후버젼부터 사용가능
    choMethod.setOnAction(event -> {
        SourceAnalysisDVO selectedItem = choMethod.getSelectionModel().getSelectedItem();
        String methodName = selectedItem.getMethodName();
        int methodBlockStart = selectedItem.getMethodBlockStart();
        int finallyBlockIdx = methodBlockStart - 1;
        String string = newInstance.getReadLines().get(finallyBlockIdx);
        if (!string.contains(methodName)) {
            for (int i = methodBlockStart - 2; i < methodBlockStart + 1; i++) {
                if (i < 0)
                    continue;
                if (i == (methodBlockStart - 1))
                    continue;
                string = newInstance.getReadLines().get(i);
                if (string.contains(methodName)) {
                    finallyBlockIdx = i;
                    break;
                }
            }
        }
        IntStream mapToInt = Stream.of(txtJavaTextArea.getText().split("\n")).limit(finallyBlockIdx).mapToInt(mapper -> {
            return mapper.length() + 1;
        });
        int length = string.split("\t").length - 1;
        int sum = mapToInt.sum() + length;
        System.out.println(string);
        txtJavaTextArea.selectRange(sum, sum + methodName.length());
    });
    this.setTop(new HBox(5, new Label("Method Name : "), choMethod));
}
Also used : HBox(javafx.scene.layout.HBox) Label(javafx.scene.control.Label) IntStream(java.util.stream.IntStream) SourceAnalysisDVO(com.kyj.fx.voeditor.visual.words.spec.auto.msword.vo.SourceAnalysisDVO) FXML(javafx.fxml.FXML)

Example 27 with HBox

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

the class NrchRealtimeSrchFlowComposite method init.

protected void init() {
    lblRequestTime.setMaxHeight(Double.MAX_VALUE);
    choWaitItems = new ChoiceBox<>(FXCollections.observableArrayList("", "5", "10", "15", "20", "25", "30"));
    Button btnReload = new Button("Reload");
    HBox hboxItems = new HBox(5, /* choWaitItems, new Label("단위 (초)"), chkTimer, */
    btnReload, lblRequestTime);
    hboxItems.setAlignment(Pos.CENTER_LEFT);
    hboxItems.setPadding(new Insets(5));
    BorderPane borTop = new BorderPane();
    Button btnStart = new Button("시작");
    Button btnStop = new Button("중지");
    btnStart.setDisable(true);
    btnStop.setDisable(true);
    borTop.setTop(new TitledPane("Timer", new HBox(5, choWaitItems, btnStart, btnStop)));
    borTop.setCenter(hboxItems);
    this.getParent().setTop(borTop);
    btnReload.setOnAction(ev -> {
        reload();
    });
    choWaitItems.valueProperty().addListener((oba, o, n) -> {
        if (ValueUtil.isNotEmpty(n) && !isRecycle.get()) {
            btnStart.setDisable(false);
        } else {
            btnStart.setDisable(true);
        }
    });
    btnStart.setOnAction(e -> {
        isRecycle.set(true);
        service.restart();
        btnStart.setDisable(true);
        btnStop.setDisable(false);
    });
    btnStop.setOnAction(e -> {
        isRecycle.set(false);
        service.cancel();
        btnStart.setDisable(false);
        btnStop.setDisable(true);
    });
    isRecycle.addListener((oba, o, n) -> {
        if (n) {
            choWaitItems.setDisable(true);
        } else {
            choWaitItems.setDisable(false);
        }
    });
    defineService();
    try {
        service.setExecutor(gargoyleThreadExecutors);
        service.start();
    } catch (RejectedExecutionException e) {
        if (gargoyleThreadExecutors.isShutdown() || gargoyleThreadExecutors.isTerminated()) {
            gargoyleThreadExecutors = ExecutorDemons.newFixedThreadExecutor(REALTIME_SRCH_THREAD_POOL_NAME, 1);
            service.setExecutor(gargoyleThreadExecutors);
        }
        LOGGER.error(ValueUtil.toString(e));
        // One more time.
        defineService();
        service.start();
    }
// reload();
}
Also used : TitledPane(javafx.scene.control.TitledPane) HBox(javafx.scene.layout.HBox) BorderPane(javafx.scene.layout.BorderPane) Insets(javafx.geometry.Insets) Button(javafx.scene.control.Button) MouseButton(javafx.scene.input.MouseButton) RejectedExecutionException(java.util.concurrent.RejectedExecutionException)

Example 28 with HBox

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

the class JFXTreeCell method updateDisplay.

void updateDisplay(T item, boolean empty) {
    if (item == null || empty) {
        hbox = null;
        setText(null);
        setGraphic(null);
    } else {
        TreeItem<T> treeItem = getTreeItem();
        if (treeItem != null && treeItem.getGraphic() != null) {
            if (item instanceof Node) {
                setText(null);
                if (hbox == null) {
                    hbox = new HBox(3);
                }
                hbox.getChildren().setAll(treeItem.getGraphic(), (Node) item);
                setGraphic(hbox);
            } else {
                hbox = null;
                setText(item.toString());
                setGraphic(treeItem.getGraphic());
            }
        } else {
            hbox = null;
            if (item instanceof Node) {
                setText(null);
                setGraphic((Node) item);
            } else {
                setText(item.toString());
                setGraphic(null);
            }
        }
    }
}
Also used : HBox(javafx.scene.layout.HBox) Node(javafx.scene.Node)

Example 29 with HBox

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

the class JFXTableColumnHeader method layoutChildren.

@Override
protected void layoutChildren() {
    super.layoutChildren();
    double w = snapSize(getWidth()) - (snappedLeftInset() + snappedRightInset());
    container.resizeRelocate(snappedLeftInset(), 0, w, getHeight());
    if (!getChildren().contains(container)) {
        invalid = true;
        container.getChildren().remove(arrowContainer);
        for (int i = 0; i < getChildren().size(); ) {
            Node child = getChildren().get(i);
            container.getChildren().add(child);
        }
        getChildren().add(container);
    }
    // add animation to sorting arrow
    if (invalid) {
        if (container.getChildren().size() > 1 && !container.getChildren().contains(arrowContainer)) {
            // setup children
            arrowPane = (GridPane) container.getChildren().get(1);
            arrow = (Region) arrowPane.getChildren().get(0);
            arrowContainer.getChildren().clear();
            container.getChildren().remove(1);
            container.getChildren().add(arrowContainer);
            for (int i = 0; i < arrowPane.getChildren().size(); ) {
                Node child = arrowPane.getChildren().get(i);
                arrowContainer.getChildren().add(child);
                if (child instanceof HBox) {
                    HBox dotsContainer = (HBox) child;
                    dotsContainer.setMaxHeight(5);
                    dotsContainer.translateYProperty().bind(Bindings.createDoubleBinding(() -> {
                        return arrow.getHeight() + 2;
                    }, arrow.heightProperty()));
                } else if (child instanceof Label) {
                    Label labelContainer = (Label) child;
                    labelContainer.setMaxHeight(5);
                    labelContainer.translateYProperty().bind(Bindings.createDoubleBinding(() -> {
                        return arrow.getHeight() + 3;
                    }, arrow.heightProperty()));
                }
            }
            arrowContainer.maxWidthProperty().bind(arrow.widthProperty());
            StackPane.setAlignment(arrowContainer, Pos.CENTER_RIGHT);
            // set padding to the label to replace it with ... if it's too close to the sorting arrow
            Label label = (Label) container.getChildren().get(0);
            oldMargin = StackPane.getMargin(label);
            StackPane.setMargin(label, new Insets(oldMargin == null ? 0 : oldMargin.getTop(), oldMargin == null || oldMargin.getRight() < 30 ? 30 : oldMargin.getRight(), oldMargin == null ? 0 : oldMargin.getBottom(), oldMargin == null || oldMargin.getLeft() < 30 ? 30 : oldMargin.getLeft()));
            // fixed the issue of arrow translate X while resizing the column header
            arrowContainer.translateXProperty().bind(Bindings.createDoubleBinding(() -> {
                if (arrowContainer.getLayoutX() <= 8)
                    return -arrowContainer.getLayoutX() - 2;
                return -10.0;
            }, arrowContainer.layoutXProperty()));
            if (arrowAnimation != null && arrowAnimation.getStatus().equals(Status.RUNNING))
                arrowAnimation.stop();
            if (arrow.getRotate() == 180 && arrow.getRotate() != currentArrowRotation) {
                arrowContainer.setOpacity(0);
                arrowContainer.setTranslateY(getHeight() / 4);
                arrowAnimation = new Timeline(new KeyFrame(Duration.millis(320), new KeyValue(arrowContainer.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(arrowContainer.translateYProperty(), 0, Interpolator.EASE_BOTH)));
            } else if (arrow.getRotate() == 0 && arrow.getRotate() != currentArrowRotation) {
                arrow.setRotate(-180);
                arrowAnimation = new Timeline(new KeyFrame(Duration.millis(160), new KeyValue(arrow.rotateProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(arrowContainer.opacityProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(arrowContainer.translateYProperty(), 0, Interpolator.EASE_BOTH)));
            }
            arrowAnimation.setOnFinished((finish) -> currentArrowRotation = arrow.getRotate());
            arrowAnimation.play();
        }
        if (arrowContainer != null && arrowPane != null && container.getChildren().size() == 1 && !arrowPane.isVisible()) {
            if (arrowAnimation != null && arrowAnimation.getStatus().equals(Status.RUNNING))
                arrowAnimation.stop();
            Label label = (Label) container.getChildren().get(0);
            // dont change the padding if arrow is not showing
            if (currentArrowRotation == 0)
                StackPane.setMargin(label, new Insets(oldMargin == null ? 0 : oldMargin.getTop(), oldMargin == null || oldMargin.getRight() < 30 ? 30 : oldMargin.getRight(), oldMargin == null ? 0 : oldMargin.getBottom(), oldMargin == null || oldMargin.getLeft() < 30 ? 30 : oldMargin.getLeft()));
            container.getChildren().add(arrowContainer);
            arrowAnimation = new Timeline(new KeyFrame(Duration.millis(320), new KeyValue(arrowContainer.opacityProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(arrowContainer.translateYProperty(), getHeight() / 4, Interpolator.EASE_BOTH)));
            arrowAnimation.setOnFinished((finish) -> {
                currentArrowRotation = -1;
                StackPane.setMargin(label, null);
            });
            arrowAnimation.play();
        }
    }
}
Also used : HBox(javafx.scene.layout.HBox) Timeline(javafx.animation.Timeline) Insets(javafx.geometry.Insets) KeyValue(javafx.animation.KeyValue) Node(javafx.scene.Node) Label(javafx.scene.control.Label) KeyFrame(javafx.animation.KeyFrame)

Example 30 with HBox

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

the class TabsDemo method start.

@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Tabs");
    Group root = new Group();
    Scene scene = new Scene(root, 700, 250);
    JFXTabPane tabPane = new JFXTabPane();
    Tab tab = new Tab();
    tab.setText(msg);
    tab.setContent(new Label("Tab 0"));
    tabPane.getTabs().add(tab);
    tabPane.setPrefSize(300, 200);
    Tab tab1 = new Tab();
    tab1.setText("Tab 01");
    tab1.setContent(new Label("Tab 01"));
    tabPane.getTabs().add(tab1);
    SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel();
    selectionModel.select(1);
    JFXButton button = new JFXButton("New Tab");
    button.setOnMouseClicked((o) -> {
        Tab temp = new Tab();
        int count = tabPane.getTabs().size();
        temp.setText(msg + count);
        temp.setContent(new Label("Tab 0" + count));
        tabPane.getTabs().add(temp);
    });
    tabPane.setMaxWidth(500);
    HBox hbox = new HBox();
    hbox.getChildren().addAll(button, tabPane);
    hbox.setSpacing(50);
    hbox.setAlignment(Pos.CENTER);
    hbox.setStyle("-fx-padding:20");
    root.getChildren().addAll(hbox);
    scene.getStylesheets().add(TabsDemo.class.getResource("/resources/css/jfoenix-components.css").toExternalForm());
    primaryStage.setScene(scene);
    primaryStage.show();
    primaryStage.setTitle("JFX Tabs Demo");
}
Also used : Group(javafx.scene.Group) HBox(javafx.scene.layout.HBox) Tab(javafx.scene.control.Tab) JFXTabPane(com.jfoenix.controls.JFXTabPane) Label(javafx.scene.control.Label) JFXButton(com.jfoenix.controls.JFXButton) Scene(javafx.scene.Scene)

Aggregations

HBox (javafx.scene.layout.HBox)57 Button (javafx.scene.control.Button)26 Insets (javafx.geometry.Insets)23 Label (javafx.scene.control.Label)23 Scene (javafx.scene.Scene)13 VBox (javafx.scene.layout.VBox)13 BorderPane (javafx.scene.layout.BorderPane)8 Node (javafx.scene.Node)7 Stage (javafx.stage.Stage)7 InputTextField (io.bitsquare.gui.components.InputTextField)6 TextArea (javafx.scene.control.TextArea)6 Popup (io.bitsquare.gui.main.overlays.popups.Popup)5 IOException (java.io.IOException)5 ObservableList (javafx.collections.ObservableList)5 FXML (javafx.fxml.FXML)5 ImageView (javafx.scene.image.ImageView)5 KeyFrame (javafx.animation.KeyFrame)4 Timeline (javafx.animation.Timeline)4 File (java.io.File)3 Group (javafx.scene.Group)3