Search in sources :

Example 1 with Text

use of javafx.scene.text.Text in project JFoenix by jfoenixadmin.

the class JFXPasswordFieldSkinAndroid method createPromptNode.

private void createPromptNode() {
    promptText = new Text();
    promptText.setManaged(false);
    promptText.getStyleClass().add("text");
    promptText.visibleProperty().bind(usePromptText);
    promptText.fontProperty().bind(getSkinnable().fontProperty());
    promptText.textProperty().bind(getSkinnable().promptTextProperty());
    promptText.fillProperty().bind(promptTextFill);
    promptText.setLayoutX(1);
}
Also used : Text(javafx.scene.text.Text)

Example 2 with Text

use of javafx.scene.text.Text in project JFoenix by jfoenixadmin.

the class JFXTextAreaSkinAndroid method createFloatingLabel.

private void createFloatingLabel() {
    if (((JFXTextArea) getSkinnable()).isLabelFloat()) {
        if (promptText == null) {
            // get the prompt text node or create it
            boolean triggerFloatLabel = false;
            if (((Region) scrollPane.getContent()).getChildrenUnmodifiable().get(0) instanceof Text)
                promptText = (Text) ((Region) scrollPane.getContent()).getChildrenUnmodifiable().get(0);
            else {
                Field field;
                try {
                    field = TextAreaSkin.class.getDeclaredField("promptNode");
                    field.setAccessible(true);
                    createPromptNode();
                    field.set(this, promptText);
                    // position the prompt node in its position
                    triggerFloatLabel = true;
                    oldPromptTextFill = promptTextFill.get();
                } catch (NoSuchFieldException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (SecurityException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalArgumentException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            // fixed issue text area is being resized when the content is excedeing its width
            promptText.wrappingWidthProperty().addListener((o, oldval, newVal) -> {
                if (newVal.doubleValue() > getSkinnable().getWidth())
                    promptText.setWrappingWidth(getSkinnable().getWidth());
            });
            promptText.getTransforms().add(promptTextScale);
            promptContainer.getChildren().add(promptText);
            if (triggerFloatLabel) {
                promptText.setTranslateY(-promptText.getBoundsInLocal().getHeight() - 2);
                promptTextScale.setX(0.85);
                promptTextScale.setY(0.85);
            }
        }
        // create prompt animations
        promptTextUpTransition = new CachedTransition(promptContainer, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptText.translateYProperty(), -promptText.getLayoutBounds().getHeight() - 2, Interpolator.EASE_BOTH), new KeyValue(promptTextScale.xProperty(), 0.85, Interpolator.EASE_BOTH), new KeyValue(promptTextScale.yProperty(), 0.85, Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(240));
            }
        };
        promptTextColorTransition = new CachedTransition(promptContainer, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptTextFill, ((JFXTextArea) getSkinnable()).getFocusColor(), Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(160));
            }

            protected void starting() {
                super.starting();
                oldPromptTextFill = promptTextFill.get();
            }

            ;
        };
        promptTextDownTransition = new CachedTransition(promptContainer, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptText.translateYProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(promptTextScale.xProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(promptTextScale.yProperty(), 1, Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(240));
            }
        };
        promptTextDownTransition.setOnFinished((finish) -> {
            promptText.setTranslateY(0);
            promptTextScale.setX(1);
            promptTextScale.setY(1);
        });
        promptText.visibleProperty().unbind();
        promptText.visibleProperty().set(true);
    }
}
Also used : JFXTextArea(com.jfoenix.controls.JFXTextArea) TextAreaSkin(com.sun.javafx.scene.control.skin.TextAreaSkin) Text(javafx.scene.text.Text) Field(java.lang.reflect.Field) CachedTransition(com.jfoenix.transitions.CachedTransition)

Example 3 with Text

use of javafx.scene.text.Text in project JFoenix by jfoenixadmin.

the class JFXTextFieldSkinAndroid method createFloatingLabel.

