This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 127782 - VisualizerNode
Summary: VisualizerNode
Status: RESOLVED WORKSFORME
Alias: None
Product: platform
Classification: Unclassified
Component: Explorer (show other bugs)
Version: 6.x
Hardware: All All
: P4 blocker (vote)
Assignee: t_h
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-02-19 18:29 UTC by longstrb
Modified: 2008-12-22 11:45 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description longstrb 2008-02-19 18:29:44 UTC
I found (2) SMALL issues with VisualizerNode:

1.  VisualizerNode should be made a public class so users can better create custom renderers.  For example, when using 
the ChoiceView, I need to be able to skip the drawing of the icon based on whether or not the Node.getImage() == null 
AND be able highlight the icon inconjunction with the text when the item is selected.  Currently, NodeRenderer does 
not allow me to do this.  Therefore, I created a custom renderer and used the Visualizer.findNode method.  This works 
except that I can't make use of VisualizerNode's ability to cache icons.  Therefore, I really need this class public.

2.  VisualizerNode.getIcon() is slightly ineffecient because the following statement is always called:

 cachedIconType = newCacheType;

when it should be part of the conditional statement (see:  TODO comment below).


    Icon getIcon(boolean opened, boolean large) {
        int newCacheType = getCacheType(opened, large);

        if (cachedIconType != newCacheType) {
            int iconType = large ? BeanInfo.ICON_COLOR_32x32 : BeanInfo.ICON_COLOR_16x16;

            Image image = opened ? node.getOpenedIcon(iconType) : node.getIcon(iconType);

            // bugfix #28515, check if getIcon contract isn't broken
            if (image == null) {
                String method = opened ? "getOpenedIcon" : "getIcon"; // NOI18N
                LOG.warning(
                    "Node \"" + node.getName() + "\" [" + node.getClass().getName() + "] cannot return null from " +
                    method + "(). See Node." + method + " contract."
                ); // NOI18N

                icon = getDefaultIcon();
            } else {
                icon = new ImageIcon(image);
            }
        }


        // TODO:  Move the following statement inside the conditional statement above:   
        cachedIconType = newCacheType;

        return icon;
    }
Comment 1 t_h 2008-10-20 11:27:15 UTC
Please subclass NodeRenderer, override getListCellRendererComponent() call super and if necessary clean icon. That
should do the trick, doesn't it?