/** * @param g Graphics context. * @return the leading of the parsed text. */ public int getLeading(Graphics g) { if (g == null) return 0; parseText(g); return leading; }
/** * @param g Graphics context. * @return the maximum descent of the parsed text. */ public int getMaxDescent(Graphics g) { if (g == null) return 0; parseText(g); return maxDescent; }
/** * @param g Graphics context. * @return the ascent of the parsed text. */ public int getAscent(Graphics g) { if (g == null) return 0; parseText(g); return ascent; }
/** * Parse the text then draw it without any rotation. * * @param g Graphics context * @param x pixel position of the text * @param y pixel position of the text */ public void draw(Graphics g, int x, int y) { TextState ts; int xoffset = x; int yoffset = y; if (g == null || text == null) return; Graphics lg = g.create(); parseText(g); if (justification == CENTER) { xoffset = x - width / 2; } else if (justification == RIGHT) { xoffset = x - width; } if (background != null) { lg.setColor(background); lg.fillRect(xoffset, yoffset - ascent, width, height); lg.setColor(g.getColor()); } if (font != null) lg.setFont(font); if (color != null) lg.setColor(color); for (int i = 0; i < list.size(); i++) { ts = ((TextState) (list.elementAt(i))); if (ts.f != null) lg.setFont(ts.f); if (ts.s != null) lg.drawString(ts.toString(), ts.x + xoffset, ts.y + yoffset); } lg.dispose(); lg = null; }
/** * @param g Graphics context. * @return the height of the parsed text. */ public int getHeight(Graphics g) { parseText(g); return height; }
/** * @param g Graphics context. * @return the width of the parsed text. */ public int getWidth(Graphics g) { parseText(g); return width; }