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;
}
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));
}
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());
}
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()));
}
}
}
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;
}
Aggregations