Search in sources :

Example 21 with Dimension2D

use of javafx.geometry.Dimension2D in project tilesfx by HanSolo.

the class PixelMatrixBuilder method build.

public final PixelMatrix build() {
    final PixelMatrix CONTROL;
    if (properties.keySet().contains("cols") && properties.keySet().contains("rows")) {
        int cols = ((IntegerProperty) properties.get("cols")).get();
        int rows = ((IntegerProperty) properties.get("rows")).get();
        CONTROL = new PixelMatrix(cols, rows);
    } else {
        CONTROL = new PixelMatrix();
    }
    for (String key : properties.keySet()) {
        if ("prefSize".equals(key)) {
            Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
            CONTROL.setPrefSize(dim.getWidth(), dim.getHeight());
        } else if ("minSize".equals(key)) {
            Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
            CONTROL.setMinSize(dim.getWidth(), dim.getHeight());
        } else if ("maxSize".equals(key)) {
            Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
            CONTROL.setMaxSize(dim.getWidth(), dim.getHeight());
        } else if ("prefWidth".equals(key)) {
            CONTROL.setPrefWidth(((DoubleProperty) properties.get(key)).get());
        } else if ("prefHeight".equals(key)) {
            CONTROL.setPrefHeight(((DoubleProperty) properties.get(key)).get());
        } else if ("minWidth".equals(key)) {
            CONTROL.setMinWidth(((DoubleProperty) properties.get(key)).get());
        } else if ("minHeight".equals(key)) {
            CONTROL.setMinHeight(((DoubleProperty) properties.get(key)).get());
        } else if ("maxWidth".equals(key)) {
            CONTROL.setMaxWidth(((DoubleProperty) properties.get(key)).get());
        } else if ("maxHeight".equals(key)) {
            CONTROL.setMaxHeight(((DoubleProperty) properties.get(key)).get());
        } else if ("scaleX".equals(key)) {
            CONTROL.setScaleX(((DoubleProperty) properties.get(key)).get());
        } else if ("scaleY".equals(key)) {
            CONTROL.setScaleY(((DoubleProperty) properties.get(key)).get());
        } else if ("layoutX".equals(key)) {
            CONTROL.setLayoutX(((DoubleProperty) properties.get(key)).get());
        } else if ("layoutY".equals(key)) {
            CONTROL.setLayoutY(((DoubleProperty) properties.get(key)).get());
        } else if ("translateX".equals(key)) {
            CONTROL.setTranslateX(((DoubleProperty) properties.get(key)).get());
        } else if ("translateY".equals(key)) {
            CONTROL.setTranslateY(((DoubleProperty) properties.get(key)).get());
        } else if ("padding".equals(key)) {
            CONTROL.setPadding(((ObjectProperty<Insets>) properties.get(key)).get());
        } else if ("pixelOnColor".equals(key)) {
            CONTROL.setPixelOnColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("pixelOffColor".equals(key)) {
            CONTROL.setPixelOffColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("pixelShape".equals(key)) {
            CONTROL.setPixelShape(((ObjectProperty<PixelShape>) properties.get(key)).get());
        } else if ("matrixFont".equals(key)) {
            CONTROL.setMatrixFont(((ObjectProperty<MatrixFont>) properties.get(key)).get());
        } else if ("useSpacer".equals(key)) {
            CONTROL.setUseSpacer(((BooleanProperty) properties.get(key)).get());
        } else if ("spacerSizeFactor".equals(key)) {
            CONTROL.setSpacerSizeFactor(((DoubleProperty) properties.get(key)).get());
        } else if ("squarePixels".equals(key)) {
            CONTROL.setSquarePixels(((BooleanProperty) properties.get(key)).get());
        }
    }
    return CONTROL;
}
Also used : ObjectProperty(javafx.beans.property.ObjectProperty) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) IntegerProperty(javafx.beans.property.IntegerProperty) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) Dimension2D(javafx.geometry.Dimension2D) Color(javafx.scene.paint.Color) DoubleProperty(javafx.beans.property.DoubleProperty) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty) PixelShape(eu.hansolo.tilesfx.chart.PixelMatrix.PixelShape)

Example 22 with Dimension2D

use of javafx.geometry.Dimension2D in project TestFX by TestFX.

the class GeometryMatchersTest method hasDimension_fails.

