Browse Source

Add render for AblageStack

feature_solitaer_AblageStack
Alexander Hartung 3 years ago
parent
commit
b16c5e74ad
  1. 29
      src/main/java/solitaer/AblageStack.java
  2. 15
      src/main/java/solitaer/SolitaerGamePanel.java

29
src/main/java/solitaer/AblageStack.java

@ -1,5 +1,9 @@
package solitaer; package solitaer;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
public class AblageStack extends BaseStack { public class AblageStack extends BaseStack {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -30,5 +34,30 @@ public class AblageStack extends BaseStack {
} }
} }
@Override
protected void paintComponent(Graphics g) {
// TODO Auto-generated method stub
super.paintComponent(g);
if (stackIsEmpty()) {
g.setColor(Color.gray);
g.fillRect(0, 0, this.getWidth(), IMAGE_HIGHT);
g.setColor(Color.black);
g.drawRect(0, 0, this.getWidth()-1, IMAGE_HIGHT-1);
if (this.sym == Symbol.Herz || this.sym == Symbol.Karo)
g.setColor(Color.red);
else
g.setColor(Color.black);
int fontSize = 20;
Font f = new Font(Font.MONOSPACED, Font.BOLD, fontSize);
g.setFont(f);
String text = this.sym.toString();
g.drawString(text, 5, this.IMAGE_HIGHT/2);
}
}
} }

15
src/main/java/solitaer/SolitaerGamePanel.java

@ -25,7 +25,7 @@ public class SolitaerGamePanel extends JPanel {
StartStack a = new StartStack(25,25);
StartStack a = new StartStack(25,125);
a.addCard(deck.getDeck().get(0)); a.addCard(deck.getDeck().get(0));
@ -46,13 +46,13 @@ public class SolitaerGamePanel extends JPanel {
this.add(a); this.add(a);
StartStack b = new StartStack(200,25);
StartStack b = new StartStack(200,125);
deck.getDeck().get(32).setFaceUp(true); deck.getDeck().get(32).setFaceUp(true);
b.addCard((deck.getDeck().get(32))); b.addCard((deck.getDeck().get(32)));
this.add(b); this.add(b);
StartStack c = new StartStack(375,25);
StartStack c = new StartStack(375,125);
deck.getDeck().get(33).setFaceUp(true); deck.getDeck().get(33).setFaceUp(true);
c.addCard((deck.getDeck().get(33))); c.addCard((deck.getDeck().get(33)));
@ -62,6 +62,15 @@ public class SolitaerGamePanel extends JPanel {
this.add(save); this.add(save);
AblageStack a1 = new AblageStack(200, 10, Symbol.Herz);
this.add(a1);
AblageStack a2 = new AblageStack(275, 10, Symbol.Kreuz);
this.add(a2);
AblageStack a3 = new AblageStack(350, 10, Symbol.Karo);
this.add(a3);
AblageStack a4 = new AblageStack(425, 10, Symbol.Pik);
this.add(a4);
} }

Loading…
Cancel
Save