[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
- Constraints(FontMetrics)
-
Create a new constraint set.
- above
-
The constraints on which variables are above which others.
- below
-
The constraints on which variables are below which others.
- fm
-
The font metrics used in these constraints.
- varCount
-
The number of variables in the constraint set.
- gap0(int, int)
-
Add a constraint x + 0 <= y
- gap1(int, int)
-
Add a constraint x + d <= y
where d is a `small' gap (20% of
- gap2(int, int)
-
Add a constraint x + d <= y
where d is a `large' gap (50% of
- gapStringHeight(String, int, int)
-
Add a constraint x + d <= y
where d is the height of the string.
- gapStringWidth(String, int, int)
-
Add a constraint x + d <= y
where d is the width of the string.
- isHorizontal(int)
-
Is this variable horizontal or vertical?
- newHVar()
-
Create a new horizontal variable.
- newVVar()
-
Create a new vertical variable.
- print(Printer)
-
Print the constraint set (useful for debugging).
- solve()
-
Solve the constraint set.
Constraints
public Constraints(FontMetrics fm);
-
Create a new constraint set.
- Parameters:
- fm - the font metrics to base all distances on.
fm
public final FontMetrics fm;
-
The font metrics used in these constraints.
varCount
public int varCount;
-
The number of variables in the constraint set.
above
public ConstraintVector above;
-
The constraints on which variables are above which others.
below
public ConstraintVector below;
-
The constraints on which variables are below which others.
print
public void print(Printer p);
-
Print the constraint set (useful for debugging).
- Parameters:
- p - where to print to.
- Overrides:
- print in class Printable
solve
public Solution solve();
-
Solve the constraint set.
- Returns:
- the solution.
newVVar
public int newVVar();
-
Create a new vertical variable.
- Returns:
- the new variable.
newHVar
public int newHVar();
-
Create a new horizontal variable.
- Returns:
- the new variable.
isHorizontal
public boolean isHorizontal(int x);
-
Is this variable horizontal or vertical?
- Parameters:
- x - the variable.
- Returns:
- true iff the variable is horizontal.
gap0
public void gap0(int x,
int y);
-
Add a constraint x + 0 <= y
- Parameters:
- x - the lower variable
- y - the higher variable
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
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
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
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