Coverage Summary for Class: CloudComponent (it.polimi.ingsw.Client.GUI.Components)
| Class | Method, % | Branch, % | Line, % |
|---|---|---|---|
| CloudComponent | 0% (0/1) | 0% (0/7) | 0% (0/16) |
| CloudComponent$1 | 0% (0/1) | 0% (0/1) | |
| Total | 0% (0/2) | 0% (0/7) | 0% (0/17) |
1 package it.polimi.ingsw.Client.GUI.Components; 2 3 import it.polimi.ingsw.Model.Cloud; 4 import it.polimi.ingsw.Model.Enums.PawnColour; 5 6 import javax.swing.*; 7 import java.awt.*; 8 import java.util.ArrayList; 9 10 import static it.polimi.ingsw.Client.GUI.IconLoader.*; 11 12 13 public class CloudComponent extends JButton { 14 15 /** 16 * Create a new JButton with cloud as icon and draw students inside it 17 * 18 * @param cloudImage Cloud's icon to display 19 * @param cloud Cloud that will be represented by button 20 */ 21 public CloudComponent(ImageIcon cloudImage, Cloud cloud) { 22 super(cloudImage); 23 ArrayList<JLabel> students = new ArrayList<>(cloud.getContents().size()); 24 //create labels basing on pawnColour 25 for (PawnColour studentOnCloud : cloud.getContents()) { 26 switch (studentOnCloud) { 27 case RED -> students.add(new JLabel(RedStudent)); 28 case GREEN -> students.add(new JLabel(GreenStudent)); 29 case YELLOW -> students.add(new JLabel(YellowStudent)); 30 case BLUE -> students.add(new JLabel(BlueStudent)); 31 case PINK -> students.add(new JLabel(PinkStudent)); 32 } 33 } 34 //remove border from CloudComponent button 35 this.setBorderPainted(false); 36 this.setContentAreaFilled(false); 37 this.setFocusPainted(false); 38 this.setOpaque(false); 39 this.setLayout(new GridLayout(2, 2)); 40 //add students' labels to CloudComponent 41 students.forEach(this::add); 42 } 43 }