Arch4J 1.1

org.arch4j.ui.layout
Class OriginConstraint

java.lang.Object
  |
  +--org.arch4j.ui.layout.OriginConstraint
Direct Known Subclasses:
AlignmentOriginConstraint, FrameConstraint

public class OriginConstraint
extends Object

An OriginConstraint is used with an instance of FractionalLayout to compute a Rectangle relative to a containing Rectangle, given a preferred Rectangle, by computing a relative origin and then adding an offset to it. The extent of the computed rectangle is the preferredRectangle's extent. After that explanation, I think a couple of examples are in order. Please see the documentation of the instance variables for more information.

Version:
1.01, 04/18/96
Author:
Eric Lunt (elunt@mcs.net)
See Also:
FractionalLayout, AlignmentOriginConstraint, FrameConstraint

Field Summary
 int left
          Represents the number of pixels to be added as an offset to the left edge of a component.
 double leftFraction
          A number between 0.0 and 1.0 which represents the relative fraction (of the container) for the left edge of a component.
 int top
          Represents the number of pixels to be added as an offset to the top edge of a component.
 double topFraction
          A number between 0.0 and 1.0 which represents the relative fraction (of the container) for the top edge of a component.
 
Constructor Summary
OriginConstraint()
          Create an instanace of an OriginConstraint.
OriginConstraint(double lf, int l, double tf, int t)
          Create an instance of an OriginConstraint given the left fraction, the left offset, the top fraction, and the top offset.
 
Method Summary
protected  int adjustedLeft(Dimension containerSize)
          Given a container size, resolve the left edge of a component
 Rectangle adjustedRectangle(Dimension containerSize, Dimension componentSize)
          Given the size of a container and the component size, return a Rectangle which appropriately bounds the component given this constraint.
protected  int adjustedTop(Dimension containerSize)
          Given a container size, resolve the top edge of a component
 Dimension containSize(Dimension componentSize)
          Given the size of a component, return the smallest size container which could contain it given this constraint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

leftFraction

public double leftFraction
A number between 0.0 and 1.0 which represents the relative fraction (of the container) for the left edge of a component.


left

public int left
Represents the number of pixels to be added as an offset to the left edge of a component.


topFraction

public double topFraction
A number between 0.0 and 1.0 which represents the relative fraction (of the container) for the top edge of a component.


top

public int top
Represents the number of pixels to be added as an offset to the top edge of a component.

Constructor Detail

OriginConstraint

public OriginConstraint()
Create an instanace of an OriginConstraint. This will place the component at the upper-left of the container.


OriginConstraint

public OriginConstraint(double lf,
                        int l,
                        double tf,
                        int t)
Create an instance of an OriginConstraint given the left fraction, the left offset, the top fraction, and the top offset.

Parameters:
lf - the left fraction
l - the left offset
tf - the top fraction
t - the top offset
Method Detail

adjustedLeft

protected int adjustedLeft(Dimension containerSize)
Given a container size, resolve the left edge of a component

Parameters:
containerSize - the size of the container
Returns:
the pixel position of the left edge of the component

adjustedRectangle

public Rectangle adjustedRectangle(Dimension containerSize,
                                   Dimension componentSize)
Given the size of a container and the component size, return a Rectangle which appropriately bounds the component given this constraint.

Parameters:
containerSize - the size of the container
componentSize - the size of the component
Returns:
the containing rectangle

adjustedTop

protected int adjustedTop(Dimension containerSize)
Given a container size, resolve the top edge of a component

Parameters:
containerSize - the size of the container
Returns:
the pixel position of the top edge of the component

containSize

public Dimension containSize(Dimension componentSize)
Given the size of a component, return the smallest size container which could contain it given this constraint.

Parameters:
componentSize - the size of a component
Returns:
the minimum size of a container to satisfy this contraint

Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.