use of org.pepsoft.worldpainter.heightMaps.DelegatingHeightMap in project WorldPainter by Captain-Chaos.
the class HeightMapTreeCellRenderer method getTreeCellRendererComponent.
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
if (value instanceof HeightMap) {
HeightMap heightMap = (HeightMap) value;
String role = null;
StringBuilder name = new StringBuilder();
if (value instanceof AbstractHeightMap) {
DelegatingHeightMap parent = ((AbstractHeightMap) value).getParent();
if (parent instanceof DisplacementHeightMap) {
role = parent.getRole(parent.getIndex(heightMap));
if (role.endsWith("HeightMap")) {
name.append(role.substring(0, role.length() - 9));
} else if (role.endsWith("Map")) {
name.append(role.substring(0, role.length() - 3));
} else {
name.append(role);
}
}
}
if (heightMap.getName() != null) {
if (name.length() > 0) {
name.append(": ");
}
name.append(heightMap.getName());
}
if (name.length() == 0) {
name.append(heightMap.getClass().getSimpleName());
}
if (value == focusHeightMap) {
setBorder(focusBorder);
} else if (getBorder() != null) {
setBorder(null);
}
setText(name.toString());
setIcon(heightMap.getIcon());
setToolTipText(getTooltipText(heightMap, role));
}
return this;
}
Aggregations