Class PixelMask


  • public class PixelMask
    extends java.lang.Object
    2-dimensional bit mask. Like a BitSet but can be used to keep track of coverage of a given region of 2-dimensional space.
    Since:
    20 Aug 2007
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      PixelMask​(java.awt.Rectangle box)
      Constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean get​(int x, int y)
      Indicates whether a pixel at given point is set.
      boolean get​(java.awt.Point p)
      Indicates whether a pixel at given point is set.
      void set​(int x, int y)
      Sets the pixel at the given coordinates.
      void set​(java.awt.Point p)
      Sets the pixel at the given coordinates.
      void set​(java.awt.Rectangle rect)
      Sets all the pixels in the given rectangle.
      • Methods inherited from class java.lang.Object

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

      • PixelMask

        public PixelMask​(java.awt.Rectangle box)
        Constructor.
        Parameters:
        box - defines the boundary of the pixel mask region
    • Method Detail

      • set

        public void set​(java.awt.Rectangle rect)
        Sets all the pixels in the given rectangle. Pixels outside the boundaries of this mask are ignored.
        Parameters:
        rect - region to set
      • set

        public void set​(java.awt.Point p)
        Sets the pixel at the given coordinates. If it is outside the boundaries of this mask it is ignored.
        Parameters:
        p - coordinates of point to set
      • get

        public boolean get​(java.awt.Point p)
        Indicates whether a pixel at given point is set. If it is outside the boundaries of this mask the answer is false.
        Parameters:
        p - coordinates of point to test
        Returns:
        true iff p is set
      • set

        public void set​(int x,
                        int y)
        Sets the pixel at the given coordinates. If it is outside the boundaries of this mask it is ignored.
        Parameters:
        x - X coordinate of point to set
        y - Y coordinate of point to set
      • get

        public boolean get​(int x,
                           int y)
        Indicates whether a pixel at given point is set. If it is outside the boundaries of this mask the answer is false.
        Parameters:
        x - X coordinate of point to test
        y - Y coordinate of point to test
        Returns:
        true iff (x,y) is set