Search in sources :

Example 1 with Region

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

the class JFXNodesList method addAnimatedNode.

/**
	 * add node to list with a specified callback that is triggered after the node animation is finished. 
	 * Note: this method must be called instead of getChildren().add().
	 * 
	 * @param node
	 */
public void addAnimatedNode(Region node, Callback<Boolean, ArrayList<KeyValue>> animationCallBack) {
    // create container for the node if it's a sub nodes list
    if (node instanceof JFXNodesList) {
        StackPane container = new StackPane(node);
        container.setPickOnBounds(false);
        addAnimatedNode(container, animationCallBack);
        return;
    }
    // init node property
    node.setVisible(false);
    node.minWidthProperty().bind(node.prefWidthProperty());
    node.minHeightProperty().bind(node.prefHeightProperty());
    if (this.getChildren().size() > 0)
        initNode(node);
    else {
        if (node instanceof Button)
            ((Button) node).setOnAction((action) -> this.animateList());
        else
            node.setOnMouseClicked((click) -> this.animateList());
        node.getStyleClass().add("trigger-node");
    }
    // init the list height and width
    if (this.getChildren().size() == 0) {
        node.setVisible(true);
        this.minHeightProperty().bind(node.prefHeightProperty());
        this.maxHeightProperty().bind(node.prefHeightProperty());
        this.minWidthProperty().bind(node.prefWidthProperty());
        this.maxWidthProperty().bind(node.prefWidthProperty());
    }
    // add the node and its listeners
    this.getChildren().add(node);
    this.rotateProperty().addListener((o, oldVal, newVal) -> node.setRotate(newVal.doubleValue() % 180 == 0 ? newVal.doubleValue() : -newVal.doubleValue()));
    if (animationCallBack == null && this.getChildren().size() != 1)
        animationCallBack = (expanded) -> {
            return initDefaultAnimation(node, expanded);
        };
    else if (animationCallBack == null && this.getChildren().size() == 1)
        animationCallBack = (expanded) -> {
            return new ArrayList<KeyValue>();
        };
    animationsMap.put(node, animationCallBack);
}
Also used : Button(javafx.scene.control.Button) KeyFrame(javafx.animation.KeyFrame) Status(javafx.animation.Animation.Status) Node(javafx.scene.Node) Timeline(javafx.animation.Timeline) StackPane(javafx.scene.layout.StackPane) HashMap(java.util.HashMap) VBox(javafx.scene.layout.VBox) ArrayList(java.util.ArrayList) Duration(javafx.util.Duration) Region(javafx.scene.layout.Region) Interpolator(javafx.animation.Interpolator) KeyValue(javafx.animation.KeyValue) Callback(javafx.util.Callback) Button(javafx.scene.control.Button) ArrayList(java.util.ArrayList) StackPane(javafx.scene.layout.StackPane)

Example 2 with Region

use of javafx.scene.layout.Region in project fxexperience2 by EricCanull.

the class StylerController method initialize.

