Search in sources :

Example 36 with Label

use of javafx.scene.control.Label in project Gargoyle by callakrsos.

the class SkinPreviewViewComposite method previewTabInit.

@FxPostInitialize
public void previewTabInit() {
    Task<Void> task = new Task<Void>() {

        @Override
        protected Void call() throws Exception {
            Thread.sleep(5000L);
            Platform.runLater(() -> {
                //메뉴바 배경.
                {
                    Background background = mbSample.getBackground();
                    Color fill = (Color) background.getFills().get(0).getFill();
                    colorMbSample.setValue(fill);
                    //메뉴바 텍스트
                    {
                        Label lookup = (Label) mbSample.lookup(".label");
                        Color textFill = (Color) lookup.getTextFill();
                        colorMbLabelSample.setValue(textFill);
                    }
                }
                //Hbox 배경.
                {
                    Background background = hboxSample.getBackground();
                    Color fill = (Color) background.getFills().get(0).getFill();
                    colorHboxSample.setValue(fill);
                }
                {
                    //선택디지않는 탭 색상 처리.
                    Set<Node> lookupAll = tabpaneSample.lookupAll(".tab:top");
                    lookupAll.forEach(lookup -> {
                        Optional<PseudoClass> findFirst = lookup.getPseudoClassStates().stream().filter(v -> {
                            return "selected".equals(v.getPseudoClassName());
                        }).findFirst();
                        if (findFirst.isPresent()) {
                            Label selectedTabLabel = (Label) lookup.lookup(".tab-label");
                            Color textFill = (Color) selectedTabLabel.getTextFill();
                            colorSelectedTabText.setValue(textFill);
                        } else {
                            Label selectedTabLabel = (Label) lookup.lookup(".tab-label");
                            Color textFill = (Color) selectedTabLabel.getTextFill();
                            colorUnSelectedTabText.setValue(textFill);
                        }
                    });
                    {
                        lookupAll.stream().findFirst().ifPresent(n -> {
                            Pane p = (Pane) n;
                            Background background = p.getBackground();
                            Color fill = (Color) background.getFills().get(0).getFill();
                            colorTabSample1Selected.setValue(fill);
                        });
                    }
                }
            });
            return null;
        }
    };
    Window window = this.getScene().getWindow();
    if (window != null) {
        FxUtil.showLoading(window, task);
    } else
        FxUtil.showLoading(task);
}
Also used : Button(javafx.scene.control.Button) TextArea(javafx.scene.control.TextArea) PseudoClass(javafx.css.PseudoClass) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) LoggerFactory(org.slf4j.LoggerFactory) HashMap(java.util.HashMap) DialogUtil(com.kyj.fx.voeditor.visual.util.DialogUtil) TableColumn(javafx.scene.control.TableColumn) Task(javafx.concurrent.Task) TabPane(javafx.scene.control.TabPane) Map(java.util.Map) FileUtil(com.kyj.fx.voeditor.visual.util.FileUtil) TableView(javafx.scene.control.TableView) Pane(javafx.scene.layout.Pane) ColorPicker(javafx.scene.control.ColorPicker) HBox(javafx.scene.layout.HBox) Color(javafx.scene.paint.Color) Pair(javafx.util.Pair) Logger(org.slf4j.Logger) Label(javafx.scene.control.Label) MenuBar(javafx.scene.control.MenuBar) Node(javafx.scene.Node) FXMLController(com.kyj.fx.voeditor.visual.framework.annotation.FXMLController) Set(java.util.Set) IOException(java.io.IOException) ValueUtil(com.kyj.fx.voeditor.visual.util.ValueUtil) JFXToggleButton(com.jfoenix.controls.JFXToggleButton) Background(javafx.scene.layout.Background) File(java.io.File) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) FxUtil(com.kyj.fx.voeditor.visual.util.FxUtil) List(java.util.List) Stage(javafx.stage.Stage) Optional(java.util.Optional) Window(javafx.stage.Window) SkinManager(com.kyj.fx.voeditor.visual.momory.SkinManager) ObservableList(javafx.collections.ObservableList) BorderPane(javafx.scene.layout.BorderPane) StringProperty(javafx.beans.property.StringProperty) Window(javafx.stage.Window) Task(javafx.concurrent.Task) Set(java.util.Set) Background(javafx.scene.layout.Background) Optional(java.util.Optional) Color(javafx.scene.paint.Color) Label(javafx.scene.control.Label) TabPane(javafx.scene.control.TabPane) Pane(javafx.scene.layout.Pane) BorderPane(javafx.scene.layout.BorderPane) FxPostInitialize(com.kyj.fx.voeditor.visual.framework.annotation.FxPostInitialize)

