/[classpath]/classpath/javax/swing/border/CompoundBorder.java
ViewVC logotype

Diff of /classpath/javax/swing/border/CompoundBorder.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.9 by mark, Sat Jul 2 20:32:49 2005 UTC revision 1.10 by rabbit78, Tue Oct 18 20:23:01 2005 UTC
# Line 48  import java.awt.Insets; Line 48  import java.awt.Insets;
48   *   *
49   * @author Sascha Brawer (brawer@dandelis.ch)   * @author Sascha Brawer (brawer@dandelis.ch)
50   */   */
51  public class CompoundBorder  public class CompoundBorder extends AbstractBorder
   extends AbstractBorder  
52  {  {
53    /**    /**
54     * Determined using the <code>serialver</code> tool     * Determined using the <code>serialver</code> tool
# Line 57  public class CompoundBorder Line 56  public class CompoundBorder
56     */     */
57    static final long serialVersionUID = 9054540377030555103L;    static final long serialVersionUID = 9054540377030555103L;
58    
   
59    /**    /**
60     * The inside border, which is painted between the bordered     * The inside border, which is painted between the bordered
61     * Component and the outside border. It is valid for     * Component and the outside border. It is valid for
# Line 65  public class CompoundBorder Line 63  public class CompoundBorder
63     */     */
64    protected Border insideBorder;    protected Border insideBorder;
65    
   
66    /**    /**
67     * The outside border, which is painted outside both the     * The outside border, which is painted outside both the
68     * bordered Component and the inside border. It is valid for     * bordered Component and the inside border. It is valid for
# Line 73  public class CompoundBorder Line 70  public class CompoundBorder
70     */     */
71    protected Border outsideBorder;    protected Border outsideBorder;
72    
   
73    /**    /**
74     * Constructs a CompoundBorder whose inside and outside borders     * Constructs a CompoundBorder whose inside and outside borders
75     * are both <code>null</code>. While this does not really make     * are both <code>null</code>. While this does not really make
# Line 83  public class CompoundBorder Line 79  public class CompoundBorder
79     *     *
80     * @see EmptyBorder     * @see EmptyBorder
81     */     */
82    public CompoundBorder ()    public CompoundBorder()
83    {    {
84      this (null, null);      this (null, null);
85    }    }
86    
   
87    /**    /**
88     * Constructs a CompoundBorder with the specified inside and     * Constructs a CompoundBorder with the specified inside and
89     * outside borders.     * outside borders.
# Line 103  public class CompoundBorder Line 98  public class CompoundBorder
98     *        component. It is acceptable to pass <code>null</code>, in     *        component. It is acceptable to pass <code>null</code>, in
99     *        which case no inside border is painted.     *        which case no inside border is painted.
100     */     */
101    public CompoundBorder (Border outsideBorder, Border insideBorder)    public CompoundBorder(Border outsideBorder, Border insideBorder)
102    {    {
103      this.outsideBorder = outsideBorder;      this.outsideBorder = outsideBorder;
104      this.insideBorder = insideBorder;      this.insideBorder = insideBorder;
105    }    }
106    
   
107    /**    /**
108     * Determines whether or not this border is opaque. An opaque     * Determines whether or not this border is opaque. An opaque
109     * border fills every pixel in its area when painting. Partially     * border fills every pixel in its area when painting. Partially
# Line 119  public class CompoundBorder Line 113  public class CompoundBorder
113     * @return <code>true</code> if both the inside and outside borders     * @return <code>true</code> if both the inside and outside borders
114     *         are opaque, or <code>false</code> otherwise.     *         are opaque, or <code>false</code> otherwise.
115     */     */
116    public boolean isBorderOpaque ()    public boolean isBorderOpaque()
117    {    {
118      /* While it would be safe to assume true for the opacity of      // While it would be safe to assume true for the opacity of
119       * a null border, this behavior would not be according to      // a null border, this behavior would not be according to
120       * the API specification. Also, it is pathological to have      // the API specification. Also, it is pathological to have
121       * null borders anyway.      // null borders anyway.
      */  
122      if ((insideBorder == null) || (outsideBorder == null))      if ((insideBorder == null) || (outsideBorder == null))
123        return false;        return false;
124    
125      return insideBorder.isBorderOpaque()      return insideBorder.isBorderOpaque()
126        && outsideBorder.isBorderOpaque();        && outsideBorder.isBorderOpaque();
127    }    }
       
128    
129    /**    /**
130     * Paints the compound border by first painting the outside border,     * Paints the compound border by first painting the outside border,
# Line 148  public class CompoundBorder Line 140  public class CompoundBorder
140    public void paintBorder(Component c, Graphics g,    public void paintBorder(Component c, Graphics g,
141                            int x, int y, int width, int height)                            int x, int y, int width, int height)
142    {    {
143      /* If there is an outside border, paint it and reduce the      // If there is an outside border, paint it and reduce the
144       * bounding box by its insets.      // bounding box by its insets.
145       */      //
146      if (outsideBorder != null)      if (outsideBorder != null)
147      {      {
148        Insets outsideInsets;        Insets outsideInsets;
# Line 161  public class CompoundBorder Line 153  public class CompoundBorder
153        x += outsideInsets.left;        x += outsideInsets.left;
154        y += outsideInsets.top;        y += outsideInsets.top;
155    
156        /* Reduce width and height by the respective extent of the        // Reduce width and height by the respective extent of the
157         * outside border.        // outside border.
        */  
158        width -= outsideInsets.left + outsideInsets.right;        width -= outsideInsets.left + outsideInsets.right;
159        height -= outsideInsets.top + outsideInsets.bottom;        height -= outsideInsets.top + outsideInsets.bottom;
160      }      }
# Line 172  public class CompoundBorder Line 163  public class CompoundBorder
163        insideBorder.paintBorder(c, g, x, y, width, height);        insideBorder.paintBorder(c, g, x, y, width, height);
164    }    }
165    
   
