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


Java FontLibrary.createFont方法代码示例

本文整理汇总了Java中net.sf.freecol.client.gui.FontLibrary.createFont方法的典型用法代码示例。如果您正苦于以下问题:Java FontLibrary.createFont方法的具体用法?Java FontLibrary.createFont怎么用?Java FontLibrary.createFont使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.sf.freecol.client.gui.FontLibrary的用法示例。


在下文中一共展示了FontLibrary.createFont方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: EndTurnPanel

import net.sf.freecol.client.gui.FontLibrary; //导入方法依赖的package包/类
public EndTurnPanel() {
    super(new MigLayout("wrap 1, center", "[center]", ""));

    final ImageLibrary lib = getGUI().getTileImageLibrary();
    Font font = FontLibrary.createFont(FontLibrary.FontType.NORMAL,
        FontLibrary.FontSize.TINY, lib.getScaleFactor());

    String labelString = Messages.message("infoPanel.endTurn");
    for (String s : splitText(labelString, " /",
                              getFontMetrics(font), 150)) {
        JLabel label = new JLabel(s);
        label.setFont(font);
        add(label);
    }

    JButton button = new JButton(getFreeColClient().getActionManager()
        .getFreeColAction(EndTurnAction.id));
    button.setFont(font);
    add(button);
    setOpaque(false);
    setSize(getPreferredSize());
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:23,代码来源:InfoPanel.java

示例2: ClassicMapControls

import net.sf.freecol.client.gui.FontLibrary; //导入方法依赖的package包/类
/**
 * The basic constructor.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public ClassicMapControls(final FreeColClient freeColClient) {
    super(freeColClient, false);

    am = freeColClient.getActionManager();
    arrowFont = FontLibrary.createFont(FontLibrary.FontType.SIMPLE,
        FontLibrary.FontSize.SMALL, Font.BOLD);

    panel = new MigPanel();
    panel.setLayout(new MigLayout("wrap 3"));
    panel.add(miniMap, "span, width " + MAP_WIDTH
                       + ", height " + MAP_HEIGHT);

    panel.add(miniMapZoomInButton, "newline 10");
    panel.add(miniMapZoomOutButton, "skip");

    panel.add(makeButton("NW", ResourceManager.getString("arrow.NW")),
              "newline 20");
    panel.add(makeButton("N",  ResourceManager.getString("arrow.N")));
    panel.add(makeButton("NE", ResourceManager.getString("arrow.NE")));
    panel.add(makeButton("W",  ResourceManager.getString("arrow.W")));
    panel.add(makeButton("E",  ResourceManager.getString("arrow.E")),
              "skip");
    panel.add(makeButton("SW", ResourceManager.getString("arrow.SW")));
    panel.add(makeButton("S",  ResourceManager.getString("arrow.S")));
    panel.add(makeButton("SE", ResourceManager.getString("arrow.SE")),
              "wrap 20");

    for (UnitButton button : unitButtons) {
        panel.add(button);
    }

    panel.add(infoPanel, "newline push, span, width "
        + infoPanel.getWidth() + ", height " + infoPanel.getHeight());
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:40,代码来源:ClassicMapControls.java

示例3: ReportReligiousPanel

import net.sf.freecol.client.gui.FontLibrary; //导入方法依赖的package包/类
/**
 * The constructor that will add the items to this panel.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public ReportReligiousPanel(FreeColClient freeColClient) {
    super(freeColClient, "reportReligionAction");

    final Font font = FontLibrary.createFont(FontLibrary.FontType.NORMAL,
        FontLibrary.FontSize.SMALLER, Font.BOLD,
        freeColClient.getGUI().getImageLibrary().getScaleFactor());
    final Player player = getMyPlayer();
    final Specification spec = getSpecification();

    reportPanel.setLayout(new MigLayout("wrap 6, fill", "center"));

    for (GoodsType gt : spec.getImmigrationGoodsTypeList()) {
        JLabel crosses = Utility.localizedLabel(gt);
        crosses.setFont(font);
        reportPanel.add(crosses, SPAN_SPLIT_2);
        FreeColProgressBar progressBar = new FreeColProgressBar(gt, 0,
            player.getImmigrationRequired(), player.getImmigration(),
            player.getTotalImmigrationProduction());
        reportPanel.add(progressBar, "span");

        for (Colony colony : freeColClient.getMySortedColonies()) {
            WorkLocation wl = first(colony.getWorkLocationsForProducing(gt));
            if (wl instanceof Building) {
                reportPanel.add(createColonyButton(colony),
                    "split 2, flowy");
                BuildingPanel bp = new BuildingPanel(getFreeColClient(),
                                                     (Building)wl);
                bp.initialize();
                reportPanel.add(bp);
            }
        }
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:39,代码来源:ReportReligiousPanel.java

示例4: AboutPanel

import net.sf.freecol.client.gui.FontLibrary; //导入方法依赖的package包/类
/**
 * The constructor that will add the items to this panel.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public AboutPanel(FreeColClient freeColClient) {
    super(freeColClient, new MigLayout("wrap"));

    // Header with image
    Image tempImage = ResourceManager.getImage("image.flavor.Title");
    JLabel apLogoLabel = new JLabel(new ImageIcon(tempImage));
    apLogoLabel.setBorder(
        new CompoundBorder(new EmptyBorder(2,2,2,2),
                           new BevelBorder(BevelBorder.LOWERED)));
    add(apLogoLabel, "center");

    // Create available Font choices
    Font fontBold = FontLibrary.createFont(FontLibrary.FontType.NORMAL,
        FontLibrary.FontSize.TINY, Font.BOLD,
        getImageLibrary().getScaleFactor());
    Font fontNormal = FontLibrary.createFont(FontLibrary.FontType.NORMAL,
        FontLibrary.FontSize.TINY, getImageLibrary().getScaleFactor());

    // Version
    JLabel apVersion = Utility.localizedLabel("aboutPanel.version");
    apVersion.setFont(fontBold);
    JLabel apRevision = new JLabel(FreeCol.getRevision());
    apRevision.setFont(fontNormal);
    add(apVersion, "newline 20");
    add(apRevision, "newline");

    // Official Site Link
    JLabel apOfficialSite = Utility.localizedLabel("aboutPanel.officialSite");
    apOfficialSite.setFont(fontBold);
    add(apOfficialSite, "newline 10");
    JButton apSiteURL = Utility.getLinkButton(SITE_URL, null, SITE_URL);
    apSiteURL.addActionListener(this);
    apSiteURL.setFont(fontNormal);
    add(apSiteURL, "newline");

    // SourceForge Project Site Link
    JLabel apSFProject = Utility.localizedLabel("aboutPanel.sfProject");
    apSFProject.setFont(fontBold);
    add(apSFProject, "newline 10");
    JButton apProjectURL = Utility.getLinkButton(PROJECT_URL, null, PROJECT_URL);
    apProjectURL.addActionListener(this);
    apProjectURL.setFont(fontNormal);
    add(apProjectURL, "newline");

    // Manual
    JLabel apManual = Utility.localizedLabel("aboutPanel.manual");
    apManual.setFont(fontBold);
    add(apManual, "newline 10");
    JButton apManualURL = Utility.getLinkButton(MANUAL_URL, null,
                                                MANUAL_URL);
    apManualURL.addActionListener(this);
    add(apManualURL, "newline");

    // License Disclaimer
    JTextArea apLegal = Utility.localizedTextArea("aboutPanel.legalDisclaimer");
    apLegal.setFont(fontNormal);
    add(apLegal, "newline 20, width 300px");

    // Copyright
    JLabel apCopyright = Utility.localizedLabel("aboutPanel.copyright");
    apCopyright.setFont(fontNormal);
    add(apCopyright, "newline 10");

    add(okButton, "newline 20, tag ok");
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:71,代码来源:AboutPanel.java

示例5: ReportExplorationPanel

import net.sf.freecol.client.gui.FontLibrary; //导入方法依赖的package包/类
/**
 * The constructor that will add the items to this panel.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public ReportExplorationPanel(FreeColClient freeColClient) {
    super(freeColClient, "reportExplorationAction");

    // Display Panel
    reportPanel.removeAll();
    reportPanel.setLayout(new MigLayout("wrap 5, fillx", "", ""));

    // Header Row
    Font font = FontLibrary.createFont(FontLibrary.FontType.NORMAL,
        FontLibrary.FontSize.TINY, Font.BOLD, getImageLibrary().getScaleFactor());
    JLabel nameOfRegion = Utility.localizedLabel("report.exploration.nameOfRegion");
    nameOfRegion.setFont(font);
    reportPanel.add(nameOfRegion);
    JLabel typeOfRegion = Utility.localizedLabel("report.exploration.typeOfRegion");
    typeOfRegion.setFont(font);
    reportPanel.add(typeOfRegion);
    JLabel discoveredIn = Utility.localizedLabel("report.exploration.discoveredIn");
    discoveredIn.setFont(font);
    reportPanel.add(discoveredIn);
    JLabel discoveredBy = Utility.localizedLabel("report.exploration.discoveredBy");
    discoveredBy.setFont(font);
    reportPanel.add(discoveredBy);
    JLabel valueOfRegion = Utility.localizedLabel("report.exploration.valueOfRegion");
    valueOfRegion.setFont(font);
    reportPanel.add(valueOfRegion);
    
    // Content Rows
    // TODO: Display "None" if no contents, though this would be rare.
    for (Region region : CollectionUtils.transform(getGame().getMap().getRegions(),
                                   isNotNull(Region::getDiscoveredIn),
                                   Function.identity(), regionComparator)) {
        reportPanel.add(new JLabel(region.getName()));
        reportPanel.add(Utility.localizedLabel(region.getType().getNameKey()));
        reportPanel.add(Utility.localizedLabel(region.getDiscoveredIn()
                .getLabel()));
        reportPanel.add(Utility.localizedLabel(region.getDiscoveredBy()
                .getCountryLabel()));
        reportPanel.add(new JLabel(String.valueOf(region.getScoreValue())));
    }
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:46,代码来源:ReportExplorationPanel.java

示例6: update

import net.sf.freecol.client.gui.FontLibrary; //导入方法依赖的package包/类
/**
 * Update this population panel.
 */
public void update() {
    final Colony colony = getColony();
    if (colony == null) return;
    final ImageLibrary lib = getGUI().getTileImageLibrary();
    final Font font = FontLibrary.createFont(FontLibrary.FontType.NORMAL,
        FontLibrary.FontSize.SMALLER, lib.getScaleFactor());
    final int uc = colony.getUnitCount();
    final int solPercent = colony.getSoL();
    final int rebels = Colony.calculateRebels(uc, solPercent);
    final Nation nation = colony.getOwner().getNation();
    final int grow = colony.getPreferredSizeChange();
    final int bonus = colony.getProductionBonus();
    StringTemplate t;

    removeAll();

    rebelShield.setIcon(new ImageIcon(
        lib.getSmallerMiscIconImage(nation)));
    add(rebelShield, "bottom");

    t = StringTemplate.template("colonyPanel.rebelLabel")
                      .addAmount("%number%", rebels);
    rebelLabel.setText(Messages.message(t));
    rebelLabel.setFont(font);
    add(rebelLabel, "split 2, flowy");

    rebelMemberLabel.setText(solPercent + "%");
    rebelMemberLabel.setFont(font);
    add(rebelMemberLabel);

    t = StringTemplate.template("colonyPanel.populationLabel")
                      .addAmount("%number%", uc);
    popLabel.setText(Messages.message(t));
    popLabel.setFont(font);
    add(popLabel, "split 2, flowy");

    String growth = (grow == 0) ? ""
        : '(' + ((grow >= Colony.CHANGE_UPPER_BOUND)
            ? Messages.message("many")
            : String.valueOf(grow)) + ')';
    t = StringTemplate.template("colonyPanel.bonusLabel")
                      .addAmount("%number%", bonus)
                      .addName("%extra%", growth);
    bonusLabel.setText(Messages.message(t));
    bonusLabel.setFont(font);
    add(bonusLabel);

    t = StringTemplate.template("colonyPanel.royalistLabel")
                      .addAmount("%number%", uc - rebels);
    royalistLabel.setText(Messages.message(t));
    royalistLabel.setFont(font);
    add(royalistLabel, "split 2, flowy");

    royalistMemberLabel.setText(colony.getTory() + "%");
    royalistMemberLabel.setFont(font);
    add(royalistMemberLabel);

    Nation other = (colony.getOwner().isREF())
        ? nation.getRebelNation()
        : nation.getREFNation();
    try {
        royalistShield.setIcon(new ImageIcon(
            lib.getSmallerMiscIconImage(other)));
        add(royalistShield, "bottom");
    } catch (Exception e) {
        logger.log(Level.WARNING, "Shield: " + nation + "/" + other, e);
    }

    revalidate();
    repaint();
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:75,代码来源:ColonyPanel.java

示例7: paintComponent

import net.sf.freecol.client.gui.FontLibrary; //导入方法依赖的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.FontLibrary.createFont方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。