use of org.csstudio.opibuilder.util.OPIColor in project yamcs-studio by yamcs.
the class ColorProperty method toStringInRuleScript.
@Override
public String toStringInRuleScript(Object propValue) {
OPIColor opiColor = (OPIColor) propValue;
if (opiColor.isPreDefined()) {
if (MediaService.getInstance().isColorNameDefined(opiColor.getColorName()))
return QUOTE + opiColor.getColorName() + QUOTE;
}
RGB rgb = opiColor.getRGBValue();
return // $NON-NLS-1$
"ColorFontUtil.getColorFromRGB(" + rgb.red + "," + rgb.green + "," + rgb.blue + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
")";
}
use of org.csstudio.opibuilder.util.OPIColor in project yamcs-studio by yamcs.
the class WidgetConnectionEditPart method activate.
@Override
public void activate() {
if (!isActive()) {
super.activate();
getWidgetModel().getProperty(ConnectionModel.PROP_LINE_COLOR).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setForegroundColor(((OPIColor) evt.getNewValue()).getSWTColor());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_LINE_STYLE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setLineStyle(getWidgetModel().getLineStyle());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_LINE_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setLineWidth(getWidgetModel().getLineWidth());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_ROUTER).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updateRouter(getConnectionFigure());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_POINTS).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(final PropertyChangeEvent evt) {
if (getViewer() == null || getViewer().getControl() == null) {
return;
}
Runnable runnable = new Runnable() {
@Override
public void run() {
if (((PointList) evt.getOldValue()).size() != ((PointList) evt.getNewValue()).size())
updateRouter(getConnectionFigure());
else
refreshBendpoints(getConnectionFigure());
}
};
// It should update at the same rate as other widget at run time
if (getExecutionMode() == ExecutionMode.RUN_MODE) {
Display display = getViewer().getControl().getDisplay();
WidgetIgnorableUITask task = new WidgetIgnorableUITask(getWidgetModel().getProperty(ConnectionModel.PROP_POINTS), runnable, display);
GUIRefreshThread.getInstance(getExecutionMode() == ExecutionMode.RUN_MODE).addIgnorableTask(task);
} else
runnable.run();
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_ARROW_LENGTH).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updateArrowLength(getConnectionFigure());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_ARROW_TYPE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updateDecoration(getConnectionFigure());
updateArrowLength(getConnectionFigure());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_FILL_ARROW).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updateDecoration(getConnectionFigure());
updateArrowLength(getConnectionFigure());
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_ANTIALIAS).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setAntialias(getWidgetModel().isAntiAlias() ? SWT.ON : SWT.OFF);
for (Object obj : getConnectionFigure().getChildren()) {
if (obj instanceof Shape)
((Shape) obj).setAntialias(getWidgetModel().isAntiAlias() ? SWT.ON : SWT.OFF);
}
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_ADD).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setLineJumpAdd(getWidgetModel().getLineJumpAdd());
Runnable runnable = new Runnable() {
@Override
public void run() {
getConnectionFigure().repaint();
}
};
WidgetIgnorableUITask task = new WidgetIgnorableUITask(getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_ADD), runnable, getViewer().getControl().getDisplay());
GUIRefreshThread.getInstance(getExecutionMode() == ExecutionMode.EDIT_MODE).addIgnorableTask(task);
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_SIZE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setLineJumpSize(getWidgetModel().getLineJumpSize());
Runnable runnable = new Runnable() {
@Override
public void run() {
getConnectionFigure().repaint();
}
};
WidgetIgnorableUITask task = new WidgetIgnorableUITask(getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_SIZE), runnable, getViewer().getControl().getDisplay());
GUIRefreshThread.getInstance(getExecutionMode() == ExecutionMode.EDIT_MODE).addIgnorableTask(task);
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_STYLE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
getConnectionFigure().setLineJumpStyle(getWidgetModel().getLineJumpStyle());
Runnable runnable = new Runnable() {
@Override
public void run() {
getConnectionFigure().repaint();
}
};
WidgetIgnorableUITask task = new WidgetIgnorableUITask(getWidgetModel().getProperty(ConnectionModel.PROP_LINE_JUMP_SIZE), runnable, getViewer().getControl().getDisplay());
GUIRefreshThread.getInstance(getExecutionMode() == ExecutionMode.EDIT_MODE).addIgnorableTask(task);
}
});
getWidgetModel().getProperty(ConnectionModel.PROP_IS_LOADED_FROM_LINKING_CONTAINER).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updateRouter(getConnectionFigure());
}
});
}
}
use of org.csstudio.opibuilder.util.OPIColor in project yamcs-studio by yamcs.
the class IntensityGraphEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
innerUpdateGraphAreaSizeProperty();
registerAxisPropertyChangeHandler();
registerROIPropertyChangeHandlers();
registerROIAmountChangeHandler();
IWidgetPropertyChangeHandler handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
if (newValue == null)
return false;
VType value = (VType) newValue;
if (value instanceof VNumberArray) {
setValue(((VNumberArray) value).getData());
return false;
}
((IntensityGraphFigure) figure).setDataArray(VTypeHelper.getDoubleArray(value));
return false;
}
};
setPropertyChangeHandler(AbstractPVWidgetModel.PROP_PVVALUE, handler);
getWidgetModel().getProperty(IntensityGraphModel.PROP_MIN).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
((IntensityGraphFigure) figure).setMin((Double) evt.getNewValue());
figure.repaint();
innerUpdateGraphAreaSizeProperty();
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_MAX).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
((IntensityGraphFigure) figure).setMax((Double) evt.getNewValue());
figure.repaint();
innerUpdateGraphAreaSizeProperty();
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_STYLE).removeAllPropertyChangeListeners();
getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_STYLE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
figure.setBorder(BorderFactory.createBorder(BorderStyle.values()[(Integer) evt.getNewValue()], getWidgetModel().getBorderWidth(), getWidgetModel().getBorderColor(), getWidgetModel().getName()));
innerUpdateGraphAreaSizeProperty();
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_WIDTH).removeAllPropertyChangeListeners();
getWidgetModel().getProperty(IntensityGraphModel.PROP_BORDER_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
figure.setBorder(BorderFactory.createBorder(getWidgetModel().getBorderStyle(), (Integer) evt.getNewValue(), getWidgetModel().getBorderColor(), getWidgetModel().getName()));
innerUpdateGraphAreaSizeProperty();
}
});
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setDataWidth((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_DATA_WIDTH, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setDataHeight((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_DATA_HEIGHT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setColorMap((ColorMap) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_COLOR_MAP, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setCropLeft((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_LEFT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setCropRight((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_RIGHT, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setCropTop((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_TOP, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) figure).setCropBottom((Integer) newValue);
return true;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_CROP_BOTTOM, handler);
getWidgetModel().getProperty(IntensityGraphModel.PROP_SHOW_RAMP).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
((IntensityGraphFigure) getFigure()).setShowRamp((Boolean) evt.getNewValue());
Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
innerTrig = true;
getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH, getWidgetModel().getWidth() - d.width);
innerTrig = false;
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!innerTrig) {
// if it is not triggered from inner
innerTrig = true;
Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH, ((Integer) evt.getNewValue()) - d.width);
// reset innerTrig to false after each inner triggering
innerTrig = false;
} else
// if it is triggered from inner, do nothing
innerTrig = false;
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_GRAPH_AREA_WIDTH).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!innerTrig) {
innerTrig = true;
Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_WIDTH, ((Integer) evt.getNewValue()) + d.width);
// reset innerTrig to false after each inner triggering
innerTrig = false;
} else
innerTrig = false;
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_HEIGHT).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!innerTrig) {
innerTrig = true;
Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_GRAPH_AREA_HEIGHT, ((Integer) evt.getNewValue()) - d.height);
// reset innerTrig to false after each inner triggering
innerTrig = false;
} else
innerTrig = false;
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_GRAPH_AREA_HEIGHT).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
if (!innerTrig) {
innerTrig = true;
Dimension d = ((IntensityGraphFigure) getFigure()).getGraphAreaInsets();
getWidgetModel().setPropertyValue(IntensityGraphModel.PROP_HEIGHT, ((Integer) evt.getNewValue()) + d.height);
// reset innerTrig to false after each inner triggering
innerTrig = false;
} else
innerTrig = false;
}
});
getWidgetModel().getProperty(IntensityGraphModel.PROP_RGB_MODE).addPropertyChangeListener(new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent evt) {
updatePropSheet();
((IntensityGraphFigure) getFigure()).setInRGBMode((Boolean) (evt.getNewValue()));
}
});
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) getFigure()).setColorDepth(getWidgetModel().getColorDepth());
return false;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_COLOR_DEPTH, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) getFigure()).setSingleLineProfiling((Boolean) newValue);
return false;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_SINGLE_LINE_PROFILING, handler);
handler = new IWidgetPropertyChangeHandler() {
@Override
public boolean handleChange(Object oldValue, Object newValue, IFigure figure) {
((IntensityGraphFigure) getFigure()).setROIColor(((OPIColor) newValue).getSWTColor());
return false;
}
};
setPropertyChangeHandler(IntensityGraphModel.PROP_ROI_COLOR, handler);
}
use of org.csstudio.opibuilder.util.OPIColor in project yamcs-studio by yamcs.
the class OPIColorDialog method refreshGUIOnSelection.
/**
* Refreshes the enabled-state of the actions.
*/
private void refreshGUIOnSelection() {
IStructuredSelection selection = (IStructuredSelection) preDefinedColorsViewer.getSelection();
if (!selection.isEmpty() && selection.getFirstElement() instanceof OPIColor) {
opiColor = ((OPIColor) selection.getFirstElement()).getCopy();
setRGBEditValue(opiColor.getRGBValue());
outputTextLabel.setText(opiColor.getColorName());
colorCanvas.setBackground(CustomMediaFactory.getInstance().getColor(opiColor.getRGBValue()));
}
}
use of org.csstudio.opibuilder.util.OPIColor in project yamcs-studio by yamcs.
the class KnobEditPart method registerPropertyChangeHandlers.
@Override
protected void registerPropertyChangeHandlers() {
registerCommonPropertyChangeHandlers();
setPropertyChangeHandler(PROP_KNOB_COLOR, (oldValue, newValue, refreshableFigure) -> {
var knob = (KnobFigure) refreshableFigure;
knob.setBulbColor(((OPIColor) newValue).getSWTColor());
return false;
});
setPropertyChangeHandler(PROP_THUMB_COLOR, (oldValue, newValue, refreshableFigure) -> {
var knob = (KnobFigure) refreshableFigure;
knob.setThumbColor(((OPIColor) newValue).getSWTColor());
return false;
});
setPropertyChangeHandler(PROP_EFFECT3D, (oldValue, newValue, refreshableFigure) -> {
var knob = (KnobFigure) refreshableFigure;
knob.setEffect3D((Boolean) newValue);
return false;
});
setPropertyChangeHandler(PROP_SHOW_VALUE_LABEL, (oldValue, newValue, refreshableFigure) -> {
var knob = (KnobFigure) refreshableFigure;
knob.setValueLabelVisibility((Boolean) newValue);
return false;
});
setPropertyChangeHandler(PROP_RAMP_GRADIENT, (oldValue, newValue, refreshableFigure) -> {
var knob = (KnobFigure) refreshableFigure;
knob.setGradient((Boolean) newValue);
return false;
});
setPropertyChangeHandler(PROP_INCREMENT, (oldValue, newValue, refreshableFigure) -> {
var knob = (KnobFigure) refreshableFigure;
knob.setIncrement((Double) newValue);
return false;
});
// force square size
IWidgetPropertyChangeHandler sizeHandler = (oldValue, newValue, figure) -> {
if (((Integer) newValue) < KnobModel.MINIMUM_SIZE) {
newValue = KnobModel.MINIMUM_SIZE;
}
getWidgetModel().setSize((Integer) newValue, (Integer) newValue);
return false;
};
PropertyChangeListener sizeListener = evt -> sizeHandler.handleChange(evt.getOldValue(), evt.getNewValue(), getFigure());
getWidgetModel().getProperty(PROP_WIDTH).addPropertyChangeListener(sizeListener);
getWidgetModel().getProperty(PROP_HEIGHT).addPropertyChangeListener(sizeListener);
}
Aggregations