private void createFloatingLabel() {
    if (((JFXTextField) getSkinnable()).isLabelFloat()) {
        if (promptText == null) {
            // get the prompt text node or create it
            boolean triggerFloatLabel = false;
            if (textPane.getChildren().get(0) instanceof Text)
                promptText = (Text) textPane.getChildren().get(0);
            else {
                Field field;
                try {
                    field = TextFieldSkin.class.getDeclaredField("promptNode");
                    field.setAccessible(true);
                    createPromptNode();
                    field.set(this, promptText);
                    // position the prompt node in its position
                    triggerFloatLabel = true;
                } catch (NoSuchFieldException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (SecurityException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalArgumentException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            promptText.getTransforms().add(promptTextScale);
            promptContainer.getChildren().add(promptText);
            if (triggerFloatLabel) {
                promptText.setTranslateY(-textPane.getHeight());
                promptTextScale.setX(0.85);
                promptTextScale.setY(0.85);
            }
        }
        promptTextUpTransition = new CachedTransition(textPane, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptText.translateYProperty(), -textPane.getHeight(), Interpolator.EASE_BOTH), new KeyValue(promptTextScale.xProperty(), 0.85, Interpolator.EASE_BOTH), new KeyValue(promptTextScale.yProperty(), 0.85, Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(240));
            }
        };
        promptTextColorTransition = new CachedTransition(textPane, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptTextFill, ((JFXTextField) getSkinnable()).getFocusColor(), Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(160));
            }

            protected void starting() {
                super.starting();
                oldPromptTextFill = promptTextFill.get();
            }

            ;
        };
        promptTextDownTransition = new CachedTransition(textPane, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptText.translateYProperty(), 0, Interpolator.EASE_BOTH), new KeyValue(promptTextScale.xProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(promptTextScale.yProperty(), 1, Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(240));
            }
        };
        promptTextDownTransition.setOnFinished((finish) -> {
            promptText.setTranslateY(0);
            promptTextScale.setX(1);
            promptTextScale.setY(1);
        });
        promptText.visibleProperty().unbind();
        promptText.visibleProperty().set(true);
    }
}
Also used : JFXTextFieldSkin(com.jfoenix.skins.JFXTextFieldSkin) TextFieldSkin(com.sun.javafx.scene.control.skin.TextFieldSkin) JFXTextField(com.jfoenix.controls.JFXTextField) Text(javafx.scene.text.Text) Field(java.lang.reflect.Field) JFXTextField(com.jfoenix.controls.JFXTextField) CachedTransition(com.jfoenix.transitions.CachedTransition)

Example 4 with Text

use of javafx.scene.text.Text in project JFoenix by jfoenixadmin.

the class JFXSliderSkinOLD method initialize.

private void initialize() {
    isHorizontal = getSkinnable().getOrientation() == Orientation.HORIZONTAL;
    thumb = new Circle();
    thumb.setStrokeWidth(2);
    thumb.setRadius(7);
    thumb.setFill(thumbColor);
    thumb.setStroke(thumbColor);
    thumb.getStyleClass().setAll("thumb");
    track = new Line();
    track.setStroke(trackColor);
    track.setStrokeWidth(3);
    track.getStyleClass().setAll("track");
    coloredTrack = new Line();
    coloredTrack.strokeProperty().bind(thumb.strokeProperty());
    coloredTrack.strokeWidthProperty().bind(track.strokeWidthProperty());
    sliderValue = new Text();
    sliderValue.setStroke(Color.WHITE);
    sliderValue.setFont(new Font(10));
    sliderValue.getStyleClass().setAll("sliderValue");
    animatedThumb = new StackPane();
    animatedThumb.getChildren().add(sliderValue);
    getChildren().clear();
    getChildren().addAll(track, coloredTrack, animatedThumb, thumb);
}
Also used : Line(javafx.scene.shape.Line) Circle(javafx.scene.shape.Circle) Text(javafx.scene.text.Text) Font(javafx.scene.text.Font) StackPane(javafx.scene.layout.StackPane)

Example 5 with Text

use of javafx.scene.text.Text in project JFoenix by jfoenixadmin.

the class JFXTextAreaOldSkin method createFloatingLabel.

