public static boolean updatePropertiesFromScanAddOn(ISpectrumConfig<?> config) {
boolean done = false;
boolean xAsDate = false;
if ((config != null) && (config.getScanAddOn() != null)
&& (config.getScanAddOn().getDisplay() != null)) {
ChartProperties chartProperties = config.getChartProperties();
if (chartProperties == null) {
chartProperties = new ChartProperties();
}
else {
chartProperties = chartProperties.clone();
}
List<DisplayAxis> axisList = config.getScanAddOn().getDisplay().getAxisList();
List<IDevice> deviceList = new ArrayList<IDevice>();
if (config.getSensorsList() != null) {
deviceList.addAll(config.getSensorsList());
}
if ((config.getDimensionX() != null)
&& (config.getDimensionX().getActuatorsList() != null)) {
deviceList.addAll(config.getDimensionX().getActuatorsList());
}
if (config instanceof IConfig2D) {
IConfig2D config2D = (IConfig2D) config;
if ((config2D.getDimensionY() != null)
&& (config2D.getDimensionX().getActuatorsList() != null)) {
deviceList.addAll(config2D.getDimensionY().getActuatorsList());
}
}
List<String> displayableList = extractAvailableDeviceNames(true, deviceList);
deviceList.clear();
int size = Math.min(axisList.size(), displayableList.size());
for (int i = 0; i < size; i++) {
String viewId = displayableList.get(i);
PlotProperties properties = config.getPlotProperties(viewId);
if (properties == null) {
properties = new PlotProperties(CometeColorUtil.getNewColor());
properties.getCurve().setName(viewId);
}
else {
properties = properties.clone();
}
int axis = convertDisplayAxisToAxis(axisList.get(i));
if (axis != -1) {
properties.setAxisChoice(axis);
}
if (axis == IChartViewer.X) {
if (TIME_STAMP_NAME.equals(viewId)) {
xAsDate = true;
chartProperties.getXAxisProperties().setLabelFormat(
IChartViewer.DATE_FORMAT);
}
}
config.setPlotProperties(viewId, properties);
}
if (xAsDate) {
chartProperties.getXAxisProperties().setLabelFormat(IChartViewer.DATE_FORMAT);
}
else {
chartProperties.getXAxisProperties().setLabelFormat(IChartViewer.AUTO_FORMAT);
}
config.setChartProperties(chartProperties);
done = true;
}
return done;