com.alee.laf
Class DefaultLayoutStyle

java.lang.Object
  extended by javax.swing.LayoutStyle
      extended by com.alee.laf.DefaultLayoutStyle
Direct Known Subclasses:
WebLayoutStyle

public class DefaultLayoutStyle
extends javax.swing.LayoutStyle

An implementation of LayoutStyle that returns 6 for related components, otherwise 12. This class also provides helper methods for subclasses.

Author:
Mikle Garin

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.LayoutStyle
javax.swing.LayoutStyle.ComponentPlacement
 
Constructor Summary
DefaultLayoutStyle()
           
 
Method Summary
protected  int flipDirection(int position)
          Returns flipped direction.
 int getButtonGap(javax.swing.JComponent c, int position)
          If c is a check box or radio button, and the border is not painted this returns the inset along the specified axis.
protected  int getButtonGap(javax.swing.JComponent source, int position, int offset)
          For some look and feels check boxs and radio buttons typically don't paint the border, yet they have padding for a border.
protected  int getButtonGap(javax.swing.JComponent source, javax.swing.JComponent target, int position, int offset)
          For some look and feels check boxs and radio buttons typically don't paint the border, yet they have padding for a border.
 int getContainerGap(javax.swing.JComponent component, int position, java.awt.Container parent)
          
protected  int getIndent(javax.swing.JComponent c, int position)
          Returns the amount to indent the specified component if it's a JCheckBox or JRadioButton.
static javax.swing.LayoutStyle getInstance()
          Returns instance of this layout style.
 int getPreferredGap(javax.swing.JComponent component1, javax.swing.JComponent component2, javax.swing.LayoutStyle.ComponentPlacement type, int position, java.awt.Container parent)
          
protected  boolean isLabelAndNonlabel(javax.swing.JComponent c1, javax.swing.JComponent c2, int position)
          Returns true if the classes identify a JLabel and a non-JLabel along the horizontal axis, false otherwise.
 
Methods inherited from class javax.swing.LayoutStyle
setInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLayoutStyle

public DefaultLayoutStyle()
Method Detail

getInstance

public static javax.swing.LayoutStyle getInstance()
Returns instance of this layout style.

Returns:
instance of this layout style

getPreferredGap

public int getPreferredGap(javax.swing.JComponent component1,
                           javax.swing.JComponent component2,
                           javax.swing.LayoutStyle.ComponentPlacement type,
                           int position,
                           java.awt.Container parent)

Specified by:
getPreferredGap in class javax.swing.LayoutStyle

getContainerGap

public int getContainerGap(javax.swing.JComponent component,
                           int position,
                           java.awt.Container parent)

Specified by:
getContainerGap in class javax.swing.LayoutStyle

isLabelAndNonlabel

protected boolean isLabelAndNonlabel(javax.swing.JComponent c1,
                                     javax.swing.JComponent c2,
                                     int position)
Returns true if the classes identify a JLabel and a non-JLabel along the horizontal axis, false otherwise.

Parameters:
c1 - first component
c2 - second component
position - position doing layout along
Returns:
true if the classes identify a JLabel and a non-JLabel along the horizontal axis, false otherwise

getButtonGap

protected int getButtonGap(javax.swing.JComponent source,
                           javax.swing.JComponent target,
                           int position,
                           int offset)
For some look and feels check boxs and radio buttons typically don't paint the border, yet they have padding for a border. Look and feel guidelines generally don't include this space. Use this method to subtract this space from the specified components.

Parameters:
source - first component
target - second component
position - position doing layout along
offset - Ideal offset, not including border/margin
Returns:
offset - border/margin around the component

getButtonGap

protected int getButtonGap(javax.swing.JComponent source,
                           int position,
                           int offset)
For some look and feels check boxs and radio buttons typically don't paint the border, yet they have padding for a border. Look and feel guidelines generally don't include this space. Use this method to subtract this space from the specified components.

Parameters:
source - component
position - position doing layout along
offset - ideal offset, not including border/margin
Returns:
offset - border/margin around the component

getButtonGap

public int getButtonGap(javax.swing.JComponent c,
                        int position)
If c is a check box or radio button, and the border is not painted this returns the inset along the specified axis.

Parameters:
c - component
position - position doing layout along
Returns:
button gap

flipDirection

protected int flipDirection(int position)
Returns flipped direction.

Parameters:
position - position doing layout along
Returns:
flipped direction

getIndent

protected int getIndent(javax.swing.JComponent c,
                        int position)
Returns the amount to indent the specified component if it's a JCheckBox or JRadioButton. If the component is not a JCheckBox or JRadioButton, 0 will be returned.

Parameters:
c - component
position - position doing layout along
Returns:
the amount to indent the specified component if it's a JCheckBox or JRadioButton or zero if it is not