case EN_CENTER:
// centered text:
baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
baseList.add(new KnuthGlue(lineEndBAP, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
auxiliaryPosition, true));
baseList.add(new KnuthPenalty(hyphIPD, unflagged
? TextLayoutManager.SOFT_HYPHEN_PENALTY
: KnuthPenalty.FLAGGED_PENALTY, !unflagged, auxiliaryPosition, false));
baseList.add(new KnuthGlue(-(lineEndBAP + lineStartBAP),
-6 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
auxiliaryPosition, false));
baseList.add(makeAuxiliaryZeroWidthBox());
baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
baseList.add(new KnuthGlue(lineStartBAP, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH,
0, auxiliaryPosition, true));
break;
case EN_START: // fall through
case EN_END:
// left- or right-aligned text:
if (lineStartBAP != 0 || lineEndBAP != 0) {
baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
baseList.add(new KnuthGlue(lineEndBAP,
3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
auxiliaryPosition, false));
baseList.add(new KnuthPenalty(widthIfBreakOccurs,
unflagged ? TextLayoutManager.SOFT_HYPHEN_PENALTY
: KnuthPenalty.FLAGGED_PENALTY, !unflagged,
auxiliaryPosition, false));
baseList.add(new KnuthGlue(widthIfNoBreakOccurs.getOpt()
- (lineStartBAP + lineEndBAP),
-3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
auxiliaryPosition, false));
baseList.add(makeAuxiliaryZeroWidthBox());
baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
baseList.add(new KnuthGlue(lineStartBAP, 0, 0, auxiliaryPosition, false));
} else {
baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
baseList.add(new KnuthGlue(0, 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
auxiliaryPosition, false));
baseList.add(new KnuthPenalty(widthIfBreakOccurs,
unflagged ? TextLayoutManager.SOFT_HYPHEN_PENALTY
: KnuthPenalty.FLAGGED_PENALTY, !unflagged,
auxiliaryPosition, false));
baseList.add(new KnuthGlue(widthIfNoBreakOccurs.getOpt(),
-3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0,
auxiliaryPosition, false));
}
break;
default:
// justified text, or last line justified:
// just a flagged penalty
if (lineStartBAP != 0 || lineEndBAP != 0) {
baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
baseList.add(new KnuthGlue(lineEndBAP, 0, 0, auxiliaryPosition, false));
baseList.add(new KnuthPenalty(widthIfBreakOccurs,
unflagged ? TextLayoutManager.SOFT_HYPHEN_PENALTY
: KnuthPenalty.FLAGGED_PENALTY, !unflagged,
auxiliaryPosition, false));
// extra elements representing a letter space that is suppressed
// if a break occurs
if (widthIfNoBreakOccurs.isNonZero()) {
baseList.add(new KnuthGlue(widthIfNoBreakOccurs.getOpt()
- (lineStartBAP + lineEndBAP),
widthIfNoBreakOccurs.getStretch(),
widthIfNoBreakOccurs.getShrink(),
auxiliaryPosition, false));
} else {
baseList.add(new KnuthGlue(-(lineStartBAP + lineEndBAP), 0, 0,
auxiliaryPosition, false));
}
baseList.add(makeAuxiliaryZeroWidthBox());
baseList.add(makeZeroWidthPenalty(KnuthElement.INFINITE));
baseList.add(new KnuthGlue(lineStartBAP, 0, 0,
auxiliaryPosition, false));
} else {
baseList.add(new KnuthPenalty(widthIfBreakOccurs,
unflagged ? TextLayoutManager.SOFT_HYPHEN_PENALTY
: KnuthPenalty.FLAGGED_PENALTY, !unflagged,
auxiliaryPosition, false));
// extra elements representing a letter space that is suppressed
// if a break occurs