src/java.desktop/share/classes/com/sun/java/swing/plaf/windows/WindowsTreeUI.java

Print this page




  89                     for(int counter = beginRow + 1; counter <= endRow; counter++) {
  90                         testRect = getPathBounds(tree,
  91                                                  getPathForRow(tree, counter));
  92                         if(testRect != null && (testRect.y + testRect.height) > maxY) {
  93                             counter = endRow;
  94                         }
  95                     }
  96 
  97                     if (testRect == null) {
  98                         return;
  99                     }
 100 
 101                     tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1,
 102                                                       testRect.y + testRect.height-
 103                                                       beginY));
 104                 }
 105             }
 106         }
 107     }
 108 
 109     static protected final int HALF_SIZE = 4;
 110     static protected final int SIZE = 9;
 111 
 112     /**
 113      * Returns the default cell renderer that is used to do the
 114      * stamping of each node.
 115      */
 116     protected TreeCellRenderer createDefaultCellRenderer() {
 117         return new WindowsTreeCellRenderer();
 118     }
 119 
 120     /**
 121      * The minus sign button icon
 122      * <p>
 123      * <strong>Warning:</strong>
 124      * Serialized objects of this class will not be compatible with
 125      * future Swing releases.  The current serialization support is appropriate
 126      * for short term storage or RMI between applications running the same
 127      * version of Swing.  A future release of Swing will provide support for
 128      * long term persistence.
 129      */
 130     @SuppressWarnings("serial") // Same-version serialization only
 131     public static class ExpandedIcon implements Icon, Serializable {
 132 
 133         static public Icon createExpandedIcon() {
 134             return new ExpandedIcon();
 135         }
 136 
 137         Skin getSkin(Component c) {
 138             XPStyle xp = XPStyle.getXP();
 139             return (xp != null) ? xp.getSkin(c, Part.TVP_GLYPH) : null;
 140         }
 141 
 142         public void paintIcon(Component c, Graphics g, int x, int y) {
 143             Skin skin = getSkin(c);
 144             if (skin != null) {
 145                 skin.paintSkin(g, x, y, State.OPENED);
 146                 return;
 147             }
 148 
 149             Color     backgroundColor = c.getBackground();
 150 
 151             if(backgroundColor != null)
 152                 g.setColor(backgroundColor);
 153             else


 165         }
 166 
 167         public int getIconHeight() {
 168             Skin skin = getSkin(null);
 169             return (skin != null) ? skin.getHeight() : SIZE;
 170         }
 171     }
 172 
 173     /**
 174      * The plus sign button icon
 175      * <p>
 176      * <strong>Warning:</strong>
 177      * Serialized objects of this class will not be compatible with
 178      * future Swing releases.  The current serialization support is appropriate
 179      * for short term storage or RMI between applications running the same
 180      * version of Swing.  A future release of Swing will provide support for
 181      * long term persistence.
 182      */
 183     @SuppressWarnings("serial") // Superclass is not serializable across versions
 184     public static class CollapsedIcon extends ExpandedIcon {
 185         static public Icon createCollapsedIcon() {
 186             return new CollapsedIcon();
 187         }
 188 
 189         public void paintIcon(Component c, Graphics g, int x, int y) {
 190             Skin skin = getSkin(c);
 191             if (skin != null) {
 192                 skin.paintSkin(g, x, y, State.CLOSED);
 193             } else {
 194             super.paintIcon(c, g, x, y);
 195             g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y + (SIZE - 3));
 196             }
 197         }
 198     }
 199 
 200     @SuppressWarnings("serial") // Superclass is not serializable across versions
 201     public class WindowsTreeCellRenderer extends DefaultTreeCellRenderer {
 202 
 203         /**
 204          * Configures the renderer based on the passed in components.
 205          * The value is set from messaging the tree with




  89                     for(int counter = beginRow + 1; counter <= endRow; counter++) {
  90                         testRect = getPathBounds(tree,
  91                                                  getPathForRow(tree, counter));
  92                         if(testRect != null && (testRect.y + testRect.height) > maxY) {
  93                             counter = endRow;
  94                         }
  95                     }
  96 
  97                     if (testRect == null) {
  98                         return;
  99                     }
 100 
 101                     tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1,
 102                                                       testRect.y + testRect.height-
 103                                                       beginY));
 104                 }
 105             }
 106         }
 107     }
 108 
 109     protected static final int HALF_SIZE = 4;
 110     protected static final int SIZE = 9;
 111 
 112     /**
 113      * Returns the default cell renderer that is used to do the
 114      * stamping of each node.
 115      */
 116     protected TreeCellRenderer createDefaultCellRenderer() {
 117         return new WindowsTreeCellRenderer();
 118     }
 119 
 120     /**
 121      * The minus sign button icon
 122      * <p>
 123      * <strong>Warning:</strong>
 124      * Serialized objects of this class will not be compatible with
 125      * future Swing releases.  The current serialization support is appropriate
 126      * for short term storage or RMI between applications running the same
 127      * version of Swing.  A future release of Swing will provide support for
 128      * long term persistence.
 129      */
 130     @SuppressWarnings("serial") // Same-version serialization only
 131     public static class ExpandedIcon implements Icon, Serializable {
 132 
 133         public static Icon createExpandedIcon() {
 134             return new ExpandedIcon();
 135         }
 136 
 137         Skin getSkin(Component c) {
 138             XPStyle xp = XPStyle.getXP();
 139             return (xp != null) ? xp.getSkin(c, Part.TVP_GLYPH) : null;
 140         }
 141 
 142         public void paintIcon(Component c, Graphics g, int x, int y) {
 143             Skin skin = getSkin(c);
 144             if (skin != null) {
 145                 skin.paintSkin(g, x, y, State.OPENED);
 146                 return;
 147             }
 148 
 149             Color     backgroundColor = c.getBackground();
 150 
 151             if(backgroundColor != null)
 152                 g.setColor(backgroundColor);
 153             else


 165         }
 166 
 167         public int getIconHeight() {
 168             Skin skin = getSkin(null);
 169             return (skin != null) ? skin.getHeight() : SIZE;
 170         }
 171     }
 172 
 173     /**
 174      * The plus sign button icon
 175      * <p>
 176      * <strong>Warning:</strong>
 177      * Serialized objects of this class will not be compatible with
 178      * future Swing releases.  The current serialization support is appropriate
 179      * for short term storage or RMI between applications running the same
 180      * version of Swing.  A future release of Swing will provide support for
 181      * long term persistence.
 182      */
 183     @SuppressWarnings("serial") // Superclass is not serializable across versions
 184     public static class CollapsedIcon extends ExpandedIcon {
 185         public static Icon createCollapsedIcon() {
 186             return new CollapsedIcon();
 187         }
 188 
 189         public void paintIcon(Component c, Graphics g, int x, int y) {
 190             Skin skin = getSkin(c);
 191             if (skin != null) {
 192                 skin.paintSkin(g, x, y, State.CLOSED);
 193             } else {
 194             super.paintIcon(c, g, x, y);
 195             g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y + (SIZE - 3));
 196             }
 197         }
 198     }
 199 
 200     @SuppressWarnings("serial") // Superclass is not serializable across versions
 201     public class WindowsTreeCellRenderer extends DefaultTreeCellRenderer {
 202 
 203         /**
 204          * Configures the renderer based on the passed in components.
 205          * The value is set from messaging the tree with