@Test
public void hasDimension_fails() {
    exception.expect(AssertionError.class);
    exception.expectMessage("Expected: Dimension2D has dimension (0.0, 0.0)\n");
    assertThat(new Dimension2D(10, 20), GeometryMatchers.hasDimension(0, 0));
}
Also used : Dimension2D(javafx.geometry.Dimension2D) Test(org.junit.Test)

Example 23 with Dimension2D

use of javafx.geometry.Dimension2D in project org.csstudio.display.builder by kasemir.

the class TextUtils method computeTextSize.

/**
 * Compute the preferred size for a text
 *
 *  <p>Must be called on the UI thread,
 *  because it's using one shared text helper.
 *
 *  @param font Font
 *  @param text Text
 *  @return Width, height
 */
public static Dimension2D computeTextSize(final Font font, final String text) {
    // com.sun.javafx.scene.control.skin.Utils contains related code,
    // but is private
    helper.setFont(font);
    // With default line spacing of 0.0,
    // height of multi-line text is too small...
    helper.setLineSpacing(1.0);
    helper.setText(text);
    final Bounds measure = helper.getLayoutBounds();
    return new Dimension2D(measure.getWidth(), measure.getHeight());
}
Also used : Bounds(javafx.geometry.Bounds) Dimension2D(javafx.geometry.Dimension2D)

Example 24 with Dimension2D

use of javafx.geometry.Dimension2D in project org.csstudio.display.builder by kasemir.

the class LabelRepresentation method updateChanges.

@Override
public void updateChanges() {
    super.updateChanges();
    if (dirty_style.checkAndClear()) {
        final int width = model_widget.propWidth().getValue();
        final int height = model_widget.propHeight().getValue();
        final RotationStep rotation = model_widget.propRotationStep().getValue();
        switch(rotation) {
            case NONE:
                jfx_node.setPrefSize(width, height);
                if (was_ever_transformed)
                    jfx_node.getTransforms().clear();
                break;
            case NINETY:
                jfx_node.setPrefSize(height, width);
                jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(-height, 0));
                was_ever_transformed = true;
                break;
            case ONEEIGHTY:
                jfx_node.setPrefSize(width, height);
                jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(-width, -height));
                was_ever_transformed = true;
                break;
            case MINUS_NINETY:
                jfx_node.setPrefSize(height, width);
                jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(0, -width));
                was_ever_transformed = true;
                break;
        }
        jfx_node.setAlignment(pos);
        jfx_node.setWrapText(model_widget.propWrapWords().getValue());
        Color color = JFXUtil.convert(model_widget.propForegroundColor().getValue());
        jfx_node.setTextFill(color);
        if (model_widget.propTransparent().getValue())
            // No fill
            jfx_node.setBackground(null);
        else {
            // Fill background
            color = JFXUtil.convert(model_widget.propBackgroundColor().getValue());
            jfx_node.setBackground(new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY)));
        }
        jfx_node.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
    }
    if (dirty_content.checkAndClear()) {
        final String text = model_widget.propText().getValue();
        jfx_node.setText(text);
        if (model_widget.propAutoSize().getValue()) {
            final Dimension2D size = TextUtils.computeTextSize(JFXUtil.convert(model_widget.propFont().getValue()), text);
            model_widget.propWidth().setValue((int) Math.ceil(size.getWidth()));
            model_widget.propHeight().setValue((int) Math.ceil(size.getHeight()));
        }
    }
}
Also used : RotationStep(org.csstudio.display.builder.model.properties.RotationStep) Rotate(javafx.scene.transform.Rotate) Background(javafx.scene.layout.Background) Color(javafx.scene.paint.Color) BackgroundFill(javafx.scene.layout.BackgroundFill) Dimension2D(javafx.geometry.Dimension2D) Translate(javafx.scene.transform.Translate)

Example 25 with Dimension2D

use of javafx.geometry.Dimension2D in project Board-Instrumentation-Framework by intel.

the class LedBuilder method build.

