package net.coljac.pirates.gui;
import net.coljac.pirates.Crew;
import net.coljac.pirates.ShipsCrew;
import net.coljac.pirates.Fleet;
import net.coljac.pirates.Ship;
import javax.swing.*;
import java.awt.*;
/**
* By Colin Jacobs, colin@q9software.com
* Date: Mar 17, 2006
*/
public class PrintableFleet extends JPanel {
private final Fleet fleet;
private JLabel label;
public PrintableFleet(Fleet fleet) {
this.fleet = fleet;
this.setBackground(Color.white);
this.setForeground(Color.black);
StringBuffer html = new StringBuffer();
html.append("<html><table width=\"310px\" border=\"1\" cellspacing=\"0\" cellpadding=\"4\">");
html.append("<tr bgcolor=\"#EEEEEE\"><td align=\"center\" colspan=\"2\"> Fleet: " + fleet.getName() + "</td></tr>");
for (Ship s : fleet.getShips()) {
html.append("<tr><td>" + s.getPoints() + "</td><td> " + s.getName() + "</td></tr>");
ShipsCrew cl = fleet.getShipCrew().get(s);
for (Crew crew : cl.getCrewList()) {
html.append("<tr><td>" + crew.getPoints() + "</td><td>  <i>" + crew.getName() + "</i></td></tr>");
}
}
for (Crew crew : fleet.getCrew()) {
html.append("<tr><td>" + crew.getPoints() + "</td><td><i>" + crew.getName() + "</i></td></tr>");
}
for (net.coljac.pirates.Card crd : fleet.getExtraCards()) {
html.append("<tr><td>" + crd.getPoints() + "</td><td><i>" + crd.getName() + "</i></td></tr>");
}
html.append("<tr bgcolor=\"#EEEEEE\"><td>" + fleet.getPoints() + "</td><td> (Total cost)</td></tr>");
html.append("</table></html>");
label = new JLabel(html.toString());
this.add(label);
}
}