Class PageShape

  • Direct Known Subclasses:
    PageShape.CompoundShape, PageShape.CupShape, PageShape.GeometricShape, PageShape.InsetShape, PageShape.MergedShape

    public class PageShape
    extends java.lang.Object
    Shapes the left and right margins of rendered text. The shape is defined in terms of insets relative to the original margins. A PageShape returns insets based on the range of Y-positions covered by a line of text. Positive inset values always reduce the margins; negative values increase them. A zero inset leaves the margin unchanged.
    Author:
    Chris Jennings
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  PageShape.CompoundShape
      A PageShape that switches between two PageShapes at a specified Y-position.
      static class  PageShape.CupShape
      A PageShape that is optimized for the most common case: a rectangle that becomes wider or narrower after a certain y-point is reached, e.g.:
      static class  PageShape.GeometricShape
      A PageShape that takes its form from a drawing shape (java.awt.Shape).
      static class  PageShape.InsetShape
      A PageShape that returns constant inset values regardless of the Y-position.
      static class  PageShape.MergedShape
      A shape that merges two source shapes into a single shape.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static PageShape RECTANGLE_SHAPE
      A standard shape that causes the text to conform to its layout rectangle.
    • Constructor Summary

      Constructors 
      Constructor Description
      PageShape()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void debugDraw​(java.awt.Graphics2D g, java.awt.geom.Rectangle2D rect)
      This function is called when the markup renderer is painting its text box for debugging purposes.
      double getLeftInset​(double y1, double y2)
      Return the narrowest (maximum) left edge inset between y1 and y2.
      double getRightInset​(double y1, double y2)
      Return the narrowest (maximum) right edge inset between y1 and y2.
      • Methods inherited from class java.lang.Object

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

      • RECTANGLE_SHAPE

        public static final PageShape RECTANGLE_SHAPE
        A standard shape that causes the text to conform to its layout rectangle. This is the default shape for a MarkupRenderer. It works just as if using new InsetShape(0,0), although it may use an optimized implementation.
    • Constructor Detail

      • PageShape

        public PageShape()
    • Method Detail

      • getLeftInset

        public double getLeftInset​(double y1,
                                   double y2)
        Return the narrowest (maximum) left edge inset between y1 and y2. y1 must be <= y2.
      • getRightInset

        public double getRightInset​(double y1,
                                    double y2)
        Return the narrowest (maximum) right edge inset between y1 and y2. y1 must be <= y2.
      • debugDraw

        public void debugDraw​(java.awt.Graphics2D g,
                              java.awt.geom.Rectangle2D rect)
        This function is called when the markup renderer is painting its text box for debugging purposes. It should draw lines or a shape to indicate how the margins are modified by this shape. The default implementation samples the left and right insets at regular intervals to construct an approximate shape. Subclasses are encouraged to override this to provide more efficient and/or more accurate implementations.
        Parameters:
        g - the graphics context to draw into
        rect - the rectangle within which text is being laid out