use of org.csstudio.display.builder.model.properties.RotationStep in project org.csstudio.display.builder by kasemir.
the class TextUpdateRepresentation method updateChanges.
@Override
public void updateChanges() {
super.updateChanges();
if (dirty_style.checkAndClear()) {
final RotationStep rotation = model_widget.propRotationStep().getValue();
final int width = model_widget.propWidth().getValue(), height = model_widget.propHeight().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;
}
if (model_widget.propTransparent().getValue())
// No fill
jfx_node.setBackground(null);
else {
final Color color = JFXUtil.convert(model_widget.propBackgroundColor().getValue());
jfx_node.setBackground(new Background(new BackgroundFill(color, CornerRadii.EMPTY, Insets.EMPTY)));
}
if (jfx_node instanceof Label) {
final Label label = (Label) jfx_node;
Color color = JFXUtil.convert(model_widget.propForegroundColor().getValue());
label.setTextFill(color);
label.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
label.setAlignment(pos);
label.setWrapText(model_widget.propWrapWords().getValue());
} else {
final TextArea area = (TextArea) jfx_node;
final StringBuilder style = new StringBuilder(100);
style.append("-fx-text-fill:");
JFXUtil.appendWebRGB(style, model_widget.propForegroundColor().getValue()).append(";");
// http://stackoverflow.com/questions/27700006/how-do-you-change-the-background-color-of-a-textfield-without-changing-the-border
final WidgetColor back_color = model_widget.propBackgroundColor().getValue();
style.append("-fx-control-inner-background: ");
JFXUtil.appendWebRGB(style, back_color).append(";");
area.setStyle(style.toString());
area.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
// Alignment (pos) not supported
area.setWrapText(model_widget.propWrapWords().getValue());
}
}
if (dirty_content.checkAndClear()) {
if (jfx_node instanceof Label)
((Label) jfx_node).setText(value_text);
else
((TextArea) jfx_node).setText(value_text);
}
}
use of org.csstudio.display.builder.model.properties.RotationStep in project org.csstudio.display.builder by kasemir.
the class ActionButtonRepresentation method updateChanges.
@Override
public void updateChanges() {
super.updateChanges();
if (dirty_actionls.checkAndClear()) {
base = makeBaseButton();
jfx_node.getChildren().setAll(base);
}
if (dirty_representation.checkAndClear()) {
button_text = makeButtonText();
base.setText(button_text);
base.setTextFill(foreground);
base.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
final RotationStep rotation = model_widget.propRotationStep().getValue();
final int width = model_widget.propWidth().getValue(), height = model_widget.propHeight().getValue();
// Applying the transformation to the Pane does not exhibit this problem.
switch(rotation) {
case NONE:
base.setPrefSize(width, height);
if (was_ever_transformed)
jfx_node.getTransforms().clear();
break;
case NINETY:
base.setPrefSize(height, width);
jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(-height, 0));
was_ever_transformed = true;
break;
case ONEEIGHTY:
base.setPrefSize(width, height);
jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(-width, -height));
was_ever_transformed = true;
break;
case MINUS_NINETY:
base.setPrefSize(height, width);
jfx_node.getTransforms().setAll(new Rotate(-rotation.getAngle()), new Translate(0, -width));
was_ever_transformed = true;
break;
}
}
if (dirty_enablement.checkAndClear()) {
base.setDisable(!enabled);
Styles.update(jfx_node, Styles.NOT_ENABLED, !enabled);
}
}
use of org.csstudio.display.builder.model.properties.RotationStep in project org.csstudio.display.builder by kasemir.
the class TextSymbolRepresentation method updateChanges.
@Override
public void updateChanges() {
super.updateChanges();
Object value;
if (dirtyGeometry.checkAndClear()) {
value = model_widget.propVisible().getValue();
if (!Objects.equals(value, jfx_node.isVisible())) {
jfx_node.setVisible((boolean) value);
}
jfx_node.setLayoutX(model_widget.propX().getValue());
jfx_node.setLayoutY(model_widget.propY().getValue());
jfx_node.setPrefWidth(model_widget.propWidth().getValue());
jfx_node.setPrefHeight(model_widget.propHeight().getValue());
}
if (dirtyContent.checkAndClear()) {
value = model_widget.propArrayIndex().getValue();
if (!Objects.equals(value, arrayIndex)) {
arrayIndex = Math.max(0, (int) value);
}
symbolIndex = Math.min(Math.max(symbolIndex, 0), model_widget.propSymbols().size() - 1);
jfx_node.setText((symbolIndex >= 0) ? model_widget.propSymbols().getElement(symbolIndex).getValue() : "\u263A");
}
if (dirtyStyle.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;
}
value = model_widget.propEnabled().getValue();
if (!Objects.equals(value, enabled)) {
enabled = (boolean) value;
Styles.update(jfx_node, Styles.NOT_ENABLED, !enabled);
}
jfx_node.setAlignment(JFXUtil.computePos(model_widget.propHorizontalAlignment().getValue(), model_widget.propVerticalAlignment().getValue()));
jfx_node.setBackground(model_widget.propTransparent().getValue() ? null : new Background(new BackgroundFill(JFXUtil.convert(model_widget.propBackgroundColor().getValue()), CornerRadii.EMPTY, Insets.EMPTY)));
jfx_node.setFont(JFXUtil.convert(model_widget.propFont().getValue()));
jfx_node.setTextFill(JFXUtil.convert(model_widget.propForegroundColor().getValue()));
jfx_node.setWrapText(model_widget.propWrapWords().getValue());
}
if (dirtyValue.checkAndClear() && updatingValue.compareAndSet(false, true)) {
try {
value = model_widget.runtimePropValue().getValue();
if (value != null) {
if (value instanceof VBoolean) {
symbolIndex = ((VBoolean) value).getValue() ? 1 : 0;
} else if (value instanceof VString) {
try {
symbolIndex = Integer.parseInt(((VString) value).getValue());
} catch (NumberFormatException nfex) {
logger.log(Level.FINE, "Failure parsing the string value: {0} [{1}].", new Object[] { ((VString) value).getValue(), nfex.getMessage() });
}
} else if (value instanceof VNumber) {
symbolIndex = ((VNumber) value).getValue().intValue();
} else if (value instanceof VEnum) {
symbolIndex = ((VEnum) value).getIndex();
} else if (value instanceof VNumberArray) {
ListNumber array = ((VNumberArray) value).getData();
if (array.size() > 0) {
symbolIndex = array.getInt(Math.min(arrayIndex, array.size() - 1));
}
} else if (value instanceof VEnumArray) {
ListInt array = ((VEnumArray) value).getIndexes();
if (array.size() > 0) {
symbolIndex = array.getInt(Math.min(arrayIndex, array.size() - 1));
}
}
}
} finally {
updatingValue.set(false);
}
symbolIndex = Math.min(Math.max(symbolIndex, 0), model_widget.propSymbols().size() - 1);
jfx_node.setText((symbolIndex >= 0) ? model_widget.propSymbols().getElement(symbolIndex).getValue() : "\u263A");
}
}
use of org.csstudio.display.builder.model.properties.RotationStep 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()));
}
}
}
Aggregations