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


Java Element.getRenderer方法代码示例

本文整理汇总了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("");
    }
}
 
开发者ID:LeNiglo,项目名称:TinyTank,代码行数:17,代码来源:ServerEntryConverter.java

示例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)));
}
 
开发者ID:Mathgoat,项目名称:square-loot,代码行数:22,代码来源:HUD.java

示例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);
}
 
开发者ID:Mathgoat,项目名称:square-loot,代码行数:22,代码来源:HUD.java

示例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());
}
 
开发者ID:LeNiglo,项目名称:TinyTank,代码行数:10,代码来源:ServerEntryConverter.java

示例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);
}
 
开发者ID:methusalah,项目名称:OpenRTS,代码行数:8,代码来源:GUIDrawer.java

示例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);
}
 
开发者ID:methusalah,项目名称:OpenRTS,代码行数:12,代码来源:GUIDrawer.java

示例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("");
            }
        }
    }
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:38,代码来源:SpellBar.java

示例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);
        }
}
 
开发者ID:Periapsis,项目名称:aphelion,代码行数:30,代码来源:ChatPlayerViewConverter.java

示例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());
}
 
开发者ID:Periapsis,项目名称:aphelion,代码行数:12,代码来源:ChatPlayerViewConverter.java

示例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);
}
 
开发者ID:methusalah,项目名称:OpenRTS,代码行数:7,代码来源:GUIDrawer.java

示例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));
}
 
开发者ID:methusalah,项目名称:OpenRTS,代码行数:7,代码来源:GUIDrawer.java

示例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);        
}
 
开发者ID:TripleSnail,项目名称:Arkhados,代码行数:43,代码来源:VisualStatistics.java


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