Search in sources :

Example 1 with AbstractHeightMap

use of org.pepsoft.worldpainter.heightMaps.AbstractHeightMap 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;
}
Also used : DelegatingHeightMap(org.pepsoft.worldpainter.heightMaps.DelegatingHeightMap) AbstractHeightMap(org.pepsoft.worldpainter.heightMaps.AbstractHeightMap) HeightMap(org.pepsoft.worldpainter.HeightMap) DisplacementHeightMap(org.pepsoft.worldpainter.heightMaps.DisplacementHeightMap) AbstractHeightMap(org.pepsoft.worldpainter.heightMaps.AbstractHeightMap) DisplacementHeightMap(org.pepsoft.worldpainter.heightMaps.DisplacementHeightMap) DelegatingHeightMap(org.pepsoft.worldpainter.heightMaps.DelegatingHeightMap)

Aggregations

HeightMap (org.pepsoft.worldpainter.HeightMap)1 AbstractHeightMap (org.pepsoft.worldpainter.heightMaps.AbstractHeightMap)1 DelegatingHeightMap (org.pepsoft.worldpainter.heightMaps.DelegatingHeightMap)1 DisplacementHeightMap (org.pepsoft.worldpainter.heightMaps.DisplacementHeightMap)1