Java Code Examples for com.badlogic.gdx.utils.StringBuilder#toString()

The following examples show how to use com.badlogic.gdx.utils.StringBuilder#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExportData.java    From talos with Apache License 2.0 6 votes vote down vote up
@Override
public String toString () {
    StringBuilder stringBuilder = new StringBuilder();

    stringBuilder.append(name);
    stringBuilder.append("\n");

    for (AbstractModule module : modules) {
        stringBuilder.append("\t");
        stringBuilder.append("ModuleID: ");
        stringBuilder.append(module.getIndex());
        stringBuilder.append("\n");
    }

    stringBuilder.append("\n");
    for (ConnectionData connection : connections) {
        stringBuilder.append("\t");
        stringBuilder.append("Connection: ");
        stringBuilder.append(connection);
        stringBuilder.append("\n");
    }

    return stringBuilder.toString();
}
 
Example 2
Source File: DialogSceneComposerJavaBuilder.java    From skin-composer with MIT License 6 votes vote down vote up
private static String alignmentToName(int align) {
    StringBuilder buffer = new StringBuilder(13);
    if ((align & Align.top) != 0)
        buffer.append("top");
    else if ((align & Align.bottom) != 0)
        buffer.append("bottom");
    else {
        if ((align & Align.left) != 0)
            buffer.append("left");
        else if ((align & Align.right) != 0)
            buffer.append("right");
        else
            buffer.append("center");
        return buffer.toString();
    }
    if ((align & Align.left) != 0)
        buffer.append("Left");
    else if ((align & Align.right) != 0)
        buffer.append("Right");
    return buffer.toString();
}
 
Example 3
Source File: PlayDataAccessor.java    From beatoraja with GNU General Public License v3.0 6 votes vote down vote up
private String getScoreHash(ScoreData 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.getTrophy() + "," + 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;
}
 
Example 4
Source File: PlayDataAccessor.java    From beatoraja with GNU General Public License v3.0 6 votes vote down vote up
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) {
			for(int i = 0;i < CourseDataConstraint.values().length;i++) {
				if(c == CourseDataConstraint.values()[i]) {
					sb.append(String.format("%02d", i + 1));
					break;
				}
			}
		}
	}
	return this.getReplayDataFolder() + File.separatorChar
			+ (ln ? replay[lnmode] : "") + hash + (sb.length() > 0 ? "_" + sb.toString() : "")
			+ (index > 0 ? "_" + index : "");
}
 
Example 5
Source File: TXT.java    From riiablo with Apache License 2.0 6 votes vote down vote up
private static String[] split(int len, String str, char token) {
  StringBuilder builder = new StringBuilder(32);
  String[] tokens = new String[len];
  char c;
  int numTokens = 0;
  final int strLen = str.length();
  for (int i = 0; i < strLen; i++) {
    c = str.charAt(i);
    if (c == token) {
      tokens[numTokens++] = builder.toString();
      builder.setLength(0);
    } else {
      builder.append(c);
    }
  }
  if (numTokens < len) Arrays.fill(tokens, numTokens, len, StringUtils.EMPTY);
  return tokens;
}
 
Example 6
Source File: SHA1.java    From libgdx-snippets with MIT License 6 votes vote down vote up
@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();
}
 
Example 7
Source File: DungeonUtils.java    From gdx-ai with Apache License 2.0 6 votes vote down vote up
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();
}
 
Example 8
Source File: JsonFloatSerializer.java    From libgdx-snippets with MIT License 5 votes vote down vote up
public static String encodeFloatBits(float value) {

		StringBuilder builder = stringBuilder.get();

		builder.setLength(0);
		builder.append("0x");
		builder.append(String.format("%08X", Float.floatToRawIntBits(value)));
		builder.append("|");
		builder.append(value);

		return builder.toString();
	}
 
Example 9
Source File: JsonFloatSerializer.java    From libgdx-snippets with MIT License 5 votes vote down vote up
public static String encodeDoubleBits(double value) {

		StringBuilder builder = stringBuilder.get();

		builder.setLength(0);
		builder.append("0x");
		builder.append(String.format("%016X", Double.doubleToRawLongBits(value)));
		builder.append("|");
		builder.append(value);

		return builder.toString();
	}
 
Example 10
Source File: Spinor.java    From box2dlights with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 11
Source File: Tools.java    From gdx-proto with Apache License 2.0 5 votes vote down vote up
public static String fmt(MeshPartBuilder.VertexInfo vi, String name) {
	if (name == null) name = "";
	StringBuilder sb = new StringBuilder();
	sb.append("VertexInfo: ").append(name).append("\n");
	sb.append("\t").append(fmt(vi.position, "position")).append("\n");
	sb.append("\t").append(fmt(vi.color)).append("\n");
	sb.append("\t").append(fmt(vi.normal, "normal"));
	return sb.toString();
}
 
Example 12
Source File: Dialogs.java    From vis-ui with Apache License 2.0 4 votes vote down vote up
private static String getStackTrace (Throwable throwable) {
	StringBuilder builder = new StringBuilder();
	getStackTrace(throwable, builder);
	return builder.toString();
}
 
Example 13
Source File: TextFileUtils.java    From libgdx-snippets with MIT License 3 votes vote down vote up
public static String readString(FileHandle file) throws IOException {

		StringBuilder builder = new StringBuilder((int) file.length());

		readLines(file, line -> {

			if (builder.length() > 0) {
				builder.append('\n');
			}

			builder.append(line);
		});

		return builder.toString();
	}