jdk/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthTreeUI.java
changeset 34407 2b40f400a30b
parent 25859 3317bb8137f4
child 37698 4d798c873df0
equal deleted inserted replaced
34406:a6823037ceb8 34407:2b40f400a30b
    45 import javax.swing.tree.DefaultTreeCellRenderer;
    45 import javax.swing.tree.DefaultTreeCellRenderer;
    46 import javax.swing.tree.TreeCellEditor;
    46 import javax.swing.tree.TreeCellEditor;
    47 import javax.swing.tree.TreeCellRenderer;
    47 import javax.swing.tree.TreeCellRenderer;
    48 import javax.swing.tree.TreeModel;
    48 import javax.swing.tree.TreeModel;
    49 import javax.swing.tree.TreePath;
    49 import javax.swing.tree.TreePath;
    50 import sun.swing.plaf.synth.SynthIcon;
       
    51 
    50 
    52 /**
    51 /**
    53  * Provides the Synth L&F UI delegate for
    52  * Provides the Synth L&F UI delegate for
    54  * {@link javax.swing.JTree}.
    53  * {@link javax.swing.JTree}.
    55  *
    54  *
   608      * {@inheritDoc}
   607      * {@inheritDoc}
   609      */
   608      */
   610     @Override
   609     @Override
   611     protected void drawCentered(Component c, Graphics graphics, Icon icon,
   610     protected void drawCentered(Component c, Graphics graphics, Icon icon,
   612                                 int x, int y) {
   611                                 int x, int y) {
   613         int w = SynthIcon.getIconWidth(icon, paintContext);
   612         int w = SynthGraphicsUtils.getIconWidth(icon, paintContext);
   614         int h = SynthIcon.getIconHeight(icon, paintContext);
   613         int h = SynthGraphicsUtils.getIconHeight(icon, paintContext);
   615 
   614 
   616         SynthIcon.paintIcon(icon, paintContext, graphics,
   615         SynthGraphicsUtils.paintIcon(icon, paintContext, graphics,
   617                             findCenteredX(x, w),
   616                             findCenteredX(x, w),
   618                             y - h/2, w, h);
   617                             y - h/2, w, h);
   619     }
   618     }
   620 
   619 
   621     /**
   620     /**
   778     //
   777     //
   779     // BasicTreeUI directly uses expandIcon outside of the Synth methods.
   778     // BasicTreeUI directly uses expandIcon outside of the Synth methods.
   780     // To get the correct context we return an instance of this that fetches
   779     // To get the correct context we return an instance of this that fetches
   781     // the SynthContext as needed.
   780     // the SynthContext as needed.
   782     //
   781     //
   783     private class ExpandedIconWrapper extends SynthIcon {
   782     private class ExpandedIconWrapper implements SynthIcon {
   784         public void paintIcon(SynthContext context, Graphics g, int x,
   783         public void paintIcon(SynthContext context, Graphics g, int x,
   785                               int y, int w, int h) {
   784                               int y, int w, int h) {
   786             if (context == null) {
   785             if (context == null) {
   787                 context = getContext(tree);
   786                 context = getContext(tree);
   788                 SynthIcon.paintIcon(expandedIcon, context, g, x, y, w, h);
   787                 SynthGraphicsUtils.paintIcon(expandedIcon, context, g, x, y, w, h);
   789                 context.dispose();
   788                 context.dispose();
   790             }
   789             }
   791             else {
   790             else {
   792                 SynthIcon.paintIcon(expandedIcon, context, g, x, y, w, h);
   791                 SynthGraphicsUtils.paintIcon(expandedIcon, context, g, x, y, w, h);
   793             }
   792             }
   794         }
   793         }
   795 
   794 
   796         public int getIconWidth(SynthContext context) {
   795         public int getIconWidth(SynthContext context) {
   797             int width;
   796             int width;
   798             if (context == null) {
   797             if (context == null) {
   799                 context = getContext(tree);
   798                 context = getContext(tree);
   800                 width = SynthIcon.getIconWidth(expandedIcon, context);
   799                 width = SynthGraphicsUtils.getIconWidth(expandedIcon, context);
   801                 context.dispose();
   800                 context.dispose();
   802             }
   801             }
   803             else {
   802             else {
   804                 width = SynthIcon.getIconWidth(expandedIcon, context);
   803                 width = SynthGraphicsUtils.getIconWidth(expandedIcon, context);
   805             }
   804             }
   806             return width;
   805             return width;
   807         }
   806         }
   808 
   807 
   809         public int getIconHeight(SynthContext context) {
   808         public int getIconHeight(SynthContext context) {
   810             int height;
   809             int height;
   811             if (context == null) {
   810             if (context == null) {
   812                 context = getContext(tree);
   811                 context = getContext(tree);
   813                 height = SynthIcon.getIconHeight(expandedIcon, context);
   812                 height = SynthGraphicsUtils.getIconHeight(expandedIcon, context);
   814                 context.dispose();
   813                 context.dispose();
   815             }
   814             }
   816             else {
   815             else {
   817                 height = SynthIcon.getIconHeight(expandedIcon, context);
   816                 height = SynthGraphicsUtils.getIconHeight(expandedIcon, context);
   818             }
   817             }
   819             return height;
   818             return height;
   820         }
   819         }
   821     }
   820     }
   822 }
   821 }