com.jgoodies.forms.util
Class LayoutStyle

java.lang.Object
  extended by com.jgoodies.forms.util.LayoutStyle
Direct Known Subclasses:
MacLayoutStyle, WindowsLayoutStyle

public abstract class LayoutStyle
extends java.lang.Object

An abstract class that describes a layout and design style guide. It provides constants used to lay out panels consistently.

This class is work in progress and the API may change without notice. Therefore it is recommended to not write custom subclasses for production code. A future version of this class will likely collaborate with a class LogicalSize or StyledSize.

Version:
$Revision: 54721 $
Author:
Karsten Lentzsch
See Also:
MacLayoutStyle, WindowsLayoutStyle, FormFactory, Borders

Field Summary
private static LayoutStyle current
          Holds the current layout style.
 
Constructor Summary
LayoutStyle()
           
 
Method Summary
abstract  ConstantSize getButtonBarPad()
          Returns a pad used to separate a button bar from a component.
static LayoutStyle getCurrent()
          Returns the current LayoutStyle.
abstract  Size getDefaultButtonHeight()
          Returns this style's default button height.
abstract  Size getDefaultButtonWidth()
          Returns this style's default button width.
abstract  ConstantSize getDialogMarginX()
          Returns this style's horizontal margin for general dialogs.
abstract  ConstantSize getDialogMarginY()
          Returns this style's vertical margin for general dialogs.
abstract  ConstantSize getLabelComponentPadX()
          Returns a gap used to separate a label and associated control.
abstract  ConstantSize getLinePad()
          Returns a narrow vertical pad used to separate lines.
abstract  ConstantSize getNarrowLinePad()
          Returns a narrow vertical pad used to separate lines.
abstract  ConstantSize getParagraphPad()
          Returns a pad used to separate paragraphs.
abstract  ConstantSize getRelatedComponentsPadX()
          Returns a horizontal gap used to separate related controls.
abstract  ConstantSize getRelatedComponentsPadY()
          Returns a vertical gap used to separate related controls.
private static java.lang.String getSystemProperty(java.lang.String key)
          Tries to look up the System property for the given key.
abstract  ConstantSize getTabbedDialogMarginX()
          Returns this style's horizontal margin for dialogs that consist of a tabbed pane.
abstract  ConstantSize getTabbedDialogMarginY()
          Returns this style's vertical margin for dialogs that consist of a tabbed pane.
abstract  ConstantSize getUnrelatedComponentsPadX()
          Returns a horizontal gap used to separate unrelated controls.
abstract  ConstantSize getUnrelatedComponentsPadY()
          Returns a vertical gap used to separate unrelated controls.
private static LayoutStyle initialLayoutStyle()
          Computes and returns the initial LayoutStyle.
abstract  boolean isLeftToRightButtonOrder()
          Checks and answers whether buttons are typically ordered from left to right or from right to left.
private static boolean isOSMac()
          Checks and answers whether Java runs on a Mac by requesting the system property os.name.
static void setCurrent(LayoutStyle newLayoutStyle)
          Set a new LayoutStyle.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

current

private static LayoutStyle current
Holds the current layout style.

Constructor Detail

LayoutStyle

public LayoutStyle()
Method Detail

initialLayoutStyle

private static LayoutStyle initialLayoutStyle()
Computes and returns the initial LayoutStyle. Checks the OS name and returns MacLayoutStyle on Mac OS X and WindowLayoutStyle on all other platforms.

Returns:
MacLayoutStyle on Mac, WindowsLayoutStyle on all other platforms

isOSMac

private static boolean isOSMac()
Checks and answers whether Java runs on a Mac by requesting the system property os.name.

Returns:
true on Mac, false on all other Platforms

getSystemProperty

private static java.lang.String getSystemProperty(java.lang.String key)
Tries to look up the System property for the given key. In untrusted environments this may throw a SecurityException. In this case we catch the exception and answer null.

Parameters:
key - the name of the system property
Returns:
the system property's String value, or a blank string if there's no such value, or a SecurityException has been catched

getCurrent

public static LayoutStyle getCurrent()
Returns the current LayoutStyle.

Returns:
the current LayoutStyle

setCurrent

public static void setCurrent(LayoutStyle newLayoutStyle)
Set a new LayoutStyle.

Parameters:
newLayoutStyle - the style to be set

getDefaultButtonWidth

public abstract Size getDefaultButtonWidth()
Returns this style's default button width.