@Override
public void initialize(URL url, ResourceBundle rb) {
    try {
        previewPanel = FXMLLoader.load(PreviewPanelController.class.getResource(AppPaths.FXML_PATH + "FXMLPreviewPanel.fxml"));
        previewPane.setCenter(previewPanel);
    } catch (IOException ex) {
        Logger.getLogger(StylerController.class.getName()).log(Level.SEVERE, null, ex);
    }
    // populate fonts choicebox
    fontChoiceBox.getItems().setAll(Font.getFamilies());
    fontChoiceBox.getSelectionModel().select("System");
    // create listener to call update css
    ChangeListener<Object> updateCssListener = (ObservableValue<?> arg0, Object arg1, Object arg2) -> {
        updateCss();
    };
    // add listeners to call update css
    fontChoiceBox.valueProperty().addListener(updateCssListener);
    fontSizeSlider.valueProperty().addListener(updateCssListener);
    paddingSlider.valueProperty().addListener(updateCssListener);
    borderRadiusSlider.valueProperty().addListener(updateCssListener);
    borderWidthSlider.valueProperty().addListener(updateCssListener);
    // create Integer Fields
    createNumberFieldForSlider(fontSizeSlider, textGridPanel, 2, 1);
    createNumberFieldForSlider(paddingSlider, sizeGridPanel, 2, 0);
    createNumberFieldForSlider(borderWidthSlider, sizeGridPanel, 2, 1);
    createNumberFieldForSlider(borderRadiusSlider, sizeGridPanel, 2, 2);
    // Add color pickers Title Pane
    simpleGridPane.getChildren().addAll(basePicker, backgroundColorPicker, focusColorPicker, textColorPicker, fieldBackgroundPicker, fieldTextColorPicker, bkgdTextColorPicker);
    // Set color pickers grid constraints
    GridPane.setConstraints(basePicker, 1, 0, 2, 1);
    GridPane.setConstraints(textColorPicker, 1, 1);
    GridPane.setConstraints(backgroundColorPicker, 1, 2);
    GridPane.setConstraints(bkgdTextColorPicker, 1, 3);
    GridPane.setConstraints(fieldBackgroundPicker, 1, 4);
    GridPane.setConstraints(fieldTextColorPicker, 1, 5);
    GridPane.setConstraints(focusColorPicker, 1, 6);
    basePicker.colorProperty().addListener(updateCssListener);
    backgroundColorPicker.colorProperty().addListener(updateCssListener);
    focusColorPicker.colorProperty().addListener(updateCssListener);
    textColorPicker.colorProperty().addListener(updateCssListener);
    baseTextToggle.selectedProperty().addListener(updateCssListener);
    textColorPicker.disableProperty().bind(baseTextToggle.selectedProperty().not());
    fieldBackgroundPicker.colorProperty().addListener(updateCssListener);
    fieldTextColorPicker.colorProperty().addListener(updateCssListener);
    fieldTextToggle.selectedProperty().addListener(updateCssListener);
    fieldTextColorPicker.disableProperty().bind(fieldTextToggle.selectedProperty().not());
    bkgdTextColorPicker.colorProperty().addListener(updateCssListener);
    backgroundTextToggle.selectedProperty().addListener(updateCssListener);
    bkgdTextColorPicker.disableProperty().bind(backgroundTextToggle.selectedProperty().not());
    // add listeners to sliders
    topHighlightSlider.valueProperty().addListener(updateCssListener);
    bottomHighlightSlider.valueProperty().addListener(updateCssListener);
    // Populate gradient combo
    gradientComboBox.getItems().addAll(Gradient.GRADIENTS);
    gradientComboBox.setCellFactory((ListView<Gradient> gradientList) -> {
        ListCell<Gradient> cell = new ListCell<Gradient>() {

            @Override
            protected void updateItem(Gradient gradient, boolean empty) {
                super.updateItem(gradient, empty);
                if (empty || gradient == null) {
                    setText(null);
                    setGraphic(null);
                } else {
                    setText(gradient.getName());
                    Region preview = new Region();
                    preview.setPrefSize(30, 30);
                    preview.setStyle("-fx-border-color: #111; -fx-background-color: " + gradient.getCss());
                    setGraphic(preview);
                }
            }
        };
        cell.setStyle("-fx-cell-size: 40;");
        return cell;
    });
    gradientComboBox.getSelectionModel().selectedItemProperty().addListener((ObservableValue<? extends Gradient> arg0, Gradient arg1, Gradient newGradient) -> {
        bodyTopSlider.setValue(newGradient.getTopDerivation());
        bodyBottomSlider.setValue(newGradient.getBottomDerivation());
        if (newGradient.isShinny()) {
            topMiddleToggle.setSelected(true);
            bottomMiddleToggle.setSelected(true);
            bodyTopMiddleSlider.setValue(newGradient.getTopMidDerivation());
            bodyBottomMiddleSlider.setValue(newGradient.getBottomMidDerivation());
        } else {
            topMiddleToggle.setSelected(false);
            bottomMiddleToggle.setSelected(false);
        }
        updateCss();
    });
    gradientComboBox.getSelectionModel().select(0);
    // Advanced toggle buttons
    topMiddleToggle.selectedProperty().addListener(updateCssListener);
    bottomMiddleToggle.selectedProperty().addListener(updateCssListener);
    borderToggle.selectedProperty().addListener(updateCssListener);
    shadowToggle.selectedProperty().addListener(updateCssListener);
    inputBorderToggle.selectedProperty().addListener(updateCssListener);
    bodyTopSlider.valueProperty().addListener(updateCssListener);
    bodyTopMiddleSlider.valueProperty().addListener(updateCssListener);
    bodyBottomMiddleSlider.valueProperty().addListener(updateCssListener);
    bodyBottomSlider.valueProperty().addListener(updateCssListener);
    borderSlider.valueProperty().addListener(updateCssListener);
    shadowSlider.valueProperty().addListener(updateCssListener);
    inputBorderSlider.valueProperty().addListener(updateCssListener);
    bodyTopMiddleSlider.disableProperty().bind(topMiddleToggle.selectedProperty().not());
    bodyBottomMiddleSlider.disableProperty().bind(bottomMiddleToggle.selectedProperty().not());
    borderSlider.disableProperty().bind(borderToggle.selectedProperty().not());
    shadowSlider.disableProperty().bind(shadowToggle.selectedProperty().not());
    inputBorderSlider.disableProperty().bind(inputBorderToggle.selectedProperty().not());
}
Also used : Gradient(com.fxexperience.tools.util.Gradient) ObservableValue(javafx.beans.value.ObservableValue) Region(javafx.scene.layout.Region)

