public class KnuthPenalty extends KnuthElement
Modifier and Type | Field and Description |
---|---|
static KnuthPenalty |
DUMMY_ZERO_PENALTY
Dummy, zero-width penalty
|
static int |
FLAGGED_PENALTY
Used for flagged penalties.
|
INFINITE
Constructor and Description |
---|
KnuthPenalty(int width,
int penalty,
boolean penaltyFlagged,
int breakClass,
Position pos,
boolean isAuxiliary)
Create a new KnuthPenalty.
|
KnuthPenalty(int width,
int penalty,
boolean penaltyFlagged,
Position pos,
boolean auxiliary)
Create a new KnuthPenalty.
|
Modifier and Type | Method and Description |
---|---|
int |
getBreakClass() |
int |
getPenalty() |
boolean |
isForcedBreak() |
boolean |
isPenalty() |
boolean |
isPenaltyFlagged() |
void |
setPenalty(int penalty)
Sets a new penalty value.
|
String |
toString() |
protected static String |
valueOf(int penaltyValue)
Get the penalty's value as a
String . |
getShrink, getStretch, getWidth, isAuxiliary, isUnresolvedElement
getLayoutManager, getPosition, isBox, isGlue, setPosition
public static final int FLAGGED_PENALTY
public static final KnuthPenalty DUMMY_ZERO_PENALTY
public KnuthPenalty(int width, int penalty, boolean penaltyFlagged, Position pos, boolean auxiliary)
width
- the width of this penaltypenalty
- the penalty value of this penaltypenaltyFlagged
- is this penalty flagged?pos
- the Position stored in this penaltyauxiliary
- is this penalty auxiliary?public KnuthPenalty(int width, int penalty, boolean penaltyFlagged, int breakClass, Position pos, boolean isAuxiliary)
width
- the width of this penaltypenalty
- the penalty value of this penaltypenaltyFlagged
- is this penalty flagged?breakClass
- the break class of this penalty (one of
Constants.EN_AUTO
,
Constants.EN_COLUMN
,
Constants.EN_PAGE
,
Constants.EN_EVEN_PAGE
,
Constants.EN_ODD_PAGE
).pos
- the Position stored in this penaltyisAuxiliary
- is this penalty auxiliary?protected static String valueOf(int penaltyValue)
String
.
(Mainly used in toString()
methods, to improve readability
of the trace logs.)
TODO: shouldn't be penalty a class of its own?penaltyValue
- the penalty valueString
public boolean isPenalty()
isPenalty
in class ListElement
public int getPenalty()
getPenalty
in class KnuthElement
public void setPenalty(int penalty)
penalty
- the new penalty valuepublic boolean isPenaltyFlagged()
public boolean isForcedBreak()
isForcedBreak
in class ListElement
public int getBreakClass()
Copyright © 2022 Apache Software Foundation. All rights reserved.