Example 37 with Label

use of javafx.scene.control.Label in project Gargoyle by callakrsos.

the class DockTabPaneSkin method clone.

/**
	 * VERY HACKY - this lets us 'duplicate' Label and ImageView nodes to be used in a
	 * Tab and the tabs menu at the same time.
	 */
private static Node clone(Node n) {
    if (n == null) {
        return null;
    }
    if (n instanceof ImageView) {
        ImageView iv = (ImageView) n;
        ImageView imageview = new ImageView();
        imageview.setImage(iv.getImage());
        return imageview;
    }
    if (n instanceof Label) {
        Label l = (Label) n;
        Label label = new Label(l.getText(), l.getGraphic());
        return label;
    }
    return null;
}
Also used : Label(javafx.scene.control.Label) ImageView(javafx.scene.image.ImageView)

Example 38 with Label

use of javafx.scene.control.Label in project Gargoyle by callakrsos.

the class Clock method start.

public void start(final Stage stage) throws Exception {
    // construct the analogueClock pieces.
    final Circle face = new Circle(100, 100, 100);
    face.setId("face");
    final Label brand = new Label("Splotch");
    brand.setId("brand");
    brand.layoutXProperty().bind(face.centerXProperty().subtract(brand.widthProperty().divide(2)));
    brand.layoutYProperty().bind(face.centerYProperty().add(face.radiusProperty().divide(2)));
    final Line hourHand = new Line(0, 0, 0, -50);
    hourHand.setTranslateX(100);
    hourHand.setTranslateY(100);
    hourHand.setId("hourHand");
    final Line minuteHand = new Line(0, 0, 0, -75);
    minuteHand.setTranslateX(100);
    minuteHand.setTranslateY(100);
    minuteHand.setId("minuteHand");
    final Line secondHand = new Line(0, 15, 0, -88);
    secondHand.setTranslateX(100);
    secondHand.setTranslateY(100);
    secondHand.setId("secondHand");
    final Circle spindle = new Circle(100, 100, 5);
    spindle.setId("spindle");
    Group ticks = new Group();
    for (int i = 0; i < 12; i++) {
        Line tick = new Line(0, -83, 0, -93);
        tick.setTranslateX(100);
        tick.setTranslateY(100);
        tick.getStyleClass().add("tick");
        tick.getTransforms().add(new Rotate(i * (360 / 12)));
        ticks.getChildren().add(tick);
    }
    final Group analogueClock = new Group(face, brand, ticks, spindle, hourHand, minuteHand, secondHand);
    // construct the digitalClock pieces.
    final Label digitalClock = new Label();
    digitalClock.setId("digitalClock");
    // determine the starting time.
    Calendar calendar = GregorianCalendar.getInstance();
    final double seedSecondDegrees = calendar.get(Calendar.SECOND) * (360 / 60);
    final double seedMinuteDegrees = (calendar.get(Calendar.MINUTE) + seedSecondDegrees / 360.0) * (360 / 60);
    final double seedHourDegrees = (calendar.get(Calendar.HOUR) + seedMinuteDegrees / 360.0) * (360 / 12);
    // define rotations to map the analogueClock to the current time.
    final Rotate hourRotate = new Rotate(seedHourDegrees);
    final Rotate minuteRotate = new Rotate(seedMinuteDegrees);
    final Rotate secondRotate = new Rotate(seedSecondDegrees);
    hourHand.getTransforms().add(hourRotate);
    minuteHand.getTransforms().add(minuteRotate);
    secondHand.getTransforms().add(secondRotate);
    // the hour hand rotates twice a day.
    final Timeline hourTime = new Timeline(new KeyFrame(Duration.hours(12), new KeyValue(hourRotate.angleProperty(), 360 + seedHourDegrees, Interpolator.LINEAR)));
    // the minute hand rotates once an hour.
    final Timeline minuteTime = new Timeline(new KeyFrame(Duration.minutes(60), new KeyValue(minuteRotate.angleProperty(), 360 + seedMinuteDegrees, Interpolator.LINEAR)));
    // move second hand rotates once a minute.
    final Timeline secondTime = new Timeline(new KeyFrame(Duration.seconds(60), new KeyValue(secondRotate.angleProperty(), 360 + seedSecondDegrees, Interpolator.LINEAR)));
    // the digital clock updates once a second.
    final Timeline digitalTime = new Timeline(new KeyFrame(Duration.seconds(0), new EventHandler<ActionEvent>() {

        @Override
        public void handle(ActionEvent actionEvent) {
            Calendar calendar = GregorianCalendar.getInstance();
            String hourString = pad(2, '0', calendar.get(Calendar.HOUR) == 0 ? "12" : calendar.get(Calendar.HOUR) + "");
            String minuteString = pad(2, '0', calendar.get(Calendar.MINUTE) + "");
            String secondString = pad(2, '0', calendar.get(Calendar.SECOND) + "");
            String ampmString = calendar.get(Calendar.AM_PM) == Calendar.AM ? "AM" : "PM";
            digitalClock.setText(hourString + ":" + minuteString + ":" + secondString + " " + ampmString);
        }
    }), new KeyFrame(Duration.seconds(1)));
    // time never ends.
    hourTime.setCycleCount(Animation.INDEFINITE);
    minuteTime.setCycleCount(Animation.INDEFINITE);
    secondTime.setCycleCount(Animation.INDEFINITE);
    digitalTime.setCycleCount(Animation.INDEFINITE);
    // start the analogueClock.
    digitalTime.play();
    secondTime.play();
    minuteTime.play();
    hourTime.play();
    stage.initStyle(StageStyle.TRANSPARENT);
    // add a glow effect whenever the mouse is positioned over the clock.
    final Glow glow = new Glow();
    analogueClock.setOnMouseEntered(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent mouseEvent) {
            analogueClock.setEffect(glow);
        }
    });
    analogueClock.setOnMouseExited(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent mouseEvent) {
            analogueClock.setEffect(null);
        }
    });
    // fade out the scene and shut it down when the mouse is clicked on the
    // clock.
    analogueClock.setOnMouseClicked(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent mouseEvent) {
            analogueClock.setMouseTransparent(true);
            FadeTransition fade = new FadeTransition(Duration.seconds(1.2), analogueClock);
            fade.setOnFinished(new EventHandler<ActionEvent>() {

                @Override
                public void handle(ActionEvent actionEvent) {
                    stage.close();
                }
            });
            fade.setFromValue(1);
            fade.setToValue(0);
            fade.play();
        }
    });
    // layout the scene.
    final VBox layout = new VBox();
    layout.getChildren().addAll(analogueClock, digitalClock);
    layout.setAlignment(Pos.CENTER);
    final Scene scene = new Scene(layout, Color.TRANSPARENT);
    scene.getStylesheets().add(getResource("clock.css"));
    stage.setScene(scene);
    // allow the clock background to be used to drag the clock around.
    final Delta dragDelta = new Delta();
    layout.setOnMousePressed(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent mouseEvent) {
            // record a delta distance for the drag and drop operation.
            dragDelta.x = stage.getX() - mouseEvent.getScreenX();
            dragDelta.y = stage.getY() - mouseEvent.getScreenY();
            scene.setCursor(Cursor.MOVE);
        }
    });
    layout.setOnMouseReleased(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent mouseEvent) {
            scene.setCursor(Cursor.HAND);
        }
    });
    layout.setOnMouseDragged(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent mouseEvent) {
            stage.setX(mouseEvent.getScreenX() + dragDelta.x);
            stage.setY(mouseEvent.getScreenY() + dragDelta.y);
        }
    });
    layout.setOnMouseEntered(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent mouseEvent) {
            if (!mouseEvent.isPrimaryButtonDown()) {
                scene.setCursor(Cursor.HAND);
            }
        }
    });
    layout.setOnMouseExited(new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent mouseEvent) {
            if (!mouseEvent.isPrimaryButtonDown()) {
                scene.setCursor(Cursor.DEFAULT);
            }
        }
    });
    // show the scene.
    stage.show();
}
Also used : MouseEvent(javafx.scene.input.MouseEvent) Rotate(javafx.scene.transform.Rotate) Label(javafx.scene.control.Label) Glow(javafx.scene.effect.Glow) VBox(javafx.scene.layout.VBox)

