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

The following examples show how to use com.badlogic.gdx.utils.StringBuilder#setLength() . 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: 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 2
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 3
Source File: IntValueLabel.java    From GdxDemo3D with Apache License 2.0 5 votes vote down vote up
@Override
public void act (float delta) {
	int newValue = getValue();
	if (oldValue != newValue) {
		oldValue = newValue;
		StringBuilder sb = getText();
		sb.setLength(appendIndex);
		sb.append(oldValue);
		invalidateHierarchy();
	}
	super.act(delta);
}
 
Example 4
Source File: FloatValueLabel.java    From GdxDemo3D with Apache License 2.0 5 votes vote down vote up
@Override
public void act (float delta) {
	float newValue = getValue();
	if (oldValue != newValue) {
		oldValue = newValue;
		StringBuilder sb = getText();
		sb.setLength(appendIndex);
		sb.append(oldValue);
		invalidateHierarchy();
	}
	super.act(delta);
}
 
Example 5
Source File: ObjectValueLabel.java    From GdxDemo3D with Apache License 2.0 5 votes vote down vote up
@Override
public void act (float delta) {
	T newValue = getValue();
	if (!oldValue.equals(newValue)) {
		copyValue(newValue, oldValue);
		StringBuilder sb = getText();
		sb.setLength(appendIndex);
		sb.append(oldValue);
		invalidateHierarchy();
	}
	super.act(delta);
}
 
Example 6
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 7
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 8
Source File: IntValueLabel.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
@Override
public void act (float delta) {
	int newValue = getValue();
	if (oldValue != newValue) {
		oldValue = newValue;
		StringBuilder sb = getText();
		sb.setLength(appendIndex);
		sb.append(oldValue);
		invalidateHierarchy();
	}
	super.act(delta);
}
 
Example 9
Source File: FloatValueLabel.java    From gdx-ai with Apache License 2.0 5 votes vote down vote up
@Override
public void act (float delta) {
	float newValue = getValue();
	if (oldValue != newValue) {
		oldValue = newValue;
		StringBuilder sb = getText();
		sb.setLength(appendIndex);
		sb.append(oldValue);
		invalidateHierarchy();
	}
	super.act(delta);
}
 
Example 10
Source File: BehaviorTreeViewer.java    From gdx-ai with Apache License 2.0 4 votes vote down vote up
private void updateStepLabel () {
	StringBuilder sb = stepLabel.getText();
	sb.setLength(LABEL_STEP.length());
	sb.append(step);
	stepLabel.invalidateHierarchy();
}