Package io.github.olyutorskii.quetexj
Class HeightKeeper
java.lang.Object
io.github.olyutorskii.quetexj.HeightKeeper
Automatically keep height of text component
by chopping head of Document model.
Component is chopped row by row.
Physical text-line layout is preserved.
Relative position of vertical BoundedRangeModel is adjusted to keep JViewport view in JScrollPane as much as possible.
PlainDocument only supported.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Default height limit.static final int
Default new height. -
Constructor Summary
ConstructorsConstructorDescriptionHeightKeeper
(JTextArea textComp, BoundedRangeModel rangeModel) Constructor.HeightKeeper
(JTextArea textComp, BoundedRangeModel rangeModel, int heightLimit, int newHeight) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionReturn associated BoundedRangeModel.int
Return height limit condition.int
Return new height.Return associated text component.void
setConditions
(int heightLimitArg, int newHeightArg) Set height condition values.
-
Field Details
-
DEF_HEIGHTLIMIT
public static final int DEF_HEIGHTLIMITDefault height limit.- See Also:
-
DEF_NEWHEIGHT
public static final int DEF_NEWHEIGHTDefault new height.- See Also:
-
-
Constructor Details
-
HeightKeeper
Constructor.Condition parameters are default value.
- Parameters:
textComp
- text componentrangeModel
- bounded range model
-
HeightKeeper
public HeightKeeper(JTextArea textComp, BoundedRangeModel rangeModel, int heightLimit, int newHeight) Constructor.- newHeight must be positive integer value.
- newHeight must be smaller than heightLimit.
- Parameters:
textComp
- text componentrangeModel
- bounded range modelheightLimit
- height limit conditionnewHeight
- new height when over limit- Throws:
IllegalArgumentException
- illegal integer argument
-
-
Method Details
-
getTextComponent
Return associated text component.- Returns:
- text component
-
getBoundedRangeModel
Return associated BoundedRangeModel.- Returns:
- BoundedRangeModel
-
getHeightLimit
public int getHeightLimit()Return height limit condition.- Returns:
- height limit
-
getNewHeight
public int getNewHeight()Return new height.- Returns:
- new height
-
setConditions
Set height condition values.- newHeightArg must be positive integer value.
- newHeightArg must be smaller than heightLimitArg.
- Parameters:
heightLimitArg
- height limit conditionnewHeightArg
- new height when over limit- Throws:
IllegalArgumentException
- illegal integer argument
-