Best way to apply dynamic styling in 1.1 [message #1401503] |
Tue, 15 July 2014 14:12  |
Eclipse User |
|
|
|
To summarize, I need to apply a particular style to cell based on its data value at runtime.
For example, displaying negative numbers in red and positive in black.
The approach I took in 1.0 was to inspect the IDataLayer from a ColumnLabelAccumulator -- not the most performant solution but it worked. After upgrading to 1.1, I am experiencing a StackOverflowException. It turns out the new features added to the GroupByDataLayer require the #getDataValueByPosition method to invoke the ColumnLabelAcumulator. Thus, my solution creates an endless loop.
It looks like there are two examples releated to this: _001_Custom_styling_of_specific_cells and _002_Using_a_custom_cell_painter
- 001's solution uses a ColumnLabelAccumulator but assumes knoweledge of the cell's position ahead of time.
- 002's solution uses CellPainters to dynamically change the cell's background based on the cell's value.
Using 002 as an example, I created a new CellPainterWrapper that adds a "negative_number" label to the LabelStack if the cell's value is less than zero.
Would you recommend doing it this way?
[Updated on: Tue, 15 July 2014 14:30] by Moderator
|
|
|
|
|
Re: Best way to apply dynamic styling in 1.1 [message #1401612 is a reply to message #1401514] |
Tue, 15 July 2014 18:17  |
Eclipse User |
|
|
|
No I don't recommend doing it that way. Adding labels in a CellPainterWrapper is the wrong way to attach labels.
For attaching labels there is the concept of label accumulators. You are just seeing the default implementations, but you can also directly implement the interface. And typically you should inspect the DataLayer in your accumulator, but inspect the IDataProvider. There is an example for that in the documentation, in the Tutorial Examples the ThemeStylingExample is using it that way and the examples for the German articles show it that way.
|
|
|
Powered by
FUDForum. Page generated in 0.11940 seconds