Skip to content

Commit

Permalink
Modified PanelComponent to hold a ProgressBarComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
Noremac201 committed Jan 3, 2018
1 parent 98bf583 commit 5a65d67
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
Expand Down Expand Up @@ -74,17 +75,21 @@ public static class Line
@Getter
private List<Line> lines = new ArrayList<>();

@Setter
private ProgressBarComponent progressBar;

@Setter
private int width = 140;

@Override
public Dimension render(Graphics2D graphics, Point parent)
{
final Dimension dimension = new Dimension();
final int elementNumber = (Strings.isNullOrEmpty(title) ? 0 : 1) + lines.size();
final int elementNumber = (Strings.isNullOrEmpty(title) ? 0 : 1) + lines.size() + (Objects.isNull(progressBar) ? 0 : 1);
int height = elementNumber == 0 ? 0 :
TOP_BORDER + (graphics.getFontMetrics().getHeight() * elementNumber)
+ SEPARATOR * elementNumber + BOTTOM_BORDER;
+ SEPARATOR * elementNumber + (Objects.isNull(progressBar) ? 0 : progressBar.getHeight() / 2)
+ BOTTOM_BORDER;
dimension.setSize(width, height);

if (dimension.height == 0)
Expand Down Expand Up @@ -131,6 +136,14 @@ public Dimension render(Graphics2D graphics, Point parent)
y += metrics.getHeight() + SEPARATOR;
}

//Render progress bar
if (!Objects.isNull(progressBar))
{
progressBar.setWidth(width - LEFT_BORDER - RIGHT_BORDER);
progressBar.setPosition(new Point(position.x + LEFT_BORDER, y - (metrics.getHeight() / 2)));
progressBar.render(graphics, parent);
}

return dimension;
}
}

0 comments on commit 5a65d67

Please sign in to comment.