Class HeightKeeper

java.lang.Object
io.github.olyutorskii.quetexj.HeightKeeper

public class HeightKeeper extends Object
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 Details

    • DEF_HEIGHTLIMIT

      public static final int DEF_HEIGHTLIMIT
      Default height limit.
      See Also:
    • DEF_NEWHEIGHT

      public static final int DEF_NEWHEIGHT
      Default new height.
      See Also:
  • Constructor Details

    • HeightKeeper

      public HeightKeeper(JTextArea textComp, BoundedRangeModel rangeModel)
      Constructor.

      Condition parameters are default value.

      Parameters:
      textComp - text component
      rangeModel - 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 component
      rangeModel - bounded range model
      heightLimit - height limit condition
      newHeight - new height when over limit
      Throws:
      IllegalArgumentException - illegal integer argument
  • Method Details

    • getTextComponent

      public JTextComponent getTextComponent()
      Return associated text component.
      Returns:
      text component
    • getBoundedRangeModel

      public BoundedRangeModel 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

      public void setConditions(int heightLimitArg, int newHeightArg) throws IllegalArgumentException
      Set height condition values.
      • newHeightArg must be positive integer value.
      • newHeightArg must be smaller than heightLimitArg.
      Parameters:
      heightLimitArg - height limit condition
      newHeightArg - new height when over limit
      Throws:
      IllegalArgumentException - illegal integer argument