本文整理汇总了Java中net.sf.freecol.client.gui.FontLibrary类的典型用法代码示例。如果您正苦于以下问题:Java FontLibrary类的具体用法?Java FontLibrary怎么用?Java FontLibrary使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FontLibrary类属于net.sf.freecol.client.gui包,在下文中一共展示了FontLibrary类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EventPanel
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.
* @param header The title.
* @param key A resource key for the image to display.
* @param footer Optional footer text.
*/
public EventPanel(FreeColClient freeColClient, String header, String key,
String footer) {
super(freeColClient, new MigLayout("wrap 1", "[center]", "[]20"));
JLabel headerLabel = new JLabel(header);
headerLabel.setFont(FontLibrary.createCompatibleFont(header,
FontLibrary.FontType.HEADER, FontLibrary.FontSize.MEDIUM));
JLabel imageLabel
= new JLabel(new ImageIcon(ResourceManager.getImage(key)));
JLabel footerLabel = (footer == null) ? null : new JLabel(footer);
add(headerLabel);
add(imageLabel);
if (footerLabel != null) add(footerLabel);
add(okButton, "tag ok");
setSize(getPreferredSize());
}
示例2: 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());
}
示例3: paintComponent
import net.sf.freecol.client.gui.FontLibrary; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void paintComponent(Graphics g) {
getIcon().paintIcon(null, g, 0, 0);
GUI gui = freeColClient.getGUI();
ImageLibrary lib = gui.getImageLibrary();
BufferedImage image = lib.getStringImage(
g,
Integer.toString(number), getForeground(),
FontLibrary.createFont(FontLibrary.FontType.SIMPLE,
FontLibrary.FontSize.TINY, Font.BOLD,
lib.getScaleFactor()));
g.drawImage(image,
(getIcon().getIconWidth() - image.getWidth(null))/2,
(getIcon().getIconHeight() - image.getHeight(null))/2, null);
}
示例4: buildDetail
import net.sf.freecol.client.gui.FontLibrary; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void buildDetail(String id, JPanel panel) {
if (getId().equals(id)) return;
Nation nation = getSpecification().getNation(id);
Player player = CollectionUtils.find(getGame().getLivePlayers(),
p -> p.getNation() == nation);
NationType currentNationType = (player == null) ? nation.getType()
: player.getNationType();
panel.setLayout(new MigLayout("wrap 3, fillx, gapx 20", "", ""));
JLabel name = Utility.localizedHeaderLabel(nation, FontLibrary.FontSize.SMALL);
panel.add(name, "span, align center, wrap 40");
JLabel artLabel = new JLabel(new ImageIcon(ImageLibrary.getMonarchImage(nation)));
panel.add(artLabel, "spany, gap 40, top");
panel.add(Utility.localizedLabel("colopedia.nation.ruler"));
panel.add(new JLabel(nation.getRulerName()));
panel.add(Utility.localizedLabel("colopedia.nation.defaultAdvantage"));
panel.add(getButton(nation.getType()));
panel.add(Utility.localizedLabel("colopedia.nation.currentAdvantage"));
panel.add(getButton(currentNationType), "wrap push");
}
示例5: buildDetail
import net.sf.freecol.client.gui.FontLibrary; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public void buildDetail(String id, JPanel panel) {
if (this.id.equals(id)) return;
panel.setLayout(new MigLayout("wrap 1, center"));
JLabel header = Utility.localizedHeaderLabel(Messages.nameKey(id),
SwingConstants.LEADING, FontLibrary.FontSize.SMALL);
panel.add(header, "align center, wrap 20");
JEditorPane editorPane = new JEditorPane("text/html",
Messages.getDescription(id)) {
@Override
public void paintComponent(Graphics g) {
Graphics2D graphics2d = (Graphics2D) g;
graphics2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
/*
graphics2d.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
graphics2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
*/
super.paintComponent(graphics2d);
}
};
editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES,
Boolean.TRUE);
editorPane.setFont(panel.getFont());
editorPane.setOpaque(false);
editorPane.setEditable(false);
editorPane.addHyperlinkListener(colopediaPanel);
panel.add(editorPane, "width 95%");
}
示例6: buildIndianNationTypeDetail
import net.sf.freecol.client.gui.FontLibrary; //导入依赖的package包/类
/**
* Builds the details panel for the given nation type.
*
* @param nationType - the IndianNationType
* @param panel the panel to use
*/
private void buildIndianNationTypeDetail(IndianNationType nationType,
JPanel panel) {
List<RandomChoice<UnitType>> skills = nationType.getSkills();
panel.setLayout(new MigLayout("wrap 2, gapx 20", "", ""));
JLabel name = Utility.localizedHeaderLabel(nationType, FontLibrary.FontSize.SMALL);
panel.add(name, "span, align center, wrap 40");
panel.add(Utility.localizedLabel("colopedia.nationType.aggression"));
panel.add(Utility.localizedLabel("colopedia.nationType."
+ nationType.getAggression().getKey()));
panel.add(Utility.localizedLabel("colopedia.nationType.settlementNumber"));
panel.add(Utility.localizedLabel("colopedia.nationType."
+ nationType.getNumberOfSettlements().getKey()));
panel.add(Utility.localizedLabel("colopedia.nationType.typeOfSettlements"));
panel.add(new JLabel(Messages.getName(nationType.getCapitalType()),
new ImageIcon(getImageLibrary().getSettlementImage(nationType.getCapitalType())),
SwingConstants.CENTER));
List<String> regionNames = new ArrayList<>();
for (String regionName : nationType.getRegions()) {
regionNames.add(Messages.getName(regionName));
}
panel.add(Utility.localizedLabel("colopedia.nationType.regions"));
panel.add(new JLabel(join(", ", regionNames)));
panel.add(Utility.localizedLabel("colopedia.nationType.skills"), "top, newline 20");
GridLayout gridLayout = new GridLayout(0, 2);
gridLayout.setHgap(10);
JPanel unitPanel = new JPanel(gridLayout);
unitPanel.setOpaque(false);
for (RandomChoice<UnitType> choice : skills) {
unitPanel.add(getUnitButton(choice.getObject()));
}
panel.add(unitPanel);
}
示例7: 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());
}
示例8: localizedHeaderLabel
import net.sf.freecol.client.gui.FontLibrary; //导入依赖的package包/类
/**
* Gets a label containing a localized message using the header font.
*
* @param key The message key to use.
* @param alignment The alignment.
* @param size The font size.
* @return A suitable {@code JLabel}.
*/
public static JLabel localizedHeaderLabel(String key, int alignment,
FontLibrary.FontSize size) {
String text = Messages.message(key);
JLabel header = new JLabel(text, alignment);
header.setFont(FontLibrary.createCompatibleFont(
text, FontLibrary.FontType.HEADER, size));
header.setOpaque(false);
return header;
}
示例9: 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);
}
}
}
}
示例10: createColonyButton
import net.sf.freecol.client.gui.FontLibrary; //导入依赖的package包/类
private JButton createColonyButton(Colony colony, String info, boolean headline) {
String text = colony.getName() + info;
JButton button = Utility.getLinkButton(text, null, colony.getId());
if (headline) {
button.setFont(FontLibrary.createCompatibleFont(text,
FontLibrary.FontType.HEADER, FontLibrary.FontSize.SMALL));
}
button.addActionListener(this);
return button;
}
示例11: LoadingSavegameDialog
import net.sf.freecol.client.gui.FontLibrary; //导入依赖的package包/类
/**
* Creates a dialog to set the options for loading a saved game.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
*/
public LoadingSavegameDialog(FreeColClient freeColClient, JFrame frame) {
super(freeColClient, frame);
JPanel panel = new JPanel();
panel.setBorder(Utility.blankBorder(10, 10, 10, 10));
panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
panel.setOpaque(false);
JLabel header = Utility.localizedHeaderLabel(
Messages.nameKey("loadingSavegameDialog"), JLabel.CENTER,
FontLibrary.FontSize.MEDIUM);
header.setBorder(Utility.blankBorder(20, 0, 0, 0));
JPanel p1 = new JPanel(new FlowLayout(FlowLayout.LEADING));
p1.add(Utility.localizedLabel("loadingSavegameDialog.serverName"));
serverNameField = new JTextField();
JPanel p2 = new JPanel(new FlowLayout(FlowLayout.LEADING));
p2.add(Utility.localizedLabel("loadingSavegameDialog.port"));
portField = new JSpinner(new SpinnerNumberModel(FreeCol.getServerPort(),
1, 65536, 1));
ButtonGroup bg = new ButtonGroup();
String str = Messages.message("loadingSavegameDialog.singlePlayer");
singlePlayer = new JRadioButton(str);
bg.add(singlePlayer);
str = Messages.message("loadingSavegameDialog.privateMultiplayer");
privateMultiplayer = new JRadioButton(str);
bg.add(privateMultiplayer);
str = Messages.message("loadingSavegameDialog.publicMultiplayer");
publicMultiplayer = new JRadioButton(str);
bg.add(publicMultiplayer);
panel.add(header);
panel.add(p1);
panel.add(serverNameField);
panel.add(p2);
panel.add(portField);
panel.add(singlePlayer);
panel.add(privateMultiplayer);
panel.add(publicMultiplayer);
panel.setSize(panel.getPreferredSize());
initializeConfirmDialog(frame, true, panel, null, "ok", "cancel");
}
示例12: FirstContactDialog
import net.sf.freecol.client.gui.FontLibrary; //导入依赖的package包/类
/**
* Create an FirstContactDialog.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param player The {@code Player} making contact.
* @param other The {@code Player} to contact.
* @param tile An optional {@code Tile} on offer.
* @param settlementCount The number of settlements the other
* player has.
*/
public FirstContactDialog(FreeColClient freeColClient, JFrame frame,
Player player, Player other, Tile tile, int settlementCount) {
super(freeColClient, frame);
MigPanel panel
= new MigPanel(new MigLayout("wrap 1", "[center]", "[]20"));
panel.setOpaque(false);
String headerKey = BASE_KEY + other.getNation().getSuffix();
String imageKey = IMAGE_BASE_KEY + other.getNationResourceKey();
if (!Messages.containsKey(headerKey)) {
headerKey = BASE_KEY + NATIVES_KEY;
imageKey = IMAGE_BASE_KEY + NATIVES_KEY;
}
JLabel header = Utility.localizedHeaderLabel(headerKey,
SwingConstants.LEADING, FontLibrary.FontSize.MEDIUM);
JLabel image
= new JLabel(new ImageIcon(ResourceManager.getImage(imageKey)));
image.setOpaque(false);
JTextArea tutorial = null;
if (!player.hasContactedIndians() && freeColClient.tutorialMode()) {
tutorial = Utility.localizedTextArea(TUTORIAL_KEY);
}
String messageId = (tile != null)
? "firstContactDialog.welcomeOffer.text"
: "firstContactDialog.welcomeSimple.text";
String type = ((IndianNationType)other.getNationType())
.getSettlementTypeKey(true);
JTextArea text = Utility.localizedTextArea(StringTemplate
.template(messageId)
.addStringTemplate("%nation%", other.getNationLabel())
.addName("%camps%", Integer.toString(settlementCount))
.add("%settlementType%", type));
// Resize the text areas to better match the image.
int columns = (int)Math.floor(text.getColumns()
* image.getPreferredSize().getWidth()
/ text.getPreferredSize().getWidth());
text.setColumns(columns);
text.setSize(text.getPreferredSize());
if (tutorial != null) {
tutorial.setColumns(columns);
tutorial.setSize(tutorial.getPreferredSize());
}
panel.add(header);
panel.add(image);
if (tutorial != null) panel.add(tutorial);
panel.add(text);
panel.setSize(panel.getPreferredSize());
ImageIcon icon = new ImageIcon(
getImageLibrary().getMiscIconImage(other.getNation()));
initializeConfirmDialog(frame, false, panel, icon, "yes", "no");
}
示例13: MonarchDialog
import net.sf.freecol.client.gui.FontLibrary; //导入依赖的package包/类
/**
* Creates a dialog to handle monarch interactions.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param action The {@code MonarchAction} the monarch is performing.
* @param template The {@code StringTemplate} describing the action.
* @param monarchKey The resource key for the monarch image.
*/
public MonarchDialog(FreeColClient freeColClient, JFrame frame,
MonarchAction action, StringTemplate template, String monarchKey) {
super(freeColClient, frame);
final ImageLibrary lib = freeColClient.getGUI().getImageLibrary();
final String messageId = action.getTextKey();
if (!Messages.containsKey(messageId)) {
throw new IllegalStateException("Unrecognized monarch action: "
+ action);
}
String yesId = action.getYesKey();
if (!Messages.containsKey(yesId)) yesId = null;
String noId = action.getNoKey();
if (!Messages.containsKey(noId)) noId = "close";
String hdrKey = action.getHeaderKey();
if (!Messages.containsKey(hdrKey)) {
hdrKey = "monarchDialog.default";
}
JLabel header = Utility.localizedHeaderLabel(hdrKey,
SwingConstants.LEADING, FontLibrary.FontSize.MEDIUM);
MigPanel panel = new MigPanel(new MigLayout("wrap 2, insets 10",
"[]20[]"));
panel.add(header, "span, align center, wrap 20");
if (action == MonarchAction.RAISE_TAX_ACT
|| action == MonarchAction.RAISE_TAX_WAR) {
JButton helpButton = Utility.localizedButton("help");
helpButton.addActionListener((ActionEvent ae) -> {
getGUI().showColopediaPanel("colopedia.concepts.taxes");
});
panel.add(helpButton, "tag help");
}
JTextArea text = (template == null)
? Utility.localizedTextArea(messageId, 30)
: Utility.localizedTextArea(StringTemplate.copy(messageId, template), 30);
panel.add(text);
panel.setSize(panel.getPreferredSize());
List<ChoiceItem<Boolean>> c = choices();
if (yesId != null) {
c.add(new ChoiceItem<>(Messages.message(yesId), Boolean.TRUE)
.okOption());
}
c.add(new ChoiceItem<>(Messages.message(noId), Boolean.FALSE)
.cancelOption().defaultOption());
initializeDialog(frame, DialogType.QUESTION, false, panel,
new ImageIcon(lib.getMiscImage(monarchKey)), c);
}
示例14: NativeDemandDialog
import net.sf.freecol.client.gui.FontLibrary; //导入依赖的package包/类
/**
* Creates a dialog to handle native demands interactions.
*
* @param freeColClient The {@code FreeColClient} for the game.
* @param frame The owner frame.
* @param unit The demanding {@code Unit}.
* @param colony The {@code Colony} being demanded of.
* @param type The {@code GoodsType} demanded (may be null for gold).
* @param amount The amount of goods demanded.
*/
public NativeDemandDialog(FreeColClient freeColClient, JFrame frame,
Unit unit, Colony colony,
GoodsType type, int amount) {
super(freeColClient, frame);
final String nation = Messages.message(unit.getOwner().getNationLabel());
StringTemplate template;
String yes, no;
if (type == null) {
template = StringTemplate.template("indianDemand.gold.text")
.addName("%nation%", nation)
.addName("%colony%", colony.getName())
.addAmount("%amount%", amount);
yes = "accept";
no = "indianDemand.gold.no";
} else if (type.isFoodType()) {
template = StringTemplate.template("indianDemand.food.text")
.addName("%nation%", nation)
.addName("%colony%", colony.getName())
.addAmount("%amount%", amount);
yes = "indianDemand.food.yes";
no = "indianDemand.food.no";
} else {
template = StringTemplate.template("indianDemand.other.text")
.addName("%nation%", nation)
.addName("%colony%", colony.getName())
.addAmount("%amount%", amount)
.addNamed("%goods%", type);
yes = "accept";
no = "indianDemand.other.no";
}
MigPanel panel = new MigPanel(new MigLayout("wrap 1, fill",
"[400, align center]"));
JLabel header = Utility.localizedHeaderLabel(StringTemplate
.template("nativeDemandDialog.name")
.addName("%colony%", colony.getName()),
SwingConstants.LEADING, FontLibrary.FontSize.BIG);
panel.add(header);
JTextArea text = Utility.localizedTextArea(template);
panel.add(text);
final ImageLibrary lib = freeColClient.getGUI().getImageLibrary();
ImageIcon icon = new ImageIcon(lib.getSmallSettlementImage(colony));
initializeConfirmDialog(frame, true, panel, icon, yes, no);
}
示例15: buildDetail
import net.sf.freecol.client.gui.FontLibrary; //导入依赖的package包/类
/**
* Builds the details panel for the given FoundingFather.
*
* @param father a FoundingFather
* @param panel the detail panel to build
*/
public void buildDetail(FoundingFather father, JPanel panel) {
panel.setLayout(new MigLayout("wrap 2, fillx, gapx 20", "", ""));
String name = Messages.getName(father);
String type = Messages.message(father.getTypeKey());
String text = name + " (" + type + ")";
JLabel header = new JLabel(text);
header.setFont(FontLibrary.createCompatibleFont(text,
FontLibrary.FontType.HEADER, FontLibrary.FontSize.SMALL));
Image image = ImageLibrary.getFoundingFatherImage(father, false);
JLabel label = new JLabel(new ImageIcon(image));
StringTemplate template = StringTemplate.label("")
.add(Messages.descriptionKey(father))
.addName("\n\n[")
.add(father.getId() + ".birthAndDeath")
.addName("] ")
.add(father.getId() + ".text");
final Turn turn = getMyPlayer().getElectionTurns().get(name);
if (turn != null) {
template
.addName("\n\n")
.add("report.continentalCongress.elected")
.addName(" ")
.addStringTemplate(turn.getLabel());
}
panel.add(header, "span, align center, wrap 40");
panel.add(label, "top");
JTextArea description = Utility.localizedTextArea(template, 20);
panel.add(description, "top, growx");
Dimension hSize = header.getPreferredSize(),
lSize = label.getPreferredSize(),
dSize = description.getPreferredSize(), size = new Dimension();
size.setSize(lSize.getWidth() + dSize.getWidth() + 20,
hSize.getHeight() + lSize.getHeight() + 10);
panel.setPreferredSize(size);
}