Class ImageRenderer

    • Field Detail

      • fixedXPosition

        protected java.lang.Float fixedXPosition
      • fixedYPosition

        protected java.lang.Float fixedYPosition
      • pivotY

        protected float pivotY
      • deltaX

        protected float deltaX
      • imageWidth

        protected float imageWidth
      • imageHeight

        protected float imageHeight
      • matrix

        float[] matrix
      • height

        private java.lang.Float height
      • width

        private java.lang.Float width
      • renderedImageHeight

        private float renderedImageHeight
      • renderedImageWidth

        private float renderedImageWidth
      • doesObjectFitRequireCutting

        private boolean doesObjectFitRequireCutting
      • initialOccupiedAreaBBox

        private Rectangle initialOccupiedAreaBBox
      • rotatedDeltaX

        private float rotatedDeltaX
      • rotatedDeltaY

        private float rotatedDeltaY
    • Constructor Detail

      • ImageRenderer

        public ImageRenderer​(Image image)
        Creates an ImageRenderer from its corresponding layout object.
        Parameters:
        image - the Image which this object should manage
    • Method Detail

      • layout

        public LayoutResult layout​(LayoutContext layoutContext)
        Description copied from interface: IRenderer
        This method simulates positioning of the renderer, including all of its children, and returns the LayoutResult, representing the layout result, including occupied area, status, i.e. if there was enough place to fit the renderer subtree, etc. LayoutResult can be extended to return custom layout results for custom elements, e.g. TextRenderer uses TextLayoutResult as its result. This method can be called standalone to learn how much area the renderer subtree needs, or can be called before IRenderer.draw(DrawContext), to prepare the renderer to be flushed to the output stream.
        Specified by:
        layout in interface IRenderer
        Parameters:
        layoutContext - the description of layout area and any other additional information
        Returns:
        result of the layout process
      • draw

        public void draw​(DrawContext drawContext)
        Description copied from class: AbstractRenderer
        Flushes the renderer subtree contents, i.e. draws itself on canvas, adds necessary objects to the PdfDocument etc.
        Specified by:
        draw in interface IRenderer
        Overrides:
        draw in class AbstractRenderer
        Parameters:
        drawContext - contains the PdfDocument to which the renderer subtree if flushed, the PdfCanvas on which the renderer subtree is drawn and other additional parameters needed to perform drawing
      • hasAspectRatio

        boolean hasAspectRatio()
        Checks if this renderer has intrinsic aspect ratio.
        Overrides:
        hasAspectRatio in class AbstractRenderer
        Returns:
        true, if aspect ratio is defined for this renderer, false otherwise
      • getAspectRatio

        java.lang.Float getAspectRatio()
        Gets intrinsic aspect ratio for this renderer.
        Overrides:
        getAspectRatio in class AbstractRenderer
        Returns:
        aspect ratio, if it is defined for this renderer, null otherwise
      • getImageWidth

        public float getImageWidth()
        Gets original width of the image, not the width set by Image.setWidth(float) method.
        Returns:
        original image width
      • getImageHeight

        public float getImageHeight()
        Gets original height of the image, not the height set by Image.setHeight(float) method.
        Returns:
        original image height
      • applyPaddings

        protected Rectangle applyPaddings​(Rectangle rect,
                                          UnitValue[] paddings,
                                          boolean reverse)
        Description copied from class: AbstractRenderer
        Applies given paddings to the given rectangle.
        Overrides:
        applyPaddings in class AbstractRenderer
        Parameters:
        rect - a rectangle paddings will be applied on.
        paddings - the paddings to be applied on the given rectangle
        reverse - indicates whether paddings will be applied inside (in case of false) or outside (in case of true) the rectangle.
        Returns:
        a border box of the renderer
      • move

        public void move​(float dxRight,
                         float dyUp)
        Description copied from class: AbstractRenderer
        Moves the renderer subtree by the specified offset. This method affects occupied area of the renderer.
        Specified by:
        move in interface IRenderer
        Overrides:
        move in class AbstractRenderer
        Parameters:
        dxRight - the x-axis offset in points. Positive value will move the renderer subtree to the right.
        dyUp - the y-axis offset in points. Positive value will move the renderer subtree to the top.
      • applyObjectFit

        private void applyObjectFit​(ObjectFit objectFit,
                                    float imageWidth,
                                    float imageHeight)
      • beginObjectFitImageClipping

        private void beginObjectFitImageClipping​(PdfCanvas canvas)
      • endObjectFitImageClipping

        private void endObjectFitImageClipping​(PdfCanvas canvas)
      • getMatrix

        private void getMatrix​(AffineTransform t,
                               float imageItselfScaledWidth,
                               float imageItselfScaledHeight)
      • adjustPositionAfterRotation

        private float adjustPositionAfterRotation​(float angle,
                                                  float maxWidth,
                                                  float maxHeight)
      • translateImage

        private void translateImage​(float xDistance,
                                    float yDistance,
                                    AffineTransform t)
      • applyConcatMatrix

        private void applyConcatMatrix​(DrawContext drawContext,
                                       java.lang.Float angle)
      • applyRotationLayout

        private void applyRotationLayout​(float angle)