Please don't take this the wrong way, but after studying your code, I've come up with a more efficient, easy-to-read method:
@Override
public void onPaint(Graphics arg0) {
Graphics2D g = (Graphics2D) arg0;
if (currentTab() == Tab.INVENTORY)
drawInventory(g);
else if (currentTab() == Tab.EQUIPMENT)
drawEquipment(g);
}
public void drawInventory(Graphics2D arg0) {
int i = 0;
for (Item next : client.getInventory().getItems()) {
if (next != null)
drawString(arg0,
String.valueOf(next.getId()),
client.getInventory().getDestinationForSlot(i));
i++;
}
}
public void drawEquipment(Graphics2D arg0) {
for (Item next : equipmentTab.getItems())
if (next != null)
drawString(arg0,
String.valueOf(next.getId()),
client.getInterface(387).getChild(equipmentTab.getSlotForId(next.getId())
.childId).getRectangle());
}
public void drawString(Graphics2D arg0, String arg1, Rectangle arg2) {
if (arg0 == null || arg1 == null || arg1.length() == 0 || arg2 == null
|| arg2.width <= 0 || arg2.height <= 0)
return; // No point painting...
FontMetrics fm = arg0.getFontMetrics();
Point p = new Point(
(int) (arg2.x + (arg2.width - fm.stringWidth(arg1)) / 2),
(int) (arg2.y + (arg2.height - fm.getHeight())));
arg0.setColor(Color.YELLOW);
arg0.draw(arg2);
arg0.setColor(Color.BLACK);
arg0.drawString(arg1, p.x - 2, p.y - 2);
arg0.drawString(arg1, p.x - 2, p.y + 2);
arg0.drawString(arg1, p.x + 2, p.y - 2);
arg0.drawString(arg1, p.x + 2, p.y + 2);
arg0.setColor(Color.YELLOW);
arg0.drawString(arg1, p.x, p.y);
}