use of javafx.scene.layout.Region in project Gargoyle by callakrsos.
the class ColorAnalysisExam method start.
/*
* (non-Javadoc)
*
* @see javafx.application.Application#start(javafx.stage.Stage)
*/
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane root = new BorderPane();
ColorPicker value = new ColorPicker();
root.setTop(value);
List<Label> arrayList = new ArrayList<>();
for (int i = 0; i < 7; i++) {
Label region = new Label();
region.setPrefWidth(100);
region.setPrefHeight(100);
String text = "";
switch(i) {
case 0:
text = "Default";
break;
case 1:
text = "Brigher";
break;
case 2:
text = "darker";
break;
case 3:
text = "desaturate";
break;
case 4:
text = "grayscale";
break;
case 5:
text = "invert";
break;
case 6:
text = "saturate";
break;
}
region.setText(text);
arrayList.add(region);
}
Region region2 = new Region();
region2.setPrefWidth(100);
region2.setPrefHeight(100);
value.valueProperty().addListener((oba, o, n) -> {
arrayList.get(0).setBackground(new Background(new BackgroundFill(n, CornerRadii.EMPTY, new Insets(0))));
arrayList.get(1).setBackground(new Background(new BackgroundFill(n.brighter(), CornerRadii.EMPTY, new Insets(0))));
arrayList.get(2).setBackground(new Background(new BackgroundFill(n.darker(), CornerRadii.EMPTY, new Insets(0))));
arrayList.get(3).setBackground(new Background(new BackgroundFill(n.desaturate(), CornerRadii.EMPTY, new Insets(0))));
arrayList.get(4).setBackground(new Background(new BackgroundFill(n.grayscale(), CornerRadii.EMPTY, new Insets(0))));
arrayList.get(5).setBackground(new Background(new BackgroundFill(n.invert(), CornerRadii.EMPTY, new Insets(0))));
arrayList.get(6).setBackground(new Background(new BackgroundFill(n.saturate(), CornerRadii.EMPTY, new Insets(0))));
});
HBox value2 = new HBox();
value2.getChildren().addAll(arrayList);
root.setCenter(value2);
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
use of javafx.scene.layout.Region in project blue by kunstmusik.
the class BSBGroupView method addBSBObject.
protected void addBSBObject(BSBObject bsbObj) {
try {
Region objectView = BSBObjectEditorFactory.getView(bsbObj);
// FIXME
// BooleanProperty editEnabledProperty = allowEditing ? bsbInterface.editEnabledProperty() : null;
BSBObjectViewHolder viewHolder = new BSBObjectViewHolder(editEnabledProperty, selection, groupsList, objectView);
if (objectView instanceof EditModeOnly) {
if (editEnabledProperty != null) {
viewHolder.visibleProperty().bind(editEnabledProperty);
} else {
viewHolder.setVisible(false);
}
}
if (bsbObj instanceof BSBGroup) {
BSBGroupView bsbGroupView = (BSBGroupView) objectView;
bsbGroupView.initialize(editEnabledProperty, selection, groupsList);
}
editorPane.getChildren().add(viewHolder);
} catch (Exception e) {
Exceptions.printStackTrace(e);
}
}
use of javafx.scene.layout.Region in project org.csstudio.display.builder by kasemir.
the class RulesDialog method createContent.
private SplitPane createContent() {
final Node rules = createRulesTable();
final HBox pvs = createPVsTable();
final HBox exprs = createExpressionsTable();
// Display PVs of currently selected rule
rules_table.getSelectionModel().selectedItemProperty().addListener((prop, old, selected) -> {
selected_rule_item = selected;
if (selected == null) {
pvs.setDisable(true);
exprs.setDisable(true);
btn_remove_rule.setDisable(true);
btn_dup_rule.setDisable(true);
btn_move_rule_up.setDisable(true);
btn_move_rule_down.setDisable(true);
btn_show_script.setDisable(true);
propComboBox.setDisable(true);
propComboBox.getSelectionModel().select(null);
valExpBox.setDisable(true);
pv_items.clear();
expression_items.clear();
} else {
pvs.setDisable(false);
exprs.setDisable(false);
final TableViewSelectionModel<RuleItem> model = rules_table.getSelectionModel();
btn_remove_rule.setDisable(false);
btn_dup_rule.setDisable(false);
btn_move_rule_up.setDisable(model.getSelectedIndex() == 0);
btn_move_rule_down.setDisable(model.getSelectedIndex() == rule_items.size() - 1);
btn_show_script.setDisable(false);
propComboBox.setDisable(false);
propComboBox.getSelectionModel().select(getPropLongString(selected));
valExpBox.setDisable(false);
valExpBox.selectedProperty().set(selected.prop_as_expr.get());
pv_items.setAll(selected.pvs);
expression_items.setAll(selected.expressions);
fixupPVs(0);
}
});
// Update PVs of selected rule from PVs table
final ListChangeListener<PVTableItem> pll = change -> {
final RuleItem selected = rules_table.getSelectionModel().getSelectedItem();
if (selected != null)
selected.pvs = new ArrayList<>(change.getList());
};
pv_items.addListener(pll);
// Update buttons for currently selected PV
pvs_table.getSelectionModel().selectedItemProperty().addListener((prop, old, selected) -> {
if (selected == null) {
btn_rm_pv.setDisable(true);
btn_move_pv_up.setDisable(true);
btn_move_pv_down.setDisable(true);
} else {
final TableViewSelectionModel<PVTableItem> model = pvs_table.getSelectionModel();
btn_rm_pv.setDisable(false);
btn_move_pv_up.setDisable(model.getSelectedIndex() == 0);
btn_move_pv_down.setDisable(model.getSelectedIndex() == pv_items.size() - 1);
}
});
// Update Expressions of selected rule from Expressions table
final ListChangeListener<ExprItem<?>> ell = change -> {
final RuleItem selected = rules_table.getSelectionModel().getSelectedItem();
if (selected != null)
selected.expressions = new ArrayList<>(change.getList());
};
expression_items.addListener(ell);
// Update buttons for currently selected expression
expressions_table.getSelectionModel().selectedItemProperty().addListener((prop, old, selected) -> {
if (selected == null) {
btn_rm_exp.setDisable(true);
btn_move_exp_up.setDisable(true);
btn_move_exp_down.setDisable(true);
} else {
final TableViewSelectionModel<ExprItem<?>> model = expressions_table.getSelectionModel();
btn_rm_exp.setDisable(false);
btn_move_exp_up.setDisable(model.getSelectedIndex() == 0);
btn_move_exp_down.setDisable(model.getSelectedIndex() == expression_items.size() - 1);
}
});
// What is the property id option we are using?
final Label propLabel = new Label("Property ID:");
// Show each property with current value
final ObservableList<String> prop_id_opts = FXCollections.observableArrayList();
for (PropInfo pi : propinfo_ls) {
// Property _value_ can be long, ex. points of a polyline
// Truncate the value that's shown in the combo box
// to prevent combo from using all screen width.
String prop_opt = pi.toString();
if (prop_opt.length() > MAX_PROP_LENGTH)
prop_opt = prop_opt.substring(0, MAX_PROP_LENGTH) + "...";
prop_id_opts.add(prop_opt);
}
propComboBox = new ComboBox<String>(prop_id_opts);
propComboBox.setDisable(true);
propComboBox.getSelectionModel().selectedIndexProperty().addListener((p, o, index) -> {
// Select property info based on index within combo.
final int idx = index.intValue();
if (idx >= 0) {
final PropInfo prop = propinfo_ls.get(idx);
if (selected_rule_item.tryUpdatePropID(undo, prop.getPropID()))
expression_items.setAll(selected_rule_item.expressions);
}
});
propComboBox.setMinHeight(27);
propComboBox.setMaxWidth(Double.MAX_VALUE);
HBox.setHgrow(propComboBox, Priority.ALWAYS);
// TODO: change this to actually manipulate expression objects in the rule
valExpBox = new CheckBox("Value as Expression");
valExpBox.setDisable(true);
valExpBox.selectedProperty().addListener((ov, old_val, new_val) -> {
if (!selected_rule_item.tryTogglePropAsExpr(undo, new_val))
logger.log(Level.FINE, "Did not update rule property as expression flag to " + new_val);
else
expression_items.setAll(selected_rule_item.expressions);
});
final Region spring = new Region();
HBox.setHgrow(spring, Priority.ALWAYS);
final HBox props = new HBox(10, propLabel, propComboBox, spring, valExpBox);
props.setAlignment(Pos.CENTER);
pvs.setPadding(new Insets(0, 10, 0, 0));
exprs.setPadding(new Insets(0, 0, 0, 10));
HBox.setHgrow(pvs, Priority.ALWAYS);
HBox.setHgrow(exprs, Priority.ALWAYS);
final Preferences pref = Preferences.userNodeForPackage(RulesDialog.class);
final double prefRSPDividerPosition = pref.getDouble("rule.content.divider.position", 0.5);
ruleSplitPane = new SplitPane(pvs, exprs);
ruleSplitPane.setOrientation(Orientation.HORIZONTAL);
ruleSplitPane.setDividerPositions(prefRSPDividerPosition);
ruleSplitPane.setStyle("-fx-background-insets: 0, 0;");
VBox.setVgrow(ruleSplitPane, Priority.ALWAYS);
final VBox subitems = new VBox(10, props, ruleSplitPane);
final VBox rulebox = new VBox(10, rules);
rulebox.setPadding(new Insets(0, 10, 0, 0));
subitems.setPadding(new Insets(0, 0, 0, 10));
VBox.setVgrow(rules, Priority.ALWAYS);
HBox.setHgrow(subitems, Priority.ALWAYS);
final double prefWidth = pref.getDouble("content.width", -1);
final double prefHeight = pref.getDouble("content.height", -1);
final double prefDividerPosition = pref.getDouble("content.divider.position", 0.3);
final SplitPane splitPane = new SplitPane(rulebox, subitems);
splitPane.setOrientation(Orientation.HORIZONTAL);
splitPane.setDividerPositions(prefDividerPosition);
if (prefWidth > 0 && prefHeight > 0)
splitPane.setPrefSize(prefWidth, prefHeight);
// Select the first rule
if (!rules_table.getItems().isEmpty()) {
Platform.runLater(() -> {
rules_table.getSelectionModel().select(0);
rules_table.requestFocus();
});
} else
Platform.runLater(() -> btn_add_rule.requestFocus());
return splitPane;
}
use of javafx.scene.layout.Region in project org.csstudio.display.builder by kasemir.
the class ColorMapDialog method createContent.
private Node createContent() {
// Table for selecting a predefined color map
predefined_table = new TableView<>();
final TableColumn<PredefinedColorMaps.Predefined, String> name_column = new TableColumn<>(Messages.ColorMapDialog_PredefinedMap);
name_column.setCellValueFactory(param -> new SimpleStringProperty(param.getValue().getDescription()));
predefined_table.getColumns().add(name_column);
predefined_table.getItems().addAll(PredefinedColorMaps.PREDEFINED);
predefined_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
// Table for viewing/editing color sections
sections_table = new TableView<>();
// Value of color section
final TableColumn<ColorSection, String> value_column = new TableColumn<>(Messages.ColorMapDialog_Value);
value_column.setCellValueFactory(param -> new SimpleStringProperty(Integer.toString(param.getValue().value)));
value_column.setCellFactory(TextFieldTableCell.forTableColumn());
value_column.setOnEditCommit(event -> {
final int index = event.getTablePosition().getRow();
try {
final int value = Math.max(0, Math.min(255, Integer.parseInt(event.getNewValue().trim())));
color_sections.set(index, new ColorSection(value, color_sections.get(index).color));
color_sections.sort((sec1, sec2) -> sec1.value - sec2.value);
updateMapFromSections();
} catch (NumberFormatException ex) {
// Ignore, field will reset to original value
}
});
// Color of color section
final TableColumn<ColorSection, ColorPicker> color_column = new TableColumn<>(Messages.ColorMapDialog_Color);
color_column.setCellValueFactory(param -> {
final ColorSection segment = param.getValue();
return new SimpleObjectProperty<ColorPicker>(createColorPicker(segment));
});
color_column.setCellFactory(column -> new ColorTableCell());
sections_table.getColumns().add(value_column);
sections_table.getColumns().add(color_column);
sections_table.setColumnResizePolicy(TableView.CONSTRAINED_RESIZE_POLICY);
sections_table.setItems(color_sections);
sections_table.setEditable(true);
add = new Button(Messages.ColorMapDialog_Add, JFXUtil.getIcon("add.png"));
add.setMaxWidth(Double.MAX_VALUE);
remove = new Button(Messages.ColorMapDialog_Remove, JFXUtil.getIcon("delete.png"));
remove.setMaxWidth(Double.MAX_VALUE);
final VBox buttons = new VBox(10, add, remove);
// Upper section with tables
final HBox tables_and_buttons = new HBox(10, predefined_table, sections_table, buttons);
HBox.setHgrow(predefined_table, Priority.ALWAYS);
HBox.setHgrow(sections_table, Priority.ALWAYS);
// Lower section with resulting color map
final Region fill1 = new Region(), fill2 = new Region(), fill3 = new Region();
HBox.setHgrow(fill1, Priority.ALWAYS);
HBox.setHgrow(fill2, Priority.ALWAYS);
HBox.setHgrow(fill3, Priority.ALWAYS);
final HBox color_title = new HBox(fill1, new Label(Messages.ColorMapDialog_Result), fill2);
color_bar = new Region();
color_bar.setMinHeight(COLOR_BAR_HEIGHT);
color_bar.setMaxHeight(COLOR_BAR_HEIGHT);
color_bar.setPrefHeight(COLOR_BAR_HEIGHT);
final HBox color_legend = new HBox(new Label("0"), fill3, new Label("255"));
final VBox box = new VBox(10, tables_and_buttons, new Separator(), color_title, color_bar, color_legend);
VBox.setVgrow(tables_and_buttons, Priority.ALWAYS);
return box;
}
use of javafx.scene.layout.Region in project org.csstudio.display.builder by kasemir.
the class ScriptsDialog method createContent.
private SplitPane createContent() {
final Region scripts = createScriptsTable();
final Region pvs = createPVsTable();
// Display PVs of currently selected script
scripts_table.getSelectionModel().selectedItemProperty().addListener((prop, old, selected) -> {
selected_script_item = selected;
if (selected == null) {
btn_script_remove.setDisable(true);
btn_edit.setDisable(true);
pvs.setDisable(true);
pv_items.clear();
} else {
btn_script_remove.setDisable(false);
btn_edit.setDisable(false);
pvs.setDisable(false);
btn_check_connections.setSelected(selected.check_connections);
pv_items.setAll(selected.pvs);
fixupPVs(0);
if (ScriptInfo.isEmbedded(selected.getScriptInfo().getPath())) {
scripts_table.setEditable(false);
btn_edit.setText(Messages.Edit);
btn_edit.setGraphic(JFXUtil.getIcon("edit.png"));
if (ScriptInfo.isJython(selected.getScriptInfo().getPath())) {
convertToFileMenuItem.setDisable(false);
convertToEmbeddedPythonMenuItem.setDisable(true);
convertToEmbeddedJavaScriptMenuItem.setDisable(false);
} else if (ScriptInfo.isJavaScript(selected.getScriptInfo().getPath())) {
convertToFileMenuItem.setDisable(false);
convertToEmbeddedPythonMenuItem.setDisable(false);
convertToEmbeddedJavaScriptMenuItem.setDisable(true);
} else {
convertToFileMenuItem.setDisable(true);
convertToEmbeddedPythonMenuItem.setDisable(true);
convertToEmbeddedJavaScriptMenuItem.setDisable(true);
}
} else {
scripts_table.setEditable(true);
btn_edit.setText(Messages.Select);
btn_edit.setGraphic(JFXUtil.getIcon("select-file.png"));
convertToFileMenuItem.setDisable(true);
convertToEmbeddedPythonMenuItem.setDisable(false);
convertToEmbeddedJavaScriptMenuItem.setDisable(false);
}
}
});
// Update PVs of selected script from PVs table
final ListChangeListener<PVTableItem> ll = change -> {
final ScriptItem selected = scripts_table.getSelectionModel().getSelectedItem();
if (selected != null)
selected.pvs = new ArrayList<>(change.getList());
};
pv_items.addListener(ll);
// Update buttons for currently selected PV
pvs_table.getSelectionModel().selectedItemProperty().addListener((prop, old, selected) -> {
if (selected == null) {
btn_pv_remove.setDisable(true);
btn_pv_up.setDisable(true);
btn_py_down.setDisable(true);
} else {
final TableViewSelectionModel<PVTableItem> model = pvs_table.getSelectionModel();
btn_pv_remove.setDisable(false);
btn_pv_up.setDisable(model.getSelectedIndex() == 0);
btn_py_down.setDisable(model.getSelectedIndex() == pv_items.size() - 1);
}
});
scripts.setPadding(new Insets(0, 10, 0, 0));
pvs.setPadding(new Insets(0, 0, 0, 10));
final Preferences pref = Preferences.userNodeForPackage(ScriptsDialog.class);
double prefWidth = pref.getDouble("content.width", -1);
double prefHeight = pref.getDouble("content.height", -1);
double prefDividerPosition = pref.getDouble("content.divider.position", 0.5);
final SplitPane splitPane = new SplitPane(scripts, pvs);
splitPane.setDividerPositions(prefDividerPosition);
if (prefWidth > 0 && prefHeight > 0)
splitPane.setPrefSize(prefWidth, prefHeight);
// Select the first script
if (!scripts_table.getItems().isEmpty()) {
Platform.runLater(() -> {
scripts_table.getSelectionModel().select(0);
scripts_table.requestFocus();
});
} else
Platform.runLater(() -> addMenuButton.requestFocus());
return splitPane;
}
Aggregations