use of org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap in project yamcs-studio by yamcs.
the class ColorMapEditDialog method createDialogArea.
@Override
protected Control createDialogArea(Composite parent) {
final Composite parent_Composite = (Composite) super.createDialogArea(parent);
final Composite mainComposite = new Composite(parent_Composite, SWT.None);
mainComposite.setLayout(new GridLayout(2, false));
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
gridData.heightHint = 300;
mainComposite.setLayoutData(gridData);
final Composite leftComposite = new Composite(mainComposite, SWT.None);
leftComposite.setLayout(new GridLayout(1, false));
GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 250;
leftComposite.setLayoutData(gd);
createLabel(leftComposite, "Color Map:");
Composite toolBarComposite = new Composite(leftComposite, SWT.BORDER);
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.marginLeft = 0;
gridLayout.marginRight = 0;
gridLayout.marginBottom = 0;
gridLayout.marginTop = 0;
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
toolBarComposite.setLayout(gridLayout);
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
toolBarComposite.setLayoutData(gd);
ToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT);
ToolBar toolBar = toolbarManager.createControl(toolBarComposite);
GridData grid = new GridData();
grid.horizontalAlignment = GridData.FILL;
grid.verticalAlignment = GridData.BEGINNING;
toolBar.setLayoutData(grid);
createActions();
toolbarManager.add(addAction);
toolbarManager.add(copyAction);
toolbarManager.add(removeAction);
toolbarManager.add(moveUpAction);
toolbarManager.add(moveDownAction);
toolbarManager.update(true);
colorListViewer = createColorListViewer(toolBarComposite);
colorListViewer.setInput(colorList);
Composite rightComposite = new Composite(mainComposite, SWT.NONE);
rightComposite.setLayout(new GridLayout(1, false));
gd = new GridData(SWT.FILL, SWT.FILL, true, true);
gd.widthHint = 340;
rightComposite.setLayoutData(gd);
this.createLabel(rightComposite, "Use predefined color map:");
preDefinedMapCombo = new Combo(rightComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
preDefinedMapCombo.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, false, false));
preDefinedMapCombo.setItems(PredefinedColorMap.getStringValues());
int i = 0;
for (PredefinedColorMap colorMap : PredefinedColorMap.values()) {
if (predefinedColorMap == colorMap)
break;
else
i++;
}
preDefinedMapCombo.select(i);
final Button InterpolateCheckBox = new Button(rightComposite, SWT.CHECK);
InterpolateCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false));
InterpolateCheckBox.setSelection(interpolate);
InterpolateCheckBox.setText("Interpolate");
final Button autoScaleCheckBox = new Button(rightComposite, SWT.CHECK);
autoScaleCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, false, false));
autoScaleCheckBox.setSelection(autoScale);
autoScaleCheckBox.setText("Auto Scale");
autoScaleCheckBox.setToolTipText("Scale the color map values to the range of" + " (" + min + ", " + max + // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
").");
Group group = new Group(rightComposite, SWT.None);
group.setLayoutData(new GridData(SWT.FILL, SWT.END, true, true));
group.setLayout(new GridLayout(2, false));
// $NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-3$
group.setText("Output" + " (" + min + "~" + max + ")");
colorMapLabel = new Label(group, SWT.None);
colorMapLabel.setLayoutData(new GridData(SWT.FILL, SWT.END, true, true));
refreshGUI();
preDefinedMapCombo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
predefinedColorMap = PredefinedColorMap.values()[preDefinedMapCombo.getSelectionIndex()];
if (preDefinedMapCombo.getSelectionIndex() != 0) {
LinkedHashMap<Double, RGB> map = PredefinedColorMap.values()[preDefinedMapCombo.getSelectionIndex()].getMap();
colorList.clear();
for (Entry<Double, RGB> entry : map.entrySet()) colorList.add(new ColorTuple(entry.getKey(), entry.getValue()));
colorListViewer.refresh();
}
refreshGUI();
}
});
InterpolateCheckBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
interpolate = InterpolateCheckBox.getSelection();
refreshGUI();
}
});
autoScaleCheckBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
autoScale = autoScaleCheckBox.getSelection();
refreshGUI();
}
});
return parent_Composite;
}
use of org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap in project yamcs-studio by yamcs.
the class ColorMapEditDialog method getOutput.
public ColorMap getOutput() {
ColorMap result = new ColorMap();
if (predefinedColorMap == PredefinedColorMap.None) {
LinkedHashMap<Double, RGB> map = new LinkedHashMap<Double, RGB>();
for (ColorTuple tuple : colorList) map.put(tuple.value, tuple.rgb);
result.setColorMap(map);
}
result.setAutoScale(autoScale);
result.setInterpolate(interpolate);
result.setPredefinedColorMap(predefinedColorMap);
return result;
}
use of org.csstudio.swt.widgets.datadefinition.ColorMap.PredefinedColorMap in project yamcs-studio by yamcs.
the class ColorMapProperty method readValueFromXML.
@Override
public ColorMap readValueFromXML(Element propElement) {
ColorMap result = new ColorMap();
result.setInterpolate(Boolean.parseBoolean(propElement.getChild(XML_ELEMENT_INTERPOLATE).getValue()));
result.setAutoScale(Boolean.parseBoolean(propElement.getChild(XML_ELEMENT_AUTOSCALE).getValue()));
if (propElement.getChild(XML_ELEMENT_MAP).getChildren().size() == 0) {
PredefinedColorMap p = PredefinedColorMap.fromIndex(Integer.parseInt(propElement.getChild(XML_ELEMENT_MAP).getValue()));
result.setPredefinedColorMap(p);
} else {
LinkedHashMap<Double, RGB> map = new LinkedHashMap<Double, RGB>();
for (Object o : propElement.getChild(XML_ELEMENT_MAP).getChildren()) {
Element e = (Element) o;
map.put(Double.parseDouble(e.getValue()), new RGB(Integer.parseInt(e.getAttributeValue(XML_ATTRIBUTE_RED)), Integer.parseInt(e.getAttributeValue(XML_ATTRIBUTE_GREEN)), Integer.parseInt(e.getAttributeValue(XML_ATTRIBUTE_BLUE))));
}
result.setColorMap(map);
}
return result;
}
Aggregations