Exemple #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));
 }
Exemple #2
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 #3
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()));
 }