Package com.tonic.vellum.layout
Class Constraint
- java.lang.Object
-
- com.tonic.vellum.layout.Constraint
-
public final class Constraint extends java.lang.ObjectAn immutable sizing rule for one child of a Split, created via the static factory methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classConstraint.KindThe category of a constraint.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)static Constraintfill()static Constraintfill(int weight)Creates a constraint taking a weighted share of the remaining space.static Constraintfixed(int cells)Creates a fixed-size constraint of exactlycellsalong the main axis.inthashCode()Constraint.Kindkind()static Constraintmax(int cells)Creates a constraint of at mostcells, growing into remaining space up to that cap.static Constraintmin(int cells)Creates a constraint of at leastcells, growing into remaining space.static Constraintpercent(int pct)Creates a constraint sized as a percentage of the original available extent.java.lang.StringtoString()intvalue()
-
-
-
Method Detail
-
fixed
public static Constraint fixed(int cells)
Creates a fixed-size constraint of exactlycellsalong the main axis.- Parameters:
cells- the size in cells, clamped to non-negative- Returns:
- the constraint
-
percent
public static Constraint percent(int pct)
Creates a constraint sized as a percentage of the original available extent.- Parameters:
pct- the percentage, clamped to non-negative- Returns:
- the constraint
-
fill
public static Constraint fill()
- Returns:
- a constraint taking an equal share of the remaining space
-
fill
public static Constraint fill(int weight)
Creates a constraint taking a weighted share of the remaining space.- Parameters:
weight- the relative weight, clamped to at least 1- Returns:
- the constraint
-
min
public static Constraint min(int cells)
Creates a constraint of at leastcells, growing into remaining space.- Parameters:
cells- the minimum size in cells, clamped to non-negative- Returns:
- the constraint
-
max
public static Constraint max(int cells)
Creates a constraint of at mostcells, growing into remaining space up to that cap.- Parameters:
cells- the maximum size in cells, clamped to non-negative- Returns:
- the constraint
-
kind
public Constraint.Kind kind()
- Returns:
- the constraint kind
-
value
public int value()
- Returns:
- the constraint value in cells, percent, or weight depending on the kind
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-