Java 类com.badlogic.gdx.utils.StringBuilder 实例源码

项目:libgdx_ui_editor    文件:NewSceneDialog.java   
private FileHandle createSceneFile(float width,float height,String name) throws IOException {
    if (!path.isDirectory()){
        path = path.parent();
    }
    StringBuilder filePath = new StringBuilder();
    filePath.append(path.path());
    filePath.append("/");
    filePath.append(name);
    filePath.append(".");
    filePath.append(Config.sceneExtension);
    FileHandle fileHandle = new FileHandle(filePath.toString());
    if (fileHandle.file().exists()) fileHandle.delete();
    fileHandle.file().createNewFile();

    Writer writer = new FileWriter(fileHandle.file());
    FileUtils.createScene(writer,width,height,name);
    writer.close();
    return fileHandle;
}
项目:cachebox3.0    文件:CoordinateActivity.java   
Coordinate getValue() {

            StringBuilder sb = new StringBuilder();
            SnapshotArray<Actor> childs = this.getChildren();
            for (Actor actor : childs) {
                if (actor == null) {
                    sb.append(" ");
                } else {
                    if (actor instanceof VisTextButton) {
                        sb.append(((VisTextButton) actor).getText());
                    } else if (actor instanceof VisLabel) {
                        sb.append(((VisLabel) actor).getText());
                    }
                }
            }
            return new Coordinate(sb.toString());
        }
