@Override public int preProcessForLength(@Nonnull final String text, final int offset) { int index = offset; colorValueParser.isColor(text, index); while (colorValueParser.isColor()) { index = colorValueParser.getNextIndex(); if (index >= text.length()) { return index; } colorValueParser.isColor(text, index); } return index; } }
public boolean isColor(@Nonnull final String text, final int startIdx) { if (text.startsWith("\\#", startIdx)) { int endIdx = text.indexOf('#', startIdx + 2); if (endIdx != -1) { setResult(text.substring(startIdx + 1, endIdx), endIdx + 1); return isColor; } } setNoResult(); return false; }
@Override public int preProcess(@Nonnull final String text, final int offset) { int index = offset; colorValueParser.isColor(text, index); while (colorValueParser.isColor()) { final Color color = colorValueParser.getColor(); assert color != null; textColor.setRed(color.getRed()); textColor.setGreen(color.getGreen()); textColor.setBlue(color.getBlue()); textColor.setAlpha(color.getAlpha()); hasColor = true; index = colorValueParser.getNextIndex(); if (index >= text.length()) { return index; } colorValueParser.isColor(text, index); } return index; }
public ColorValueParser() { setNoResult(); }
colorValueParser.isColor(text, i); while (colorValueParser.isColor()) { Color color = colorValueParser.getColor(); assert color != null; GL11.glColor4f(color.getRed(), color.getGreen(), color.getBlue(), alpha); i = colorValueParser.getNextIndex(); if (i >= text.length()) { break; colorValueParser.isColor(text, i);
colorValueParser.isColor(text, i); while (colorValueParser.isColor()) { Color color = colorValueParser.getColor(); assert color != null; GL11.glColor4f(color.getRed(), color.getGreen(), color.getBlue(), alpha); i = colorValueParser.getNextIndex(); if (i >= text.length()) { break; colorValueParser.isColor(text, i);
private int getStringWidthInternal(@Nonnull final String text, final float size) { int length = 0; for (int i = 0; i < text.length(); i++) { colorValueParser.isColor(text, i); if (colorValueParser.isColor()) { i = colorValueParser.getNextIndex(); if (i >= text.length()) { break; } } char currentCharacter = text.charAt(i); char nextCharacter = FontHelper.getNextCharacter(text, i); int w = getCharacterWidth(currentCharacter, nextCharacter, size); if (w != -1) { length += w; } } return length; }
colorValueParser.isColor(text, i); while (colorValueParser.isColor()) { Color color = colorValueParser.getColor(); assert color != null; gl.glColor4f(color.getRed(), color.getGreen(), color.getBlue(), alpha); i = colorValueParser.getNextIndex(); if (i >= text.length()) { break; colorValueParser.isColor(text, i);
private int getStringWidthInternal(@Nonnull final String text, final float size) { int length = 0; for (int i = 0; i < text.length(); i++) { colorValueParser.isColor(text, i); if (colorValueParser.isColor()) { i = colorValueParser.getNextIndex(); if (i >= text.length()) { break; } } char currentCharacter = text.charAt(i); char nextCharacter = FontHelper.getNextCharacter(text, i); int w = getCharacterWidth(currentCharacter, nextCharacter, size); if (w != -1) { length += w; } } return length; }
/** * @param text text * @param size size * @return length */ private int getStringWidthInternal(@Nonnull final String text, final float size) { int length = 0; for (int i = 0; i < text.length(); i++) { colorValueParser.isColor(text, i); if (colorValueParser.isColor()) { i = colorValueParser.getNextIndex(); if (i >= text.length()) { break; } } char currentCharacter = text.charAt(i); char nextCharacter = FontHelper.getNextCharacter(text, i); length += getCharacterWidth(currentCharacter, nextCharacter, size); } return length; }