com.jgoodies.forms.layout

Class PrototypeSize

public final class PrototypeSize extends Object implements Size, Serializable

A Size implementation that computes its width and height by a prototype String.

Examples:

 new PrototypeSize("123-456-789");
 new FormLayout("p, 2dlu, 'MMMM'");
 

Since: 1.2

Version: $Revision: 1.3 $

Author: Karsten Lentzsch

See Also: Size

Constructor Summary
PrototypeSize(String prototype)
Constructs a PrototypeSize for the given String.
Method Summary
booleancompressible()
Describes if this Size can be compressed, if container space gets scarce.
Stringencode()
Returns a parseable string representation of this prototype size.
booleanequals(Object o)
Indicates whether some other ConstantSize is "equal to" this one.
StringgetPrototype()
Returns this size's prototype string.
inthashCode()
Returns a hash code value for the object.
intmaximumSize(Container container, List components, FormLayout.Measure minMeasure, FormLayout.Measure prefMeasure, FormLayout.Measure defaultMeasure)
Computes and returns the width of this Size's prototype in pixel.
StringtoString()
Returns a string representation of this size object.

Constructor Detail

PrototypeSize

public PrototypeSize(String prototype)
Constructs a PrototypeSize for the given String.

Parameters: prototype the String used to compute the width and height.

Throws: NullPointerException if {@code prototype} is {@code null}.

Since: 1.2

Method Detail

compressible

public boolean compressible()
Describes if this Size can be compressed, if container space gets scarce. Used by the FormLayout size computations in #compressedSizes to check whether a column or row can be compressed or not.

PrototypeSizes are incompressible.

Returns: {@code false}

encode

public String encode()
Returns a parseable string representation of this prototype size.

Returns: a String that can be parsed by the Forms parser

equals

public boolean equals(Object o)
Indicates whether some other ConstantSize is "equal to" this one.

Parameters: o the Object with which to compare

Returns: true if this object is the same as the obj argument; false otherwise.

See Also: java.lang.Object#hashCode() java.util.Hashtable

getPrototype

public String getPrototype()
Returns this size's prototype string.

Returns: the prototype string

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by {@code java.util.Hashtable}.

Returns: a hash code value for this object.

See Also: java.lang.Object#equals(java.lang.Object) java.util.Hashtable

maximumSize

public int maximumSize(Container container, List components, FormLayout.Measure minMeasure, FormLayout.Measure prefMeasure, FormLayout.Measure defaultMeasure)
Computes and returns the width of this Size's prototype in pixel. Ignores the component list and measures. Obtains the FontMetrics from the given layout {@code container} for the default dialog font provided by getDefaultDialogFont.

Invoked by FormSpec to determine the size of a column or row.

Parameters: container the layout container components the list of components used to compute the size minMeasure the measure that determines the minimum sizes prefMeasure the measure that determines the preferred sizes defaultMeasure the measure that determines the default sizes

Returns: the {@code stringWidth} for this size's prototype string computed by the {@code container}'s FontMetrics for the {@code DefaultUnitConverter}'s default dialog font

toString

public String toString()
Returns a string representation of this size object. Note: This string representation may change at any time. It is intended for debugging purposes. For parsing, use encode instead.

Returns: a string representation of the constant size

Copyright © 2002-2008 JGoodies Karsten Lentzsch. All Rights Reserved.