Skip to content

Commit

Permalink
Impl #59 - Extend PercentageBarDecorator to override getting the data
Browse files Browse the repository at this point in the history
Fixed javadoc

Signed-off-by: Dirk Fauth <[email protected]>
  • Loading branch information
fipro78 committed Feb 14, 2024
1 parent 32cc40a commit 3f05edd
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
package org.eclipse.nebula.widgets.nattable.painter.cell.decorator;

import org.eclipse.nebula.widgets.nattable.config.IConfigRegistry;
import org.eclipse.nebula.widgets.nattable.data.convert.IDisplayConverter;
import org.eclipse.nebula.widgets.nattable.layer.cell.ILayerCell;
import org.eclipse.nebula.widgets.nattable.painter.cell.CellPainterWrapper;
import org.eclipse.nebula.widgets.nattable.painter.cell.ICellPainter;
Expand Down Expand Up @@ -47,7 +48,7 @@ public PercentageBarDecorator(ICellPainter interiorPainter) {
public void paintCell(ILayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) {
Pattern originalBackgroundPattern = gc.getBackgroundPattern();

double factor = Math.min(1.0, convertDataType(cell).doubleValue());
double factor = Math.min(1.0, convertDataType(cell, configRegistry).doubleValue());
factor = Math.max(0.0, factor);

Rectangle bar = new Rectangle(
Expand Down Expand Up @@ -108,11 +109,14 @@ public void paintCell(ILayerCell cell, GC gc, Rectangle rectangle, IConfigRegist
*
* @param cell
* The cell for which the {@link Number} value is requested.
* @return The {@link Number} value to show. Should be a factor value <= 1.0
* to be interpreted as a percentage.
* @param configRegistry
* The {@link IConfigRegistry} to retrieve the
* {@link IDisplayConverter} for the cell.
* @return The {@link Number} value to show. Should be a factor value &lt;=
* 1.0 to be interpreted as a percentage.
* @since 2.3
*/
protected Number convertDataType(ILayerCell cell) {
protected Number convertDataType(ILayerCell cell, IConfigRegistry configRegistry) {
if (cell.getDataValue() instanceof Number) {
return (Number) cell.getDataValue();
}
Expand Down

0 comments on commit 3f05edd

Please sign in to comment.