Example 39 with Label

use of javafx.scene.control.Label in project Gargoyle by callakrsos.

the class DockPaneExam method start.

/* (non-Javadoc)
	 * @see javafx.application.Application#start(javafx.stage.Stage)
	 */
@Override
public void start(Stage primaryStage) throws Exception {
    DockNode dockNode = new DockNode(new BorderPane(new Label("Master")), "hello m");
    DockNode dockNode2 = new DockNode(new BorderPane(new Label("Slave")), "hello s");
    //		SplitPane root = new SplitPane();
    DockPane dockPane = new DockPane();
    dockNode2.dock(dockPane, DockPos.CENTER);
    dockNode.dock(dockPane, DockPos.LEFT);
    //		root.getItems().add(dockPane);
    Application.setUserAgentStylesheet(Application.STYLESHEET_MODENA);
    DockPane.initializeDefaultUserAgentStylesheet();
    primaryStage.setScene(new Scene(dockPane));
    primaryStage.show();
}
Also used : BorderPane(javafx.scene.layout.BorderPane) DockPane(com.kyj.fx.voeditor.visual.component.dock.pane.DockPane) Label(javafx.scene.control.Label) DockNode(com.kyj.fx.voeditor.visual.component.dock.pane.DockNode) Scene(javafx.scene.Scene)