public final Led build() {
    final Led CONTROL = new Led();
    for (String key : properties.keySet()) {
        if ("prefSize".equals(key)) {
            Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
            CONTROL.setPrefSize(dim.getWidth(), dim.getHeight());
        } else if ("minSize".equals(key)) {
            Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
            CONTROL.setPrefSize(dim.getWidth(), dim.getHeight());
        } else if ("maxSize".equals(key)) {
            Dimension2D dim = ((ObjectProperty<Dimension2D>) properties.get(key)).get();
            CONTROL.setPrefSize(dim.getWidth(), dim.getHeight());
        } else if ("prefWidth".equals(key)) {
            CONTROL.setPrefWidth(((DoubleProperty) properties.get(key)).get());
        } else if ("prefHeight".equals(key)) {
            CONTROL.setPrefHeight(((DoubleProperty) properties.get(key)).get());
        } else if ("minWidth".equals(key)) {
            CONTROL.setMinWidth(((DoubleProperty) properties.get(key)).get());
        } else if ("minHeight".equals(key)) {
            CONTROL.setMinHeight(((DoubleProperty) properties.get(key)).get());
        } else if ("maxWidth".equals(key)) {
            CONTROL.setMaxWidth(((DoubleProperty) properties.get(key)).get());
        } else if ("maxHeight".equals(key)) {
            CONTROL.setMaxHeight(((DoubleProperty) properties.get(key)).get());
        } else if ("scaleX".equals(key)) {
            CONTROL.setScaleX(((DoubleProperty) properties.get(key)).get());
        } else if ("scaleY".equals(key)) {
            CONTROL.setScaleY(((DoubleProperty) properties.get(key)).get());
        } else if ("layoutX".equals(key)) {
            CONTROL.setLayoutX(((DoubleProperty) properties.get(key)).get());
        } else if ("layoutY".equals(key)) {
            CONTROL.setLayoutY(((DoubleProperty) properties.get(key)).get());
        } else if ("translateX".equals(key)) {
            CONTROL.setTranslateX(((DoubleProperty) properties.get(key)).get());
        } else if ("translateY".equals(key)) {
            CONTROL.setTranslateY(((DoubleProperty) properties.get(key)).get());
        } else if ("styleClass".equals(key)) {
            CONTROL.getStyleClass().setAll("led", ((StringProperty) properties.get(key)).get());
        } else if ("ledColor".equals(key)) {
            CONTROL.setLedColor(((ObjectProperty<Color>) properties.get(key)).get());
        } else if ("on".equals(key)) {
            CONTROL.setOn(((BooleanProperty) properties.get(key)).get());
        } else if ("blinking".equals(key)) {
            CONTROL.setBlinking(((BooleanProperty) properties.get(key)).get());
        } else if ("interval".equals(key)) {
            CONTROL.setInterval(((IntegerProperty) properties.get(key)).get());
        } else if ("frameVisible".equals(key)) {
            CONTROL.setFrameVisible(((BooleanProperty) properties.get(key)).get());
        }
    }
    return CONTROL;
}
Also used : ObjectProperty(javafx.beans.property.ObjectProperty) SimpleObjectProperty(javafx.beans.property.SimpleObjectProperty) IntegerProperty(javafx.beans.property.IntegerProperty) SimpleIntegerProperty(javafx.beans.property.SimpleIntegerProperty) BooleanProperty(javafx.beans.property.BooleanProperty) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) Dimension2D(javafx.geometry.Dimension2D) Color(javafx.scene.paint.Color) SimpleStringProperty(javafx.beans.property.SimpleStringProperty) StringProperty(javafx.beans.property.StringProperty) DoubleProperty(javafx.beans.property.DoubleProperty) SimpleDoubleProperty(javafx.beans.property.SimpleDoubleProperty)

Aggregations

Dimension2D (javafx.geometry.Dimension2D)43 DoubleProperty (javafx.beans.property.DoubleProperty)32 ObjectProperty (javafx.beans.property.ObjectProperty)32 SimpleDoubleProperty (javafx.beans.property.SimpleDoubleProperty)32 SimpleObjectProperty (javafx.beans.property.SimpleObjectProperty)32 BooleanProperty (javafx.beans.property.BooleanProperty)24 SimpleBooleanProperty (javafx.beans.property.SimpleBooleanProperty)24 SimpleStringProperty (javafx.beans.property.SimpleStringProperty)23 StringProperty (javafx.beans.property.StringProperty)23 Color (javafx.scene.paint.Color)22 IntegerProperty (javafx.beans.property.IntegerProperty)12 SimpleIntegerProperty (javafx.beans.property.SimpleIntegerProperty)12 List (java.util.List)7 Section (eu.hansolo.enzo.common.Section)4 VisibleData (eu.hansolo.tilesfx.chart.SunburstChart.VisibleData)2 Orientation (javafx.geometry.Orientation)2 Point2D (javafx.geometry.Point2D)2 Image (javafx.scene.image.Image)2 Stop (javafx.scene.paint.Stop)2 ShapeType (com.almasb.fxgl.physics.box2d.collision.shapes.ShapeType)1