项目:cachebox3.0    文件:CoordinateActivity.java   
@Override
Coordinate getValue() {

    StringBuilder sb = new StringBuilder();
    SnapshotArray<Actor> childs = this.getChildren();
    for (Actor actor : childs) {
        if (actor == null) {
            sb.append(" ");
        } else {
            if (actor instanceof VisTextButton) {
                sb.append(((VisTextButton) actor).getText());
            } else if (actor instanceof VisLabel) {
                sb.append(((VisLabel) actor).getText());
            }
        }
    }

    sb = sb.replace("OstW", "").replace("NordW", " ").replace("Zone", " ");

    //switch Zone to first block
    String s[] = sb.toString().split(" ");
    String utmStr = s[2] + " " + s[0] + " " + s[1];


    return new Coordinate(utmStr);
}
项目:beatoraja    文件:PlayDataAccessor.java   
private String getScoreHash(IRScoreData score) {
    byte[] cipher_byte;
    try {
        MessageDigest md = MessageDigest.getInstance("SHA-256");
        md.update((hashkey + score.getSha256() + "," + score.getExscore() + "," + score.getEpg() + ","
                + score.getLpg() + "," + score.getEgr() + "," + score.getLgr() + "," + score.getEgd() + ","
                + score.getLgd() + "," + score.getEbd() + "," + score.getLbd() + "," + score.getEpr() + ","
                + score.getLpr() + "," + score.getEms() + "," + score.getLms() + "," + score.getClear() + ","
                + score.getMinbp() + "," + score.getCombo() + "," + score.getMode() + "," + score.getClearcount()
                + "," + score.getPlaycount() + "," + score.getOption() + "," + score.getRandom() + ","
                + score.getHistory() + "," + score.getDate()).getBytes());
        cipher_byte = md.digest();
        StringBuilder sb = new StringBuilder(2 * cipher_byte.length);
        for (byte b : cipher_byte) {
            sb.append(String.format("%02x", b & 0xff));
        }
        return "035" + sb.toString();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
项目:beatoraja    文件:PlayDataAccessor.java   
private String getReplayDataFilePath(String[] hashes, boolean ln, int lnmode, int index,
        CourseData.CourseDataConstraint[] constraint) {
    StringBuilder hash = new StringBuilder();
    for (String s : hashes) {
        hash.append(s.substring(0, 10));
    }
    StringBuilder sb = new StringBuilder();
    for (CourseData.CourseDataConstraint c : constraint) {
        if (c != CLASS && c != MIRROR && c != RANDOM) {
            sb.append(String.format("%02d", c.id));
        }
    }
    return "player" + File.separatorChar + player + File.separatorChar + "replay" + File.separatorChar
            + (ln ? replay[lnmode] : "") + hash + (sb.length() > 0 ? "_" + sb.toString() : "")
            + (index > 0 ? "_" + index : "");
}
项目:fabulae    文件:Quest.java   
/**
 * Returns the history of this quest (descriptions and times
 * of all its states) in a human readable string form.
 * 
 * Returns an empty string if the quest is not started.
 * 
 * @return
 */
public String getStory() {
    StringBuilder builder = StringUtil.getFSB();
    int i = 0;
    for (State<QuestTransition> state : story) {
        String description = state.getDescription();
        if (description != null && !description.isEmpty()) {
            String separator = i == story.size-1 ? "" : "\n\n";
            builder.append(storyTimes.get(i).toStringNoTime());
            builder.append(": ");
            builder.append(description);
            builder.append(separator);
        }
        ++i;
    }
    String returnValue = builder.toString();
    StringUtil.freeFSB(builder);
    return returnValue;
}
项目:fabulae    文件:Effect.java   
/**
 * Gets the effects of this Perk as a human
 * readable string.
 * 
 * This does not include any modifiers
 * associated with this Perk.
 * 
 * @return null if there are no associated effects, the string otherwise
 */
public static String getEffectsAsString(EffectContainer ec, Object user) {
    ObjectMap<Effect, Array<EffectParameter>> effects = ec.getEffects();
    if (effects.size == 0) {
        return null;
    }
    StringBuilder fsb = StringUtil.getFSB();
    int i = 0;
    for (Effect effect : effects.keys()) {
        String desc = effect.getDescription(user, effects.get(effect));
        if (desc == null) {
            continue;
        }
        if (i > 0) {
            fsb.append("\n");
        }
        fsb.append(desc);
        ++i;
    }
    String returnValue = fsb.toString();
    StringUtil.freeFSB(fsb);
    return returnValue;
}
项目:fabulae    文件:Modifier.java   
/**
 * Prints this Modifier into a user-friendly string.
 * 
 * If includeName is set to true, the resulting string
 * will also include the name of the Modifier.
 * 
 * @param includeName
 * @return
 */
public String toString(boolean includeName) {
    StringBuilder fsb = StringUtil.getFSB();
    if (includeName) {
        fsb.append(getName());
        fsb.append(": ");
    }

    for (ModifiableStat mod : ModifiableStat.values()) {
        fsb.append(modToString(mod, ", "));
    }

    String returnValue = fsb.toString();
    StringUtil.freeFSB(fsb);

    if (returnValue.endsWith(": ")) {
        returnValue = "";
    } else if (returnValue.endsWith(", ")) {
        returnValue = returnValue.substring(0, returnValue.lastIndexOf(", "));
    }

    return returnValue;
}
项目:fabulae    文件:Modifier.java   
private String modToString(ModifiableStat mod, String separator) {
    float value = getMod(mod);
    boolean multiply = mod.isMultiplier();

    if ((value == 0 && !multiply) || (multiply && value == 1)) {
        return "";
    }

    StringBuilder fsb = StringUtil.getFSB();

    fsb.append(mod.toUIString());
    fsb.append(": ");
    fsb.append(getModAsString(mod));

    if (separator != null) {
        fsb.append(separator);
    }
    String returnValue = fsb.toString();
    StringUtil.freeFSB(fsb);

    return returnValue;
}
项目:fabulae    文件:Modifier.java   
/**
 * Prints all the Modifiers in the suppled ModifierContainer
 * in a user-friendly String. The supplied separator
 * is used to separate individual Modifiers. If includeNames
 * is true, the Modifiers names will also be printed.
 * @param mc
 * @param separator
 * @param includeNames
 * @return
 */
public static String getModifiersAsString(ModifierContainer mc, String separator, boolean includeNames) {
    StringBuilder builder = StringUtil.getFSB();
    Iterator<Modifier> modifiers = mc.getModifiers();
    int i = 0;
    while (modifiers.hasNext()) {
        Modifier modifier = modifiers.next();
        if (modifier.isNonZero()) {
            if (i > 0) {
                builder.append(separator);
            }
            builder.append(modifier.toString(includeNames));
        }
        ++i;
    }
    String returnValue = builder.toString();
    StringUtil.freeFSB(builder);
    return returnValue;
}
项目:fabulae    文件:SpellTooltip.java   
@Override
protected void buildActivationRequirements(GameCharacter character,
        StringBuilder fsb) {
    super.buildActivationRequirements(character, fsb);
    ObjectMap<String, Boolean> foci = spell.getFoci();

    if (foci.size > 0) {
        addLine();
        addLine(Strings.getString(Spell.STRING_TABLE, "foci"), style.headingStyle);

        Inventory inventory = character.getInventory();
        for (Entry<String, Boolean> entry : foci.entries()) {
            fsb.append(InventoryItem.getItemPrototype(entry.key).getName());
            if (entry.value) {
                fsb.append(" (");
                fsb.append(Strings.getString(Spell.STRING_TABLE, "consumed"));
                fsb.append(")");
            }
            addLine(fsb.toString(),
                    inventory.getItem(entry.key) != null ? style.reqsReachedStyle
                            : style.reqsNotReachedStyle);
            fsb.setLength(0);
        }
    }
}
项目:fabulae    文件:ItemTooltip.java   
public void updateText(GameCharacter ic) {
    clear();

    StringBuilder fsb = StringUtil.getFSB();

    buildName(ic, fsb);
    buildDescription(fsb);
    buildOwner(ic, fsb);
    buildArmorInfo(fsb);
    buildWeaponInfo(fsb);
    buildUsesLeft(fsb);
    buildUseRequirements(ic, fsb);
    buildEquipRequirements(ic, fsb);
    buildEffectsAndModifiers(ic, fsb);

    StringUtil.freeFSB(fsb);
}
项目:fabulae    文件:ItemTooltip.java   
protected void buildEffectsAndModifiers(GameCharacter ic, StringBuilder fsb) {
    String modifiers = Modifier.getModifiersAsString(item, ", ", false);
    String effects = null;
    if (item instanceof EffectContainer) {
        effects = Effect.getEffectsAsString((EffectContainer)item, ic);
    }
    if (!modifiers.isEmpty() || effects != null) {
        addLine();
        addLine(Strings.getString(InventoryItem.STRING_TABLE, "effects"), style.subheadingStyle);
    }

    if (!modifiers.isEmpty()) {
        addLine(modifiers);
    }

    if (effects != null) {
        addLine(effects);
    }
}
项目:fabulae    文件:PerkTooltip.java   
public void updateText(GameCharacter character, boolean includeLearnRequirements) {
    clear();

    StringBuilder fsb = StringUtil.getFSB();

    buildName(fsb);
    buildDescription(fsb);

    if (includeLearnRequirements) {
        buildLearnRequirements(character, fsb);
    }

    if (perk.isActivated()) {
        buildActivationRequirements(character, fsb);
        buildTarget(character, fsb);
    }

    buildEffectsAndModifiers(character, fsb);

    buildSynergiesDescription(fsb);

    StringUtil.freeFSB(fsb);
}
项目:fabulae    文件:PerkTooltip.java   
protected void buildEffectsAndModifiers(GameCharacter character, StringBuilder fsb) {
    String modifiers = Modifier.getModifiersAsString(perk, ", ", false);
    String effects = Effect.getEffectsAsString(perk, character);
    if (!modifiers.isEmpty() || effects != null) {
        addLine();
        addLine(Strings.getString(Perk.STRING_TABLE, "effects"), style.subheadingStyle);
    }

    if (!modifiers.isEmpty()) {
        addLine(modifiers);
    }

    if (effects != null) {
        addLine(effects);
    }
}
项目:fabulae    文件:PerkTooltip.java   
protected void buildLearnRequirements(GameCharacter character, StringBuilder fsb) {
    addLine();
    addLine(Strings.getString(Perk.STRING_TABLE, "learnRequirements"), style.subheadingStyle);

    fsb.append(Strings.getString(ModifiableStat.STRING_TABLE, "level"));
    fsb.append(": ");
    fsb.append(Integer.toString(perk.getLevelRequirement()));
    if (perk.getLevelRequirement() > character.stats().getLevel()) {
        addLine(fsb.toString(), style.reqsNotReachedStyle);
    } else {
        addLine(fsb.toString(), style.reqsReachedStyle);
    }
    fsb.setLength(0);

    Array<ConditionResult> learnReqs = perk.evaluateLearnRequirements(character);
    if (learnReqs != null) {
        for (ConditionResult result : learnReqs) {
            addLine(result.conditionName, result.passed ? style.reqsReachedStyle : style.reqsNotReachedStyle);
        }
    }
}
项目:fabulae    文件:DialoguePanel.java   
private void loadBanters(NPCTalk npcTalk) {
    Array<Banter> banters = npcTalk.getRelevantBanters();

    StringBuilder bantersText = StringUtil.getFSB();
    int i = 0;
    for (Banter banter : banters) {
        ++i;
        bantersText.append(((GameCharacter)GameState.getGameObjectByInternalId(banter.getCharacterId())).getName());
        bantersText.append(": ");
        bantersText.append(banter.getText(dialogueParameters));
        if (i != banters.size) {
            bantersText.append("\n\n");
        }
    }

    if (banters.size > 0) {
        bantersPanel.setText(bantersText.toString());
        banterCell.setActor(banterContainer);
    } else {
        banterCell.setActor(null);
    }
    StringUtil.freeFSB(bantersText);
}
项目:fabulae    文件:QuickUseListener.java   
private void useItem(InventoryItem item, GameCharacter user) {
    Array<ConditionResult> results = item.canBeUsedBy(user);
    if (Condition.areResultsOk(results)) {
        calculateTargetAndUseItem((UsableItem)item);
    } else {
        StringBuilder fsb = StringUtil.getFSB();
        for (ConditionResult result : results) {
            if (!result.passed) {
                fsb.append(result.conditionName);
                fsb.append(", ");
            }
        }
        String failedConditions = fsb.substring(0, fsb.lastIndexOf(", "));
        StringUtil.freeFSB(fsb);
        Log.logLocalized("cannotUseItem", LogType.INVENTORY, user.getName(),
                item.getName(), failedConditions);
    }
}
项目:fabulae    文件:GraphicsUtil.java   
public static int renderLoadingIndicator(float stateTime, int numberOfDots, SpriteBatch batch, BitmapFont font, String text) {
    if (stateTime > 0.3f) {
        ++numberOfDots;
        if (numberOfDots > 3) {
            numberOfDots = 0; 
        }
    }

    StringBuilder fsb = StringUtil.getFSB();
    fsb.append(text);
    for (int i=0; i <numberOfDots; ++i) {
        fsb.append(".");
    }

    batch.begin();
    font.draw(batch, fsb.toString(), Gdx.graphics.getWidth()/2-50,  Gdx.graphics.getHeight()/2+30); 
    batch.end();
    StringUtil.freeFSB(fsb);
    return numberOfDots;
}
项目:libgdx-snippets    文件:TextFileUtils.java   
public static void writeString(FileHandle file, String text) throws IOException {

        StringBuilder builder = new StringBuilder(text.length());
        String newLine = Host.os != Host.OS.Windows ? "\n" : "\r\n";

        try (BufferedReader reader = new BufferedReader(new StringReader(text))) {

            String line;
            while ((line = reader.readLine()) != null) {

                if (builder.length() > 0) {
                    builder.append(newLine);
                }

                builder.append(line);
            }
        }

        file.writeString(builder.toString(), false);
    }
项目:libgdx-snippets    文件:SHA1.java   
@Override
public String toString() {

    StringBuilder builder = algorithm.stringBuilder.get();
    builder.setLength(0);

    int v;
    char c;

    for (byte b : value) {
        v = (b & 0xf0) >> 4;
        c = (v < 10) ? (char) ('0' + v) : (char) ('a' + v - 10);
        builder.append(c);
        v = b & 0x0f;
        c = (v < 10) ? (char) ('0' + v) : (char) ('a' + v - 10);
        builder.append(c);
    }

    return builder.toString();
}
项目:CodeBase    文件:DevConsoleView.java   
@Override
protected void append(ILoggingEvent e) {
    Level level = e.getLevel();
    LogLabel log = logLabels.getLast();
    if (log.getLevel() != level) {
        log = new LogLabel("", skin, level);
        addLogLabel(log);
    }
    StringBuilder sb = (StringBuilder) log.getText();
    if (level == Level.INFO) {
        sb.append(e.getFormattedMessage());
    } else if (level == Level.ERROR) {
        sb.append("Error: ").append(e.getFormattedMessage());
    } else if (level == Level.WARN) {
        sb.append("Warning: ").append(e.getFormattedMessage());
    } else if (level == Level.DEBUG) {
        sb.append("Debug: ").append(e.getFormattedMessage());
    } else if (level == Level.TRACE) {
        sb.append("Trace: ").append(e.getFormattedMessage());
    }
    sb.append("\n");
    log.invalidateHierarchy();
    DevConsoleView.sheduleScrollToEnd = 10;
}
项目:GdxStudio    文件:Scene.java   
public void save(String sceneName){
    if(!isDirty)
        return;
    if(sceneName == null || sceneName.isEmpty())
        return;
    Scene.log("Save "+sceneName);
    if(!sceneName.contains(basePackage) && !sceneName.contains("gdxstudio"))
        sceneName = basePackage+sceneName;
    StringBuilder sb = new StringBuilder();
    for(Actor actor: getChildren()){
        sb.append(json.toJson(actor));
        sb.append("\n");
    }
    sb.append(json.toJson(getRoot().findActor(this.sceneName)));//??Warning
    scenesMap.put(sceneName, sb.toString());
    Gdx.files.local(Asset.basePath+"scene").writeString(json.toJson(scenesMap, ArrayMap.class, 
            String.class), false);
    sb = null;
    isDirty = false;
}
项目:gdx-proto    文件:HUD.java   
public void showChatMessages(StringBuilder sb) {
    for (ChatMessage chat : chatMessages) {
        long elapsed = TimeUtils.timeSinceMillis(chat.createTime);
        if (elapsed >= chatMessageLifeTime) {
            chatMessages.removeValue(chat, true);
        } else {
            sb.append("\n[");
            if (chat.playerId == -1) {
                sb.append("Server");
            } else {
                sb.append("Player ").append(chat.playerId);
            }
            sb.append("]: ").append(chat.text);
        }
    }
}
项目:vis-editor    文件:Dialogs.java   
private static void getStackTrace (Throwable throwable, StringBuilder builder) {
    String msg = throwable.getMessage();
    if (msg != null) {
        builder.append(msg);
        builder.append("\n\n");
    }

    for (StackTraceElement element : throwable.getStackTrace()) {
        builder.append(element);
        builder.append("\n");
    }

    if (throwable.getCause() != null) {
        builder.append("\nCaused by: ");
        getStackTrace(throwable.getCause(), builder);
    }
}
项目:ModularArmour    文件:OrderedMap.java   
public String toString() {
    if (size == 0)
        return "{}";
    StringBuilder buffer = new StringBuilder(32);
    buffer.append('{');
    Array<K> keys = this.keys;
    for (int i = 0, n = keys.size; i < n; i++) {
        K key = keys.get(i);
        if (i > 0)
            buffer.append(", ");
        buffer.append(key);
        buffer.append('=');
        buffer.append(get(key));
    }
    buffer.append('}');
    return buffer.toString();
}
项目:gdx-ai    文件:DungeonUtils.java   
public static String mapToString (int[][] map) {
    StringBuilder sb = new StringBuilder(map.length * (map[0].length + 1)); // +1 is due to the new line char
    for (int x = 0; x < map.length; x++) {
        for (int y = 0; y < map[0].length; y++) {
            switch (map[x][y]) {
            case TILE_EMPTY:
                sb.append(' ');
                break;
            case TILE_FLOOR:
                sb.append('.');
                break;
            case TILE_WALL:
                sb.append('#');
                break;
            default:
                sb.append('?');
                break;
            }
        }
        sb.append('\n');
    }
    return sb.toString();
}
项目:gdx-ai    文件:BehaviorTreeViewer.java   
private static void appendFieldString (StringBuilder sb, Task<?> task, TaskAttribute ann, Field field) {
    // prefer name from annotation if there is one
    String name = ann.name();
    if (name == null || name.length() == 0) name = field.getName();
    Object value;
    try {
        field.setAccessible(true);
        value = field.get(task);
    } catch (ReflectionException e) {
        Gdx.app.error("", "Failed to get field", e);
        return;
    }
    sb.append(name).append(":");
    Class<?> fieldType = field.getType();
    if (fieldType.isEnum() || fieldType == String.class) {
        sb.append('\"').append(value).append('\"');
    } else if (Distribution.class.isAssignableFrom(fieldType)) {
        sb.append('\"').append(DAs.toString((Distribution)value)).append('\"');
    } else
        sb.append(value);
}
项目:ingress-indonesia-dev    文件:Label.java   
public void setText(CharSequence paramCharSequence)
{
  if ((paramCharSequence instanceof StringBuilder))
  {
    if (this.text.equals(paramCharSequence))
      return;
    this.text.setLength(0);
    this.text.append((StringBuilder)paramCharSequence);
  }
  while (true)
  {
    computeBounds();
    invalidateHierarchy();
    return;
    if (paramCharSequence == null)
      paramCharSequence = "";
    if (textEquals(paramCharSequence))
      break;
    this.text.setLength(0);
    this.text.append(paramCharSequence);
  }
}
项目:gdx-cclibs    文件:StringBuilderSerializer.java   
@Override
public void write(Kryo kryo, Output output, StringBuilder stringBuilder) {
    output.writeVarInt(stringBuilder.length, true);
    for (int i = 0; i < stringBuilder.length(); i++) {
        output.writeChar(stringBuilder.charAt(i));
    }
}
项目:gdx-cclibs    文件:StringBuilderSerializer.java   
@Override
public StringBuilder read(Kryo kryo, Input input, Class<StringBuilder> type) {
    int length = input.readVarInt(true);
    StringBuilder stringBuilder = new StringBuilder(length);
    for (int i = 0; i < length; i++) {
        stringBuilder.append(input.readChar());
    }
    return stringBuilder;
}
项目:gdx-cclibs    文件:UtilsTest.java   
public void testUtils (){
    StringBuilder stringBuilder = new StringBuilder();
    for (int i = 0, size = randSize(); i < size; i++) {
        stringBuilder.append((char)randInt());
    }
    simpleRoundTrip(stringBuilder);
}
项目:gdx-cclibs    文件:BatchablePreparation.java   
public static String generateGenericVertexShader (int textureCount) {
    boolean v3 = Gdx.gl30 != null;
    String attribute = v3 ? "in" : "attribute";
    String varying = v3 ? "out" : "varying";

    StringBuilder sb = new StringBuilder();

    if (v3) sb.append("#version 300 es\n");
    sb.append(attribute).append(" vec4 ").append(ShaderProgram.POSITION_ATTRIBUTE).append(";\n");
    sb.append(attribute).append(" vec4 ").append(ShaderProgram.COLOR_ATTRIBUTE).append(";\n");
    for (int i = 0; i < textureCount; i++)
        sb.append(attribute).append(" vec2 ").append(ShaderProgram.TEXCOORD_ATTRIBUTE).append(i).append(";\n");
    sb.append("uniform mat4 u_projTrans;\n");
    sb.append(varying).append(" vec4 v_color;\n");
    for (int i = 0; i < textureCount; i++)
        sb.append(varying).append(" vec2 v_texCoords").append(i).append(";\n\n");

    sb.append("void main()\n");
    sb.append("{\n");
    sb.append("   v_color = ").append(ShaderProgram.COLOR_ATTRIBUTE).append(";\n");
    sb.append("   v_color.a = v_color.a * (255.0/254.0);\n");
    for (int i = 0; i < textureCount; i++)
        sb.append("   v_texCoords").append(i).append(" = ").append(ShaderProgram.TEXCOORD_ATTRIBUTE).append(i).append(";\n");
    sb.append("   gl_Position =  u_projTrans * ").append(ShaderProgram.POSITION_ATTRIBUTE).append(";\n");
    sb.append("}\n");

    return sb.toString();
}
项目:gdx-cclibs    文件:BatchablePreparation.java   
public static String generateGenericFragmentShader (int textureCount) { // TODO default should only use first texture
    boolean v3 = Gdx.gl30 != null;
    String varying = v3 ? "in" : "varying";
    String outColor = v3 ? "fragmentColor" : "gl_FragColor";
    String tex2D = v3 ? "texture, " : "texture2D";

    StringBuilder sb = new StringBuilder();

    if (v3) sb.append("#version 300 es\n");
    sb.append("#ifdef GL_ES\n");
    sb.append("#define LOWP lowp\n");
    sb.append("precision mediump float;\n");
    sb.append("#else\n");
    sb.append("#define LOWP \n");
    sb.append("#endif\n\n");

    sb.append(varying).append(" LOWP vec4 v_color;\n");
    for (int i = 0; i < textureCount; i++)
        sb.append(varying).append(" vec2 v_texCoords").append(i).append(";\n");
    for (int i = 0; i < textureCount; i++)
        sb.append("uniform sampler2D u_texture").append(i).append(";\n");
    if (v3) sb.append("out LOWP vec4 ").append(outColor).append("\n");

    sb.append("\n");
    sb.append("void main()\n");
    sb.append("{\n");
    if (textureCount == 0)
        sb.append("  ").append(outColor).append(" = v_color;\n");
    else if (textureCount == 1)
        sb.append("  ").append(outColor).append(" = v_color * texture2D(u_texture0, v_texCoords0);\n");
    else {
        sb.append("LOWP vec4 color = ").append(tex2D).append("(u_texture0, v_texCoords0);\n");
        for (int i = 1; i < textureCount; i++)
            sb.append("color += ").append(tex2D).append("(u_texture").append(i).append(", v_texCoords").append(i).append(");\n");
        sb.append("  ").append(outColor).append(" = v_color * color / ").append(textureCount).append(";\n");
    }
    sb.append("}");

    return sb.toString();
}
项目:rbcgj-2016    文件:Spinor.java   
@Override public String toString() {
  StringBuilder result = new StringBuilder();
  float radians = angle();
  result.append("radians: ");
  result.append(radians);
  result.append(", degrees: ");
  result.append(radians * MathUtils.radiansToDegrees);
  return result.toString();
}
项目:Argent    文件:ShaderForm.java   
private DynamicShader.Info read(String name) throws IOException {
    File dir = new File("shaders/");
    if (!dir.exists()) dir.mkdir();

    File file = new File("shaders/" + name + ".shader");
    List<String> lines = Files.readAllLines(file.toPath());
    StringBuilder sb = new StringBuilder();
    lines.forEach(sb::append);
    String json = sb.toString();
    DynamicShader.Info info = Argent.serial.deserialize(json, DynamicShader.Info.class);
    System.out.println(info);
    return info;
}
项目:cachebox3.0    文件:Validate_UnusedSvgFiles.java   
@Override
public void runValidation() {

    FileHandle svgFolder = validationSkin.skinFolder.child("svg");
    FileHandle[] files = svgFolder.list();

    ObjectMap<java.lang.String, ScaledSvg> registed = validationSkin.getAll(ScaledSvg.class);

    Array<String> neadedList = new Array<String>();
    for (ScaledSvg scaledSvg : registed.values()) {
        neadedList.add(scaledSvg.path);
    }

    Array<String> svgList = new Array<String>();
    for (FileHandle file : files) {
        svgList.add("svg/" + file.name());
    }

    for (String test : neadedList) {
        svgList.removeValue(test, true);
    }

    StringBuilder warnMassageBuilder = new StringBuilder();
    if (svgList.size > 0) {
        warnMassageBuilder.append("Unused *.svg files : \n\n");
        for (String unusedFile : svgList) {
            warnMassageBuilder.append(unusedFile);
            warnMassageBuilder.append("\n");
        }
        warnMsg = warnMassageBuilder.toString();
    }

}
项目:cachebox3.0    文件:ThreadStackTest.java   
@Test
void runTest() {
    if (EXCLUDE_FROM_TRAVIS.VALUE) return;
    synchronized (TestIsRunning) {
        StringBuilder stringBuilder = new StringBuilder();

        ThreadStack<TestCancelRunnable> runnables = new ThreadStack<TestCancelRunnable>();
        TestCancelRunnable runnable = new TestCancelRunnable(stringBuilder, "SingleRunnable");

        runnables.pushAndStart(runnable);

        sleep(1000);

        //wait for ready with work
        int testCount = 0;
        while (!runnables.isReadyAndEmpty()) {
            sleep(10);
            testCount++;
        }

        System.out.println("TestCount:" + testCount);
        System.out.print(stringBuilder.toString());
        System.out.flush();


        StringBuilder testStringBuilder = new StringBuilder();
        testStringBuilder.append("Start Runnable SingleRunnable\n");
        testStringBuilder.append("Finish Runnable SingleRunnable\n\n");

        assertThat("Threat must start and finish", testStringBuilder.equals(stringBuilder));
    }
}
项目:fabulae    文件:PCSelector.java   
private String buildSkillInfo(Skills characterSkills) {
    StringBuilder fsb = StringUtil.getFSB();
    for (int i = 0; i < skills.size; ++i) {
        Skill skill = skills.get(i);
        fsb.append(skill.toUIString());
        fsb.append(": ");
        fsb.append(characterSkills.getSkillRank(skill));
        if (i < skills.size -1) {
            fsb.append(", ");
        }
    }
    String returnValue = fsb.toString();
    StringUtil.freeFSB(fsb);
    return returnValue;
}
项目:fabulae    文件:UseInventoryItemAction.java   
@Override
public void update(float deltaTime) {
    if (usable == null && itemId != null) {
        // TODO: this probably needs fixing for world maps?
        usable = (UsableItem) InventoryItem.getItem(itemId);
        effectTarget = usable.getTargetTypeInstance(user);
        effectTarget.setTarget((int)targetX, (int)targetY, user.getMap());
    }
    if (!isFinished) {
        if (!itemUseInProgress) {
            Array<ConditionResult> results = usable.canBeUsedBy(user);
            if (!Condition.areResultsOk(results)) {
                StringBuilder fsb = StringUtil.getFSB();
                for (ConditionResult result : results) {
                    if (!result.passed) {
                        fsb.append(result.conditionName);
                        fsb.append(", ");
                    }
                }
                String failedConditions = fsb.substring(0, fsb.lastIndexOf(", "));
                StringUtil.freeFSB(fsb);
                Log.logLocalized("cannotUseItem", LogType.INVENTORY, user.getName(),
                        usable.getName(), failedConditions);
                isFinished = true;
                return;
            }
            if (user.getMap() == null || user.canSeeTile((int)effectTarget.getTargetX(), (int)effectTarget.getTargetY())) {
                useItem();
            } else {
                moveTo(deltaTime);
            }
        } else {
            if (user.isAnimationFinished()) {
                user.setState(State.IDLE);
                isFinished = true;
            }
        }
    }
}