Class HeatmapToBufferedImageExpression

  • All Implemented Interfaces:
    adams.core.AdditionalInformationHandler, adams.core.CleanUpHandler, adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.QuickInfoSupporter, adams.core.ShallowCopySupporter<adams.data.conversion.AbstractConversion>, adams.core.SizeOfHandler, adams.core.Stoppable, adams.data.conversion.Conversion, adams.parser.GrammarSupplier, Serializable

    public class HeatmapToBufferedImageExpression
    extends adams.data.conversion.AbstractConversion
    implements adams.parser.GrammarSupplier
    Turns a heatmap into a BufferedImage, using the provided expression for generating greyscale values (0-255).

    The following grammar is used:

    expr_list ::= '=' expr_list expr_part | expr_part ;
    expr_part ::= expr ;

    expr ::= ( expr )

    # data types
    | number
    | string
    | boolean
    | date

    # constants
    | true
    | false
    | pi
    | e
    | now()
    | today()

    # negating numeric value
    | -expr

    # comparisons
    | expr < expr
    | expr <= expr
    | expr > expr
    | expr >= expr
    | expr = expr
    | expr != expr (or: expr <> expr)

    # boolean operations
    | ! expr (or: not expr)
    | expr & expr (or: expr and expr)
    | expr | expr (or: expr or expr)
    | if[else] ( expr , expr (if true) , expr (if false) )
    | ifmissing ( variable , expr (default value if variable is missing) )
    | isNaN ( expr )

    # arithmetics
    | expr + expr
    | expr - expr
    | expr * expr
    | expr / expr
    | expr ^ expr (power of)
    | expr % expr (modulo)
    ;

    # numeric functions
    | abs ( expr )
    | sqrt ( expr )
    | cbrt ( expr )
    | log ( expr )
    | log10 ( expr )
    | exp ( expr )
    | sin ( expr )
    | sinh ( expr )
    | cos ( expr )
    | cosh ( expr )
    | tan ( expr )
    | tanh ( expr )
    | atan ( expr )
    | atan2 ( exprY , exprX )
    | hypot ( exprX , exprY )
    | signum ( expr )
    | rint ( expr )
    | floor ( expr )
    | pow[er] ( expr , expr )
    | ceil ( expr )
    | min ( expr1 , expr2 )
    | max ( expr1 , expr2 )
    | year ( expr )
    | month ( expr )
    | day ( expr )
    | hour ( expr )
    | minute ( expr )
    | second ( expr )
    | weekday ( expr )
    | weeknum ( expr )

    # string functions
    | substr ( expr , start [, end] )
    | left ( expr , len )
    | mid ( expr , start , len )
    | right ( expr , len )
    | rept ( expr , count )
    | concatenate ( expr1 , expr2 [, expr3-5] )
    | lower[case] ( expr )
    | upper[case] ( expr )
    | trim ( expr )
    | matches ( expr , regexp )
    | trim ( expr )
    | len[gth] ( str )
    | find ( search , expr [, pos] )
    | replace ( str , pos , len , newstr )
    | substitute ( str , find , replace [, occurrences] )
    ;

    Notes:
    - Variables are either all upper case letters (e.g., "ABC") or any character apart from "]" enclosed by "[" and "]" (e.g., "[Hello World]").
    - 'start' and 'end' for function 'substr' are indices that start at 1.
    - Index 'end' for function 'substr' is excluded (like Java's 'String.substring(int,int)' method)
    - Line comments start with '#'.
    - Semi-colons (';') or commas (',') can be used as separator in the formulas,
    e.g., 'pow(2,2)' is equivalent to 'pow(2;2)'
    - dates have to be of format 'yyyy-MM-dd' or 'yyyy-MM-dd HH:mm:ss'
    - times have to be of format 'HH:mm:ss' or 'yyyy-MM-dd HH:mm:ss'
    - the characters in square brackets in function names are optional:
    e.g. 'len("abc")' is the same as 'length("abc")'

    A lot of the functions have been modeled after LibreOffice:
    https://help.libreoffice.org/Calc/Functions_by_Category

    Additional functions:
    - env(String): String
       First argument is the name of the environment variable to retrieve.
       The result is the value of the environment variable.

    Additional procedures:
    - println(...)
       One or more arguments are printed as comma-separated list to stdout.
       If no argument is provided, a simple line feed is output.


    -logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel)
        The logging level for outputting errors and debugging output.
        default: WARNING
     
    -generator <adams.gui.visualization.core.ColorGradientGenerator> (property: generator)
        The generator to use for creating the gradient colors.
        default: adams.gui.visualization.core.BiColorGenerator
     
    -missing-value-color <java.awt.Color> (property: missingValueColor)
        The color to use for missing values.
        default: #00ffffff
     
    -expression <adams.parser.MathematicalExpressionText> (property: expression)
        The expression to use for generating the greyscale values.
        default: (X - 273.15) / 50
     
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected adams.parser.MathematicalExpressionText m_Expression
      the math expression.
      protected adams.gui.visualization.core.ColorGradientGenerator m_Generator
      the generator to use.
      protected Color[] m_GradientColors
      the gradient colors.
      protected Color m_MissingValueColor
      the color for missing values.
      • Fields inherited from class adams.data.conversion.AbstractConversion

        m_Input, m_Output, m_Owner, m_Stopped
      • Fields inherited from class adams.core.option.AbstractOptionHandler

        m_OptionManager
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Class accepts()
      Returns the class that is accepted as input.
      void defineOptions()
      Adds options to the internal list of options.
      protected Object doConvert()
      Performs the actual conversion.
      String expressionTipText()
      Returns the tip text for this property.
      Class generates()
      Returns the class that is generated as output.
      String generatorTipText()
      Returns the tip text for this property.
      adams.parser.MathematicalExpressionText getExpression()
      Returns the mathematical expression to use for generating the greyscale values.
      adams.gui.visualization.core.ColorGradientGenerator getGenerator()
      Returns the color generator.
      protected Color[] getGradientColors()
      Generates the gradient colors.
      String getGrammar()
      Returns a string representation of the grammar.
      Color getMissingValueColor()
      Returns the color for missing values.
      String getQuickInfo()
      Returns a quick info about the object, which can be displayed in the GUI.
      String globalInfo()
      Returns a string describing the object.
      String missingValueColorTipText()
      Returns the tip text for this property.
      protected void reset()
      Resets the object.
      void setExpression​(adams.parser.MathematicalExpressionText value)
      Sets the mathematical expression to use for generating the greyscale values.
      void setGenerator​(adams.gui.visualization.core.ColorGradientGenerator value)
      Sets the color generator.
      void setMissingValueColor​(Color value)
      Sets the color for missing values.
      • Methods inherited from class adams.data.conversion.AbstractConversion

        checkData, cleanUp, convert, getAdditionalInformation, getInput, getInput, getOutput, getOutput, getOwner, setInput, setOwner, shallowCopy, shallowCopy, stopExecution
      • Methods inherited from class adams.core.option.AbstractOptionHandler

        cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
      • Methods inherited from class adams.core.logging.LoggingObject

        configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
      • Methods inherited from interface adams.core.logging.LoggingLevelHandler

        getLoggingLevel
    • Field Detail

      • m_Generator

        protected adams.gui.visualization.core.ColorGradientGenerator m_Generator
        the generator to use.
      • m_MissingValueColor

        protected Color m_MissingValueColor
        the color for missing values.
      • m_Expression

        protected adams.parser.MathematicalExpressionText m_Expression
        the math expression.
      • m_GradientColors

        protected Color[] m_GradientColors
        the gradient colors.
    • Constructor Detail

      • HeatmapToBufferedImageExpression

        public HeatmapToBufferedImageExpression()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing the object.
        Specified by:
        globalInfo in interface adams.core.GlobalInfoSupporter
        Specified by:
        globalInfo in class adams.core.option.AbstractOptionHandler
        Returns:
        a description suitable for displaying in the gui
      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class adams.core.option.AbstractOptionHandler
      • reset

        protected void reset()
        Resets the object.
        Overrides:
        reset in class adams.data.conversion.AbstractConversion
      • getGrammar

        public String getGrammar()
        Returns a string representation of the grammar.
        Specified by:
        getGrammar in interface adams.parser.GrammarSupplier
        Returns:
        the grammar, null if not available
      • getQuickInfo

        public String getQuickInfo()
        Returns a quick info about the object, which can be displayed in the GUI.
        Specified by:
        getQuickInfo in interface adams.core.QuickInfoSupporter
        Overrides:
        getQuickInfo in class adams.data.conversion.AbstractConversion
        Returns:
        null if no info available, otherwise short string
      • setGenerator

        public void setGenerator​(adams.gui.visualization.core.ColorGradientGenerator value)
        Sets the color generator.
        Parameters:
        value - the generator
      • getGenerator

        public adams.gui.visualization.core.ColorGradientGenerator getGenerator()
        Returns the color generator.
        Returns:
        the generator
      • generatorTipText

        public String generatorTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setMissingValueColor

        public void setMissingValueColor​(Color value)
        Sets the color for missing values.
        Parameters:
        value - the color
      • getMissingValueColor

        public Color getMissingValueColor()
        Returns the color for missing values.
        Returns:
        the color
      • missingValueColorTipText

        public String missingValueColorTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setExpression

        public void setExpression​(adams.parser.MathematicalExpressionText value)
        Sets the mathematical expression to use for generating the greyscale values.
        Parameters:
        value - the expression
      • getExpression

        public adams.parser.MathematicalExpressionText getExpression()
        Returns the mathematical expression to use for generating the greyscale values.
        Returns:
        the expression
      • expressionTipText

        public String expressionTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • accepts

        public Class accepts()
        Returns the class that is accepted as input.
        Specified by:
        accepts in interface adams.data.conversion.Conversion
        Specified by:
        accepts in class adams.data.conversion.AbstractConversion
        Returns:
        the class
      • generates

        public Class generates()
        Returns the class that is generated as output.
        Specified by:
        generates in interface adams.data.conversion.Conversion
        Specified by:
        generates in class adams.data.conversion.AbstractConversion
        Returns:
        the class
      • getGradientColors

        protected Color[] getGradientColors()
        Generates the gradient colors.
        Returns:
        the colors
      • doConvert

        protected Object doConvert()
                            throws Exception
        Performs the actual conversion.
        Specified by:
        doConvert in class adams.data.conversion.AbstractConversion
        Returns:
        the converted data
        Throws:
        Exception - if something goes wrong with the conversion