Class JavaExpressionMaskOverlay

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

public class JavaExpressionMaskOverlay extends MaskOverlay implements GridContainerOverlay
The JavaExpressionMaskOverlay class uses a mathematical expression in Java syntax to compute a data mask. If the expression evaluates to true, then the data is masked, otherwise the data is left visible. A JavaExpressionMaskOverlay is thus a more general type of BitmaskOverlay.
Since:
3.7.1
Author:
Peter Hollemans
See Also:
  • Constructor Details

    • JavaExpressionMaskOverlay

      public JavaExpressionMaskOverlay(Color color, EarthDataReader reader, List<String> variableList, String expression)
      Constructs a new 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.
      expression - the mask expression. Variables names in the expression must have corresponding grids in the list.
  • Method Details

    • setDataSource

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

      public void setExpression(String newExpression)
      Sets the expression used by the mask.
      Parameters:
      newExpression - the new math expression.
      Throws:
      IllegalArgumentException - is the expression has a parsing error or contains variables that are not available in the current list of variables.
    • getExpression

      public String getExpression()
      Gets the current expression.
    • 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