Permalink
Browse files

vertically aligning texts

  • Loading branch information...
robert-virkus committed Mar 13, 2012
1 parent d6ca190 commit d24bf8ba20a24171eaf6fc4eeded4bf6df0ccc5c
@@ -392,6 +392,9 @@ public void drawString(String text, int textColor, int x, int y, int orientation
int textStart = 0;
int drawStart = 0;
+ int verticalDiff = (smileyHeight - super.getFontHeight()) / 2;
+
+
for (int index = 0; index < text.length(); index++) {
char hash = Character.toLowerCase(text.charAt(index));
ArrayList smileys = (ArrayList)smileyHash.get(hash);
@@ -402,7 +405,7 @@ public void drawString(String text, int textColor, int x, int y, int orientation
{
Smiley smiley = (Smiley)smileyMap.get(sequence.hashCode());
- g.drawSubstring(text, textStart, index - textStart, x + drawStart, y, orientation);
+ g.drawSubstring(text, textStart, index - textStart, x + drawStart, y + verticalDiff, orientation);
int textWidth = getFont().substringWidth(text, textStart, index - textStart);
@@ -421,7 +424,7 @@ public void drawString(String text, int textColor, int x, int y, int orientation
}
}
- g.drawSubstring(text, textStart, text.length() - textStart, x + drawStart, y, orientation);
+ g.drawSubstring(text, textStart, text.length() - textStart, x + drawStart, y + verticalDiff, orientation);
}
/**

0 comments on commit d24bf8b

Please sign in to comment.