166    /**    /**
167     * Changes the specified insets to the insets of this border,     * Changes the specified insets to the insets of this border,
168     * which is the sum of the insets of the inside and the outside     * which is the sum of the insets of the inside and the outside
# Line 192  public class CompoundBorder Line 182  public class CompoundBorder
182      else      else
183        insets.left = insets.right = insets.top = insets.bottom = 0;        insets.left = insets.right = insets.top = insets.bottom = 0;
184    
185      /* If there is an outside border, add it to insets. */      // If there is an outside border, add it to insets.
186      if (outsideBorder != null)      if (outsideBorder != null)
187      {      {
188        borderInsets = outsideBorder.getBorderInsets(c);        borderInsets = outsideBorder.getBorderInsets(c);
# Line 202  public class CompoundBorder Line 192  public class CompoundBorder
192        insets.bottom += borderInsets.bottom;        insets.bottom += borderInsets.bottom;
193      }      }
194    
195      /* If there is an inside border, add it to insets. */      // If there is an inside border, add it to insets.
196      if (insideBorder != null)      if (insideBorder != null)
197      {      {
198        borderInsets = insideBorder.getBorderInsets(c);        borderInsets = insideBorder.getBorderInsets(c);
# Line 215  public class CompoundBorder Line 205  public class CompoundBorder
205      return insets;      return insets;
206    }    }
207    
   
208    /**    /**
209     * Determines the insets of this border, which is the sum of the     * Determines the insets of this border, which is the sum of the
210     * insets of the inside and the outside border.     * insets of the inside and the outside border.
211     *     *
212     * @param c the component in the center of this border.     * @param c the component in the center of this border.
213     */     */
214    public Insets getBorderInsets (Component c)    public Insets getBorderInsets(Component c)
215    {    {
216      /* It is not clear why CompoundBorder does not simply inherit      // It is not clear why CompoundBorder does not simply inherit
217       * the implementation from AbstractBorder. However, we want      // the implementation from AbstractBorder. However, we want
218       * to be compatible with the API specification, which overrides      // to be compatible with the API specification, which overrides
219       * the getBorderInsets(Component) method.      // the getBorderInsets(Component) method.
      */  
220      return getBorderInsets (c, null);      return getBorderInsets (c, null);
221    }    }
222    
   
223    /**    /**
224     * Returns the outside border, which is painted outside both the     * Returns the outside border, which is painted outside both the
225     * bordered Component and the inside border. It is valid for the     * bordered Component and the inside border. It is valid for the
226     * result to be <code>null</code>.     * result to be <code>null</code>.
227     */     */
228    public Border getOutsideBorder ()    public Border getOutsideBorder()
229    {    {
230      return outsideBorder;      return outsideBorder;
231    }    }
232    
   
233    /**    /**
234     * Returns the inside border, which is painted between the bordered     * Returns the inside border, which is painted between the bordered
235     * Component and the outside border. It is valid for the result to     * Component and the outside border. It is valid for the result to
# Line 254  public class CompoundBorder Line 240  public class CompoundBorder
240      return insideBorder;      return insideBorder;
241    }    }
242  }  }
   

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.10

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26