Difference between revisions of "Beanshell Attribute Calculator"

From OpenJUMP Wiki
Jump to navigation Jump to search
(Created page with "Tools == The plugin User interface == File:BeanshellAttributeCalculator.png This plugin makes it possible to add a calculated attribute to a layer. The dialog box o...")
(No difference)

Revision as of 21:04, 13 September 2014

Tools

The plugin User interface

BeanshellAttributeCalculator.png

This plugin makes it possible to add a calculated attribute to a layer. The dialog box offers several options

  • Source Layer - Select the name of the future attribute.


  • CALC - Enter the name of the future calculated attribute.


  • New AttributeType - Type of the new attribute. It must be consistent with the value returned by the beanshell expression. String type can be used safely as any beanshell expression can be converted to String if needed.


  • Dynamic (computed as needed) - If checked, the computed attribute will be dynamically computed. Static and dynamic attributes are very different.
    • Static (box unchecked) : value is evaluated for each feature when the plugin is executed and result values are statically stored in the feature (it will not be re-evaluated if expression parameters change in the future).
    • Dynamic (box checked) : expression is cached and attribute value is evaluated every time it is read. For this reason, a dynamic attribute is read-only. If the expression relies on the feature geometry and the geometry change in the future, the attribute value will also change. If you display a layer with a style relying on a dynamic attribute (ex. label or color theming), you can easily check that values are re-evaluated every time a parameter of the expression changes.


  • Beanshell Expression : the expression which will be evaluated for each feature. Expression must use java syntax, or beanshell syntax (beanshell syntax is the same as java syntax with some syntactic sugar making it lighter - see beanshell documentation). You can also use some variable names which will be automatically recognized like :
    • wc : refers to the workbenchContext
    • <attribute name> : attribute names will be replaced by the current feature attribute values


  • Script Snippets - The Script Snippet section, on the right side of the dialog, will help you to write simple script expressions. In this section, you will find available attribute names, including geometry attribute name. Double click on an attribute name to include it in your expression and avoid typos. You will also find small expression which can follow an attribute name or take an attribute name as argument. Examples :
    • MyAttribute.toLowerCase()

The plugin User interface