public class CalculatedValueCache extends Object implements ICalculatedValueCache
The CalculatedValueCache uses implementations of
ICalculatedValueCacheKey as the key for the value cache. Usually the
internal default implementations for column or row position, or the
column-row coordinates should fit most of the use cases.
| Constructor and Description |
|---|
CalculatedValueCache(ILayer layer,
boolean useColumnAsKey,
boolean useRowAsKey)
Creates a new CalculatedValueCache for the specified layer that performs
smooth updates of the calculated values.
|
CalculatedValueCache(ILayer layer,
boolean useColumnAsKey,
boolean useRowAsKey,
boolean smoothUpdates)
Creates a new CalculatedValueCache for the specified layer.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
addToCache(ICalculatedValueCacheKey key,
Object value)
Adds the given value to the cache and the cache-copy.
|
void |
clearCache()
Clear the internal cache.
|
void |
dispose()
Cleaning up internal resources like shutting down the ExecutorService.
|
Object |
getCalculatedValue(int columnPosition,
int rowPosition,
boolean calculateInBackground,
ICalculator calculator)
Returns the calculated value for the specified column and row position.
|
Object |
getCalculatedValue(int columnPosition,
int rowPosition,
ICalculatedValueCacheKey key,
boolean calculateInBackground,
ICalculator calculator)
Returns the calculated value for the specified column and row position.
|
void |
killCache()
Kills all cached values.
|
void |
setLayer(ILayer layer)
Set the layer that should be used by this CalculatedValueCache to trigger
updates after the calculation processing is done.
|
public CalculatedValueCache(ILayer layer, boolean useColumnAsKey, boolean useRowAsKey)
Setting one or both key flags to true will enable automatic
cache key resolution dependent on the configuration. Setting both values
to false will leave the developer to use
getCalculatedValue(int, int, ICalculatedValueCacheKey, boolean, ICalculator)
as it is not possible to determine the ICalculatedValueCacheKey
automatically.
layer - The layer to which the CalculatedValueCache is connected.useColumnAsKey - Flag to specify if the column position should be used as cache
key.useRowAsKey - Flag to specify if the row position should be used as cache
key.public CalculatedValueCache(ILayer layer, boolean useColumnAsKey, boolean useRowAsKey, boolean smoothUpdates)
null until the re-calculation is done.
Setting one or both key flags to true will enable automatic
cache key resolution dependent on the configuration. Setting both values
to false will leave the developer to use
getCalculatedValue(int, int, ICalculatedValueCacheKey, boolean, ICalculator)
as it is not possible to determine the ICalculatedValueCacheKey
automatically.
layer - The layer to which the CalculatedValueCache is connected.useColumnAsKey - Flag to specify if the column position should be used as cache
key.useRowAsKey - Flag to specify if the row position should be used as cache
key.smoothUpdates - Flag to specify if the update of the calculated values should
be performed smoothly.public Object getCalculatedValue(int columnPosition, int rowPosition, boolean calculateInBackground, ICalculator calculator)
ICalculatedValueCacheThis method tries to use a predefined cache key dependent on the configuration of this CalculatedValueCache.
getCalculatedValue in interface ICalculatedValueCachecolumnPosition - The column position of the requested value.rowPosition - The row position of the requested value.calculateInBackground - Flag to specify whether the value calculation should be
processed in the background or not. Setting this value to
false will cause calculation in the UI thread,
which is usually necessary in case of exporting and printing.calculator - The ICalculator that is used for calculating the
values.public Object getCalculatedValue(int columnPosition, int rowPosition, ICalculatedValueCacheKey key, boolean calculateInBackground, ICalculator calculator)
ICalculatedValueCacheThis method uses the given ICalculatedValueCacheKey instead of determining the cache key out of the CalculatedValueCache key configuration.
getCalculatedValue in interface ICalculatedValueCachecolumnPosition - The column position of the requested value.rowPosition - The row position of the requested value.key - The key that is used by this CalculatedValueCache.calculateInBackground - Flag to specify whether the value calculation should be
processed in the background or not. Setting this value to
false will cause calculation in the UI thread,
which is usually necessary in case of exporting and printing.calculator - The ICalculator that is used for calculating the
values.public void clearCache()
ICalculatedValueCacheclearCache in interface ICalculatedValueCachepublic void killCache()
ICalculatedValueCachekillCache in interface ICalculatedValueCacheprotected void addToCache(ICalculatedValueCacheKey key, Object value)
key - The key to which the calculated value belongs to.value - The value for the given coordinates to be cached.public void dispose()
ICalculatedValueCachedispose in interface ICalculatedValueCachepublic void setLayer(ILayer layer)
ICalculatedValueCachesetLayer in interface ICalculatedValueCachelayer - The ILayer that should be used to fire the
CellVisualChangeEvent after the background calculation process
is done.Copyright © 2016. All rights reserved.