Package adams.data.conversion
Class HeatmapToBufferedImageExpression
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.conversion.AbstractConversion
-
- adams.data.conversion.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.GrammarSupplierTurns 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.MathematicalExpressionTextm_Expressionthe math expression.protected adams.gui.visualization.core.ColorGradientGeneratorm_Generatorthe generator to use.protected Color[]m_GradientColorsthe gradient colors.protected Colorm_MissingValueColorthe color for missing values.
-
Constructor Summary
Constructors Constructor Description HeatmapToBufferedImageExpression()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Classaccepts()Returns the class that is accepted as input.voiddefineOptions()Adds options to the internal list of options.protected ObjectdoConvert()Performs the actual conversion.StringexpressionTipText()Returns the tip text for this property.Classgenerates()Returns the class that is generated as output.StringgeneratorTipText()Returns the tip text for this property.adams.parser.MathematicalExpressionTextgetExpression()Returns the mathematical expression to use for generating the greyscale values.adams.gui.visualization.core.ColorGradientGeneratorgetGenerator()Returns the color generator.protected Color[]getGradientColors()Generates the gradient colors.StringgetGrammar()Returns a string representation of the grammar.ColorgetMissingValueColor()Returns the color for missing values.StringgetQuickInfo()Returns a quick info about the object, which can be displayed in the GUI.StringglobalInfo()Returns a string describing the object.StringmissingValueColorTipText()Returns the tip text for this property.protected voidreset()Resets the object.voidsetExpression(adams.parser.MathematicalExpressionText value)Sets the mathematical expression to use for generating the greyscale values.voidsetGenerator(adams.gui.visualization.core.ColorGradientGenerator value)Sets the color generator.voidsetMissingValueColor(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
-
-
-
-
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.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin classadams.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:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.core.option.AbstractOptionHandler
-
reset
protected void reset()
Resets the object.- Overrides:
resetin classadams.data.conversion.AbstractConversion
-
getGrammar
public String getGrammar()
Returns a string representation of the grammar.- Specified by:
getGrammarin interfaceadams.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:
getQuickInfoin interfaceadams.core.QuickInfoSupporter- Overrides:
getQuickInfoin classadams.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:
acceptsin interfaceadams.data.conversion.Conversion- Specified by:
acceptsin classadams.data.conversion.AbstractConversion- Returns:
- the class
-
generates
public Class generates()
Returns the class that is generated as output.- Specified by:
generatesin interfaceadams.data.conversion.Conversion- Specified by:
generatesin classadams.data.conversion.AbstractConversion- Returns:
- the class
-
getGradientColors
protected Color[] getGradientColors()
Generates the gradient colors.- Returns:
- the colors
-
-