org.apache.fop.layoutmgr

Class KnuthPenalty


public class KnuthPenalty
extends KnuthElement

An instance of this class represents information about a feasible breaking point; it does not represent any piece of content. A KnuthPenalty is a feasible breaking point unless its value is infinity; a KnuthPenalty whose value is -infinity represents a forced break. A KnuthPenalty is suppressed, and its width is ignored, if it is not a chosen breaking point; for example, a KnuthPenalty representing a hyphenation point has a width (the "-" width), which must be ignored if that point is not chosen as a breaking point. Besides the inherited methods and attributes, this class has two more attributes and the methods used to get them: the penalty value, which is a kind of "aesthetic cost" (the higher the value, the more unsightly the breaking point), and a boolean that marks KnuthPenalties which should not be chosen as breaking points for consecutive lines.

Field Summary

static int
FLAGGED_PENALTY
Used for flagged penalties.

Fields inherited from class org.apache.fop.layoutmgr.KnuthElement

INFINITE

Constructor Summary

KnuthPenalty(int w, int p, boolean f, int iBreakClass, Position pos, boolean bAux)
Create a new KnuthPenalty.
KnuthPenalty(int w, int p, boolean f, Position pos, boolean bAux)
Create a new KnuthPenalty.

Method Summary

int
getBreakClass()
int
getP()
boolean
isFlagged()
boolean
isForcedBreak()
boolean
isPenalty()
void
setBreakClass(int cl)
Sets the break class for this penalty.
void
setP(int p)
Sets a new penalty value.
String
toString()

Methods inherited from class org.apache.fop.layoutmgr.KnuthElement

getP, getW, getY, getZ, isAuxiliary, isUnresolvedElement

Methods inherited from class org.apache.fop.layoutmgr.ListElement

getLayoutManager, getPosition, isBox, isForcedBreak, isGlue, isPenalty, isUnresolvedElement, setPosition

Field Details

FLAGGED_PENALTY

public static final int FLAGGED_PENALTY
Used for flagged penalties. See Knuth algorithm.
Field Value:
50

Constructor Details

KnuthPenalty

public KnuthPenalty(int w,
                    int p,
                    boolean f,
                    int iBreakClass,
                    Position pos,
                    boolean bAux)
Create a new KnuthPenalty.
Parameters:
w - the width of this penalty
p - the penalty value of this penalty
f - is this penalty flagged?
iBreakClass - the break class of this penalty (one of the break-* constants)
pos - the Position stored in this penalty
bAux - is this penalty auxiliary?

KnuthPenalty

public KnuthPenalty(int w,
                    int p,
                    boolean f,
                    Position pos,
                    boolean bAux)
Create a new KnuthPenalty.
Parameters:
w - the width of this penalty
p - the penalty value of this penalty
f - is this penalty flagged?
pos - the Position stored in this penalty
bAux - is this penalty auxiliary?

Method Details

getBreakClass

public int getBreakClass()
Returns:
the break class of this penalty (EN_AUTO, EN_COLUMN, EN_PAGE, EN_EVEN_PAGE, EN_ODD_PAGE)

getP

public int getP()
Overrides:
getP in interface KnuthElement
Returns:
the penalty value of this penalty.

isFlagged

public boolean isFlagged()
Returns:
true is this penalty is a flagged one.

isForcedBreak

public boolean isForcedBreak()
Overrides:
isForcedBreak in interface ListElement

isPenalty

public boolean isPenalty()
Overrides:
isPenalty in interface ListElement

setBreakClass

public void setBreakClass(int cl)
Sets the break class for this penalty.
Parameters:
cl - the break class (EN_AUTO, EN_COLUMN, EN_PAGE, EN_EVEN_PAGE, EN_ODD_PAGE)

setP

public void setP(int p)
Sets a new penalty value.
Parameters:
p - the new penalty value

toString

public String toString()
See Also:
java.lang.Object.toString()

Copyright 1999-2007 The Apache Software Foundation. All Rights Reserved.