public void text(double x,double y,String s){
  offscreen.setFont(font);
  FontMetrics metrics=offscreen.getFontMetrics();
  double xs=scaleX(x);
  double ys=scaleY(y);
  int ws=metrics.stringWidth(s);
  int hs=metrics.getDescent();
  offscreen.drawString(s,(float)(xs - ws / 2.0),(float)(ys + hs));
  draw();
}

public void text ( double x , double y , String s ) { offscreen . setFont ( font ) ; FontMetrics metrics = offscreen . getFontMetrics ( ) ; double xs = scaleX ( x ) ; double ys = scaleY ( y ) ; int ws = metrics . stringWidth ( s ) ; int hs = metrics . getDescent ( ) ; offscreen . drawString ( s , ( float ) ( xs - ws / 2.0 ) , ( float ) ( ys + hs ) ) ; draw ( ) ; }
writes the given text string in the current font , centered on ( x , y ) .
