Class TilingPaint

  • All Implemented Interfaces:
    java.awt.Paint, java.awt.Transparency

    class TilingPaint
    extends java.lang.Object
    implements java.awt.Paint
    AWT Paint for a tiling pattern, which consists of a small repeating graphical figure.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static java.lang.String DEFAULTMAXEDGE  
      private static org.apache.commons.logging.Log LOG  
      private static int MAXEDGE  
      private java.awt.Paint paint  
      private Matrix patternMatrix  
      • Fields inherited from interface java.awt.Transparency

        BITMASK, OPAQUE, TRANSLUCENT
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private static int ceiling​(double num)
      Returns the closest integer which is larger than the given number.
      java.awt.PaintContext createContext​(java.awt.image.ColorModel cm, java.awt.Rectangle deviceBounds, java.awt.geom.Rectangle2D userBounds, java.awt.geom.AffineTransform xform, java.awt.RenderingHints hints)
      Not called in TexturePaint subclasses, which is why we wrap TexturePaint.
      private java.awt.geom.Rectangle2D getAnchorRect​(PDTilingPattern pattern)
      Returns the anchor rectangle, which includes the XStep/YStep and scaling.
      private java.awt.image.BufferedImage getImage​(PageDrawer drawer, PDTilingPattern pattern, PDColorSpace colorSpace, PDColor color, java.awt.geom.AffineTransform xform, java.awt.geom.Rectangle2D anchorRect)
      Returns the pattern image in parent stream coordinates.
      int getTransparency()  
      • Methods inherited from class java.lang.Object

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

      • LOG

        private static final org.apache.commons.logging.Log LOG
      • paint

        private final java.awt.Paint paint
      • patternMatrix

        private final Matrix patternMatrix
      • MAXEDGE

        private static final int MAXEDGE
    • Constructor Detail

      • TilingPaint

        TilingPaint​(PageDrawer drawer,
                    PDTilingPattern pattern,
                    java.awt.geom.AffineTransform xform)
             throws java.io.IOException
        Creates a new colored tiling Paint, i.e. one that has its own colors.
        Parameters:
        drawer - renderer to render the page
        pattern - tiling pattern dictionary
        xform - device scale transform
        Throws:
        java.io.IOException - if something goes wrong while drawing the pattern
      • TilingPaint

        TilingPaint​(PageDrawer drawer,
                    PDTilingPattern pattern,
                    PDColorSpace colorSpace,
                    PDColor color,
                    java.awt.geom.AffineTransform xform)
             throws java.io.IOException
        Creates a new tiling Paint. The parameters color and colorSpace must be null for a colored tiling Paint (because it has its own colors), and non null for an uncolored tiling Paint.
        Parameters:
        drawer - renderer to render the page
        pattern - tiling pattern dictionary
        colorSpace - color space for this tiling
        color - color for this tiling
        xform - device scale transform
        Throws:
        java.io.IOException - if something goes wrong while drawing the pattern
    • Method Detail

      • createContext

        public java.awt.PaintContext createContext​(java.awt.image.ColorModel cm,
                                                   java.awt.Rectangle deviceBounds,
                                                   java.awt.geom.Rectangle2D userBounds,
                                                   java.awt.geom.AffineTransform xform,
                                                   java.awt.RenderingHints hints)
        Not called in TexturePaint subclasses, which is why we wrap TexturePaint.
        Specified by:
        createContext in interface java.awt.Paint
      • getImage

        private java.awt.image.BufferedImage getImage​(PageDrawer drawer,
                                                      PDTilingPattern pattern,
                                                      PDColorSpace colorSpace,
                                                      PDColor color,
                                                      java.awt.geom.AffineTransform xform,
                                                      java.awt.geom.Rectangle2D anchorRect)
                                               throws java.io.IOException
        Returns the pattern image in parent stream coordinates.
        Throws:
        java.io.IOException
      • ceiling

        private static int ceiling​(double num)
        Returns the closest integer which is larger than the given number. Uses BigDecimal to avoid floating point error which would cause gaps in the tiling.
      • getTransparency

        public int getTransparency()
        Specified by:
        getTransparency in interface java.awt.Transparency
      • getAnchorRect

        private java.awt.geom.Rectangle2D getAnchorRect​(PDTilingPattern pattern)
        Returns the anchor rectangle, which includes the XStep/YStep and scaling.