Exemple #1
0
 public static int drawtext(Graphics g, String text, Coord c) {
   java.awt.FontMetrics m = g.getFontMetrics();
   g.drawString(text, c.x, c.y + m.getAscent());
   return (m.getHeight());
 }
Exemple #2
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));
 }