[all packages] [package ] [class hierarchy] [index]

public class Constraints

(source file: Constraints.java)
java.lang.Object
   |
   +----Printable
           |
           +----Constraints

The pure class interface.
public class Constraints
  extends Printable

A class representing a collection of constraints. Each constraint is of the form x +d <= y where x and y are variables and d is a non-negative constant.

There should be no cyclic dependencies, such as x + 1 <= y, y + 1 <= x, since such dependencies obviously have no solution.

Variables are implemented as integers.

Constraint sets can be solved returning an object of class Solution.

See also:
Solution

Constuctor Index

O Constraints(FontMetrics)
Create a new constraint set.

Variables Index

O above
The constraints on which variables are above which others.
O below
The constraints on which variables are below which others.
O fm
The font metrics used in these constraints.
O varCount
The number of variables in the constraint set.

Methods

O gap0(int, int)
Add a constraint x + 0 <= y
O gap1(int, int)
Add a constraint x + d <= y where d is a `small' gap (20% of
O gap2(int, int)
Add a constraint x + d <= y where d is a `large' gap (50% of
O gapStringHeight(String, int, int)
Add a constraint x + d <= y where d is the height of the string.
O gapStringWidth(String, int, int)
Add a constraint x + d <= y where d is the width of the string.
O isHorizontal(int)
Is this variable horizontal or vertical?
O newHVar()
Create a new horizontal variable.
O newVVar()
Create a new vertical variable.
O print(Printer)
Print the constraint set (useful for debugging).
O solve()
Solve the constraint set.

Constructors

O Constraints
public Constraints(FontMetrics fm);
Create a new constraint set.

Parameters:
fm - the font metrics to base all distances on.

Variables

O fm
public final FontMetrics fm;
The font metrics used in these constraints.

O varCount

public int varCount;
The number of variables in the constraint set.

O above

public ConstraintVector above;
The constraints on which variables are above which others.

O below

public ConstraintVector below;
The constraints on which variables are below which others.

Methods

O print
public void print(Printer p);
Print the constraint set (useful for debugging).

Parameters:
p - where to print to.
Overrides:
print in class Printable

O solve

public Solution solve();
Solve the constraint set.

Returns:
the solution.

O newVVar

public int newVVar();
Create a new vertical variable.

Returns:
the new variable.

O newHVar

public int newHVar();
Create a new horizontal variable.

Returns:
the new variable.

O isHorizontal

public boolean isHorizontal(int x);
Is this variable horizontal or vertical?

Parameters:
x - the variable.
Returns:
true iff the variable is horizontal.

O gap0

public void gap0(int x,
                 int y);
Add a constraint x + 0 <= y

Parameters:
x - the lower variable
y - the higher variable

O gap1

public void gap1(int x,
                 int y);
Add a constraint x + d <= y where d is a `small' gap (20% of the font height).

Parameters:
x - the lower variable
y - the higher variable

O gap2

public void gap2(int x,
                 int y);
Add a constraint x + d <= y where d is a `large' gap (50% of the font height).

Parameters:
x - the lower variable
y - the higher variable

O gapStringWidth

public void gapStringWidth(String s,
                           int x,
                           int y);
Add a constraint x + d <= y where d is the width of the string.

Parameters:
s - the string to measure
x - the lower variable
y - the higher variable

O gapStringHeight

public void gapStringHeight(String s,
                            int x,
                            int y);
Add a constraint x + d <= y where d is the height of the string.

Parameters:
s - the string to measure
x - the lower variable
y - the higher variable


[all packages] [package ] [class hierarchy] [index]
Constraints.html