@Override
public String getText(Object element) {
String result = "error";
if (element instanceof IExplainTreeNode) {
IExplainTreeNode debugNode = (IExplainTreeNode) element;
TypeSystem ts = debugNode.getTypeSystem();
Type ruleType = ts.getType(ExplainConstants.RULE_APPLY_TYPE);
FeatureStructure fs = debugNode.getFeatureStructure();
if (fs != null && ts.subsumes(ruleType, fs.getType())) {
Feature f1 = ruleType.getFeatureByBaseName(ExplainConstants.APPLIED);
int v1 = fs.getIntValue(f1);
Feature f2 = ruleType.getFeatureByBaseName(ExplainConstants.TRIED);
int v2 = fs.getIntValue(f2);
Feature f3 = ruleType.getFeatureByBaseName(ExplainConstants.ELEMENT);
String v3 = fs.getStringValue(f3);
v3 = v3.replaceAll("[\\n\\r]", "");
Feature f4 = ruleType.getFeatureByBaseName(ExplainConstants.TIME);
long v4 = fs.getLongValue(f4);
String time = "";
if (v4 > 0.0) {
double took = v4 / 1000.0;
time = " [" + took + "s";
IExplainTreeNode parentNode = debugNode.getParent();
if (parentNode != null) {
FeatureStructure parent = parentNode.getFeatureStructure();
if (parent != null) {
long parentTime = parent.getLongValue(f4);
double percent = (took / (parentTime / 1000.0)) * 100.0;
percent = Math.round(percent * 100.0) / 100.0;
time += "|" + percent + "%]";