use of javafx.scene.layout.Region in project org.csstudio.display.builder by kasemir.
the class ScriptsDialog method createScriptsTable.
/**
* @return Node for UI elements that edit the scripts
*/
private Region createScriptsTable() {
scripts_icon_col = new TableColumn<>();
scripts_icon_col.setCellValueFactory(cdf -> new SimpleObjectProperty<ImageView>(getScriptImage(cdf.getValue())) {
{
bind(Bindings.createObjectBinding(() -> getScriptImage(cdf.getValue()), cdf.getValue().fileProperty()));
}
});
scripts_icon_col.setCellFactory(col -> new TableCell<ScriptItem, ImageView>() {
/* Instance initializer. */
{
setAlignment(Pos.CENTER_LEFT);
}
@Override
protected void updateItem(final ImageView item, final boolean empty) {
super.updateItem(item, empty);
super.setGraphic(item);
}
});
scripts_icon_col.setEditable(false);
scripts_icon_col.setSortable(false);
scripts_icon_col.setMaxWidth(25);
scripts_icon_col.setMinWidth(25);
// Create table with editable script 'file' column
scripts_name_col = new TableColumn<>(Messages.ScriptsDialog_ColScript);
scripts_name_col.setCellValueFactory(new PropertyValueFactory<ScriptItem, String>("file"));
scripts_name_col.setCellFactory(col -> new TextFieldTableCell<ScriptItem, String>(new DefaultStringConverter()) {
private final ChangeListener<? super Boolean> focusedListener = (ob, o, n) -> {
if (!n)
cancelEdit();
};
@Override
public void cancelEdit() {
((TextField) getGraphic()).focusedProperty().removeListener(focusedListener);
super.cancelEdit();
}
@Override
public void startEdit() {
super.startEdit();
((TextField) getGraphic()).focusedProperty().addListener(focusedListener);
}
@Override
public void commitEdit(final String newValue) {
((TextField) getGraphic()).focusedProperty().removeListener(focusedListener);
super.commitEdit(newValue);
Platform.runLater(() -> btn_pv_add.requestFocus());
}
});
scripts_name_col.setOnEditCommit(event -> {
final int row = event.getTablePosition().getRow();
script_items.get(row).file.set(event.getNewValue());
fixupScripts(row);
});
scripts_table = new TableView<>(script_items);
scripts_table.getColumns().add(scripts_icon_col);
scripts_table.getColumns().add(scripts_name_col);
scripts_table.setEditable(true);
scripts_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
scripts_table.setTooltip(new Tooltip(Messages.ScriptsDialog_ScriptsTT));
scripts_table.setPlaceholder(new Label(Messages.ScriptsDialog_NoScripts));
// Buttons
addMenuButton = new MenuButton(Messages.Add, JFXUtil.getIcon("add.png"), new MenuItem(Messages.AddPythonFile, JFXUtil.getIcon("file-python.png")) {
{
setOnAction(e -> addPythonFile());
}
}, new MenuItem(Messages.AddJavaScriptFile, JFXUtil.getIcon("file-javascript.png")) {
{
setOnAction(e -> addJavaScriptFile());
}
}, new SeparatorMenuItem(), new MenuItem(Messages.AddEmbeddedPython, JFXUtil.getIcon("python.png")) {
{
setOnAction(e -> addEmbeddedJython());
}
}, new MenuItem(Messages.AddEmbeddedJavaScript, JFXUtil.getIcon("javascript.png")) {
{
setOnAction(e -> addEmbeddedJavaScript());
}
});
addMenuButton.setMaxWidth(Double.MAX_VALUE);
addMenuButton.setAlignment(Pos.CENTER_LEFT);
btn_script_remove = new Button(Messages.Remove, JFXUtil.getIcon("delete.png"));
btn_script_remove.setMaxWidth(Double.MAX_VALUE);
btn_script_remove.setAlignment(Pos.CENTER_LEFT);
btn_script_remove.setDisable(true);
btn_script_remove.setOnAction(event -> {
final int sel = scripts_table.getSelectionModel().getSelectedIndex();
if (sel >= 0) {
script_items.remove(sel);
fixupScripts(sel);
}
});
btn_edit = new SplitMenuButton(convertToFileMenuItem, new SeparatorMenuItem(), convertToEmbeddedPythonMenuItem, convertToEmbeddedJavaScriptMenuItem);
btn_edit.setText(Messages.Select);
btn_edit.setGraphic(JFXUtil.getIcon("select-file.png"));
btn_edit.setMaxWidth(Double.MAX_VALUE);
btn_edit.setMinWidth(120);
btn_edit.setAlignment(Pos.CENTER_LEFT);
btn_edit.setDisable(true);
btn_edit.setOnAction(e -> editOrSelect());
final VBox buttons = new VBox(10, addMenuButton, btn_script_remove, btn_edit);
final HBox content = new HBox(10, scripts_table, buttons);
HBox.setHgrow(scripts_table, Priority.ALWAYS);
HBox.setHgrow(buttons, Priority.NEVER);
return content;
}
use of javafx.scene.layout.Region in project Board-Instrumentation-Framework by intel.
the class ClockSkin method resize.
private void resize() {
size = getSkinnable().getWidth() < getSkinnable().getHeight() ? getSkinnable().getWidth() : getSkinnable().getHeight();
logoLayer.setWidth(size);
logoLayer.setHeight(size);
if (size > 0) {
pane.setMaxSize(size, size);
background.setPrefSize(size, size);
if (Clock.Design.IOS6 == getSkinnable().getDesign()) {
hourPointerWidthFactor = 0.04;
hourPointerHeightFactor = 0.55;
minutePointerWidthFactor = 0.04;
minutePointerHeightFactor = 0.4;
secondPointerWidthFactor = 0.075;
secondPointerHeightFactor = 0.46;
majorTickWidthFactor = 0.04;
majorTickHeightFactor = 0.12;
minorTickWidthFactor = 0.01;
minorTickHeightFactor = 0.05;
majorTickOffset = 0.018;
minorTickOffset = 0.05;
minuteRotate.setPivotX(size * 0.5 * hourPointerWidthFactor);
minuteRotate.setPivotY(size * 0.76 * hourPointerHeightFactor);
hourRotate.setPivotX(size * 0.5 * minutePointerWidthFactor);
hourRotate.setPivotY(size * 0.66 * minutePointerHeightFactor);
secondRotate.setPivotX(size * 0.5 * secondPointerWidthFactor);
secondRotate.setPivotY(size * 0.7341040462 * secondPointerHeightFactor);
} else if (Clock.Design.BRAUN == getSkinnable().getDesign()) {
hourPointerWidthFactor = 0.105;
hourPointerHeightFactor = 0.485;
minutePointerWidthFactor = 0.105;
minutePointerHeightFactor = 0.4;
secondPointerWidthFactor = 0.09;
secondPointerHeightFactor = 0.53;
majorTickWidthFactor = 0.015;
majorTickHeightFactor = 0.045;
minorTickWidthFactor = 0.0075;
minorTickHeightFactor = 0.0225;
majorTickOffset = 0.012;
minorTickOffset = 0.02;
minuteRotate.setPivotX(size * 0.5 * hourPointerWidthFactor);
minuteRotate.setPivotY(size * 0.895 * hourPointerHeightFactor);
hourRotate.setPivotX(size * 0.5 * minutePointerWidthFactor);
hourRotate.setPivotY(size * 0.87 * minutePointerHeightFactor);
secondRotate.setPivotX(size * 0.5 * secondPointerWidthFactor);
secondRotate.setPivotY(size * 0.8125 * secondPointerHeightFactor);
} else if (Clock.Design.BOSCH == getSkinnable().getDesign()) {
hourPointerWidthFactor = 0.04;
hourPointerHeightFactor = 0.54;
minutePointerWidthFactor = 0.04;
minutePointerHeightFactor = 0.38;
secondPointerWidthFactor = 0.09;
secondPointerHeightFactor = 0.53;
majorTickWidthFactor = 0.02;
majorTickHeightFactor = 0.145;
minorTickWidthFactor = 0.006;
minorTickHeightFactor = 0.07;
majorTickOffset = 0.005;
minorTickOffset = 0.04;
minuteRotate.setPivotX(size * 0.5 * hourPointerWidthFactor);
minuteRotate.setPivotY(size * 0.8240740741 * hourPointerHeightFactor);
hourRotate.setPivotX(size * 0.5 * minutePointerWidthFactor);
hourRotate.setPivotY(size * 0.75 * minutePointerHeightFactor);
secondRotate.setPivotX(size * 0.5 * secondPointerWidthFactor);
secondRotate.setPivotY(size * 0.8125 * secondPointerHeightFactor);
} else {
hourPointerWidthFactor = 0.04;
hourPointerHeightFactor = 0.47;
minutePointerWidthFactor = 0.055;
minutePointerHeightFactor = 0.33;
secondPointerWidthFactor = 0.1;
secondPointerHeightFactor = 0.455;
majorTickWidthFactor = 0.04;
majorTickHeightFactor = 0.12;
minorTickWidthFactor = 0.025;
minorTickHeightFactor = 0.04;
majorTickOffset = 0.018;
minorTickOffset = 0.06;
minuteRotate.setPivotX(size * 0.5 * hourPointerWidthFactor);
minuteRotate.setPivotY(size * hourPointerHeightFactor);
hourRotate.setPivotX(size * 0.5 * minutePointerWidthFactor);
hourRotate.setPivotY(size * minutePointerHeightFactor);
secondRotate.setPivotX(size * 0.5 * secondPointerWidthFactor);
secondRotate.setPivotY(size * secondPointerHeightFactor);
}
drawLogoLayer();
double radius = 0.4;
double sinValue;
double cosValue;
int index = 0;
for (double angle = 0; angle < 360; angle += 6) {
sinValue = Math.sin(Math.toRadians(angle));
cosValue = Math.cos(Math.toRadians(angle));
Region tick = ticks.get(index);
if (angle % 30 == 0) {
tick.setPrefWidth(size * majorTickWidthFactor);
tick.setPrefHeight(size * majorTickHeightFactor);
tick.relocate(size * 0.5 + ((size * (radius + majorTickOffset) * sinValue) - (size * (majorTickWidthFactor) * 0.5)), size * 0.5 + ((size * (radius + majorTickOffset) * cosValue) - (size * (majorTickHeightFactor) * 0.5)));
} else {
tick.setPrefWidth(size * minorTickWidthFactor);
tick.setPrefHeight(size * minorTickHeightFactor);
tick.relocate(size * 0.5 + ((size * (radius + minorTickOffset) * sinValue) - (size * (minorTickWidthFactor) * 0.5)), size * 0.5 + ((size * (radius + minorTickOffset) * cosValue) - (size * (minorTickHeightFactor) * 0.5)));
}
tick.setRotate(-angle);
index++;
}
if (Clock.Design.BRAUN == getSkinnable().getDesign()) {
int tickLabelCounter = 0;
// tickLabelFont = Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/helvetica.ttf"), (0.075 * size));
tickLabelFont = Font.font("Bebas Neue", FontWeight.THIN, FontPosture.REGULAR, 0.09 * size);
for (double angle = 0; angle < 360; angle += 30.0) {
double x = 0.34 * size * Math.sin(Math.toRadians(150 - angle));
double y = 0.34 * size * Math.cos(Math.toRadians(150 - angle));
tickLabels.get(tickLabelCounter).setFont(tickLabelFont);
tickLabels.get(tickLabelCounter).setX(size * 0.5 + x - tickLabels.get(tickLabelCounter).getLayoutBounds().getWidth() * 0.5);
tickLabels.get(tickLabelCounter).setY(size * 0.5 + y);
tickLabels.get(tickLabelCounter).setTextOrigin(VPos.CENTER);
tickLabels.get(tickLabelCounter).setTextAlignment(TextAlignment.CENTER);
tickLabelCounter++;
}
}
minutePointer.setPrefSize(size * hourPointerWidthFactor, size * hourPointerHeightFactor);
if (Clock.Design.IOS6 == getSkinnable().getDesign()) {
minutePointer.relocate(size * 0.5 - (minutePointer.getPrefWidth() * 0.5), size * 0.5 - (minutePointer.getPrefHeight()) + (minutePointer.getPrefHeight() * 0.24));
} else if (Clock.Design.BRAUN == getSkinnable().getDesign()) {
minutePointer.relocate(size * 0.5 - (minutePointer.getPrefWidth() * 0.5), size * 0.5 - (minutePointer.getPrefHeight()) + (minutePointer.getPrefHeight() * 0.108));
minutePointerFlour.setPrefSize(size * hourPointerWidthFactor, size * hourPointerHeightFactor);
minutePointerFlour.relocate(size * 0.5 - (minutePointer.getPrefWidth() * 0.5), size * 0.5 - (minutePointer.getPrefHeight()) + (minutePointer.getPrefHeight() * 0.108));
} else if (Clock.Design.BOSCH == getSkinnable().getDesign()) {
minutePointer.relocate(size * 0.5 - (minutePointer.getPrefWidth() * 0.5), size * 0.5 - (minutePointer.getPrefHeight()) + (minutePointer.getPrefHeight() * 0.1759259259));
} else {
minutePointer.relocate(size * 0.5 - (minutePointer.getPrefWidth() * 0.5), size * 0.5 - minutePointer.getPrefHeight());
}
hourPointer.setPrefSize(size * minutePointerWidthFactor, size * minutePointerHeightFactor);
if (Clock.Design.IOS6 == getSkinnable().getDesign()) {
hourPointer.relocate(size * 0.5 - (hourPointer.getPrefWidth() * 0.5), size * 0.5 - (hourPointer.getPrefHeight()) + (hourPointer.getPrefHeight() * 0.34));
} else if (Clock.Design.BRAUN == getSkinnable().getDesign()) {
hourPointer.relocate(size * 0.5 - (hourPointer.getPrefWidth() * 0.5), size * 0.5 - (hourPointer.getPrefHeight()) + (hourPointer.getPrefHeight() * 0.128));
hourPointerFlour.setPrefSize(size * minutePointerWidthFactor, size * minutePointerHeightFactor);
hourPointerFlour.relocate(size * 0.5 - (hourPointer.getPrefWidth() * 0.5), size * 0.5 - (hourPointer.getPrefHeight()) + (hourPointer.getPrefHeight() * 0.128));
} else if (Clock.Design.BOSCH == getSkinnable().getDesign()) {
hourPointer.relocate(size * 0.5 - (hourPointer.getPrefWidth() * 0.5), size * 0.5 - (hourPointer.getPrefHeight()) + (hourPointer.getPrefHeight() * 0.25));
} else {
hourPointer.relocate(size * 0.5 - (hourPointer.getPrefWidth() * 0.5), size * 0.5 - hourPointer.getPrefHeight());
}
secondPointer.setPrefSize(size * secondPointerWidthFactor, size * secondPointerHeightFactor);
if (Clock.Design.IOS6 == getSkinnable().getDesign()) {
secondPointer.relocate(size * 0.5 - (secondPointer.getPrefWidth() * 0.5), size * 0.5 - (secondPointer.getPrefHeight()) + (secondPointer.getPrefHeight() * 0.2658959538));
} else if (Clock.Design.BRAUN == getSkinnable().getDesign()) {
secondPointer.relocate(size * 0.5 - (secondPointer.getPrefWidth() * 0.5), size * 0.5 - secondPointer.getPrefHeight() + (secondPointer.getPrefHeight() * 0.189));
} else {
secondPointer.relocate(size * 0.5 - (secondPointer.getPrefWidth() * 0.5), size * 0.5 - secondPointer.getPrefHeight());
}
if (Clock.Design.IOS6 == getSkinnable().getDesign()) {
centerKnob.setPrefSize(size * 0.015, size * 0.015);
} else if (Clock.Design.BRAUN == getSkinnable().getDesign()) {
centerKnob.setPrefSize(size * 0.085, size * 0.085);
} else if (Clock.Design.BOSCH == getSkinnable().getDesign()) {
centerKnob.setPrefSize(size * 0.035, size * 0.035);
} else {
centerKnob.setPrefSize(size * 0.1, size * 0.1);
}
centerKnob.relocate(size * 0.5 - (centerKnob.getPrefWidth() * 0.5), size * 0.5 - (centerKnob.getPrefHeight() * 0.5));
foreground.setPrefSize(size * 0.955, size * 0.495);
foreground.relocate(size * 0.5 - (foreground.getPrefWidth() * 0.5), size * 0.01);
}
}
use of javafx.scene.layout.Region in project Board-Instrumentation-Framework by intel.
the class SimplePieChartSkin method initGraphics.
private void initGraphics() {
Fonts.robotoLight(0.06 * PREFERRED_HEIGHT);
dataCanvas = new Canvas(PREFERRED_WIDTH, PREFERRED_HEIGHT);
dataCtx = dataCanvas.getGraphicsContext2D();
info = new Region();
info.getStyleClass().setAll("info");
sum = new Text(String.format(Locale.US, "%." + getSkinnable().getDecimals() + "f", getSkinnable().getSum()));
sum.setMouseTransparent(true);
sum.setTextOrigin(VPos.CENTER);
sum.getStyleClass().setAll("info-text");
title = new Text(getSkinnable().getTitle());
title.setTextOrigin(VPos.CENTER);
title.getStyleClass().setAll("title");
// Add all nodes
pane = new Pane();
pane.getStyleClass().setAll("simple-pie-chart");
pane.getChildren().setAll(dataCanvas, info, sum, title);
getChildren().setAll(pane);
}
use of javafx.scene.layout.Region in project Board-Instrumentation-Framework by intel.
the class VuMeterSkin method handleControlPropertyChanged.
// ******************** Methods *******************************************
protected void handleControlPropertyChanged(final String PROPERTY) {
if ("RESIZE".equals(PROPERTY)) {
resize();
} else if ("STYLE".equals(PROPERTY)) {
resize();
} else if ("VALUE".equals(PROPERTY)) {
int currentLedPeakIndex;
if (Orientation.HORIZONTAL == getSkinnable().getOrientation()) {
// HORIZONTAL
currentLedPeakIndex = 0;
for (int i = 0; i < leds.size(); i++) {
leds.get(i).getStyleClass().remove("led-on");
if (Double.compare(i * stepSize.doubleValue(), getSkinnable().getValue()) <= 0) {
leds.get(i).getStyleClass().add("led-on");
currentLedPeakIndex = i;
}
}
if (getSkinnable().isPeakValueVisible()) {
if (currentLedPeakIndex > peakLedIndex) {
timer.stop();
leds.get(peakLedIndex).getStyleClass().remove("led-peak");
leds.get(currentLedPeakIndex).getStyleClass().add("led-peak");
peakLedIndex = currentLedPeakIndex;
lastTimerCall = System.nanoTime();
timer.start();
}
}
} else {
// VERTICAL
currentLedPeakIndex = leds.size() - 1;
for (int i = 0; i < leds.size(); i++) {
if (i != peakLedIndex)
leds.get(i).getStyleClass().remove("led-on");
if (Double.compare((leds.size() - i - 1) * stepSize.doubleValue(), getSkinnable().getValue()) <= 0) {
leds.get(i).getStyleClass().add("led-on");
} else {
currentLedPeakIndex = i;
}
}
if (getSkinnable().isPeakValueVisible()) {
if (currentLedPeakIndex < peakLedIndex) {
timer.stop();
leds.get(peakLedIndex).getStyleClass().remove("led-peak");
leds.get(currentLedPeakIndex).getStyleClass().add("led-peak");
peakLedIndex = currentLedPeakIndex;
lastTimerCall = System.nanoTime();
timer.start();
}
}
}
} else if ("ORIENTATION".equals(PROPERTY)) {
hBox.getChildren().clear();
vBox.getChildren().clear();
if (Orientation.HORIZONTAL == getSkinnable().getOrientation()) {
vBox.setManaged(false);
vBox.setVisible(false);
hBox.getChildren().setAll(leds);
} else {
hBox.setManaged(false);
hBox.setVisible(false);
vBox.getChildren().setAll(leds);
}
} else if ("NO_OF_LEDS".equals(PROPERTY)) {
leds.clear();
hBox.getChildren().clear();
vBox.getChildren().clear();
for (int i = 0; i < getSkinnable().getNoOfLeds(); i++) {
Region led = new Region();
led.setPrefSize(10, 20);
if (getSkinnable().getSections().isEmpty()) {
led.getStyleClass().setAll("led");
} else {
for (Section section : getSkinnable().getSections()) {
if (section.contains(i * stepSize.doubleValue())) {
led.getStyleClass().setAll("led", section.getStyleClass());
}
}
}
leds.add(led);
}
if (Orientation.HORIZONTAL == getSkinnable().getOrientation()) {
hBox.getChildren().setAll(leds);
} else {
vBox.getChildren().setAll(leds);
}
} else if ("SECTIONS".equals(PROPERTY)) {
for (int i = 0; i < getSkinnable().getNoOfLeds(); i++) {
Region led = new Region();
led.setPrefSize(10, 20);
if (getSkinnable().getSections().isEmpty()) {
led.getStyleClass().setAll("led");
} else {
for (Section section : getSkinnable().getSections()) {
if (section.contains(i * stepSize.doubleValue())) {
led.getStyleClass().setAll("led", section.getStyleClass());
}
}
}
leds.add(led);
}
}
}
use of javafx.scene.layout.Region in project Board-Instrumentation-Framework by intel.
the class SignalTowerSkin method initGraphics.
private void initGraphics() {
green = new Region();
green.getStyleClass().setAll("green");
yellow = new Region();
yellow.getStyleClass().setAll("yellow");
red = new Region();
red.getStyleClass().setAll("red");
rack = new Region();
rack.getStyleClass().setAll("rack");
bodyDropShadow = new DropShadow(BlurType.TWO_PASS_BOX, Color.web("0x000000a6"), 0.0133333333 * PREFERRED_WIDTH, 1.0, 0d, 2d);
bodyInnerShadow = new InnerShadow(BlurType.TWO_PASS_BOX, Color.web("0x000000a6"), 0.0133333333 * PREFERRED_WIDTH, 1.0, 1.4142135623730951, 1.4142135623730951);
bodyInnerShadow.setInput(bodyDropShadow);
body = new Region();
body.getStyleClass().setAll("body");
body.setEffect(bodyInnerShadow);
roof = new Region();
roof.getStyleClass().setAll("roof");
pane = new Pane();
pane.getChildren().setAll(green, yellow, red, rack, body, roof);
getChildren().setAll(pane);
resize();
}
Aggregations