private void createFloatingLabel() {
    if (((JFXTextArea) getSkinnable()).isLabelFloat()) {
        if (promptText == null) {
            // get the prompt text node or create it
            boolean triggerFloatLabel = false;
            if (((Region) scrollPane.getContent()).getChildrenUnmodifiable().get(0) instanceof Text)
                promptText = (Text) ((Region) scrollPane.getContent()).getChildrenUnmodifiable().get(0);
            else {
                Field field;
                try {
                    field = TextAreaSkin.class.getDeclaredField("promptNode");
                    field.setAccessible(true);
                    createPromptNode();
                    field.set(this, promptText);
                    // position the prompt node in its position
                    triggerFloatLabel = true;
                    oldPromptTextFill = promptTextFill.get();
                } catch (NoSuchFieldException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (SecurityException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalArgumentException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            promptTextGroup = new Group(promptText);
            promptContainer.getChildren().add(promptTextGroup);
            StackPane.setAlignment(promptTextGroup, Pos.TOP_LEFT);
            // MUST KEEP: having transparent border fix the blurring effect on focus
            promptContainer.setStyle("-fx-border-color:TRANSPARENT");
            if (triggerFloatLabel) {
                promptContainer.setTranslateY(-promptText.getLayoutBounds().getHeight() - 5);
                promptText.setScaleX(0.85);
                promptText.setScaleY(0.85);
            }
        }
        // create prompt animations
        promptTextUpTransition = new CachedTransition(promptContainer, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptContainer.translateYProperty(), -promptText.getLayoutBounds().getHeight() - 5, Interpolator.EASE_BOTH), //								new KeyValue(promptText.translateXProperty(), - promptText.getLayoutBounds().getWidth()*0.15/2, Interpolator.EASE_BOTH),
        new KeyValue(promptText.scaleXProperty(), 0.85, Interpolator.EASE_BOTH), new KeyValue(promptText.scaleYProperty(), 0.85, Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(300));
            }
        };
        promptTextColorTransition = new CachedTransition(promptContainer, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptTextFill, focusedLine.getStroke(), Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(300));
            }

            protected void starting() {
                super.starting();
                oldPromptTextFill = promptTextFill.get();
            }

            ;
        };
        promptTextDownTransition = new CachedTransition(promptContainer, new Timeline(new KeyFrame(Duration.millis(1300), new KeyValue(promptContainer.translateYProperty(), 0, Interpolator.EASE_BOTH), //										new KeyValue(promptText.translateXProperty(), 0, Interpolator.EASE_BOTH),
        new KeyValue(promptText.scaleXProperty(), 1, Interpolator.EASE_BOTH), new KeyValue(promptText.scaleYProperty(), 1, Interpolator.EASE_BOTH)))) {

            {
                setDelay(Duration.millis(0));
                setCycleDuration(Duration.millis(300));
            }
        };
        promptTextDownTransition.setOnFinished((finish) -> {
            promptContainer.setTranslateY(0);
            promptText.setScaleX(1);
            promptText.setScaleY(1);
        });
        promptText.visibleProperty().unbind();
        promptText.visibleProperty().set(true);
    }
}
Also used : JFXTextArea(com.jfoenix.controls.JFXTextArea) Group(javafx.scene.Group) TextAreaSkin(com.sun.javafx.scene.control.skin.TextAreaSkin) Text(javafx.scene.text.Text) Field(java.lang.reflect.Field) CachedTransition(com.jfoenix.transitions.CachedTransition)

Aggregations

Text (javafx.scene.text.Text)324 VBox (javafx.scene.layout.VBox)55 TextFlow (javafx.scene.text.TextFlow)55 Label (javafx.scene.control.Label)51 Pane (javafx.scene.layout.Pane)34 Font (javafx.scene.text.Font)30 Region (javafx.scene.layout.Region)26 Button (javafx.scene.control.Button)25 Color (javafx.scene.paint.Color)24 Rectangle (javafx.scene.shape.Rectangle)24 Group (javafx.scene.Group)23 GridPane (javafx.scene.layout.GridPane)23 List (java.util.List)22 HBox (javafx.scene.layout.HBox)22 StackPane (javafx.scene.layout.StackPane)21 Insets (javafx.geometry.Insets)18 Scene (javafx.scene.Scene)18 Canvas (javafx.scene.canvas.Canvas)17 Circle (javafx.scene.shape.Circle)17 TextWithStyle (org.phoenicis.javafx.views.common.TextWithStyle)17