package client.custom;
import game.dice.Dice;
import game.dice.Die;
import java.awt.Graphics;
import javax.swing.JPanel;
import client.gfx.wrapper.DieImageEngine;
/**
* The <code>DrawingPanel</code> is a subclass of <code>JPanel</code> which adds desired functionality to
* the <code>paintComponent()</code> method of JPanel. Namingly, it uses the <code>DieImageEngine</code>
* graphics wrapper to get the die background tiles accordingly to their current values and paints them on the panel.
*
* @author Priidu Neemre
*/
public class DrawingPanel extends JPanel {
private static final long serialVersionUID = 00000001L;
private Dice curGameDice;
private DieImageEngine dieImageEngine;
public DrawingPanel(Dice diceToDraw){
this.curGameDice = diceToDraw;
dieImageEngine = new DieImageEngine();
}
@Override
public void paintComponent(Graphics g){
super.paintComponent(g);
//Draw the dice onto the panel
for(Die die : curGameDice.getDice()){
if(die.getCurValue() == Die.NEUTRAL_DIE_VALUE)continue; //In case we have a neutral die
g.drawImage(dieImageEngine.getCombinationImage(die.getCurValue()), (int)die.getDieFixture().getX(),
(int)die.getDieFixture().getY(), null);
}
}
}