Package grp25.captcha

Class ImgWithTag


  • class ImgWithTag
    extends java.lang.Object
    A wrapper class for a image and its patches with tags.
    • Constructor Summary

      Constructors 
      Constructor Description
      ImgWithTag​(java.io.File img, int rows, int cols, boolean hab)
      A wrapper class for a image and its patches with tags.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.io.File getImg()
      Get the source image file.
      (package private) java.awt.image.BufferedImage getPatch​(int row, int col)
      Get the BufferedImage of patch of the given coordinate.
      (package private) Tag getTag​(int row, int col)
      Get the tag of patch given its row and column index.
      (package private) java.lang.String getType()
      Get the file extension of source image file
      void setAll​(boolean hab)
      Set all patches to given tag.
      (package private) void setTag​(int row, int col, Tag t)
      Set the tag of the given patch to given value.
      • Methods inherited from class java.lang.Object

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

      • ImgWithTag

        ImgWithTag​(java.io.File img,
                   int rows,
                   int cols,
                   boolean hab)
            throws java.io.IOException
        A wrapper class for a image and its patches with tags.
        Parameters:
        img - The source Image
        rows - The number of rows that the image will be sliced into
        cols - The number of cols that the image will be sliced into
        hab - The default value of whether each patches are habitable or not. This argument should be generalize to general Tag value.
        Throws:
        java.io.IOException - The exception be raised when reading images from the file system
    • Method Detail

      • getPatch

        java.awt.image.BufferedImage getPatch​(int row,
                                              int col)
        Get the BufferedImage of patch of the given coordinate.
        Parameters:
        row - The row coordinate (y).
        col - The col coordinate (x).
        Returns:
        The BufferedImage of patch of the given coordinate.
      • getTag

        Tag getTag​(int row,
                   int col)
        Get the tag of patch given its row and column index.
        Parameters:
        row - The row index of patch.
        col - The column index of patch.
        Returns:
        The tag of given row and column.
      • setTag

        void setTag​(int row,
                    int col,
                    Tag t)
        Set the tag of the given patch to given value.
        Parameters:
        row - The row index of patch to set.
        col - The column index of patch to set
        t - The tag that the patch to set to.
      • getType

        java.lang.String getType()
                          throws java.io.IOException
        Get the file extension of source image file
        Returns:
        The file extension of source image file.
        Throws:
        java.io.IOException - IO excption generated from operations about file.
      • getImg

        public java.io.File getImg()
        Get the source image file.
        Returns:
        The source image file.
      • setAll

        public void setAll​(boolean hab)
        Set all patches to given tag. This function should be generalize so that it can work with any Tag.
        Parameters:
        hab - Whether all patches are inhabitable.