|
JClass DesktopViews 6.3.0 API Documentation |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.klg.jclass.util.swing.JCElasticLayout
A layout manager that supports JCElastic
components either
horizontally or vertically. A component is considered elastic if it
either implements the JCElastic
interface or it has a
constraint object the implements the JCElastic
interface.
Layout is performed in either a single row or column (depending on its orientation at creation). The preferred size is calculated in the direction of orientation. If the container is bigger than the preferred size of all the components, then the extra space is divided up between the components that are "elastic" in the direction of the orientation.
The extra space is allocated to each of the components with respect to their "elasticity". If all the elastic components have the same elasticity (in the direction of the orientation), then they are equally stretched. If there is an uneven number of pixels to allot, then the first n units of elasticity are allocated the extra pixels; where n = total_elasticity % extra_pixels.
JCElastic
,
JCSpring
,
JCBrace
,
Serialized FormField Summary | |
protected int |
alignment
Alignment to use when laying out. |
static com.klg.jclass.util.swing.JCElastic |
COMPLETELY_ELASTIC_CONSTRAINT
Constant to use when adding an elastic constraint to this object. |
static String |
COMPLETELY_ELASTIC_TAG
Constant to use when adding an String constraint to this object. |
protected static HashMap |
constraintCache
|
protected HashMap |
constraintMap
Hashtable to store components added to the layout. |
static int |
HORIZONTAL
|
protected static int |
HORIZONTALLY_ELASTIC
Returned by getElasticity() . |
static com.klg.jclass.util.swing.JCElastic |
HORIZONTALLY_ELASTIC_CONSTRAINT
Constant to use when adding an elastic constraint to this object. |
static String |
HORIZONTALLY_ELASTIC_TAG
Constant to use when adding an String constraint to this object. |
protected static int |
NOT_ELASTIC
Returned by getElasticity() . |
protected int |
orientation
Orientation to lay out in. |
static int |
VERTICAL
|
protected static int |
VERTICALLY_ELASTIC
Returned by getElasticity() . |
static com.klg.jclass.util.swing.JCElastic |
VERTICALLY_ELASTIC_CONSTRAINT
Constant to use when adding an elastic constraint to this object. |
static String |
VERTICALLY_ELASTIC_TAG
Constant to use when adding an String constraint to this object. |
Constructor Summary | |
JCElasticLayout(int orientation)
Creates a row layout that by default aligns components to the left of the row. |
|
JCElasticLayout(int orientation,
int alignment)
Creates a column layout that aligns components according to the specified alignment. |
Method Summary | |
void |
addLayoutComponent(Component comp,
Object constraints)
Adds a component to the layout manager with the specified constraint. |
void |
addLayoutComponent(String name,
Component comp)
Adds a component to the layout. |
protected int |
calcStretch(int slice,
int elasticity,
int current_slice,
int fatter_slice_count)
Calculates the amount to stretch an elastic component based on the parameters passed in. |
static com.klg.jclass.util.swing.JCElastic |
createElasticConstraint(int horizontal_elasticity,
int vertical_elasticity)
Creates a JCElastic constraint with the elasticity specified. |
int |
getAlignment()
Returns the alignment for the layout. |
protected com.klg.jclass.util.swing.JCElastic |
getElastic(Component c)
Returns the Elastic information for a particular component. |
protected int |
getElasticity(Component c)
A component may be specified as elastic in two ways. |
float |
getLayoutAlignmentX(Container target)
Returns the X layout alignment. |
float |
getLayoutAlignmentY(Container target)
Returns the Y layout alignment. |
protected int |
getPreferredLayoutSize(Container parent,
Dimension preferred_size)
Returns the preferred layout size of the containers within their parent given this layout, and the total amount of "elasticity" in the child components. |
void |
invalidateLayout(Container target)
Invalidates the current layout: deletes any information that might be cached regarding the current layout. |
protected boolean |
isDim1Elastic(Component c)
Queries whether or not the dimension opposite to the current orientation is elastic or not. |
protected boolean |
isHorizontallyElastic(Component c)
Queries whther the given component is horizontally elastic or not. |
protected boolean |
isVerticallyElastic(Component c)
Queries whther the given component is vertically elastic or not. |
void |
layoutContainer(Container parent)
Lays out the components within the specified parent. |
Dimension |
maximumLayoutSize(Container parent)
Returns the maximum layout size of the component. |
Dimension |
minimumLayoutSize(Container parent)
Returns the minimum layout size of the containers within their parent given this layout. |
Dimension |
preferredLayoutSize(Container parent)
Returns the preferred layout size of the containers within their parent, given this layout. |
void |
removeLayoutComponent(Component comp)
Removes a component from the layout. |
void |
setAlignment(int alignment)
Sets the alignment for the layout. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int HORIZONTAL
public static final int VERTICAL
public static final com.klg.jclass.util.swing.JCElastic HORIZONTALLY_ELASTIC_CONSTRAINT
public static final com.klg.jclass.util.swing.JCElastic VERTICALLY_ELASTIC_CONSTRAINT
public static final com.klg.jclass.util.swing.JCElastic COMPLETELY_ELASTIC_CONSTRAINT
public static final String HORIZONTALLY_ELASTIC_TAG
public static final String VERTICALLY_ELASTIC_TAG
public static final String COMPLETELY_ELASTIC_TAG
protected static final int NOT_ELASTIC
getElasticity()
.
protected static final int VERTICALLY_ELASTIC
getElasticity()
.
protected static final int HORIZONTALLY_ELASTIC
getElasticity()
.
protected int alignment
protected int orientation
HORIZONTAL
or VERTICAL
.
protected HashMap constraintMap
protected static HashMap constraintCache
Constructor Detail |
public JCElasticLayout(int orientation)
orientation
- public JCElasticLayout(int orientation, int alignment)
alignment
- SwingConstants.LEFT
,
SwingConstants.TOP
,
SwingConstants.CENTER
,
SwingConstants.BOTTOM
, or
SwingConstants.RIGHT
orientation
- Method Detail |
public static com.klg.jclass.util.swing.JCElastic createElasticConstraint(int horizontal_elasticity, int vertical_elasticity)
JCElastic
constraint with the elasticity specified.
horizontal_elasticity
- vertical_elasticity
-
public void addLayoutComponent(String name, Component comp)
addLayoutComponent
in interface LayoutManager
name
- comp
- public void removeLayoutComponent(Component comp)
removeLayoutComponent
in interface LayoutManager
comp
- public Dimension preferredLayoutSize(Container parent)
preferredLayoutSize
in interface LayoutManager
parent
-
protected int getPreferredLayoutSize(Container parent, Dimension preferred_size)
parent
- container in which the layout is occuringpreferred_size
- object to return the preferred size in
public Dimension minimumLayoutSize(Container parent)
minimumLayoutSize
in interface LayoutManager
parent
-
public void layoutContainer(Container parent)
layoutContainer
in interface LayoutManager
parent
- protected int calcStretch(int slice, int elasticity, int current_slice, int fatter_slice_count)
slice
- the size of a "slice" of the extra space in the parent componentelasticity
- the amount of elasticity in the current componentcurrent_slice
- the starting slice for the calculationfatter_slice_count
- the number of slices that need to be "Fatter" by
a pixel because the extra space did not divide evenly into the number of
slices
protected boolean isDim1Elastic(Component c)
c
-
protected com.klg.jclass.util.swing.JCElastic getElastic(Component c)
c
-
protected boolean isVerticallyElastic(Component c)
c
-
protected boolean isHorizontallyElastic(Component c)
c
-
protected int getElasticity(Component c)
JCElastic
interface.
c
-
public void addLayoutComponent(Component comp, Object constraints)
addLayoutComponent
in interface LayoutManager2
comp
- constraints
- public Dimension maximumLayoutSize(Container parent)
maximumLayoutSize
in interface LayoutManager2
parent
-
public float getLayoutAlignmentX(Container target)
getLayoutAlignmentX
in interface LayoutManager2
target
-
public float getLayoutAlignmentY(Container target)
getLayoutAlignmentY
in interface LayoutManager2
target
-
public int getAlignment()
public void setAlignment(int alignment)
alignment
- public void invalidateLayout(Container target)
invalidateLayout
in interface LayoutManager2
target
-
|
Copyright © 2004 Quest Software Inc.. All rights reserved. |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |