BufferedImage bale = loader.getImage("bale_icon");
g2d.drawImage(barrel, x, y-(int)Math.rint(positions.titleHeigth), null); // Is y correct ???
// loaded on ship and ship capacity
x += 50;
IShip ship = city.getActiveShip();
StringBuilder sb = new StringBuilder();
sb.append(ship.getLoad()).append(" / ").append(ship.getSize()).append(" ").append(ship.getName());
gv = OpenPatricianPainter.createGlyphVector(g2d, sb.toString(), 18);
g2d.drawGlyphVector(gv, x, y); // TODO this is a dynamic line
BufferedImage waxSeal = loader.getImage("waxseal");
// Table header
y += positions.lineHeight; // more space to the title
y += positions.lineHeight;
// Table
EWare[] wares = EWare.values();
for (EWare ware : wares) {
// Ware name
y += positions.lineHeight;
// Available amount in the city
AmountablePrice<EWare> wareInCity = cityModel.getWare(ware);
int availableAmount = wareInCity.getAmount();
int value = availableAmount; // amount available
if (value>0){
gv = OpenPatricianPainter.createGlyphVector(g2d, String.valueOf(value), 18);
g2d.drawGlyphVector(gv, positions.xCity, y);
// draw barrel or burden
if (ware.getSizeAsBarrels()==1){
// barrel
g2d.drawImage(barrel, (int)(positions.xCity+gv.getVisualBounds().getWidth())+5, y-positions.lineHeight*2/3, null);
} else {
g2d.drawImage(bale, (int)(positions.xCity+gv.getVisualBounds().getWidth())+5, y-positions.lineHeight*2/3, null);
}
}
g2d.setColor(new Color(0xEA,0xC1,0x17)); // Gold
// buy
if (availableAmount>0){
value = ware.computeBuyPrice(availableAmount, getAmount(availableAmount));
} else {
value = 0; // cannot buy anything if nothing is there
}
gv = OpenPatricianPainter.createGlyphVector(g2d, String.valueOf(value), 18);
int xPadding = ImageUtil.computeCenterAlignX(positions.xBuy, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
g2d.drawGlyphVector(gv, xPadding, y);
// sell
if (movableAmount==ETransferAmount.MAX){
value = ware.getMaxValueSell();
} else {
value = ware.computeSellPrice(availableAmount, getAmount(availableAmount));
}
gv = OpenPatricianPainter.createGlyphVector(g2d, String.valueOf(value), 18);
xPadding = ImageUtil.computeCenterAlignX(positions.xSell, waxSeal.getWidth(), (int)gv.getVisualBounds().getWidth());
g2d.drawGlyphVector(gv, xPadding, y);
g2d.setColor(Color.BLACK);
// amount loaded
value = city.getActiveShip().getWare(ware).getAmount(); // differ between ship and convoi
if (value>0){
gv = OpenPatricianPainter.createGlyphVector(g2d, String.valueOf(value), 18);
g2d.drawGlyphVector(gv, positions.xShip, y); // this value is dynamic
// draw barrel or burden
}
if (ship.getWare(ware).getAmount()>0){
value = ship.getWare(ware).getAVGPrice();
gv = OpenPatricianPainter.createGlyphVector(g2d, String.valueOf(value), 18);
g2d.drawGlyphVector(gv, positions.xPrice+10, y);
}
} // end for wares