Class Picture

java.lang.Object
overit.geocall.servlet.MultipartRaw
overit.geocall.servlet.Raw
overit.geocall.ux.util.Picture
All Implemented Interfaces:
com.esotericsoftware.kryo.KryoSerializable, Serializable

public class Picture extends overit.geocall.servlet.Raw implements Serializable, com.esotericsoftware.kryo.KryoSerializable
This class implements a Picture object
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
     
    protected float
     

    Fields inherited from class overit.geocall.servlet.MultipartRaw

    _autoCache, _caches, _compression
  • Constructor Summary

    Constructors
    Constructor
    Description
    Picture(byte[] bb)
    Creates a new Picture object starting from the byte array passed as parameter to obtain a BufferedImage
    Creates a new Picture object starting from the BufferedImage passed as parameter
    Creates a new Picture object, reading the InputStream passed as parameter to obtain a BufferedImage
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    cropAndScale(Color bkg, int x1, int y1, int x2, int y2, int w, int h)
    Makes the crop and scale transformations on the image
    Returns the BufferedImage created constructing the Picture object
     
    Returns the format of the Picture object (see setFormat(java.lang.String, float))
    int
    Returns the height of the BufferedImage created constructing the Picture object
    int
    Returns the width of the BufferedImage created constructing the Picture object
    void
    Writes the image stream on the OutputStream
    void
    read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input)
     
    void
    setFormat(String format, float quality)
    Sets the format of the Picture object
    byte[]
    Returns an array of byte of the image element of the Picture object
    void
    write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output)
     
    void
    Writes the image into the File passed as parameter

    Methods inherited from class overit.geocall.servlet.Raw

    getContentType, output, output

    Methods inherited from class overit.geocall.servlet.MultipartRaw

    enableCompression, getAutoCache, getCompress, getCompression, output, setAutoCache

    Methods inherited from class java.lang.Object

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

    • _format

      protected String _format
    • _quality

      protected float _quality
  • Constructor Details

    • Picture

      public Picture(InputStream is) throws IOException
      Creates a new Picture object, reading the InputStream passed as parameter to obtain a BufferedImage
      Parameters:
      is - The InputStream to read
      Throws:
      IOException - If an error occur during reading an exception is raised
    • Picture

      public Picture(byte[] bb) throws IOException
      Creates a new Picture object starting from the byte array passed as parameter to obtain a BufferedImage
      Parameters:
      bb - The byte array to read
      Throws:
      IOException - If an error occur during reading, an exception is raised
    • Picture

      public Picture(BufferedImage bi)
      Creates a new Picture object starting from the BufferedImage passed as parameter
      Parameters:
      bi - The BufferedImage used to create the object
  • Method Details

    • setFormat

      public void setFormat(String format, float quality)
      Sets the format of the Picture object
      Parameters:
      format - Can be "png" that is the default value, or "jpg"
      quality - The compression quality, a float value between 0 and 1; if the format is "png" the quality is lossless
    • getFormat

      public String getFormat()
      Returns the format of the Picture object (see setFormat(java.lang.String, float))
      Returns:
      The string that defines the format of the Picture object
    • getBufferedImage

      public BufferedImage getBufferedImage()
      Returns the BufferedImage created constructing the Picture object
      Returns:
      The BufferedImage
    • getWidth

      public int getWidth()
      Returns the width of the BufferedImage created constructing the Picture object
      Returns:
      The int value that defines the width of the Picture
    • getHeight

      public int getHeight()
      Returns the height of the BufferedImage created constructing the Picture object
      Returns:
      The int value that defines the height of the Picture
    • cropAndScale

      public void cropAndScale(Color bkg, int x1, int y1, int x2, int y2, int w, int h) throws IOException
      Makes the crop and scale transformations on the image
      Parameters:
      bkg - The background color to use in the tool
      x1 - The first x coordinate for the crop
      y1 - The second x coordinate for the crop
      x2 - The first y coordinate for the crop
      y2 - The second y coordinate for the crop
      w - The width for the scaling
      h - The height for the scaling
      Throws:
      IOException - If an error occur during the transformations, an exception is raised
    • getContentType

      public String getContentType()
      Specified by:
      getContentType in class overit.geocall.servlet.Raw
    • output

      public void output(OutputStream os) throws IOException
      Writes the image stream on the OutputStream
      Specified by:
      output in class overit.geocall.servlet.Raw
      Parameters:
      os - The OutputStream
      Throws:
      IOException - If there is an error, an IOException is thrown
    • toByteArray

      public byte[] toByteArray() throws IOException
      Returns an array of byte of the image element of the Picture object
      Returns:
      The array of byte of the image element of the Picture object
      Throws:
      IOException - If there is an error, an IOException is thrown
    • write

      public void write(File f) throws IOException
      Writes the image into the File passed as parameter
      Parameters:
      f - The file to write
      Throws:
      IOException - If there is an error in writing, an IOException is thrown
    • write

      public void write(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Output output)
      Specified by:
      write in interface com.esotericsoftware.kryo.KryoSerializable
      Overrides:
      write in class overit.geocall.servlet.MultipartRaw
    • read

      public void read(com.esotericsoftware.kryo.Kryo kryo, com.esotericsoftware.kryo.io.Input input)
      Specified by:
      read in interface com.esotericsoftware.kryo.KryoSerializable
      Overrides:
      read in class overit.geocall.servlet.MultipartRaw