Class ImageLayout

  • All Implemented Interfaces:
    Constants

    public class ImageLayout
    extends java.lang.Object
    implements Constants
    Helper class which calculates the size and position in the viewport of an image.
    • Field Detail

      • log

        protected static final org.apache.commons.logging.Log log
        logging instance
      • intrinsicSize

        private java.awt.Dimension intrinsicSize
      • placement

        private java.awt.Rectangle placement
      • viewportSize

        private java.awt.Dimension viewportSize
      • clip

        private boolean clip
    • Constructor Detail

      • ImageLayout

        public ImageLayout​(GraphicsProperties props,
                           PercentBaseContext percentBaseContext,
                           java.awt.Dimension intrinsicSize)
        Main constructor
        Parameters:
        props - the properties for the image
        percentBaseContext - the context object for percentage calculations
        intrinsicSize - the image's intrinsic size
    • Method Detail

      • doLayout

        protected void doLayout()
        Does the actual calculations for the image.
      • constrain

        private java.awt.Dimension constrain​(java.awt.Dimension size)
      • adjustContentSize

        private java.awt.Dimension adjustContentSize​(int cwidth,
                                                     int cheight,
                                                     java.awt.Dimension defaultSize)
      • computeXOffset

        public int computeXOffset​(int ipd,
                                  int cwidth)
        Given the ipd and the content width calculates the required x offset based on the text-align property
        Parameters:
        ipd - the inline-progression-dimension of the object
        cwidth - the calculated content width of the object
        Returns:
        the X offset
      • computeYOffset

        public int computeYOffset​(int bpd,
                                  int cheight)
        Given the bpd and the content height calculates the required y offset based on the display-align property
        Parameters:
        bpd - the block-progression-dimension of the object
        cheight - the calculated content height of the object
        Returns:
        the Y offset
      • getPlacement

        public java.awt.Rectangle getPlacement()
        Returns the placement of the image inside the viewport.
        Returns:
        the placement of the image inside the viewport (coordinates in millipoints)
      • getViewportSize

        public java.awt.Dimension getViewportSize()
        Returns the size of the image's viewport.
        Returns:
        the viewport size (in millipoints)
      • getIntrinsicSize

        public java.awt.Dimension getIntrinsicSize()
        Returns the size of the image's intrinsic (natural) size.
        Returns:
        the intrinsic size (in millipoints)
      • isClipped

        public boolean isClipped()
        Indicates whether the image is clipped.
        Returns:
        true if the image shall be clipped
      • evaluateLength

        private int evaluateLength​(Length length,
                                   int referenceValue)
      • evaluateLength

        private int evaluateLength​(Length length)