本文整理汇总了Java中de.lessvoid.nifty.elements.render.TextRenderer.setText方法的典型用法代码示例。如果您正苦于以下问题:Java TextRenderer.setText方法的具体用法?Java TextRenderer.setText怎么用?Java TextRenderer.setText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.lessvoid.nifty.elements.render.TextRenderer
的用法示例。
在下文中一共展示了TextRenderer.setText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: display
import de.lessvoid.nifty.elements.render.TextRenderer; //导入方法依赖的package包/类
@Override
public void display(@Nonnull final Element element, final ServerEntry serverEntry) {
final Element text = element.findElementById("#server-name");
final TextRenderer textRenderer = text.getRenderer(TextRenderer.class);
final Element ip = element.findElementById("#server-ip");
final TextRenderer ipRenderer = ip.getRenderer(TextRenderer.class);
if (serverEntry != null) {
textRenderer.setText(serverEntry.getName());
ipRenderer.setColor(Color.WHITE);
ipRenderer.setText(serverEntry.getIp());
} else {
textRenderer.setText("");
ipRenderer.setText("");
}
}
示例2: updateTexts
import de.lessvoid.nifty.elements.render.TextRenderer; //导入方法依赖的package包/类
private static void updateTexts(){
Element e = HUD.nifty.getCurrentScreen().findElementByName("fps");
TextRenderer txt = e.getRenderer(TextRenderer.class);
String s = Timer.getFPSDisplay();
txt.setText(s);
e = HUD.nifty.getCurrentScreen().findElementByName("time");
txt = e.getRenderer(TextRenderer.class);
s = Timer.getChrono();
txt.setText(s);
e = HUD.nifty.getCurrentScreen().findElementByName("energy");
txt = e.getRenderer(TextRenderer.class);
s = "" + player.getEnergy();
txt.setText(s);
e = HUD.nifty.getCurrentScreen().findElementByName("battery");
txt = e.getRenderer(TextRenderer.class);
s = "" + player.getBatteriesNb();
txt.setText(s);
}
示例3: updateIcons
import de.lessvoid.nifty.elements.render.TextRenderer; //导入方法依赖的package包/类
void updateIcons() {
if (playerCharacter == null) {
return;
}
CSpellCast cCast = playerCharacter.getControl(CSpellCast.class);
CCharacterBuff cBuff = playerCharacter.getControl(CCharacterBuff.class);
boolean hasSilence = cBuff.hasBuff(BuffTypeIds.SILENCE);
for (Map.Entry<String, Element> entry : icons.entrySet()) {
float cooldown = cCast.getCooldown(Spell
.getSpell(entry.getKey()).getId());
Element overlay = entry.getValue()
.findElementById(entry.getKey() + "-overlay");
if (cooldown <= 0 && !hasSilence) {
if (overlay.isVisible()) {
overlay.hide();
}
} else {
if (!overlay.isVisible()) {
overlay.show();
}
Element cooldownText = overlay
.findElementById(entry.getKey() + "-spell-counter");
TextRenderer txt = cooldownText.getRenderer(TextRenderer.class);
if (cooldown > 3) {
txt.setText(String.format("%d", (int) cooldown));
} else if (cooldown > 0) {
txt.setText(String.format("%.1f", cooldown));
} else {
txt.setText("");
}
}
}
}
示例4: display
import de.lessvoid.nifty.elements.render.TextRenderer; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public final void display(final Element listBoxItem, final PlayerEntry item)
{
final Element text = listBoxItem.findElementByName(CHAT_LINE_TEXT);
final TextRenderer textRenderer = text.getRenderer(TextRenderer.class);
final Element icon = listBoxItem.findElementByName(CHAT_LINE_ICON);
final ImageRenderer iconRenderer = icon.getRenderer(ImageRenderer.class);
if (item != null)
{
textRenderer.setText(item.toString());
iconRenderer.setImage(item.getIcon());
if (item.getStyle() != null && !item.getStyle().equals(""))
{
text.setStyle(item.getStyle());
}
else
{
text.setStyle("default");
}
}
else
{
textRenderer.setText("");
iconRenderer.setImage(null);
}
}
示例5: insertStats
import de.lessvoid.nifty.elements.render.TextRenderer; //导入方法依赖的package包/类
private void insertStats(Element root, int index, PlayerRoundStats stats,
boolean team) {
String name;
int playerId = stats.playerId;
int teamId;
if (team) {
teamId = playerId;
name = VisualCharacterInfo.TEAM_NAMES[teamId];
} else {
teamId = PlayerData.getIntData(playerId, PlayerData.TEAM_ID);
name = PlayerData.getStringData(playerId, PlayerData.NAME);
}
ColorRGBA rgba = VisualCharacterInfo.TEAM_COLORS[teamId];
Color teamColor = new Color(rgba.r, rgba.g, rgba.b, rgba.a);
Element eName = root.findElementById(index + "-name");
Element eDamage = root.findElementById(index + "-damage");
Element eRestoration = root.findElementById(index + "-restoration");
Element eKills = root.findElementById(index + "-kills");
// FIXME: NullPointerError happens here
// Possibly related problem is that after this nifty complains
// about possibly conflicting ids.
TextRenderer rName = eName.getRenderer(TextRenderer.class);
rName.setText(name);
rName.setColor(teamColor);
TextRenderer rDamage = eDamage.getRenderer(TextRenderer.class);
rDamage.setText(String.format("%d", (int) stats.damageDone));
rDamage.setColor(teamColor);
TextRenderer rResto = eRestoration.getRenderer(TextRenderer.class);
rResto.setText(String.format("%d", (int) stats.healthRestored));
rResto.setColor(teamColor);
TextRenderer rKills = eKills.getRenderer(TextRenderer.class);
rKills.setText(String.format("%d", stats.kills));
rKills.setColor(teamColor);
}