本文整理汇总了Java中de.lessvoid.nifty.elements.Element.getRenderer方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getRenderer方法的具体用法?Java Element.getRenderer怎么用?Java Element.getRenderer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.lessvoid.nifty.elements.Element
的用法示例。
在下文中一共展示了Element.getRenderer方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: display
import de.lessvoid.nifty.elements.Element; //导入方法依赖的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: updateEquipment
import de.lessvoid.nifty.elements.Element; //导入方法依赖的package包/类
private static void updateEquipment(){
Element e = HUD.nifty.getCurrentScreen().findElementByName("equipment1");
ImageRenderer img = e.getRenderer(ImageRenderer.class);
img.setImage(itemImages.get(inventory.getInfo(InventoryItemEnum.PWEAPON)));
e = HUD.nifty.getCurrentScreen().findElementByName("equipment2");
img = e.getRenderer(ImageRenderer.class);
img.setImage(itemImages.get(inventory.getInfo(InventoryItemEnum.SWEAPON)));
e = HUD.nifty.getCurrentScreen().findElementByName("equipment3");
img = e.getRenderer(ImageRenderer.class);
img.setImage(itemImages.get(inventory.getInfo(InventoryItemEnum.SHIELD)));
e = HUD.nifty.getCurrentScreen().findElementByName("equipment4");
img = e.getRenderer(ImageRenderer.class);
img.setImage(itemImages.get(inventory.getInfo(InventoryItemEnum.ACCESSORY)));
e = HUD.nifty.getCurrentScreen().findElementByName("equipment5");
img = e.getRenderer(ImageRenderer.class);
img.setImage(itemImages.get(inventory.getInfo(InventoryItemEnum.MGEAR)));
}
示例3: updateTexts
import de.lessvoid.nifty.elements.Element; //导入方法依赖的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);
}
示例4: getWidth
import de.lessvoid.nifty.elements.Element; //导入方法依赖的package包/类
@Override
public int getWidth(@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);
return textRenderer.getFont().getWidth(serverEntry.getName()) + ipRenderer.getFont().getWidth(serverEntry.getIp());
}
示例5: changeLabelText
import de.lessvoid.nifty.elements.Element; //导入方法依赖的package包/类
protected void changeLabelText(String id, String text){
Element e = guiCtrl.getElement(id);
if(e == null || e.getRenderer(TextRenderer.class) == null)
throw new IllegalArgumentException("can't find label '"+id+"'.");
e.getRenderer(TextRenderer.class).setText(text);
}
示例6: changeButtonTextColor
import de.lessvoid.nifty.elements.Element; //导入方法依赖的package包/类
protected void changeButtonTextColor(String id, Color color){
float a = color.getAlpha();
float r = color.getRed();
float g = color.getGreen();
float b = color.getBlue();
de.lessvoid.nifty.tools.Color niftyColor = new de.lessvoid.nifty.tools.Color(r/255, g/255, b/255, 1);
Element e = guiCtrl.getElement(id+"#text");
if(e == null || e.getRenderer(TextRenderer.class) == null)
throw new IllegalArgumentException("can't find button's text '"+id+"'.");
e.getRenderer(TextRenderer.class).setColor(niftyColor);
}
示例7: updateIcons
import de.lessvoid.nifty.elements.Element; //导入方法依赖的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("");
}
}
}
}
示例8: display
import de.lessvoid.nifty.elements.Element; //导入方法依赖的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);
}
}
示例9: getWidth
import de.lessvoid.nifty.elements.Element; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public final int getWidth(final Element listBoxItem, final PlayerEntry item)
{
final Element text = listBoxItem.findElementByName(CHAT_LINE_TEXT);
final TextRenderer textRenderer = text.getRenderer(TextRenderer.class);
return ((textRenderer.getFont() == null) ? 0 : textRenderer.getFont().getWidth(item.getLabel()))
+ ((item.getIcon() == null) ? 0 : item.getIcon().getWidth());
}
示例10: changeButtonText
import de.lessvoid.nifty.elements.Element; //导入方法依赖的package包/类
protected void changeButtonText(String id, String text){
Element e = guiCtrl.getElement(id+"#text");
if(e == null || e.getRenderer(TextRenderer.class) == null)
throw new IllegalArgumentException("can't find button's text '"+id+"'.");
e.getRenderer(TextRenderer.class).setText(text);
}
示例11: setBackground
import de.lessvoid.nifty.elements.Element; //导入方法依赖的package包/类
protected void setBackground(String id, String backgroundPath){
Element e = guiCtrl.getElement(id);
if(e == null || e.getRenderer(ImageRenderer.class) == null)
throw new IllegalArgumentException("can't find element with background '"+id+"'.");
e.getRenderer(ImageRenderer.class).setImage(guiCtrl.nifty.createImage(backgroundPath, false));
}
示例12: insertStats
import de.lessvoid.nifty.elements.Element; //导入方法依赖的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);
}