Example 3 with Region

use of javafx.scene.layout.Region in project POL-POM-5 by PlayOnLinux.

the class WinePrefixContainerDisplayTab method populate.

private void populate() {
    final VBox displayPane = new VBox();
    final Text title = new TextWithStyle(tr("Display settings"), TITLE_CSS_CLASS);
    displayPane.getStyleClass().add(CONFIGURATION_PANE_CSS_CLASS);
    displayPane.getChildren().add(title);
    final GridPane displayContentPane = new GridPane();
    displayContentPane.getStyleClass().add("grid");
    final ComboBox<UseGLSL> glslComboBox = new ComboBox<>();
    glslComboBox.setMaxWidth(Double.MAX_VALUE);
    glslComboBox.setValue(container.getUseGlslValue());
    glslComboBox.valueProperty().addListener((observable, oldValue, newValue) -> this.changeSettings(newValue));
    addItems(glslComboBox, UseGLSL.class);
    displayContentPane.add(new TextWithStyle(tr("GLSL support"), CAPTION_TITLE_CSS_CLASS), 0, 0);
    displayContentPane.add(glslComboBox, 1, 0);
    final ComboBox<DirectDrawRenderer> directDrawRendererComboBox = new ComboBox<>();
    directDrawRendererComboBox.setMaxWidth(Double.MAX_VALUE);
    directDrawRendererComboBox.setValue(container.getDirectDrawRenderer());
    directDrawRendererComboBox.valueProperty().addListener((observable, oldValue, newValue) -> this.changeSettings(newValue));
    addItems(directDrawRendererComboBox, DirectDrawRenderer.class);
    displayContentPane.add(new TextWithStyle(tr("Direct Draw Renderer"), CAPTION_TITLE_CSS_CLASS), 0, 1);
    displayContentPane.add(directDrawRendererComboBox, 1, 1);
    final ComboBox<VideoMemorySize> videoMemorySizeComboBox = new ComboBox<>();
    videoMemorySizeComboBox.setMaxWidth(Double.MAX_VALUE);
    videoMemorySizeComboBox.setValue(container.getVideoMemorySize());
    videoMemorySizeComboBox.valueProperty().addListener((observable, oldValue, newValue) -> this.changeSettings(newValue));
    addItemsVideoMemorySize(videoMemorySizeComboBox);
    displayContentPane.add(new TextWithStyle(tr("Video memory size"), CAPTION_TITLE_CSS_CLASS), 0, 2);
    displayContentPane.add(videoMemorySizeComboBox, 1, 2);
    final ComboBox<OffscreenRenderingMode> offscreenRenderingModeComboBox = new ComboBox<>();
    offscreenRenderingModeComboBox.setMaxWidth(Double.MAX_VALUE);
    offscreenRenderingModeComboBox.setValue(container.getOffscreenRenderingMode());
    offscreenRenderingModeComboBox.valueProperty().addListener((observable, oldValue, newValue) -> this.changeSettings(newValue));
    addItems(offscreenRenderingModeComboBox, OffscreenRenderingMode.class);
    displayContentPane.add(new TextWithStyle(tr("Offscreen rendering mode"), CAPTION_TITLE_CSS_CLASS), 0, 3);
    displayContentPane.add(offscreenRenderingModeComboBox, 1, 3);
    final ComboBox<RenderTargetModeLock> renderTargetModeLockComboBox = new ComboBox<>();
    renderTargetModeLockComboBox.setMaxWidth(Double.MAX_VALUE);
    renderTargetModeLockComboBox.setValue(container.getRenderTargetModeLock());
    renderTargetModeLockComboBox.valueProperty().addListener((observable, oldValue, newValue) -> this.changeSettings(newValue));
    addItems(renderTargetModeLockComboBox, RenderTargetModeLock.class);
    displayContentPane.add(new TextWithStyle(tr("Render target lock mode"), CAPTION_TITLE_CSS_CLASS), 0, 4);
    displayContentPane.add(renderTargetModeLockComboBox, 1, 4);
    final ComboBox<Multisampling> multisamplingComboBox = new ComboBox<>();
    multisamplingComboBox.setMaxWidth(Double.MAX_VALUE);
    multisamplingComboBox.setValue(container.getMultisampling());
    multisamplingComboBox.valueProperty().addListener((observable, oldValue, newValue) -> this.changeSettings(newValue));
    addItems(multisamplingComboBox, Multisampling.class);
    displayContentPane.add(new TextWithStyle(tr("Multisampling"), CAPTION_TITLE_CSS_CLASS), 0, 5);
    displayContentPane.add(multisamplingComboBox, 1, 5);
    final ComboBox<StrictDrawOrdering> strictDrawOrderingComboBox = new ComboBox<>();
    strictDrawOrderingComboBox.setMaxWidth(Double.MAX_VALUE);
    strictDrawOrderingComboBox.setValue(container.getStrictDrawOrdering());
    strictDrawOrderingComboBox.valueProperty().addListener((observable, oldValue, newValue) -> this.changeSettings(newValue));
    addItems(strictDrawOrderingComboBox, StrictDrawOrdering.class);
    displayContentPane.add(new TextWithStyle(tr("Strict Draw Ordering"), CAPTION_TITLE_CSS_CLASS), 0, 6);
    displayContentPane.add(strictDrawOrderingComboBox, 1, 6);
    final ComboBox<AlwaysOffscreen> alwaysOffscreenComboBox = new ComboBox<>();
    alwaysOffscreenComboBox.setMaxWidth(Double.MAX_VALUE);
    alwaysOffscreenComboBox.setValue(container.getAlwaysOffscreen());
    alwaysOffscreenComboBox.valueProperty().addListener((observable, oldValue, newValue) -> this.changeSettings(newValue));
    addItems(alwaysOffscreenComboBox, AlwaysOffscreen.class);
    displayContentPane.add(new TextWithStyle(tr("Always Offscreen"), CAPTION_TITLE_CSS_CLASS), 0, 7);
    displayContentPane.add(alwaysOffscreenComboBox, 1, 7);
    Region spacer = new Region();
    GridPane.setHgrow(spacer, Priority.ALWAYS);
    displayContentPane.add(spacer, 2, 0);
    displayPane.getChildren().addAll(displayContentPane);
    this.setContent(displayPane);
    lockableElements.addAll(Arrays.asList(glslComboBox, directDrawRendererComboBox, offscreenRenderingModeComboBox, renderTargetModeLockComboBox, multisamplingComboBox, strictDrawOrderingComboBox, alwaysOffscreenComboBox, videoMemorySizeComboBox));
}
Also used : TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) GridPane(javafx.scene.layout.GridPane) ComboBox(javafx.scene.control.ComboBox) Text(javafx.scene.text.Text) Region(javafx.scene.layout.Region) VBox(javafx.scene.layout.VBox)

