"leader-length.optimum").getLength().mvalue();
int leaderLengthMinimum = this.properties.get(
"leader-length.minimum").getLength().mvalue();
- //brute force method to set default, because default values cannot be set
- //in the properties classes for all subtypes
- if (leaderLengthMinimum == 12000) {
- leaderLengthMinimum = 0;
- }
int leaderLengthMaximum = this.properties.get(
"leader-length.maximum").getLength().mvalue();
- //here too
- if (leaderLengthMaximum == 12000) {
- leaderLengthMaximum = 24000;
- }
//the following properties only apply for leader-pattern = "rule"
int ruleThickness = this.properties.get(
"rule-thickness").getLength().mvalue();
this.currentLineArea.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 (leaderLengthMinimum <= (this.getContentWidth() -
+ if (leaderLengthOptimum <= (this.getContentWidth() -
this.currentLineArea.finalWidth -
this.currentLineArea.pendingWidth)) {
this.currentLineArea.addLeader(leaderPattern,
int leaderLength;
int remainingWidth =
this.getContentWidth() - this.getCurrentXPosition();
-
- //here is the point to decide which leader-length is to be used, either
- //optimum or maximum. At the moment maximum is used if the remaining
- //width isn't smaller. In this case only the remaining width is used for
- //the leader. Actually this means, optimum is never used at the moment.
- if (remainingWidth < leaderLengthMaximum) {
+ //checks whether leaderLenghtOptimum fits into rest of line;
+ //should never overflow, asit has been checked already in BlockArea
+ if (remainingWidth < leaderLengthOptimum) {
leaderLength = remainingWidth;
} else {
- leaderLength = leaderLengthMaximum;
+ leaderLength = leaderLengthOptimum;
}
switch (leaderPattern) {
case LeaderPattern.SPACE:
}
+ /** extracts word for hyphenation and calls hyphenation package,
+ * handles cases of inword punctuation and quotation marks at the beginning
+ * of words, but not in a internationalized way
+ */
private int doHyphenation (char [] characters, int position, int wordStart, int remainingWidth) {
//check whether the language property has been set
if (this.language.equalsIgnoreCase("none")) {
//extracts whole word from string
wordToHyphenate = getHyphenationWord(characters,wordStart+1);
} else {
-// remainingString = "";
wordToHyphenate = getHyphenationWord(characters,wordStart);
}
-
-
//if the extracted word is smaller than the remaining width
//we have a non letter character inside the word. at the moment
//we will only handle hard hyphens and slashes
return wordStart;
}
+
/** calculates the wordWidth using the actual fontstate*/
private int getWordWidth (String word) {
int wordLength = word.length();
return width;
}
+
+ /** adds a single character to the line area tree*/
public int addCharacter (char data, LinkSet ls, boolean ul) {
InlineArea ia = null;
int remainingWidth =
}
}
- /** adds a string to the line area children. insert a space before the word */
+
+ /** adds a InlineArea containing the String startChar+wordBuf to the line area children. */
private void addWord (char startChar, StringBuffer wordBuf) {
String word = wordBuf.toString();
InlineArea hia;
}
+ /** extracts from a hyphenated word the best (most greedy) fit */
private int getFinalHyphenationPoint(Hyphenation hyph, int remainingWidth) {
int [] hyphenationPoints = hyph.getHyphenationPoints();
int numberOfHyphenationPoints = hyphenationPoints.length;