@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
BrowserTreeModel browserTreeModel = (BrowserTreeModel) tree.getModel();
IntellicutManager intellicutManager = gemCutter.getIntellicutManager();
if (intellicutManager.getIntellicutMode() == IntellicutMode.NOTHING) {
// If Intellicut is not active
if (value instanceof GemTreeNode) {
// Add scope icon (public, protected, private) to the gem icon on the bottom right corner
// Uses a cache to store icons already combined
GemEntity entity = (GemEntity) ((GemTreeNode) value).getUserObject();
Icon baseGemIcon = getIcon();
Icon overlayIcon = null;
Map<Icon, Icon> cache = null;
if (entity.getScope().isPublic()) {
cache = imageCache_public;
overlayIcon = SCOPE_PUBLIC_ICON;
} else if (entity.getScope().isProtected()) {
cache = imageCache_protected;
overlayIcon = SCOPE_PROTECTED_ICON;
} else { //entity.getScope().isPrivate()
cache = imageCache_private;
overlayIcon = SCOPE_PRIVATE_ICON;
}
Icon cachedImage = cache.get(baseGemIcon);
if (cachedImage != null) {
setIcon(cachedImage);
} else {
Icon newIcon = UIUtilities.combineIcons(baseGemIcon, overlayIcon);
setIcon(newIcon);
cache.put(baseGemIcon, newIcon);
}
if (((GemTreeNode) value).hasDesign()) {
// Add a design decal to the gem icon
baseGemIcon = getIcon();
Icon newIcon = UIUtilities.combineIcons(baseGemIcon, GEM_DESIGN_DECAL);
setIcon(newIcon);
}
}
return this;
}
// If Intellicut is active, use special Intellicut icons to indicate Intellicut status.
if (leaf) {
// This is a gem. Give it an icon and text color that indicates how intellicut can connect it.
GemEntity gemEntity = (GemEntity) ((GemTreeNode) value).getUserObject();
if (browserTreeModel.isVisibleGem(gemEntity)) {
IntellicutInfo intellicutInfo = intellicutManager.getIntellicutInfo(gemEntity);
AutoburnUnifyStatus autoburnStatus = intellicutInfo.getAutoburnUnifyStatus();
if (autoburnStatus == AutoburnUnifyStatus.UNAMBIGUOUS) {
setIcon(BURN_ICON);
setForeground(BURN_COLOR);
} else if (autoburnStatus == AutoburnUnifyStatus.AMBIGUOUS) {
setIcon(AMBIGUOUS_ICON);
setForeground(AMBIGUOUS_COLOR);
} else if (autoburnStatus == AutoburnUnifyStatus.NOT_POSSIBLE) {
setIcon(CANNOT_CONNECT_ICON);
setForeground(CANNOT_CONNECT_COLOR);
} else if (autoburnStatus == AutoburnUnifyStatus.UNAMBIGUOUS_NOT_NECESSARY &&
intellicutInfo.getBurnTypeCloseness() > intellicutInfo.getNoBurnTypeCloseness()) {
setIcon(BURN_ICON);
setForeground(BURN_COLOR);
} else if (autoburnStatus == AutoburnUnifyStatus.AMBIGUOUS_NOT_NECESSARY &&
intellicutInfo.getBurnTypeCloseness() > intellicutInfo.getNoBurnTypeCloseness()) {
setIcon(AMBIGUOUS_ICON);
setForeground(AMBIGUOUS_COLOR);
}
} else {
setIcon(CANNOT_CONNECT_ICON);
setForeground(CANNOT_CONNECT_COLOR);
}
} else {
// This is a folder. Determine if and how it should pulse.
// Assume we can't connect at all to start with.
Color folderColor = CANNOT_CONNECT_COLOR;
Enumeration<TreeNode> subTreeEnum = UnsafeCast.<Enumeration<TreeNode>>unsafeCast(((DefaultMutableTreeNode)value).breadthFirstEnumeration());
while (subTreeEnum.hasMoreElements()) {
DefaultMutableTreeNode childTreeNode = (DefaultMutableTreeNode) subTreeEnum.nextElement();
if (childTreeNode instanceof GemTreeNode) {
GemEntity gemEntity = (GemEntity) childTreeNode.getUserObject();
if (browserTreeModel.isVisibleGem(gemEntity)) {
IntellicutInfo intellicutInfo = intellicutManager.getIntellicutInfo(gemEntity);
AutoburnUnifyStatus autoburnStatus = intellicutInfo.getAutoburnUnifyStatus();
if (autoburnStatus == AutoburnUnifyStatus.NOT_NECESSARY) {