src/share/classes/com/sun/java/swing/plaf/motif/MotifTreeUI.java

Print this page


   1 /*
   2  * Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  74               g.fillRect( x - 1, top, 2, bottom - top + 2 );
  75           }
  76       }
  77 
  78     protected void paintHorizontalLine( Graphics g, JComponent c, int y, int left, int right )
  79       {
  80           g.fillRect( left, y, right - left + 1, 2 );
  81       }
  82 
  83 
  84     /**
  85      * The minus sign button icon.
  86      * <p>
  87      * <strong>Warning:</strong>
  88      * Serialized objects of this class will not be compatible with
  89      * future Swing releases.  The current serialization support is appropriate
  90      * for short term storage or RMI between applications running the same
  91      * version of Swing.  A future release of Swing will provide support for
  92      * long term persistence.
  93      */

  94     public static class MotifExpandedIcon implements Icon, Serializable {
  95         static Color bg;
  96         static Color fg;
  97         static Color highlight;
  98         static Color shadow;
  99 
 100         public MotifExpandedIcon() {
 101             bg = UIManager.getColor("Tree.iconBackground");
 102             fg = UIManager.getColor("Tree.iconForeground");
 103             highlight = UIManager.getColor("Tree.iconHighlight");
 104             shadow = UIManager.getColor("Tree.iconShadow");
 105         }
 106 
 107         public static Icon createExpandedIcon() {
 108             return new MotifExpandedIcon();
 109         }
 110 
 111         public void paintIcon(Component c, Graphics g, int x, int y) {
 112             g.setColor(highlight);
 113             g.drawLine(x, y, x+SIZE-1, y);


 122 
 123             g.setColor(fg);
 124             g.drawLine(x+3, y+HALF_SIZE-1, x+SIZE-4, y+HALF_SIZE-1);
 125             g.drawLine(x+3, y+HALF_SIZE, x+SIZE-4, y+HALF_SIZE);
 126         }
 127 
 128         public int getIconWidth() { return SIZE; }
 129         public int getIconHeight() { return SIZE; }
 130     }
 131 
 132     /**
 133      * The plus sign button icon.
 134      * <p>
 135      * <strong>Warning:</strong>
 136      * Serialized objects of this class will not be compatible with
 137      * future Swing releases.  The current serialization support is appropriate
 138      * for short term storage or RMI between applications running the same
 139      * version of Swing.  A future release of Swing will provide support for
 140      * long term persistence.
 141      */

 142     public static class MotifCollapsedIcon extends MotifExpandedIcon {
 143         public static Icon createCollapsedIcon() {
 144             return new MotifCollapsedIcon();
 145         }
 146 
 147         public void paintIcon(Component c, Graphics g, int x, int y) {
 148             super.paintIcon(c, g, x, y);
 149             g.drawLine(x + HALF_SIZE-1, y + 3, x + HALF_SIZE-1, y + (SIZE - 4));
 150             g.drawLine(x + HALF_SIZE, y + 3, x + HALF_SIZE, y + (SIZE - 4));
 151         }
 152     }
 153 
 154     public static ComponentUI createUI(JComponent x) {
 155         return new MotifTreeUI();
 156     }
 157 
 158     /**
 159      * Returns the default cell renderer that is used to do the
 160      * stamping of each node.
 161      */
   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  74               g.fillRect( x - 1, top, 2, bottom - top + 2 );
  75           }
  76       }
  77 
  78     protected void paintHorizontalLine( Graphics g, JComponent c, int y, int left, int right )
  79       {
  80           g.fillRect( left, y, right - left + 1, 2 );
  81       }
  82 
  83 
  84     /**
  85      * The minus sign button icon.
  86      * <p>
  87      * <strong>Warning:</strong>
  88      * Serialized objects of this class will not be compatible with
  89      * future Swing releases.  The current serialization support is appropriate
  90      * for short term storage or RMI between applications running the same
  91      * version of Swing.  A future release of Swing will provide support for
  92      * long term persistence.
  93      */
  94     @SuppressWarnings("serial") // Same-version serialization only
  95     public static class MotifExpandedIcon implements Icon, Serializable {
  96         static Color bg;
  97         static Color fg;
  98         static Color highlight;
  99         static Color shadow;
 100 
 101         public MotifExpandedIcon() {
 102             bg = UIManager.getColor("Tree.iconBackground");
 103             fg = UIManager.getColor("Tree.iconForeground");
 104             highlight = UIManager.getColor("Tree.iconHighlight");
 105             shadow = UIManager.getColor("Tree.iconShadow");
 106         }
 107 
 108         public static Icon createExpandedIcon() {
 109             return new MotifExpandedIcon();
 110         }
 111 
 112         public void paintIcon(Component c, Graphics g, int x, int y) {
 113             g.setColor(highlight);
 114             g.drawLine(x, y, x+SIZE-1, y);


 123 
 124             g.setColor(fg);
 125             g.drawLine(x+3, y+HALF_SIZE-1, x+SIZE-4, y+HALF_SIZE-1);
 126             g.drawLine(x+3, y+HALF_SIZE, x+SIZE-4, y+HALF_SIZE);
 127         }
 128 
 129         public int getIconWidth() { return SIZE; }
 130         public int getIconHeight() { return SIZE; }
 131     }
 132 
 133     /**
 134      * The plus sign button icon.
 135      * <p>
 136      * <strong>Warning:</strong>
 137      * Serialized objects of this class will not be compatible with
 138      * future Swing releases.  The current serialization support is appropriate
 139      * for short term storage or RMI between applications running the same
 140      * version of Swing.  A future release of Swing will provide support for
 141      * long term persistence.
 142      */
 143     @SuppressWarnings("serial") // Same-version serialization only
 144     public static class MotifCollapsedIcon extends MotifExpandedIcon {
 145         public static Icon createCollapsedIcon() {
 146             return new MotifCollapsedIcon();
 147         }
 148 
 149         public void paintIcon(Component c, Graphics g, int x, int y) {
 150             super.paintIcon(c, g, x, y);
 151             g.drawLine(x + HALF_SIZE-1, y + 3, x + HALF_SIZE-1, y + (SIZE - 4));
 152             g.drawLine(x + HALF_SIZE, y + 3, x + HALF_SIZE, y + (SIZE - 4));
 153         }
 154     }
 155 
 156     public static ComponentUI createUI(JComponent x) {
 157         return new MotifTreeUI();
 158     }
 159 
 160     /**
 161      * Returns the default cell renderer that is used to do the
 162      * stamping of each node.
 163      */