Class Image

java.lang.Object
net.atthegate.server.service.pdf.Image
All Implemented Interfaces:
Drawable

public class Image extends Object implements Drawable
Used to create image objects and draw them on a page. The image type can be one of the following: ImageType.JPG, ImageType.PNG, ImageType.BMP or ImageType.JET Please see Example_03 and Example_24.
  • Field Details

    • objNumber

      protected int objNumber
    • x

      protected float x
    • y

      protected float y
    • w

      protected float w
    • h

      protected float h
    • uri

      protected String uri
    • key

      protected String key
  • Constructor Details

    • Image

      public Image(PDF pdf, InputStream inputStream, int imageType) throws Exception
      The main constructor for the Image class.
      Parameters:
      pdf - the PDF to which we add this image.
      inputStream - the input stream to read the image from.
      imageType - ImageType.JPG, ImageType.PNG and ImageType.BMP.
      Throws:
      Exception
    • Image

      public Image(PDF pdf, PDFobj obj) throws Exception
      Throws:
      Exception
    • Image

      public Image(Map<Integer,PDFobj> objects, InputStream inputStream, int imageType) throws Exception
      Constructor used to attach images to existing PDF.
      Parameters:
      objects - the map to which we add this image.
      inputStream - the input stream to read the image from.
      imageType - ImageType.JPG, ImageType.PNG and ImageType.BMP.
      Throws:
      Exception
  • Method Details

    • setPosition

      public Image setPosition(double x, double y)
      Sets the position of this image on the page to (x, y).
      Parameters:
      x - the x coordinate of the top left corner of the image.
      y - the y coordinate of the top left corner of the image.
    • setPosition

      public Image setPosition(float x, float y)
      Sets the position of this image on the page to (x, y).
      Parameters:
      x - the x coordinate of the top left corner of the image.
      y - the y coordinate of the top left corner of the image.
    • setLocation

      public Image setLocation(float x, float y)
      Sets the location of this image on the page to (x, y).
      Parameters:
      x - the x coordinate of the top left corner of the image.
      y - the y coordinate of the top left corner of the image.
    • scaleBy

      public Image scaleBy(double factor)
      Scales this image by the specified factor.
      Parameters:
      factor - the factor used to scale the image.
    • scaleBy

      public Image scaleBy(float factor)
      Scales this image by the specified factor.
      Parameters:
      factor - the factor used to scale the image.
    • scaleBy

      public Image scaleBy(float widthFactor, float heightFactor)
      Scales this image by the specified width and height factor.

      Author: Pieter Libin, pieter@emweb.be

      Parameters:
      widthFactor - the factor used to scale the width of the image
      heightFactor - the factor used to scale the height of the image
    • placeIn

      public void placeIn(Box box) throws Exception
      Places this image in the specified box.
      Parameters:
      box - the specified box.
      Throws:
      Exception
    • setURIAction

      public void setURIAction(String uri)
      Sets the URI for the "click box" action.
      Parameters:
      uri - the URI
    • setGoToAction

      public void setGoToAction(String key)
      Sets the destination key for the action.
      Parameters:
      key - the destination name.
    • setRotateCW90

      public void setRotateCW90(boolean rotate90)
      Sets the rotate90 flag. When the flag is true the image is rotated 90 degrees clockwise.
      Parameters:
      rotate90 - the flag.
    • setRotate

      public void setRotate(int degrees)
      Sets the image rotation to the specified number of degrees.
      Parameters:
      degrees - the number of degrees.
    • setAltDescription

      public Image setAltDescription(String altDescription)
      Sets the alternate description of this image.
      Parameters:
      altDescription - the alternate description of the image.
      Returns:
      this Image.
    • setActualText

      public Image setActualText(String actualText)
      Sets the actual text for this image.
      Parameters:
      actualText - the actual text for the image.
      Returns:
      this Image.
    • drawOn

      public float[] drawOn(Page page) throws Exception
      Draws this image on the specified page.
      Specified by:
      drawOn in interface Drawable
      Parameters:
      page - the page to draw this image on.
      Returns:
      x and y coordinates of the bottom right corner of this component.
      Throws:
      Exception
    • getWidth

      public float getWidth()
      Returns the width of this image when drawn on the page. The scaling is take into account.
      Returns:
      w - the width of this image.
    • getHeight

      public float getHeight()
      Returns the height of this image when drawn on the page. The scaling is take into account.
      Returns:
      h - the height of this image.
    • resizeToFit

      public void resizeToFit(Page page, boolean keepAspectRatio)
    • flipUpsideDown

      public void flipUpsideDown(boolean flipUpsideDown)