Example 4 with Region

use of javafx.scene.layout.Region in project POL-POM-5 by PlayOnLinux.

the class WinePrefixContainerInformationTab method populate.

private void populate() {
    final VBox informationPane = new VBox();
    final Text title = new TextWithStyle(tr("Information"), TITLE_CSS_CLASS);
    informationPane.getStyleClass().add(CONFIGURATION_PANE_CSS_CLASS);
    informationPane.getChildren().add(title);
    final GridPane informationContentPane = new GridPane();
    informationContentPane.getStyleClass().add("grid");
    informationContentPane.add(new TextWithStyle(tr("Name:"), CAPTION_TITLE_CSS_CLASS), 0, 0);
    Label name = new Label(container.getName());
    name.setWrapText(true);
    informationContentPane.add(name, 1, 0);
    informationContentPane.add(new TextWithStyle(tr("Path:"), CAPTION_TITLE_CSS_CLASS), 0, 1);
    Label path = new Label(container.getPath());
    path.setWrapText(true);
    informationContentPane.add(path, 1, 1);
    informationContentPane.add(new TextWithStyle(tr("Wine version:"), CAPTION_TITLE_CSS_CLASS), 0, 2);
    Label version = new Label(container.getVersion());
    version.setWrapText(true);
    informationContentPane.add(version, 1, 2);
    informationContentPane.add(new TextWithStyle(tr("Wine architecture:"), CAPTION_TITLE_CSS_CLASS), 0, 3);
    Label architecture = new Label(container.getArchitecture());
    architecture.setWrapText(true);
    informationContentPane.add(architecture, 1, 3);
    informationContentPane.add(new TextWithStyle(tr("Wine distribution:"), CAPTION_TITLE_CSS_CLASS), 0, 4);
    Label distribution = new Label(container.getDistribution());
    distribution.setWrapText(true);
    informationContentPane.add(distribution, 1, 4);
    Region spacer = new Region();
    spacer.setPrefHeight(20);
    VBox.setVgrow(spacer, Priority.NEVER);
    ComboBox<EngineVersionDTO> changeEngineComboBox = new ComboBox<EngineVersionDTO>(FXCollections.observableList(engineVersions));
    changeEngineComboBox.setConverter(new StringConverter<EngineVersionDTO>() {

        @Override
        public String toString(EngineVersionDTO object) {
            return object.getVersion();
        }

        @Override
        public EngineVersionDTO fromString(String string) {
            return engineVersions.stream().filter(engineVersion -> engineVersion.getVersion().equals(string)).findFirst().get();
        }
    });
    changeEngineComboBox.getSelectionModel().select(engineVersions.stream().filter(engineVersion -> engineVersion.getVersion().equals(container.getVersion())).findFirst().get());
    Button deleteButton = new Button(tr("Delete container"));
    deleteButton.setOnMouseClicked(event -> this.onDeletePrefix.accept(container));
    informationPane.getChildren().addAll(informationContentPane, spacer, changeEngineComboBox, deleteButton);
    this.setContent(informationPane);
}
Also used : Button(javafx.scene.control.Button) Label(javafx.scene.control.Label) TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) FXCollections(javafx.collections.FXCollections) Localisation.tr(org.phoenicis.configuration.localisation.Localisation.tr) StringConverter(javafx.util.StringConverter) VBox(javafx.scene.layout.VBox) EngineVersionDTO(org.phoenicis.engines.dto.EngineVersionDTO) Text(javafx.scene.text.Text) Consumer(java.util.function.Consumer) Priority(javafx.scene.layout.Priority) List(java.util.List) Region(javafx.scene.layout.Region) ComboBox(javafx.scene.control.ComboBox) Tab(javafx.scene.control.Tab) WinePrefixContainerDTO(org.phoenicis.containers.dto.WinePrefixContainerDTO) GridPane(javafx.scene.layout.GridPane) TextWithStyle(org.phoenicis.javafx.views.common.TextWithStyle) GridPane(javafx.scene.layout.GridPane) ComboBox(javafx.scene.control.ComboBox) Label(javafx.scene.control.Label) Text(javafx.scene.text.Text) EngineVersionDTO(org.phoenicis.engines.dto.EngineVersionDTO) Button(javafx.scene.control.Button) Region(javafx.scene.layout.Region) VBox(javafx.scene.layout.VBox)

