/** * @param c the character to get the width of * @return the width of the provided character in pixels */ public static int getCharacterWidth(char c) { if(c >= '\u2588' && c <= '\u258F') { return ('\u258F' - c) + 2; } switch(c) { case ' ': return 4; case '\u2714': return 8; case '\u2718': return 7; default: MapFont.CharacterSprite mcChar = MinecraftFont.Font.getChar(c); if(mcChar != null) return mcChar.getWidth() + 1; return 0; } }
public void drawText(int x, int y, MapFont font, String text) { int xStart = x; byte color = MapPalette.DARK_GRAY; if (!font.isValid(text)) { throw new IllegalArgumentException("text contains invalid characters"); } for (int i = 0; i < text.length(); ++i) { char ch = text.charAt(i); if (ch == '\n') { x = xStart; y += font.getHeight() + 1; continue; } else if (ch == '\u00A7') { int j = text.indexOf(';', i); if (j >= 0) { try { color = Byte.parseByte(text.substring(i + 1, j)); i = j; continue; } catch (NumberFormatException ex) {} } } CharacterSprite sprite = font.getChar(text.charAt(i)); for (int r = 0; r < font.getHeight(); ++r) { for (int c = 0; c < sprite.getWidth(); ++c) { if (sprite.get(r, c)) { setPixel(x + c, y + r, color); } } } x += sprite.getWidth() + 1; } }
public void drawText(MapCanvas canvas, int x, int y, int width, int height, MapFont font, String text, byte color) { int xStart = x; if(!font.isValid(text)) throw new IllegalArgumentException("text contains invalid characters"); for(int i = 0; i < text.length(); i++) { char ch = text.charAt(i); if(ch == '\n') { x = xStart; y += font.getHeight() + 1; continue; } if(ch == COLOR_CHAR) { int j = text.indexOf(';', i); if(j >= 0) try { color = Byte.parseByte(text.substring(i + 1, j)); i = j; continue; } catch(NumberFormatException ex) { } } org.bukkit.map.MapFont.CharacterSprite sprite = font.getChar(text.charAt(i)); for(int r = 0; r < font.getHeight(); ++r) for(int c = 0; c < sprite.getWidth(); ++c) for(int xx = 0; xx < width; xx++) for(int yy = 0; yy < height; yy++) if(sprite.get(r, c)) canvas.setPixel(x + xx + c * width, y + yy + r * height, color); x += (sprite.getWidth() + 1) * width; } }
@SuppressWarnings("deprecation") public void drawText(int x, int y, MapFont font, String text) { int xStart = x; byte color = MapPalette.DARK_GRAY; if (!font.isValid(text)) { throw new IllegalArgumentException("text contains invalid characters"); } for (int i = 0; i < text.length(); ++i) { char ch = text.charAt(i); if (ch == '\n') { x = xStart; y += font.getHeight() + 1; continue; } else if (ch == '\u00A7') { int j = text.indexOf(';', i); if (j >= 0) { try { color = Byte.parseByte(text.substring(i + 1, j)); i = j; continue; } catch (NumberFormatException ex) {} } } CharacterSprite sprite = font.getChar(text.charAt(i)); for (int r = 0; r < font.getHeight(); ++r) { for (int c = 0; c < sprite.getWidth(); ++c) { if (sprite.get(r, c)) { setPixel(x + c, y + r, color); } } } x += sprite.getWidth() + 1; } }
public void drawText(Byte[][] canvas, int x, int y, int width, int height, MapFont font, String text, byte color) { int xStart = x; if(!font.isValid(text)) throw new IllegalArgumentException("text contains invalid characters"); for(int i = 0; i < text.length(); i++) { char ch = text.charAt(i); if(ch == '\n') { x = xStart; y += font.getHeight() + 1; continue; } if(ch == COLOR_CHAR) { int j = text.indexOf(';', i); if(j >= 0) try { color = Byte.parseByte(text.substring(i + 1, j)); i = j; continue; } catch(NumberFormatException ex) { } } org.bukkit.map.MapFont.CharacterSprite sprite = font.getChar(text.charAt(i)); for(int r = 0; r < font.getHeight(); ++r) for(int c = 0; c < sprite.getWidth(); ++c) for(int xx = 0; xx < width; xx++) for(int yy = 0; yy < height; yy++) if(sprite.get(r, c)) { int absX = x + xx + c * width; int absY = y + yy + r * height; if(canvas.length > absX && canvas[absX].length > absY) canvas[absX][absY] = color; } x += (sprite.getWidth() + 1) * width; } }
public static void drawTextOld(MapCanvas canvas, int x, int y, int width, int height, MapFont font, String text) { int xStart = x; byte color = MapPalette.DARK_GRAY; /* String text = ""; for(char c : rawText.toCharArray()) if(MinecraftFont.Font.getChar(c) != null) text += c;*/ if(!MinecraftFont.Font.isValid(text)) return; for (int i = 0; i < text.length(); ++i) { char ch = text.charAt(i); if (ch == '\n') { x = xStart; y += font.getHeight() + 1; continue; } else if (ch == '§') { int j = text.indexOf(';', i); if (j >= 0) try { color = Byte.parseByte(text.substring(i + 1, j)); i = j; continue; } catch (NumberFormatException ex) { } } CharacterSprite sprite = font.getChar(text.charAt(i)); for(int r = 0; r < font.getHeight(); ++r) for(int c = 0; c < sprite.getWidth(); ++c) for(int xx = 0; xx < width; xx++) for(int yy = 0; yy < height; yy++) if(sprite.get(r, c)) canvas.setPixel(x + xx + c * width, y + yy + r * height, color); x += (sprite.getWidth() + 1) * width; } }
public static void drawTextOld(Byte[][] canvas, int x, int y, int width, int height, MapFont font, String text) { int xStart = x; byte color = MapPalette.DARK_GRAY; /* String text = ""; for(char c : rawText.toCharArray()) if(MinecraftFont.Font.getChar(c) != null) text += c;*/ if(!MinecraftFont.Font.isValid(text)) return; for (int i = 0; i < text.length(); ++i) { char ch = text.charAt(i); if (ch == '\n') { x = xStart; y += font.getHeight() + 1; continue; } else if (ch == '§') { int j = text.indexOf(';', i); if (j >= 0) try { color = Byte.parseByte(text.substring(i + 1, j)); i = j; continue; } catch (NumberFormatException ex) { } } CharacterSprite sprite = font.getChar(text.charAt(i)); for (int r = 0; r < font.getHeight(); ++r) for (int c = 0; c < sprite.getWidth(); ++c) for (int xx = 0; xx < width; xx++) for (int yy = 0; yy < height; yy++) if (sprite.get(r, c)) { int absX = x + xx + c * width; int absY = y + yy + r * height; if(canvas.length > absX && canvas[absX].length > absY) canvas[absX][absY] = color; } x += (sprite.getWidth() + 1) * width; } }
@Override public void drawText(int x, int y, MapFont font, String text) { throw new NotImplementedException("TODO"); }
public MapFont() { }
public void setChar(char ch, MapFont.CharacterSprite sprite) { }
public MapFont.CharacterSprite getChar(char ch) { return null; }
void drawText(int x, int y, MapFont font, String text);