Example usage for javafx.util.converter DoubleStringConverter DoubleStringConverter

List of usage examples for javafx.util.converter DoubleStringConverter DoubleStringConverter

Introduction

In this page you can find the example usage for javafx.util.converter DoubleStringConverter DoubleStringConverter.

Prototype

DoubleStringConverter

Source Link

Usage

From source file:Main.java

private VBox getTransformationControls() {
    xSlider.setShowTickMarks(true);/*  w w w .  ja  v a  2 s.c  o  m*/
    xSlider.setShowTickLabels(true);
    xSlider.snapToTicksProperty().set(true);

    ySlider.setShowTickMarks(true);
    ySlider.setShowTickLabels(true);
    ySlider.snapToTicksProperty().set(true);

    widthSlider.setShowTickMarks(true);
    widthSlider.setShowTickLabels(true);
    widthSlider.snapToTicksProperty().set(true);

    heightSlider.setShowTickMarks(true);
    heightSlider.setShowTickLabels(true);
    heightSlider.snapToTicksProperty().set(true);

    opacitySlider.setShowTickMarks(true);
    opacitySlider.setShowTickLabels(true);
    opacitySlider.snapToTicksProperty().set(true);
    opacitySlider.setMinorTickCount(5);
    opacitySlider.setMajorTickUnit(0.20d);

    strokeSlider.setShowTickMarks(true);
    strokeSlider.setShowTickLabels(true);
    strokeSlider.snapToTicksProperty().set(true);
    strokeSlider.setMinorTickCount(5);
    strokeSlider.setMajorTickUnit(1.0d);

    translateXSlider.setShowTickMarks(true);
    translateXSlider.setShowTickLabels(true);
    translateXSlider.snapToTicksProperty().set(true);

    translateYSlider.setShowTickMarks(true);
    translateYSlider.setShowTickLabels(true);
    translateYSlider.snapToTicksProperty().set(true);

    rotateSlider.setShowTickMarks(true);
    rotateSlider.setShowTickLabels(true);
    rotateSlider.snapToTicksProperty().set(true);
    rotateSlider.setMinorTickCount(5);
    rotateSlider.setMajorTickUnit(30.0);

    scaleXSlider.setShowTickMarks(true);
    scaleXSlider.setShowTickLabels(true);
    scaleXSlider.setMajorTickUnit(0.2d);
    scaleXSlider.setLabelFormatter(new DoubleStringConverter());
    scaleXSlider.snapToTicksProperty().set(true);

    scaleYSlider.setShowTickMarks(true);
    scaleYSlider.setShowTickLabels(true);
    scaleYSlider.setMajorTickUnit(0.2d);
    scaleYSlider.setLabelFormatter(new DoubleStringConverter());
    scaleYSlider.snapToTicksProperty().set(true);

    shearXSlider.setShowTickMarks(true);
    shearXSlider.setShowTickLabels(true);
    shearXSlider.setMajorTickUnit(0.2d);
    shearXSlider.setLabelFormatter(new DoubleStringConverter());
    shearXSlider.snapToTicksProperty().set(true);

    shearYSlider.setShowTickMarks(true);
    shearYSlider.setShowTickLabels(true);
    shearYSlider.setMajorTickUnit(0.2d);
    shearYSlider.setLabelFormatter(new DoubleStringConverter());
    shearYSlider.snapToTicksProperty().set(true);

    HBox xyBox = new HBox();
    xyBox.setSpacing(5);
    xyBox.getChildren().addAll(VBoxBuilder.create().children(xLabel, xSlider).build(),
            VBoxBuilder.create().children(yLabel, ySlider).build());

    HBox whBox = new HBox();
    whBox.setSpacing(5);
    whBox.getChildren().addAll(VBoxBuilder.create().children(widthLabel, widthSlider).build(),
            VBoxBuilder.create().children(heightLabel, heightSlider).build());

    HBox colorBox = new HBox();
    colorBox.setSpacing(5);
    colorBox.getChildren().addAll(VBoxBuilder.create().children(strokeLabel, strokeSlider).build(),
            VBoxBuilder.create().children(new Label("Stroke Color"), rectStrokeColorChoiceBox).build());

    HBox opacityBox = new HBox();
    opacityBox.setSpacing(5);
    opacityBox.getChildren().addAll(VBoxBuilder.create().children(opacityLabel, opacitySlider).build(),
            VBoxBuilder.create().children(new Label("Fill Color"), rectFillColorChoiceBox).build());

    HBox translateBox = new HBox();
    translateBox.setSpacing(5);
    translateBox.getChildren().addAll(VBoxBuilder.create().children(translateXLabel, translateXSlider).build(),
            VBoxBuilder.create().children(translateYLabel, translateYSlider).build());

    HBox rotateBox = new HBox();
    rotateBox.setSpacing(5);
    rotateBox.getChildren().addAll(VBoxBuilder.create().children(rotateLabel, rotateSlider).build());

    HBox scaleBox = new HBox();
    scaleBox.setSpacing(5);
    scaleBox.getChildren().addAll(VBoxBuilder.create().children(scaleXLabel, scaleXSlider).build(),
            VBoxBuilder.create().children(scaleYLabel, scaleYSlider).build());

    HBox shearBox = new HBox();
    shearBox.setSpacing(5);
    shearBox.getChildren().addAll(VBoxBuilder.create().children(shearXLabel, shearXSlider).build(),
            VBoxBuilder.create().children(shearYLabel, shearYSlider).build());

    VBox rectangleBox = new VBox();
    rectangleBox.getChildren().addAll(xyBox, whBox, colorBox, opacityBox);
    TitledPane rectangleProps = new TitledPane("Rectangle", rectangleBox);

    VBox transformBox = new VBox();
    transformBox.getChildren().addAll(translateBox, rotateBox, scaleBox, shearBox);
    TitledPane transformsProps = new TitledPane("Tranformations", transformBox);

    TitledPane showBoundsControls = getShowBoundsControls();
    TitledPane effectPane = getEffectTitledPane();

    Button resetAllButton = new Button("Reset All");
    resetAllButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            resetAll();
        }
    });

    Button saveButton = new Button("Save Layout as Image");
    saveButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            saveLayoutAsImage();
        }
    });

    Button exitButton = new Button("Exit");
    exitButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            Platform.exit();
        }
    });

    /*
    Button printButton = new Button("Print");
    printButton.setOnAction(new EventHandler<ActionEvent>() {
        @Override
        public void handle(ActionEvent actionEvent) {
            String str = getDesc("layoutBounds", mainRect.getLayoutBounds()) +
                         getDesc("\nboundsInLocal", mainRect.getBoundsInLocal()) +
                         getDesc("\nboundsInParent", mainRect.getBoundsInParent());
                    
            //printDataTextArea.setText(str);
        }
                
        private String getDesc(String type, Bounds b) {
            String str = type + "[minX=" + b.getMinX() +
                         ", minY=" + b.getMinY() +
                         ", width=" + b.getWidth() +
                         ", height=" + b.getHeight() + "]";
            return str;
        }
    });
    */

    HBox buttonBox = new HBox();
    buttonBox.setSpacing(10);
    buttonBox.getChildren().addAll(resetAllButton, saveButton, exitButton);

    VBox vBox = new VBox();
    vBox.getChildren().addAll(buttonBox, showBoundsControls, rectangleProps, effectPane, transformsProps);
    return vBox;
}