Skip to content

Commit 2180a78

Browse files
committed
implemented some rudimentary image drawin which is BAD,
1 parent 99aeda6 commit 2180a78

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/de/littlerolf/sav/gui/SAVHistoryComponent.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ public class SAVHistoryComponent extends JComponent {
4949
private List<HistoryItem> historyItems = new ArrayList<HistoryItem>();
5050
private int currentIndex = 0;
5151

52+
public SAVHistoryComponent() {
53+
HistoryItem i = new HistoryItem();
54+
i.values = new int[] { 4, 50, 42, 3 };
55+
getHistoryItems().add(i);
56+
}
57+
5258
public void nextStep() {
5359
currentIndex++;
5460
if (currentIndex >= historyItems.size())
@@ -64,6 +70,24 @@ public void reset() {
6470
@Override
6571
protected void paintComponent(Graphics g) {
6672
super.paintComponent(g);
73+
74+
HistoryItem currentItem = getHistoryItems().get(currentIndex);
75+
if (currentItem == null)
76+
return;
77+
78+
int valueAmount = currentItem.values.length;
79+
int width = getWidth();
80+
int height = getHeight();
81+
int x = 0;
82+
for (int value : currentItem.values) {
83+
if (value > cardImages.length || value < 0)
84+
continue;
85+
BufferedImage cardImage = cardImages[value];
86+
g.drawImage(cardImage,
87+
x + width / 2 - (valueAmount * cardImage.getWidth()) / 2,
88+
height / 2 - cardImage.getHeight() / 2, null);
89+
x += cardImage.getWidth();
90+
}
6791
}
6892

6993
public List<HistoryItem> getHistoryItems() {

0 commit comments

Comments
 (0)