Example 40 with Label

use of javafx.scene.control.Label in project Gargoyle by callakrsos.

the class DockTabPaneExam method start.

/* (non-Javadoc)
	 * @see javafx.application.Application#start(javafx.stage.Stage)
	 */
@Override
public void start(Stage primaryStage) throws Exception {
    DockTabPane dockTabPane = new DockTabPane();
    dockTabPane.setSide(Side.LEFT);
    {
        DockTab e = new DockTab("Hello1");
        e.setContent(new Label("Hello world!1"));
        dockTabPane.getTabs().add(e);
    }
    {
        DockTab e = new DockTab("Hello2");
        e.setContent(new Label("Hello world!2"));
        dockTabPane.getTabs().add(e);
    }
    {
        DockTab e = new DockTab("Hello3");
        e.setContent(new Label("Hello world!3"));
        dockTabPane.getTabs().add(e);
    }
    DockPane.initializeDefaultUserAgentStylesheet();
    primaryStage.setScene(new Scene(dockTabPane));
    primaryStage.show();
}
Also used : DockTabPane(com.kyj.fx.voeditor.visual.component.dock.tab.DockTabPane) DockTab(com.kyj.fx.voeditor.visual.component.dock.tab.DockTab) Label(javafx.scene.control.Label) Scene(javafx.scene.Scene)

Aggregations

Label (javafx.scene.control.Label)148 Insets (javafx.geometry.Insets)51 Button (javafx.scene.control.Button)42 Scene (javafx.scene.Scene)31 HBox (javafx.scene.layout.HBox)27 VBox (javafx.scene.layout.VBox)27 TextField (javafx.scene.control.TextField)23 GridPane (javafx.scene.layout.GridPane)23 BorderPane (javafx.scene.layout.BorderPane)19 Node (javafx.scene.Node)17 Stage (javafx.stage.Stage)14 ArrayList (java.util.ArrayList)13 ImageView (javafx.scene.image.ImageView)13 List (java.util.List)12 InputTextField (io.bitsquare.gui.components.InputTextField)11 Tooltip (javafx.scene.control.Tooltip)11 ActionEvent (javafx.event.ActionEvent)10 Image (javafx.scene.image.Image)10 StackPane (javafx.scene.layout.StackPane)10 Map (java.util.Map)9