Example 5 with Region

use of javafx.scene.layout.Region in project POL-POM-5 by PlayOnLinux.

the class DetailsView method populateHeader.

/**
     * Populate the header with a label for the title of this details view and a close button
     */
private void populateHeader() {
    this.titleLabel = new Label();
    this.titleLabel.getStyleClass().add("descriptionTitle");
    this.titleLabel.setAlignment(Pos.CENTER_LEFT);
    this.titleLabel.setWrapText(true);
    this.closeButton = new Button();
    this.closeButton.getStyleClass().add("closeIcon");
    this.closeButton.setOnAction(event -> onClose.run());
    this.closeButton.setAlignment(Pos.CENTER_RIGHT);
    Region filler = new Region();
    HBox headerBox = new HBox();
    headerBox.getChildren().setAll(titleLabel, filler, closeButton);
    HBox.setHgrow(filler, Priority.ALWAYS);
    this.setTop(headerBox);
}
Also used : HBox(javafx.scene.layout.HBox) Button(javafx.scene.control.Button) Label(javafx.scene.control.Label) Region(javafx.scene.layout.Region)

Aggregations

Region (javafx.scene.layout.Region)106 Text (javafx.scene.text.Text)25 VBox (javafx.scene.layout.VBox)22 Label (javafx.scene.control.Label)21 Pane (javafx.scene.layout.Pane)21 Button (javafx.scene.control.Button)18 InnerShadow (javafx.scene.effect.InnerShadow)17 Scene (javafx.scene.Scene)16 Node (javafx.scene.Node)15 Insets (javafx.geometry.Insets)14 HBox (javafx.scene.layout.HBox)14 DropShadow (javafx.scene.effect.DropShadow)13 ArrayList (java.util.ArrayList)12 StackPane (javafx.scene.layout.StackPane)12 Canvas (javafx.scene.canvas.Canvas)11 Color (javafx.scene.paint.Color)11 GridPane (javafx.scene.layout.GridPane)10 Group (javafx.scene.Group)9 Background (javafx.scene.layout.Background)8 BackgroundFill (javafx.scene.layout.BackgroundFill)8