本文整理汇总了Java中net.sf.freecol.client.gui.panel.InPortPanel类的典型用法代码示例。如果您正苦于以下问题:Java InPortPanel类的具体用法?Java InPortPanel怎么用?Java InPortPanel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
InPortPanel类属于net.sf.freecol.client.gui.panel包,在下文中一共展示了InPortPanel类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintComponent
import net.sf.freecol.client.gui.panel.InPortPanel; //导入依赖的package包/类
/**
* Paints this UnitLabel.
*
* @param g The graphics context in which to do the painting.
*/
@Override
public void paintComponent(Graphics g) {
final Player player = freeColClient.getMyPlayer();
final ImageLibrary lib = useTileImageLibrary
? gui.getTileImageLibrary()
: gui.getImageLibrary();
if (ignoreLocation || selected
|| (!unit.isCarrier() && unit.getState() != UnitState.SENTRY)) {
setEnabled(true);
} else if (unit.getOwner() != player
&& unit.getColony() == null) {
setEnabled(true);
} else {
setEnabled(false);
}
super.paintComponent(g);
if (ignoreLocation)
return;
if (unit.getLocation() instanceof ColonyTile) {
// Not Buildings. Buildings have their own production display.
GoodsType workType = unit.getWorkType();
if (workType != null) {
int production = ((ColonyTile)unit.getLocation())
.getTotalProductionOf(workType);
ProductionLabel pl = new ProductionLabel(freeColClient, lib,
new AbstractGoods(workType, production));
g.translate(0, 10);
pl.paintComponent(g);
g.translate(0, -10);
}
} else if (getParent() instanceof ColonyPanel.OutsideColonyPanel ||
getParent() instanceof InPortPanel ||
getParent() instanceof EuropePanel.DocksPanel ||
getParent().getParent() instanceof ReportPanel) {
String text = Messages.message(unit.getOccupationLabel(player, false));
g.drawImage(lib.getOccupationIndicatorChip((Graphics2D)g, unit, text), 0, 0, null);
if (unit.isDamaged()) {
String underRepair = Messages.message(unit.getRepairLabel());
String underRepair1 = underRepair.substring(0, underRepair.indexOf('(')).trim();
String underRepair2 = underRepair.substring(underRepair.indexOf('(')).trim();
Font font = FontLibrary.createFont(FontLibrary.FontType.NORMAL,
FontLibrary.FontSize.TINY, lib.getScaleFactor());
Image repairImage1 = lib.getStringImage(g, underRepair1, Color.RED, font);
Image repairImage2 = lib.getStringImage(g, underRepair2, Color.RED, font);
int textHeight = repairImage1.getHeight(null) + repairImage2.getHeight(null);
int leftIndent = Math.min(5, Math.min(getWidth() - repairImage1.getWidth(null),
getWidth() - repairImage2.getWidth(null)));
g.drawImage(repairImage1,
leftIndent, // indent from left side of label (icon is placed at the left side)
((getHeight() - textHeight) / 2),
null);
g.drawImage(repairImage2,
leftIndent,
((getHeight() - textHeight) / 2) + repairImage1.getHeight(null),
null);
}
}
}