use of javafx.geometry.Dimension2D in project Board-Instrumentation-Framework by intel.
the class SplitFlapBuilder method build.
public final SplitFlap build() {
final SplitFlap CONTROL;
if (properties.containsKey("selection")) {
if (properties.containsKey("text")) {
CONTROL = new SplitFlap(((ObjectProperty<String[]>) properties.get("selection")).get(), ((StringProperty) properties.get("text")).get());
} else {
CONTROL = new SplitFlap(((ObjectProperty<String[]>) properties.get("selection")).get(), ((ObjectProperty<String[]>) properties.get("selection")).get()[0]);
}
} else {
CONTROL = new SplitFlap();
}
for (String key : properties.keySet()) {
if ("keepAspect".equals(key)) {
CONTROL.setKeepAspect(((BooleanProperty) properties.get(key)).get());
} else if ("flipTime".equals(key)) {
CONTROL.setFlipTime(((DoubleProperty) properties.get(key)).get());
} else if ("wordMode".equals(key)) {
CONTROL.setWordMode(((BooleanProperty) properties.get(key)).get());
} else if ("withFixture".equals(key)) {
CONTROL.setWithFixture(((BooleanProperty) properties.get(key)).get());
} else if ("darkFixture".equals(key)) {
CONTROL.setDarkFixture(((BooleanProperty) properties.get(key)).get());
} else if ("squareFlaps".equals(key)) {
CONTROL.setSquareFlaps(((BooleanProperty) properties.get(key)).get());
} else if ("flapColor".equals(key)) {
CONTROL.setFlapColor(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("textColor".equals(key)) {
CONTROL.setTextColor(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("text".equals(key)) {
CONTROL.setText(((StringProperty) properties.get(key)).get());
} else if ("selection".equals(key)) {
CONTROL.setSelection(((ObjectProperty<String[]>) properties.get(key)).get());
} else 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());
}
}
return CONTROL;
}
use of javafx.geometry.Dimension2D in project Board-Instrumentation-Framework by intel.
the class VuMeterBuilder method build.
public final VuMeter build() {
final VuMeter CONTROL = new VuMeter();
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 ("noOfLeds".equals(key)) {
CONTROL.setNoOfLeds(((IntegerProperty) properties.get(key)).get());
} else if ("orientation".equals(key)) {
CONTROL.setOrientation(((ObjectProperty<Orientation>) properties.get(key)).get());
} else if ("peakValueVisible".equals(key)) {
CONTROL.setPeakValueVisible(((BooleanProperty) properties.get(key)).get());
} else if ("value".equals(key)) {
CONTROL.setValue(((DoubleProperty) properties.get(key)).get());
} else if ("sections".equals(key)) {
CONTROL.setSections(((ListProperty<Section>) properties.get(key)).get());
} else if ("interactive".equals(key)) {
CONTROL.setInteractive(((BooleanProperty) properties.get(key)).get());
}
}
return CONTROL;
}
use of javafx.geometry.Dimension2D in project org.csstudio.display.builder by kasemir.
the class SymbolRepresentation method computeMaximumSize.
/**
* Compute the maximum width and height of the given {@code widget} based on
* the its set of symbol images.
*
* @param widget The {@link SymbolWidget} whose size must be computed.
* @return A not {@code null} maximum dimension of the given {@code widget}.
*/
public static Dimension2D computeMaximumSize(final SymbolWidget widget) {
Double[] max_size = new Double[] { 0.0, 0.0 };
widget.propSymbols().getValue().stream().forEach(s -> {
final String imageFile = s.getValue();
try {
final String filename = ModelResourceUtil.resolveResource(widget.getTopDisplayModel(), imageFile);
final Image image = new Image(ModelResourceUtil.openResourceStream(filename));
if (max_size[0] < image.getWidth()) {
max_size[0] = image.getWidth();
}
if (max_size[1] < image.getHeight()) {
max_size[1] = image.getHeight();
}
} catch (Exception ex) {
// The following message has proven to be annoying and not useful.
// logger.log(Level.WARNING, "Cannot obtain image size for {0} [{1}].", new Object[] { imageFile, ex.getMessage() });
}
});
return new Dimension2D(max_size[0], max_size[1]);
}
use of javafx.geometry.Dimension2D in project org.csstudio.display.builder by kasemir.
the class WidgetTransfer method updateSymbolWidgetSize.
/**
* Update a symbol widget's size from image files, using the maximum
* width and height from the widget's symbols.
*
* @param widget {@link PictureWidget}
*/
private static void updateSymbolWidgetSize(final SymbolWidget widget) {
Dimension2D maxSize = SymbolRepresentation.computeMaximumSize(widget);
widget.propWidth().setValue((int) Math.round(maxSize.getWidth()));
widget.propHeight().setValue((int) Math.round(maxSize.getHeight()));
widget.propAutoSize().setValue(true);
}
use of javafx.geometry.Dimension2D in project KNOBS by ESSICS.
the class KnobBuilder method build.
@SuppressWarnings("unchecked")
public Knob build() {
final Knob knob = new Knob();
// Inter-dependent properties.
if (properties.containsKey("minValue")) {
knob.setMinValue((double) properties.get("minValue"));
}
if (properties.containsKey("maxValue")) {
knob.setMaxValue((double) properties.get("maxValue"));
}
if (properties.containsKey("currentValue")) {
knob.setCurrentValue((double) properties.get("currentValue"));
}
// All other properties.
if (properties.containsKey("backgroundColor")) {
knob.setBackgroundColor((Color) properties.get("backgroundColor"));
}
if (properties.containsKey("color")) {
knob.setColor((Color) properties.get("color"));
}
if (properties.containsKey("currentValueColor")) {
knob.setCurrentValueColor((Color) properties.get("currentValueColor"));
}
if (properties.containsKey("decimals")) {
knob.setDecimals((int) properties.get("decimals"));
}
if (properties.containsKey("dragDisabled")) {
knob.setDragDisabled((boolean) properties.get("dragDisabled"));
}
if (properties.containsKey("extremaVisible")) {
knob.setExtremaVisible((boolean) properties.get("extremaVisible"));
}
if (properties.containsKey("gradientStops")) {
knob.setGradientStops((List<Stop>) properties.get("gradientStops"));
}
if (properties.containsKey("id")) {
knob.setId((String) properties.get("id"));
}
if (properties.containsKey("indicatorColor")) {
knob.setIndicatorColor((Color) properties.get("indicatorColor"));
}
if (properties.containsKey("layoutX")) {
knob.setLayoutX((double) properties.get("layoutX"));
}
if (properties.containsKey("layoutY")) {
knob.setLayoutY((double) properties.get("layoutY"));
}
if (properties.containsKey("maxHeight")) {
knob.setMaxHeight((double) properties.get("maxHeight"));
}
if (properties.containsKey("maxSize")) {
Dimension2D maxSize = (Dimension2D) properties.get("maxSize");
knob.setMaxSize(maxSize.getWidth(), maxSize.getHeight());
}
if (properties.containsKey("maxWidth")) {
knob.setMaxWidth((double) properties.get("maxWidth"));
}
if (properties.containsKey("minHeight")) {
knob.setMinHeight((double) properties.get("minHeight"));
}
if (properties.containsKey("minSize")) {
Dimension2D minSize = (Dimension2D) properties.get("minSize");
knob.setMinSize(minSize.getWidth(), minSize.getHeight());
}
if (properties.containsKey("minWidth")) {
knob.setMinWidth((double) properties.get("minWidth"));
}
if (properties.containsKey("onAdjusted")) {
knob.setOnAdjusted((EventHandler<KnobEvent>) properties.get("onAdjusted"));
}
if (properties.containsKey("onAdjusting")) {
knob.setOnAdjusting((EventHandler<KnobEvent>) properties.get("onAdjusting"));
}
if (properties.containsKey("onTargetSet")) {
knob.setOnTargetSet((EventHandler<KnobEvent>) properties.get("onTargetSet"));
}
if (properties.containsKey("opacity")) {
knob.setOpacity((double) properties.get("opacity"));
}
if (properties.containsKey("padding")) {
knob.setPadding((Insets) properties.get("padding"));
}
if (properties.containsKey("prefHeight")) {
knob.setPrefHeight((double) properties.get("prefHeight"));
}
if (properties.containsKey("prefSize")) {
Dimension2D size = (Dimension2D) properties.get("prefSize");
knob.setPrefSize(size.getWidth(), size.getHeight());
}
if (properties.containsKey("prefWidth")) {
knob.setPrefWidth((double) properties.get("prefWidth"));
}
if (properties.containsKey("scaleX")) {
knob.setScaleX((double) properties.get("scaleX"));
}
if (properties.containsKey("scaleY")) {
knob.setScaleY((double) properties.get("scaleY"));
}
if (properties.containsKey("selected")) {
knob.setSelected((boolean) properties.get("selected"));
}
if (properties.containsKey("selectionColor")) {
knob.setSelectionColor((Color) properties.get("selectionColor"));
}
if (properties.containsKey("tagColor")) {
knob.setTagColor((Color) properties.get("tagColor"));
}
if (properties.containsKey("tagVisible")) {
knob.setTagVisible((boolean) properties.get("tagVisible"));
}
if (properties.containsKey("targetValueAlwaysVisible")) {
knob.setTargetValueAlwaysVisible((boolean) properties.get("targetValueAlwaysVisible"));
}
if (properties.containsKey("targetValue")) {
knob.setTargetValue((double) properties.get("targetValue"));
}
if (properties.containsKey("textColor")) {
knob.setTextColor((Color) properties.get("textColor"));
}
if (properties.containsKey("translateX")) {
knob.setTranslateX((double) properties.get("translateX"));
}
if (properties.containsKey("translateY")) {
knob.setTranslateY((double) properties.get("translateY"));
}
if (properties.containsKey("unit")) {
knob.setUnit((String) properties.get("unit"));
}
if (properties.containsKey("zeroDetentEnabled")) {
knob.setZeroDetentEnabled((boolean) properties.get("zeroDetentEnabled"));
}
return knob;
}
Aggregations