float blue, int leaderPattern, int leaderLengthMinimum,
int leaderLengthOptimum, int leaderLengthMaximum,
int ruleThickness, int ruleStyle, int leaderPatternWidth,
int leaderAlignment) {
LineArea la = ba.getCurrentLineArea();
//this should start a new page
if (la == null) {
return -1;
}
la.changeFont(fontState);
la.changeColor(red, green, blue);
//check whether leader fits into the (rest of the) line
//using length.optimum to determine where to break the line as defined
// in the xsl:fo spec: "User agents may choose to use the value of 'leader-length.optimum'
// to determine where to break the line" (7.20.4)
//if leader is longer then create a new LineArea and put leader there
if (leaderLengthOptimum <= (la.getRemainingWidth())) {
la.addLeader(leaderPattern,
leaderLengthMinimum, leaderLengthOptimum,
leaderLengthMaximum, ruleStyle, ruleThickness,
leaderPatternWidth, leaderAlignment);
} else {
la = ba.createNextLineArea();
if(la == null) {
// not enough room
return -1;
}
la.changeFont(fontState);
la.changeColor(red, green, blue);
//check whether leader fits into LineArea at all, otherwise
//clip it (should honor the clip option of containing area)
if (leaderLengthMinimum <=
la.getContentWidth()) {
la.addLeader(leaderPattern,
leaderLengthMinimum, leaderLengthOptimum,
leaderLengthMaximum, ruleStyle, ruleThickness,
leaderPatternWidth, leaderAlignment);
} else {
MessageHandler.errorln("Leader doesn't fit into line, it will be clipped to fit.");
la.addLeader(leaderPattern,
la.getRemainingWidth(),
leaderLengthOptimum, leaderLengthMaximum,
ruleStyle, ruleThickness, leaderPatternWidth,
leaderAlignment);
}
}