fixed LabelVisualizer to work with empty strings and null

parent 06a9e9ed
......@@ -327,9 +327,11 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
public Label(Node<?,?,?> node, Object data) {
String label = generateDataString(data);
labelComponent = new SceneGraphComponent(getNodePrefix() + String.format("%0"+getNumDigits()+"d",node.getIndex())); //name the sgc with its prefix, e.g. V, and format s.t. leading zeros are added
IndexedLineSet labelLineSet = ttfLineSetFactory.getIndexLineSet(prefix + label); //with the factory: generate a lineset out of the string
labelComponent.setGeometry(labelLineSet); // and set this lineset as geometry of the SGC
labelComponent = new SceneGraphComponent(getNodePrefix() + String.format("%0"+getNumDigits()+"d",node.getIndex())); //name the sgc with its prefix, e.g. V, and format s.t. leading zeros are added
if(!label.trim().isEmpty()) {
IndexedLineSet labelLineSet = ttfLineSetFactory.getIndexLineSet(prefix + label); //with the factory: generate a lineset out of the string
labelComponent.setGeometry(labelLineSet); // and set this lineset as geometry of the SGC
}
}
/**
......@@ -341,11 +343,13 @@ public class LabelVisualizer extends DataVisualizerPlugin implements ActionListe
NumberFormat n = NumberFormat.getInstance();
n.setMaximumFractionDigits(decimals);
String label = new String();
if(data.getClass() == Double.class){
label = n.format(data); //cuts off the Double to have #decimals after comma and makes it a string
}else{
label = data.toString();
}
if(data == null) {
label = "";
} else if(data.getClass() == Double.class){
label = n.format(data); //cuts off the Double to have #decimals after comma and makes it a string
}else{
label = data.toString();
}
return label;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment