com.jgoodies.forms.layout
Class LayoutMap

java.lang.Object
  extended by com.jgoodies.forms.layout.LayoutMap

public final class LayoutMap
extends Object

Provides a hierarchical variable expansion useful to improve layou consistency, style guide compliance, and layout readability.

new FormLayout("pref, $lcg, pref") o new FormLayout("pref, ${lcg}, pref").

getRoot(). Application-wid variables should be defined in the root LayoutMap. If you want to overrid application-wide variables locally, obtain a LayoutMap using new LayoutMap(), configure it, and provide it as argument to th FormLayout, ColumnSpec, and RowSpec constructors/factory methods.

Variable NameAbbreviationsOrientationDescriptionlabel-component-gaplcg, lcgapbothgap between a label and the labeled componentrelated-gaprg, rgapbothgap between two related componentsunrelated-gapug, ugapbothgap between two unrelated componentsbuttonbhorizontalbutton column with minimum widthline-gaplg, lgapverticalgap between two linesnarrow-line-gapnlg, nlgapverticalnarrow gap between two linesparagraphpg, pgapverticalgap between two paragraphs/sections

Examples: "pref, $lcgap, $half, 2dlu, $half" "p, $lcgap, $table") Tips:

Since:
1.2
Version:
$Revision: 1.24 $
Author:
Karsten Lentzsch
See Also:
FormLayout, ColumnSpec, RowSpec

Constructor Summary
LayoutMap()
          Constructs a LayoutMap that has the root LayoutMap as parent.
LayoutMap(LayoutMap parent)
          Constructs a LayoutMap with the given optional parent.
 
Method Summary
 boolean columnContainsKey(String key)
          Returns true if this map or a parent map - if any - contain a mapping for the specified key.
 String columnGet(String key)
          Looks up and returns the String associated with the given key.
 String columnPut(String key, ColumnSpec value)
           
 String columnPut(String key, Size value)
           
 String columnPut(String key, String value)
          Associates the specified column String with the specified ke in this map.
 String columnRemove(String key)
          Removes the column value mapping for this key from this map if it i present.
static LayoutMap getRoot()
          Lazily initializes and returns the LayoutMap that is use for variable expansion, if no custom LayoutMap is provided.
 boolean rowContainsKey(String key)
          Returns true if this map or a parent map - if any - contain a RowSpec mapping for the specified key.
 String rowGet(String key)
          Looks up and returns the RowSpec associated with the given key.
 String rowPut(String key, RowSpec value)
          Associates the specified ColumnSpec with the specified key in this map.
 String rowPut(String key, Size value)
           
 String rowPut(String key, String value)
           
 String rowRemove(String key)
          Removes the row value mapping for this key from this map if it i present.
 String toString()
          Returns a string representation of this LayoutMap that list the column and row associations.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LayoutMap

public LayoutMap()
Constructs a LayoutMap that has the root LayoutMap as parent.


LayoutMap

public LayoutMap(LayoutMap parent)
Constructs a LayoutMap with the given optional parent.

Parameters:
parent - the parent LayoutMap, may be null
Method Detail

getRoot

public static LayoutMap getRoot()
Lazily initializes and returns the LayoutMap that is use for variable expansion, if no custom LayoutMap is provided.

Returns:
the LayoutMap that is used, if no custom LayoutMap is provided

columnContainsKey

public boolean columnContainsKey(String key)
Returns true if this map or a parent map - if any - contain a mapping for the specified key.

Parameters:
key - key whose presence in this LayoutMap chain is to be tested.
Returns:
true if this map contains a column mappin for the specified key.
Throws:
NullPointerException - if the key is null.
See Also:
Map.containsKey(Object)

columnGet

public String columnGet(String key)
Looks up and returns the String associated with the given key First looks for an association in this LayoutMap. If there's n association, the lookup continues with the parent map - if any.

Parameters:
key - key whose associated value is to be returned.
Returns:
the column String associated with the key or null if no LayoutMap in the parent chai contains an association.
Throws:
NullPointerException - if key is null
See Also:
Map.get(Object)

columnPut

public String columnPut(String key,
                        String value)
Associates the specified column String with the specified ke in this map If the map previously contained a mapping for this key, the old valu is replaced by the specified value. The value set in this ma overrides an association - if any - in the chain of parent LayoutMaps.

value must not be null. To remov an association from this map use columnRemove(String).

Parameters:
key - key with which the specified value is to be associated.
value - column expression value to be associated with the specified key.
Returns:
previous String associated with specified key or null if there was no mapping for key.
Throws:
NullPointerException - if the key or valuenull.
See Also:
Map.put(Object, Object)

columnPut

public String columnPut(String key,
                        ColumnSpec value)

columnPut

public String columnPut(String key,
                        Size value)

columnRemove

public String columnRemove(String key)
Removes the column value mapping for this key from this map if it i present.

null if the map contained no mapping for this key The map will not contain a String mapping for the specified ke once the call returns.

Parameters:
key - key whose mapping is to be removed from the map.
Returns:
previous value associated with specified key, or nullThrows:
NullPointerException - if key is null.
See Also:
Map.remove(Object)

rowContainsKey

public boolean rowContainsKey(String key)
Returns true if this map or a parent map - if any - contain a RowSpec mapping for the specified key.

Parameters:
key - key whose presence in this LayoutMap chain is to be tested.
Returns:
true if this map contains a row mappin for the specified key.
Throws:
NullPointerException - if the key is null.
See Also:
Map.containsKey(Object)

rowGet

public String rowGet(String key)
Looks up and returns the RowSpec associated with the given key First looks for an association in this LayoutMap. If there's n association, the lookup continues with the parent map - if any.

Parameters:
key - key whose associated value is to be returned.
Returns:
the row specification associated with the key or null if no LayoutMap in the parent chai contains an association.
Throws:
NullPointerException - if key is null
See Also:
Map.get(Object)

rowPut

public String rowPut(String key,
                     String value)

rowPut

public String rowPut(String key,
                     RowSpec value)
Associates the specified ColumnSpec with the specified key in this map If the map previously contained a mapping for this key, the old valu is replaced by the specified value. The RowSpec set in this ma override an association - if any - in the chain of parent LayoutMaps.

null. To remove an associatio from this map use rowRemove(String).

Parameters:
key - key with which the specified value is to be associated.
value - ColumnSpec to be associated with the specified key.
Returns:
previous ColumnSpec associated with specified key or null if there was no mapping for key.
Throws:
NullPointerException - if the key or valuenull.
See Also:
Map.put(Object, Object)

rowPut

public String rowPut(String key,
                     Size value)

rowRemove

public String rowRemove(String key)
Removes the row value mapping for this key from this map if it i present.

null if the map contained no mapping for this key The map will not contain a String mapping for the specified ke once the call returns.

Parameters:
key - key whose mapping is to be removed from the map.
Returns:
previous value associated with specified key, or nullThrows:
NullPointerException - if key is null.
See Also:
Map.remove(Object)

toString

public String toString()
Returns a string representation of this LayoutMap that list the column and row associations.

Overrides:
toString in class Object
Returns:
a string representation


Copyright © 2002-2013 JGoodies Software GmbH. All Rights Reserved.