Package com.openhtmltopdf.layout
Class LineBreakContext
- java.lang.Object
-
- com.openhtmltopdf.layout.LineBreakContext
-
public class LineBreakContext extends java.lang.Object
A bean which serves as a way for the layout code to pass information to the line breaking code and for the line breaking code to pass instructions back to the layout code.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LineBreakContext.LineBreakResult
-
Field Summary
Fields Modifier and Type Field Description private int
_end
private boolean
_endsOnNL
private boolean
_endsOnSoftHyphen
private boolean
_endsOnWordBreak
private boolean
_finishedInCharBreakingMode
private boolean
_isFirstChar
private int
_lastNewLineStartPosition
private java.lang.String
_master
private boolean
_needsNewLine
private int
_newlineAttemptsForLastStartPosition
private int
_nextWidth
private int
_savedEnd
private int
_start
private boolean
_unbreakable
private int
_width
-
Constructor Summary
Constructors Constructor Description LineBreakContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
checkConsistency(Breaker.BreakTextResult breakResult)
Given the result of text breaking, makes some sanity preserving asserts to check the state of this object.java.lang.String
getCalculatedSubstring()
int
getEnd()
int
getLast()
java.lang.String
getMaster()
int
getNextWidth()
If needs newline, returns the graphics width of the next unbreakable sequence.int
getStart()
java.lang.String
getStartSubstring()
int
getWidth()
boolean
isEndsOnNL()
boolean
isEndsOnSoftHyphen()
boolean
isEndsOnWordBreak()
boolean
isFinished()
boolean
isFinishedInCharBreakingMode()
If this is true, it means we finished in char breaking mode because a word was too large.boolean
isFirstCharInLine()
boolean
isNeedsNewLine()
boolean
isUnbreakable()
void
newLine()
Record a newline attempt.boolean
possibleEndlessLoop()
void
reset()
void
resetEnd()
void
saveEnd()
void
setEnd(int end)
void
setEndsOnNL(boolean b)
void
setEndsOnSoftHyphen(boolean b)
void
setEndsOnWordBreak(boolean _endsOnWordBreak)
void
setFinishedInCharBreakingMode(boolean mode)
void
setFirstCharInLine(boolean isFirstChar)
void
setMaster(java.lang.String master)
void
setNeedsNewLine(boolean needsLineBreak)
void
setNextWidth(int nextWidth)
void
setStart(int start)
void
setUnbreakable(boolean unbreakable)
void
setWidth(int width)
-
-
-
Field Detail
-
_master
private java.lang.String _master
-
_start
private int _start
-
_end
private int _end
-
_savedEnd
private int _savedEnd
-
_unbreakable
private boolean _unbreakable
-
_needsNewLine
private boolean _needsNewLine
-
_width
private int _width
-
_endsOnNL
private boolean _endsOnNL
-
_endsOnSoftHyphen
private boolean _endsOnSoftHyphen
-
_nextWidth
private int _nextWidth
-
_endsOnWordBreak
private boolean _endsOnWordBreak
-
_finishedInCharBreakingMode
private boolean _finishedInCharBreakingMode
-
_isFirstChar
private boolean _isFirstChar
-
_lastNewLineStartPosition
private int _lastNewLineStartPosition
-
_newlineAttemptsForLastStartPosition
private int _newlineAttemptsForLastStartPosition
-
-
Method Detail
-
reset
public void reset()
-
newLine
public void newLine()
Record a newline attempt. This should be called at each newline and then possibleEndlessLoop method can be called to check if excessive attempts have been made to output the same character on newlines.
-
possibleEndlessLoop
public boolean possibleEndlessLoop()
-
getLast
public int getLast()
-
getEnd
public int getEnd()
-
setEnd
public void setEnd(int end)
-
getMaster
public java.lang.String getMaster()
-
setMaster
public void setMaster(java.lang.String master)
-
getStart
public int getStart()
-
setStart
public void setStart(int start)
-
getStartSubstring
public java.lang.String getStartSubstring()
-
getCalculatedSubstring
public java.lang.String getCalculatedSubstring()
-
isUnbreakable
public boolean isUnbreakable()
-
setUnbreakable
public void setUnbreakable(boolean unbreakable)
-
isNeedsNewLine
public boolean isNeedsNewLine()
-
setNeedsNewLine
public void setNeedsNewLine(boolean needsLineBreak)
-
getWidth
public int getWidth()
-
setWidth
public void setWidth(int width)
-
isFinished
public boolean isFinished()
-
resetEnd
public void resetEnd()
-
saveEnd
public void saveEnd()
-
isEndsOnNL
public boolean isEndsOnNL()
-
setEndsOnNL
public void setEndsOnNL(boolean b)
-
isEndsOnSoftHyphen
public boolean isEndsOnSoftHyphen()
-
setEndsOnSoftHyphen
public void setEndsOnSoftHyphen(boolean b)
-
getNextWidth
public int getNextWidth()
If needs newline, returns the graphics width of the next unbreakable sequence. We use this to test if we should actually put in a newline before a long word when break-word is on. If getNextWidth would fit on an empty line we put in the new line else we split in the long word immediately.
-
setNextWidth
public void setNextWidth(int nextWidth)
-
isEndsOnWordBreak
public boolean isEndsOnWordBreak()
-
setEndsOnWordBreak
public void setEndsOnWordBreak(boolean _endsOnWordBreak)
-
setFinishedInCharBreakingMode
public void setFinishedInCharBreakingMode(boolean mode)
-
isFinishedInCharBreakingMode
public boolean isFinishedInCharBreakingMode()
If this is true, it means we finished in char breaking mode because a word was too large. The next line should begin in char breaking mode.
-
isFirstCharInLine
public boolean isFirstCharInLine()
- Returns:
- true if this is the first non-trimmed character in a line.
-
setFirstCharInLine
public void setFirstCharInLine(boolean isFirstChar)
- Parameters:
isFirstChar
- set to true if this is the first non-trimmable character in a line.
-
checkConsistency
public void checkConsistency(Breaker.BreakTextResult breakResult)
Given the result of text breaking, makes some sanity preserving asserts to check the state of this object.
-
-