Class ParagraphWidowsControl


  • public class ParagraphWidowsControl
    extends java.lang.Object
    A specialized class holding configurable parameters related to Paragraph's widows restrictions. This class is meant to be used as the value for the Property.WIDOWS_CONTROL key.
    • Constructor Summary

      Constructors 
      Constructor Description
      ParagraphWidowsControl​(int minWidows, int maxLinesToMove, boolean overflowParagraphOnViolation)
      Creates a ParagraphWidowsControl instance with specified widows restrictions.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getMaxLinesToMove()
      Gets a number of lines that are allowed to be moved to the next area in order to fix widows constraint violation.
      int getMinWidows()
      Gets minimal number of paragraph's lines to be overflowed to the next area.
      void handleViolatedWidows​(ParagraphRenderer widowsRenderer, java.lang.String message)
      Writes a log message reporting that widows constraint is violated and cannot be automatically fixed.
      boolean isOverflowOnWidowsViolation()
      Indicates whether paragraph should be completely pushed to the next area if widows constraint is violated and cannot be automatically fixed.
      ParagraphWidowsControl setMinAllowedWidows​(int minWidows, int maxLinesToMove, boolean overflowParagraphOnViolation)
      Sets parameters that define widows restrictions and conditions of handling cases of widows constraint violation.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • minWidows

        private int minWidows
      • maxLinesToMove

        private int maxLinesToMove
      • overflowOnWidowsViolation

        private boolean overflowOnWidowsViolation
    • Constructor Detail

      • ParagraphWidowsControl

        public ParagraphWidowsControl​(int minWidows,
                                      int maxLinesToMove,
                                      boolean overflowParagraphOnViolation)
        Creates a ParagraphWidowsControl instance with specified widows restrictions.
        Parameters:
        minWidows - minimal number of paragraph's lines to be overflowed to the next area.
        maxLinesToMove - a number of lines that are allowed to be moved to the next area in order to fix widows constraint violation.
        overflowParagraphOnViolation - defines whether the entire paragraph should be pushed to the next area if widows constraint is violated and cannot be automatically fixed.
    • Method Detail

      • setMinAllowedWidows

        public ParagraphWidowsControl setMinAllowedWidows​(int minWidows,
                                                          int maxLinesToMove,
                                                          boolean overflowParagraphOnViolation)
        Sets parameters that define widows restrictions and conditions of handling cases of widows constraint violation.
        Parameters:
        minWidows - minimal number of paragraph's lines to be overflowed to the next area.
        maxLinesToMove - a number of lines that are allowed to be moved to the next area in order to fix widows constraint violation.
        overflowParagraphOnViolation - defines whether paragraph should be completely pushed to the next area if widows constraint is violated and cannot be automatically fixed.
        Returns:
        this ParagraphWidowsControl instance.
      • getMinWidows

        public int getMinWidows()
        Gets minimal number of paragraph's lines to be overflowed to the next area.
        Returns:
        minimal number of paragraph's lines to be overflowed to the next area
      • getMaxLinesToMove

        public int getMaxLinesToMove()
        Gets a number of lines that are allowed to be moved to the next area in order to fix widows constraint violation.
        Returns:
        a number of lines that are allowed to be moved to the next are
      • isOverflowOnWidowsViolation

        public boolean isOverflowOnWidowsViolation()
        Indicates whether paragraph should be completely pushed to the next area if widows constraint is violated and cannot be automatically fixed.
        Returns:
        true if paragraph should be completely pushed to the next area if widows constraint is violated and cannot be automatically fixed, otherwise - false
      • handleViolatedWidows

        public void handleViolatedWidows​(ParagraphRenderer widowsRenderer,
                                         java.lang.String message)
        Writes a log message reporting that widows constraint is violated and cannot be automatically fixed. This method is to be overridden if violation scenarios need to be handled in some other way.
        Parameters:
        widowsRenderer - a renderer processing widows
        message - String explaining the reason for violation