Returns:
the default button width
See Also:
getDefaultButtonHeight()

getDefaultButtonHeight

public abstract Size getDefaultButtonHeight()
Returns this style's default button height.

Returns:
the default button height
See Also:
getDefaultButtonWidth()

getDialogMarginX

public abstract ConstantSize getDialogMarginX()
Returns this style's horizontal margin for general dialogs.

Returns:
the horizontal margin for general dialogs
See Also:
getDialogMarginY(), getTabbedDialogMarginX()

getDialogMarginY

public abstract ConstantSize getDialogMarginY()
Returns this style's vertical margin for general dialogs.

Returns:
the vertical margin for general dialogs
See Also:
getDialogMarginX(), getTabbedDialogMarginY()

getTabbedDialogMarginX

public abstract ConstantSize getTabbedDialogMarginX()
Returns this style's horizontal margin for dialogs that consist of a tabbed pane.

Returns:
the horizontal margin for dialogs that consist of a tabbed pane
Since:
1.0.3
See Also:
getTabbedDialogMarginY(), getDialogMarginX()

getTabbedDialogMarginY

public abstract ConstantSize getTabbedDialogMarginY()
Returns this style's vertical margin for dialogs that consist of a tabbed pane.

Returns:
the vertical margin for dialogs that consist of a tabbed pane
Since:
1.0.3
See Also:
getTabbedDialogMarginX(), getDialogMarginY()

getLabelComponentPadX

public abstract ConstantSize getLabelComponentPadX()
Returns a gap used to separate a label and associated control.

Returns:
a gap between label and associated control
See Also:
getRelatedComponentsPadX(), getUnrelatedComponentsPadX()

getRelatedComponentsPadX

public abstract ConstantSize getRelatedComponentsPadX()
Returns a horizontal gap used to separate related controls.

Returns:
a horizontal gap between related controls
See Also:
getLabelComponentPadX(), getRelatedComponentsPadY(), getUnrelatedComponentsPadX()

getRelatedComponentsPadY

public abstract ConstantSize getRelatedComponentsPadY()
Returns a vertical gap used to separate related controls.

Returns:
a vertical gap between related controls
See Also:
getRelatedComponentsPadX(), getUnrelatedComponentsPadY()

getUnrelatedComponentsPadX

public abstract ConstantSize getUnrelatedComponentsPadX()
Returns a horizontal gap used to separate unrelated controls.

Returns:
a horizontal gap between unrelated controls
See Also:
getLabelComponentPadX(), getUnrelatedComponentsPadY(), getRelatedComponentsPadX()

getUnrelatedComponentsPadY

public abstract ConstantSize getUnrelatedComponentsPadY()
Returns a vertical gap used to separate unrelated controls.

Returns:
a vertical gap between unrelated controls
See Also:
getUnrelatedComponentsPadX(), getRelatedComponentsPadY()

getNarrowLinePad

public abstract ConstantSize getNarrowLinePad()
Returns a narrow vertical pad used to separate lines.

Returns:
a narrow vertical pad used to separate lines
See Also:
getLinePad(), getParagraphPad()

getLinePad

public abstract ConstantSize getLinePad()
Returns a narrow vertical pad used to separate lines.

Returns:
a vertical pad used to separate lines
See Also:
getNarrowLinePad(), getParagraphPad()

getParagraphPad

public abstract ConstantSize getParagraphPad()
Returns a pad used to separate paragraphs.

Returns:
a vertical pad used to separate paragraphs
See Also:
getNarrowLinePad(), getLinePad()

getButtonBarPad

public abstract ConstantSize getButtonBarPad()
Returns a pad used to separate a button bar from a component.

Returns:
a vertical pad used to separate paragraphs
Since:
1.0.3
See Also:
getRelatedComponentsPadY(), getUnrelatedComponentsPadY()

isLeftToRightButtonOrder

public abstract boolean isLeftToRightButtonOrder()
Checks and answers whether buttons are typically ordered from left to right or from right to left. Useful for building button bars that shall comply with the platform's layout style guide.

For example the Windows style guide recommends to layout out OK, Cancel, Apply from left to right, where the Mac Aqua style guide recommends to layout out these buttons from right to left.

Although most button sequences shall honor this order some buttons require a left to right order. For example Back, Next or Move Left, Move Right.

Returns:
true if buttons are typically ordered from left to right
Since:
1.0.3
See Also:
ButtonBarBuilder, ButtonBarFactory