icon = ICONS.getIcon("NodeScalar");
Label textLabel = new Label();
textLabel.switchDAOFactory(DummyDAOFactory.class.getName());
try {
IArray data = di.getData();
// instead we could use getIndexIterator and get the first value
// Index index = data.getIndex();
// index.set(0);
// String value = getNodeName(gtn) + " = " +
// data.getObject(index);
IArrayIterator iterator = data.getIterator();
String value = getNodeName(gtn) + " = "
+ iterator.getObjectNext();
textLabel.setData(value);
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
viewer = (JComponent) textLabel.getComponent();
break;
case SPECTRUM:
icon = ICONS.getIcon("NodeSpectrum");
ChartViewer chart = new ChartViewer();
chart.switchDAOFactory(DummyDAOFactory.class.getName());
try {
IArray data = di.getData();
if (data.getElementType().equals(double.class)
|| data.getElementType().equals(float.class)) {
List<DataArray> values = new ArrayList<DataArray>(1);
DataArray array = new DataArray();
values.add(array);
IArrayIterator iterator = data.getIterator();
for (int i = 0; iterator.hasNext(); i++) {
array.add(i, iterator.getDoubleNext());
}
array.setId(di.getShortName());
chart.setData(values);
// TODO remove when default = false in comete
chart.getComponent().setFreezePanelVisible(false);
chart.getComponent().setManagementPanelVisible(false);
// chart.getAxis(JLChart.Y1).setName(di.getUnits());
fr.soleil.comete.widget.swing.ChartViewer component2 = (fr.soleil.comete.widget.swing.ChartViewer) chart
.getComponent();
component2.setAxisName(di.getUnitsString(), IChartViewer.Y1);
}
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
viewer = (JComponent) chart.getComponent();
break;
case IMAGE:
icon = ICONS.getIcon("NodeImage");
ImageViewer imageViewer = new ImageViewer();
imageViewer.switchDAOFactory(DummyDAOFactory.class.getName());
try {
IArray data = di.getData();
// int length = (int) data.getSize();
int[] shape = data.getShape();
Class<?> elementType = data.getElementType();
// TODO sysout SMA
// System.out.println("element type= " + elementType.getName());
Object storage = data.getStorage();
int dimY = shape[0];
int dimX = shape[1];
if (data.getElementType().equals(double.class)) {
// TODO sysout SMA
// System.out.println("case double");
double[] storage2 = (double[]) storage;
Number[] dataArray = new Number[storage2.length];
// loop because of autoboxing
for (int i = 0; i < storage2.length; i++) {
dataArray[i] = storage2[i];
}
NumberMatrix matrix = new NumberMatrix();
matrix.setFlatValues(dataArray, dimY, dimX);
imageViewer.setData(matrix);
viewer = (JComponent) imageViewer.getComponent();
}
else if (data.getElementType().equals(short.class)
|| data.getElementType().equals(int.class)) {
// TODO sysout SMA
// System.out.println("case short");
int[] storage2 = (int[]) storage;
Number[] dataArray = new Number[storage2.length];