use of javafx.geometry.Dimension2D in project FXGL by AlmasB.
the class HitBox method readObject.
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
name = (String) in.readObject();
bounds = new BoundingBox(in.readDouble(), in.readDouble(), in.readDouble(), in.readDouble());
Dimension2D size = new Dimension2D(in.readDouble(), in.readDouble());
ShapeType type = (ShapeType) in.readObject();
switch(type) {
case CIRCLE:
shape = BoundingShape.circle(size.getWidth() / 2);
break;
case POLYGON:
shape = BoundingShape.box(size.getWidth(), size.getHeight());
break;
case CHAIN:
int length = in.readInt();
Point2D[] points = new Point2D[length];
for (int i = 0; i < length; i++) {
points[i] = new Point2D(in.readDouble(), in.readDouble());
}
shape = BoundingShape.chain(points);
break;
default:
throw new IllegalArgumentException("Unknown shape type");
}
}
use of javafx.geometry.Dimension2D in project FXGL by AlmasB.
the class BoundingShape method chain.
/**
* Constructs new closed chain shaped bounding shape.
* Note: chain shape can only be used with static objects.
* Note: chain shape must have at least 2 points
*
* @param points points to use in a chain
* @return closed chain bounding shape
* @throws IllegalArgumentException if number of points is less than 2
*/
public static BoundingShape chain(Point2D... points) {
if (points.length < 2)
throw new IllegalArgumentException("Chain shape requires at least 2 points. Given points: " + points.length);
double maxX = Stream.of(points).mapToDouble(Point2D::getX).max().getAsDouble();
double maxY = Stream.of(points).mapToDouble(Point2D::getY).max().getAsDouble();
return new BoundingShape(ShapeType.CHAIN, points, new Dimension2D(maxX, maxY));
}
use of javafx.geometry.Dimension2D in project Board-Instrumentation-Framework by intel.
the class ClockBuilder method build.
public final Clock build() {
final Clock CONTROL = new Clock();
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 ("text".equals(key)) {
CONTROL.setText(((StringProperty) properties.get(key)).get());
} else if ("nightMode".equals(key)) {
CONTROL.setNightMode(((BooleanProperty) properties.get(key)).get());
} else if ("design".equals(key)) {
CONTROL.setDesign(((ObjectProperty<Clock.Design>) properties.get(key)).get());
} else if ("discreteSecond".equals(key)) {
CONTROL.setDiscreteSecond(((BooleanProperty) properties.get(key)).get());
} else if ("secondPointerVisible".equals(key)) {
CONTROL.setSecondPointerVisible(((BooleanProperty) properties.get(key)).get());
} else if ("highlightVisible".equals(key)) {
CONTROL.setHighlightVisible(((BooleanProperty) properties.get(key)).get());
} else if ("dateTime".equals(key)) {
CONTROL.setTime(((ObjectProperty<LocalTime>) properties.get(key)).get());
} else if ("running".equals(key)) {
CONTROL.setRunning(((BooleanProperty) properties.get(key)).get());
} else if ("autoNightMode".equals(key)) {
CONTROL.setAutoNightMode(((BooleanProperty) properties.get(key)).get());
}
}
return CONTROL;
}
use of javafx.geometry.Dimension2D in project Board-Instrumentation-Framework by intel.
the class AvGaugeBuilder method build.
public final AvGauge build() {
final AvGauge CONTROL = new AvGauge();
properties.forEach((key, property) -> {
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 ("opacity".equals(key)) {
CONTROL.setOpacity(((DoubleProperty) properties.get(key)).get());
} else if ("styleClass".equals(key)) {
CONTROL.getStyleClass().setAll("av-gauge");
CONTROL.getStyleClass().addAll(((ObjectProperty<String[]>) properties.get(key)).get());
} else if ("minValue".equals(key)) {
CONTROL.setMinValue(((DoubleProperty) properties.get(key)).get());
} else if ("maxValue".equals(key)) {
CONTROL.setMaxValue(((DoubleProperty) properties.get(key)).get());
} else if ("outerValue".equals(key)) {
CONTROL.setOuterValue(((DoubleProperty) properties.get(key)).get());
} else if ("innerValue".equals(key)) {
CONTROL.setInnerValue(((DoubleProperty) properties.get(key)).get());
} else if ("decimals".equals(key)) {
CONTROL.setDecimals(((IntegerProperty) properties.get(key)).get());
} else if ("title".equals(key)) {
CONTROL.setTitle(((StringProperty) properties.get(key)).get());
} else if ("animationDuration".equals(key)) {
CONTROL.setAnimationDurationInMs(((IntegerProperty) properties.get(key)).get());
} else if ("outerBarColor".equals(key)) {
CONTROL.setOuterBarColor(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("innerBarColor".equals(key)) {
CONTROL.setInnerBarColor(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("backgroundColor".equals(key)) {
CONTROL.setBackgroundColor(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("outerValueTextColor".equals(key)) {
CONTROL.setOuterValueTextColor(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("innerValueTextColor".equals(key)) {
CONTROL.setInnerValueTextColor(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("titleTextColor".equals(key)) {
CONTROL.setTitleTextColor(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("borderColor".equals(key)) {
CONTROL.setBorderColor(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("separatorColor".equals(key)) {
CONTROL.setSeparatorColor(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("multiColor".equals(key)) {
CONTROL.setMultiColor(((BooleanProperty) properties.get(key)).get());
}
});
if (null != outerStops)
CONTROL.setOuterGradient(outerStops);
if (null != innerStops)
CONTROL.setInnerGradient(innerStops);
return CONTROL;
}
use of javafx.geometry.Dimension2D in project Board-Instrumentation-Framework by intel.
the class DoubleRadialGaugeBuilder method build.
public final DoubleRadialGauge build() {
final DoubleRadialGauge CONTROL = new DoubleRadialGauge();
// Make sure that sections and markers will be added first
if (properties.keySet().contains("sectionsArrayOne")) {
CONTROL.setSectionsOne(((ObjectProperty<Section[]>) properties.get("sectionsArrayOne")).get());
}
if (properties.keySet().contains("sectionsListOne")) {
CONTROL.setSectionsOne(((ObjectProperty<List<Section>>) properties.get("sectionsListOne")).get());
}
if (properties.keySet().contains("areasArrayOne")) {
CONTROL.setAreasOne(((ObjectProperty<Section[]>) properties.get("areasArrayOne")).get());
}
if (properties.keySet().contains("areasListOne")) {
CONTROL.setAreasOne(((ObjectProperty<List<Section>>) properties.get("areasListOne")).get());
}
if (properties.keySet().contains("sectionsArrayTwo")) {
CONTROL.setSectionsTwo(((ObjectProperty<Section[]>) properties.get("sectionsArrayTwo")).get());
}
if (properties.keySet().contains("sectionsListTwo")) {
CONTROL.setSectionsTwo(((ObjectProperty<List<Section>>) properties.get("sectionsListTwo")).get());
}
if (properties.keySet().contains("areasArrayTwo")) {
CONTROL.setAreasTwo(((ObjectProperty<Section[]>) properties.get("areasArrayTwo")).get());
}
if (properties.keySet().contains("areasListTwo")) {
CONTROL.setAreasTwo(((ObjectProperty<List<Section>>) properties.get("areasListTwo")).get());
}
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("gauge");
CONTROL.getStyleClass().addAll(((ObjectProperty<String[]>) properties.get(key)).get());
} else if ("animated".equals(key)) {
CONTROL.setAnimated(((BooleanProperty) properties.get(key)).get());
} else if ("dropShadowEnabled".equals(key)) {
CONTROL.setDropShadowEnabled(((BooleanProperty) properties.get(key)).get());
} else if ("animationDuration".equals(key)) {
CONTROL.setAnimationDuration(((DoubleProperty) properties.get(key)).get());
} else if ("style".equals(key)) {
CONTROL.setStyle(((StringProperty) properties.get(key)).get());
} else if ("minValueOne".equals(key)) {
CONTROL.setMinValueOne(((DoubleProperty) properties.get(key)).get());
} else if ("maxValueOne".equals(key)) {
CONTROL.setMaxValueOne(((DoubleProperty) properties.get(key)).get());
} else if ("valueOne".equals(key)) {
CONTROL.setValueOne(((DoubleProperty) properties.get(key)).get());
} else if ("decimalsOne".equals(key)) {
CONTROL.setDecimalsOne(((IntegerProperty) properties.get(key)).get());
} else if ("titleOne".equals(key)) {
CONTROL.setTitleOne(((StringProperty) properties.get(key)).get());
} else if ("unitOne".equals(key)) {
CONTROL.setUnitOne(((StringProperty) properties.get(key)).get());
} else if ("autoScaleOne".equals(key)) {
CONTROL.setAutoScaleOne(((BooleanProperty) properties.get(key)).get());
} else if ("needleColorOne".equals(key)) {
CONTROL.setNeedleColorOne(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("tickLabelOrientationOne".equals(key)) {
CONTROL.setTickLabelOrientationOne(((ObjectProperty<DoubleRadialGauge.TickLabelOrientation>) properties.get(key)).get());
} else if ("numberFormatOne".equals(key)) {
CONTROL.setNumberFormatOne(((ObjectProperty<DoubleRadialGauge.NumberFormat>) properties.get(key)).get());
} else if ("majorTickSpaceOne".equals(key)) {
CONTROL.setMajorTickSpaceOne(((DoubleProperty) properties.get(key)).get());
} else if ("minorTickSpaceOne".equals(key)) {
CONTROL.setMinorTickSpaceOne(((DoubleProperty) properties.get(key)).get());
} else if ("tickLabelFill".equals(key)) {
CONTROL.setTickLabelFillOne(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("tickMarkFillOne".equals(key)) {
CONTROL.setTickMarkFillOne(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("ledColorOne".equals(key)) {
CONTROL.setLedColorOne(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("ledVisibleOne".equals(key)) {
CONTROL.setLedVisibleOne(((BooleanProperty) properties.get(key)).get());
} else if ("valueVisibleOne".equals(key)) {
CONTROL.setValueVisibleOne(((BooleanProperty) properties.get(key)).get());
} else if ("sectionFill0One".equals(key)) {
CONTROL.setSectionFill0One(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("sectionFill1One".equals(key)) {
CONTROL.setSectionFill1One(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("sectionFill2One".equals(key)) {
CONTROL.setSectionFill2One(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("sectionFill3One".equals(key)) {
CONTROL.setSectionFill3One(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("sectionFill4One".equals(key)) {
CONTROL.setSectionFill4One(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("areaFill0One".equals(key)) {
CONTROL.setAreaFill0One(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("areaFill1One".equals(key)) {
CONTROL.setAreaFill1One(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("areaFill2One".equals(key)) {
CONTROL.setAreaFill2One(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("areaFill3One".equals(key)) {
CONTROL.setAreaFill3One(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("areaFill4One".equals(key)) {
CONTROL.setAreaFill4One(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("minValueTwo".equals(key)) {
CONTROL.setMinValueTwo(((DoubleProperty) properties.get(key)).get());
} else if ("maxValueTwo".equals(key)) {
CONTROL.setMaxValueTwo(((DoubleProperty) properties.get(key)).get());
} else if ("valueTwo".equals(key)) {
CONTROL.setValueTwo(((DoubleProperty) properties.get(key)).get());
} else if ("decimalsTwo".equals(key)) {
CONTROL.setDecimalsTwo(((IntegerProperty) properties.get(key)).get());
} else if ("titleTwo".equals(key)) {
CONTROL.setTitleTwo(((StringProperty) properties.get(key)).get());
} else if ("unitTwo".equals(key)) {
CONTROL.setUnitTwo(((StringProperty) properties.get(key)).get());
} else if ("autoScaleTwo".equals(key)) {
CONTROL.setAutoScaleTwo(((BooleanProperty) properties.get(key)).get());
} else if ("needleColorTwo".equals(key)) {
CONTROL.setNeedleColorTwo(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("tickLabelOrientationTwo".equals(key)) {
CONTROL.setTickLabelOrientationTwo(((ObjectProperty<DoubleRadialGauge.TickLabelOrientation>) properties.get(key)).get());
} else if ("numberFormatTwo".equals(key)) {
CONTROL.setNumberFormatTwo(((ObjectProperty<DoubleRadialGauge.NumberFormat>) properties.get(key)).get());
} else if ("majorTickSpaceTwo".equals(key)) {
CONTROL.setMajorTickSpaceTwo(((DoubleProperty) properties.get(key)).get());
} else if ("minorTickSpaceTwo".equals(key)) {
CONTROL.setMinorTickSpaceTwo(((DoubleProperty) properties.get(key)).get());
} else if ("tickLabelFill".equals(key)) {
CONTROL.setTickLabelFillTwo(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("tickMarkFillTwo".equals(key)) {
CONTROL.setTickMarkFillTwo(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("ledColorTwo".equals(key)) {
CONTROL.setLedColorTwo(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("ledVisibleTwo".equals(key)) {
CONTROL.setLedVisibleTwo(((BooleanProperty) properties.get(key)).get());
} else if ("valueVisibleTwo".equals(key)) {
CONTROL.setValueVisibleTwo(((BooleanProperty) properties.get(key)).get());
} else if ("sectionFill0Two".equals(key)) {
CONTROL.setSectionFill0Two(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("sectionFill1Two".equals(key)) {
CONTROL.setSectionFill1Two(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("sectionFill2Two".equals(key)) {
CONTROL.setSectionFill2Two(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("sectionFill3Two".equals(key)) {
CONTROL.setSectionFill3Two(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("sectionFill4Two".equals(key)) {
CONTROL.setSectionFill4Two(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("areaFill0Two".equals(key)) {
CONTROL.setAreaFill0Two(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("areaFill1Two".equals(key)) {
CONTROL.setAreaFill1Two(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("areaFill2Two".equals(key)) {
CONTROL.setAreaFill2Two(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("areaFill3Two".equals(key)) {
CONTROL.setAreaFill3Two(((ObjectProperty<Color>) properties.get(key)).get());
} else if ("areaFill4Two".equals(key)) {
CONTROL.setAreaFill4Two(((ObjectProperty<Color>) properties.get(key)).get());
}
}
return CONTROL;
}
Aggregations