Prevent ProgressBarComponent from overflowing

Limit max bar width to 100% to prevent overflowing.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2019-01-26 13:53:26 +01:00
committed by Adam
parent 3dc608a6c3
commit c198433bb6

View File

@@ -80,7 +80,7 @@ public class ProgressBarComponent implements LayoutableRenderableEntity
final int height = Math.max(preferredSize.height, 16);
final int progressTextX = barX + (width - metrics.stringWidth(textToWrite)) / 2;
final int progressTextY = barY + ((height - metrics.getHeight()) / 2) + metrics.getHeight();
final int progressFill = (int) (width * pc);
final int progressFill = (int) (width * Math.min(1, pc));
//Draw bar
graphics.setColor(backgroundColor);