Package 

Class Pixa

  • All Implemented Interfaces:
    java.lang.Iterable

    
    public class Pixa
     implements Iterable<Pix>
                        

    Java representation of a native PIXA object. This object contains multiple PIX objects and their associated bounding BOX objects.

    • Constructor Summary

      Constructors 
      Constructor Description
      Pixa(long nativePixa, int width, int height) Creates a wrapper for the specified native Pixa pointer.
    • Method Summary

      Modifier and Type Method Description
      static Pixa createPixa(int size) Creates a new Pixa with the specified minimum capacity.
      static Pixa createPixa(int size, int width, int height) Creates a new Pixa with the specified minimum capacity.
      long getNativePixa() Returns a pointer to the native PIXA object.
      Pixa copy() Creates a shallow copy of this Pixa.
      Pixa sort(int field, int order) Sorts this Pixa using the specified field and order.
      int size() Returns the number of elements in this Pixa.
      synchronized void recycle() Recycles this Pixa and frees natively allocated memory.
      boolean join(Pixa otherPixa) Merges the contents of another Pixa into this one.
      void addPix(Pix pix, int mode) Adds a Pix to this Pixa.
      void addBox(Box box, int mode) Adds a Box to this Pixa.
      void add(Pix pix, Box box, int mode) Adds a Pix and associated Box to this Pixa.
      Box getBox(int index) Creates and returns clone of the Box at the specified index, or null on error.Returned object should be recycled after use.
      Pix getPix(int index) Creates and returns clone of the Pix at the specified index, or null on error.Returned object should be recycled after use.
      int getWidth() Returns the width of this Pixa, or 0 if one was not set when it wascreated.
      int getHeight() Returns the height of this Pixa, or 0 if one was not set when it wascreated.
      Rect getRect() Returns a bounding Rect for this Pixa, which may be (0,0,0,0) if widthand height were not specified on creation.
      Array<int> getBoxGeometry(int index) Returns a geometry array for the Box at the specified index.
      boolean getBoxGeometry(int index, @Size(min = 4) Array<int> dimensions) Fills an array with the geometry of the Box at the specified index.
      Rect getBoxRect(int index) Returns a bounding Rect for the Box at the specified index.
      ArrayList<Rect> getBoxRects() Returns an ArrayList of Box bounding Rects.
      void replacePix(int index, Pix pix, Box box) Replaces the Pix and Box at the specified index with the specified Pixand Box.
      void mergeAndReplacePix(int indexA, int indexB) Merges the Pix at the specified indices and removes the Pix at the secondindex.
      boolean writeToFileRandomCmap(File file) Writes the components of this Pix to a bitmap-formatted file using arandom color map.
      Iterator<Pix> iterator()
      • Methods inherited from class java.lang.Iterable

        forEach, iterator, spliterator
      • Methods inherited from class java.lang.Object

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

      • Pixa

        Pixa(long nativePixa, int width, int height)
        Creates a wrapper for the specified native Pixa pointer.
        Parameters:
        nativePixa - Native pointer to a PIXA object.
        width - The width of the PIXA.
        height - The height of the PIXA.
    • Method Detail

      • createPixa

         static Pixa createPixa(int size)

        Creates a new Pixa with the specified minimum capacity. The Pixa willexpand automatically as new Pix are added.

        Parameters:
        size - The minimum capacity of this Pixa.
      • createPixa

         static Pixa createPixa(int size, int width, int height)

        Creates a new Pixa with the specified minimum capacity. The Pixa willexpand automatically as new Pix are added.

        If non-zero, the specified width and height will be used to specify thebounds of output images. *

        Parameters:
        size - The minimum capacity of this Pixa.
        width - (Optional) The width of this Pixa, use 0 for default.
        height - (Optional) The height of this Pixa, use 0 for default.
      • getNativePixa

         long getNativePixa()

        Returns a pointer to the native PIXA object. This is used by native code.

      • copy

         Pixa copy()

        Creates a shallow copy of this Pixa. Contained Pix are cloned, and theresulting Pixa may be recycled separately from the original.

      • sort

         Pixa sort(int field, int order)

        Sorts this Pixa using the specified field and order. SeeConstants.L_SORT_BY_* and Constants.L_SORT_INCREASING orConstants.L_SORT_DECREASING.

        Parameters:
        field - The field to sort by.
        order - The order in which to sort.
      • size

         int size()

        Returns the number of elements in this Pixa.

      • recycle

         synchronized void recycle()

        Recycles this Pixa and frees natively allocated memory. You may notaccess or modify the Pixa after calling this method.

        Any Pix obtained from this Pixa or copies of this Pixa will still beaccessible until they are explicitly recycled or finalized by the garbagecollector.

      • join

         boolean join(Pixa otherPixa)

        Merges the contents of another Pixa into this one.

        Parameters:
        otherPixa - The Pix to merge.
      • addPix

         void addPix(Pix pix, int mode)

        Adds a Pix to this Pixa.

        Parameters:
        pix - The Pix to add.
        mode - The mode in which to add this Pix, typicallyConstants.L_CLONE.
      • addBox

         void addBox(Box box, int mode)

        Adds a Box to this Pixa.

        Parameters:
        box - The Box to add.
        mode - The mode in which to add this Box, typicallyConstants.L_CLONE.
      • add

         void add(Pix pix, Box box, int mode)

        Adds a Pix and associated Box to this Pixa.

        Parameters:
        pix - The Pix to add.
        box - The Box to add.
        mode - The mode in which to add this Pix and Box, typicallyConstants.L_CLONE.
      • getBox

         Box getBox(int index)

        Creates and returns clone of the Box at the specified index, or null on error.Returned object should be recycled after use.

        Parameters:
        index - The index of the Box to return.
      • getPix

         Pix getPix(int index)

        Creates and returns clone of the Pix at the specified index, or null on error.Returned object should be recycled after use.

        Parameters:
        index - The index of the Pix to return.
      • getWidth

         int getWidth()

        Returns the width of this Pixa, or 0 if one was not set when it wascreated.

      • getHeight

         int getHeight()

        Returns the height of this Pixa, or 0 if one was not set when it wascreated.

      • getRect

         Rect getRect()

        Returns a bounding Rect for this Pixa, which may be (0,0,0,0) if widthand height were not specified on creation.

      • getBoxGeometry

         Array<int> getBoxGeometry(int index)

        Returns a geometry array for the Box at the specified index. SeeBox.INDEX_* for indices.

        Parameters:
        index - The index of the Box to get the geometry of.
      • getBoxGeometry

         boolean getBoxGeometry(int index, @Size(min = 4) Array<int> dimensions)

        Fills an array with the geometry of the Box at the specified index. SeeBox.INDEX_* for indices.

        Parameters:
        index - The index of the Box to get the geometry of.
        dimensions - The array to fill with Box geometry.
      • getBoxRect

         Rect getBoxRect(int index)

        Returns a bounding Rect for the Box at the specified index.

        Parameters:
        index - The index of the Box to get the bounding Rect of.
      • replacePix

         void replacePix(int index, Pix pix, Box box)

        Replaces the Pix and Box at the specified index with the specified Pixand Box. Pixa takes ownership of the given objects, they shouldn't beused or recycled after calling this method.

        Parameters:
        index - The index of the Pix to replace.
        pix - The Pix to replace the existing Pix; it becomes an alias of the one stored in Pixa.
        box - The Box to replace the existing Box; it becomes an alias of the one stored in Pixa.
      • mergeAndReplacePix

         void mergeAndReplacePix(int indexA, int indexB)

        Merges the Pix at the specified indices and removes the Pix at the secondindex.

        Parameters:
        indexA - The index of the first Pix.
        indexB - The index of the second Pix, which will be removed aftermerging.
      • writeToFileRandomCmap

         boolean writeToFileRandomCmap(File file)

        Writes the components of this Pix to a bitmap-formatted file using arandom color map.

        Parameters:
        file - The file to write to.