当前位置: 首页>>代码示例>>Java>>正文


Java InPortPanel类代码示例

本文整理汇总了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);
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:67,代码来源:UnitLabel.java


注:本文中的net.sf.freecol.client.gui.panel.InPortPanel类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。