use of org.diirt.vtype.VBoolean in project yamcs-studio by yamcs.
the class AbstractVBooleanVBooleanToVBooleanFormulaFunction method calculate.
@Override
public Object calculate(List<Object> args) {
if (NullUtils.containsNull(args)) {
return null;
}
VBoolean arg1 = (VBoolean) args.get(0);
VBoolean arg2 = (VBoolean) args.get(1);
return ValueFactory.newVBoolean(calculate(arg1.getValue(), arg2.getValue()), highestSeverityOf(args, false), latestValidTimeOrNowOf(args));
}
use of org.diirt.vtype.VBoolean in project yamcs-studio by yamcs.
the class DimDisplayFormulaFunction method calculate.
@Override
public Object calculate(final List<Object> args) {
VNumber size = (VNumber) args.get(0);
VBoolean invert = (VBoolean) args.get(1);
if (size == null || invert == null) {
return null;
}
return ValueFactory.newDisplay(size.getValue().intValue(), VTableFactory.step(0, 1), invert.getValue());
}
use of org.diirt.vtype.VBoolean in project yamcs-studio by yamcs.
the class ConditionalOperatorFormulaFunction method calculate.
@Override
public Object calculate(List<Object> args) {
// Convert arguments to actual types
VBoolean condition = (VBoolean) args.get(0);
// Handle null case
if (condition == null) {
return null;
}
// Select return based on value
Object value;
if (condition.getValue()) {
value = args.get(1);
} else {
value = args.get(2);
}
return value;
}
use of org.diirt.vtype.VBoolean in project org.csstudio.display.builder by kasemir.
the class SymbolRepresentation 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);
}
value = model_widget.propAutoSize().getValue();
if (!Objects.equals(value, autoSize)) {
autoSize = (boolean) value;
}
if (autoSize) {
model_widget.propWidth().setValue((int) Math.round(maxSize.getWidth()));
model_widget.propHeight().setValue((int) Math.round(maxSize.getHeight()));
}
double w = model_widget.propWidth().getValue();
double h = model_widget.propHeight().getValue();
jfx_node.setLayoutX(model_widget.propX().getValue());
jfx_node.setLayoutY(model_widget.propY().getValue());
jfx_node.setPrefWidth(w);
jfx_node.setPrefHeight(h);
double minSize = Math.min(w, h);
indexLabelBackground.setRadius(Math.min(minSize / 2, 16.0));
}
if (dirtyIndex.checkAndClear()) {
setImageIndex(Math.min(Math.max(model_widget.propInitialIndex().getValue(), 0), imagesList.size() - 1));
}
if (dirtyContent.checkAndClear()) {
value = model_widget.propArrayIndex().getValue();
if (!Objects.equals(value, arrayIndex)) {
arrayIndex = Math.max(0, (int) value);
}
setImageIndex(Math.min(Math.max(getImageIndex(), 0), imagesList.size() - 1));
}
if (dirtyStyle.checkAndClear()) {
value = model_widget.propPreserveRatio().getValue();
if (!Objects.equals(value, imageView.isPreserveRatio())) {
imageView.setPreserveRatio((boolean) value);
}
value = model_widget.propEnabled().getValue();
if (!Objects.equals(value, enabled)) {
enabled = (boolean) value;
Styles.update(jfx_node, Styles.NOT_ENABLED, !enabled);
}
value = model_widget.propShowIndex().getValue();
if (!Objects.equals(value, indexLabel.isVisible())) {
indexLabel.setVisible((boolean) value);
indexLabelBackground.setVisible((boolean) value);
}
if (model_widget.propTransparent().getValue()) {
jfx_node.setBackground(null);
} else {
jfx_node.setBackground(new Background(new BackgroundFill(JFXUtil.convert(model_widget.propBackgroundColor().getValue()), CornerRadii.EMPTY, Insets.EMPTY)));
}
value = model_widget.propRotation().getValue();
if (!Objects.equals(value, imagePane.getRotate())) {
imagePane.setRotate((double) value);
}
}
if (dirtyValue.checkAndClear() && updatingValue.compareAndSet(false, true)) {
int idx = -1;
try {
value = model_widget.runtimePropValue().getValue();
if (value != null) {
if (value instanceof VBoolean) {
idx = ((VBoolean) value).getValue() ? 1 : 0;
} else if (value instanceof VString) {
try {
idx = 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) {
idx = ((VNumber) value).getValue().intValue();
} else if (value instanceof VEnum) {
idx = ((VEnum) value).getIndex();
} else if (value instanceof VNumberArray) {
ListNumber array = ((VNumberArray) value).getData();
if (array.size() > 0) {
idx = array.getInt(Math.min(arrayIndex, array.size() - 1));
}
} else if (value instanceof VEnumArray) {
ListInt array = ((VEnumArray) value).getIndexes();
if (array.size() > 0) {
idx = array.getInt(Math.min(arrayIndex, array.size() - 1));
}
}
}
} finally {
updatingValue.set(false);
}
setImageIndex(Math.min(Math.max(idx, 0), imagesList.size() - 1));
}
}
use of org.diirt.vtype.VBoolean 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");
}
}
Aggregations