示例#1
0
 static void aligntext(Graphics g, String text, Coord c, double ax, double ay) {
   java.awt.FontMetrics m = g.getFontMetrics();
   java.awt.geom.Rectangle2D ts = m.getStringBounds(text, g);
   g.drawString(
       text, (int) (c.x - ts.getWidth() * ax), (int) (c.y + m.getAscent() - ts.getHeight() * ay));
 }
示例#2
0
 static Coord textsz(Graphics g, String text) {
   java.awt.FontMetrics m = g.getFontMetrics();
   java.awt.geom.Rectangle2D ts = m.getStringBounds(text, g);
   return (new Coord((int) ts.getWidth(), (int) ts.getHeight()));
 }