Class BitmaskOverlay

All Implemented Interfaces:
Serializable, Cloneable, Comparable, GridContainerOverlay, TransparentOverlay

public class BitmaskOverlay extends MaskOverlay implements GridContainerOverlay
A BitmaskOverlay annotates a data view using a data grid and an integer bit mask. The mask is computed by logically anding the bit mask value with each integer-cast data value in the grid. If the result is non-zero at a given location, the data is masked. The bit mask is effectively a selection mechanism for byte or integer valued data that allows certain bits in the data values to act as overlay graphics planes.
Since:
3.1.1
Author:
Peter Hollemans
See Also:
  • Constructor Details

    • BitmaskOverlay

      public BitmaskOverlay(Color color, Grid grid, int mask)
      Constructs a new bitmask overlay. The layer number is initialized to 0. If this constructor is used, then the setGridName(java.lang.String) method performs no operation and getGridNameValues() returns null.
      Parameters:
      color - the overlay color.
      grid - the grid to use for data.
      mask - the bit mask value.
    • BitmaskOverlay

      public BitmaskOverlay(Color color, EarthDataReader reader, List variableList, String gridName, int mask)
      Constructs a new bitmask overlay. The layer number is initialized to 0.
      Parameters:
      color - the overlay color.
      reader - the reader to use for data variables.
      variableList - the list of allowed data variable names.
      gridName - the initial grid name from the list.
      mask - the bit mask value.
  • Method Details

    • setDataSource

      public void setDataSource(EarthDataReader reader, List variableList)
      Sets the data source for grid data. The reader and variable list must contain a data grid with the current grid name.
      Specified by:
      setDataSource in interface GridContainerOverlay
      Parameters:
      reader - the reader to use for data variables.
      variableList - the list of allowed data variable names.
    • getMask

      public int getMask()
      Gets the bit mask value.
    • setMask

      public void setMask(int mask)
      Sets the bit mask value.
    • getReader

      public EarthDataReader getReader()
      Gets the reader used to fetch the data for this bitmask, or null if no reader was explicitly given to the constructor.
    • getGridName

      public String getGridName()
      Gets the grid variable name.
    • getGridNameValues

      public List getGridNameValues()
      Gets the possible grid variable names, or null if no list was explicitly given to the constructor.
    • setGridName

      public void setGridName(String name)
      Sets the grid variable based on the name. This method may only be used if the overlay was constructed using a reader and grid name list.
    • getGrid

      public Grid getGrid()
      Gets the active grid variable.
    • prepareData

      protected void prepareData()
      Description copied from class: MaskOverlay
      Prepares any data structures that may be necessary for computing the mask values prior to running MaskOverlay.prepare(java.awt.Graphics2D, noaa.coastwatch.render.EarthDataView). This should be overrideen in the child class if anything needs to be done.
      Overrides:
      prepareData in class MaskOverlay
    • isMasked

      public boolean isMasked(DataLocation loc, boolean isNavigated)
      Description copied from class: MaskOverlay
      Determines if the data location should be masked.
      Specified by:
      isMasked in class MaskOverlay
      Parameters:
      loc - the data location in question.
      isNavigated - the navigated flag, true if the data location is pre-navigated
      Returns:
      true if the data should be masked at the location or false if not.
    • isCompatible

      protected boolean isCompatible(EarthDataView view)
      Description copied from class: MaskOverlay
      Determines if the data view is compatible with this overlay. If so, then the precomputed view coordinate cache tables will be used to determine data locations for each view point. If not, then each view point is transformed individually using the view's image transform.
      Specified by:
      isCompatible in class MaskOverlay
      Parameters:
      view - the data view in question.
      Returns:
      true if the view has compatible data coordinate caches for the data used to create the mask values in the MaskOverlay.isMasked(noaa.coastwatch.util.DataLocation, boolean) method, or false if not.
    • getGridList

      public List<Grid> getGridList()
      Description copied from interface: GridContainerOverlay
      Gets the active list of grid variables.
      Specified by:
      getGridList in interface GridContainerOverlay