code: protected Point getTextBasePoint(String text, double xCoord, double yCoord, Graphics2D graphics) {
          FontMetrics fontMetrics = graphics.getFontMetrics();
          Rectangle2D stringBounds = fontMetrics.getStringBounds(text, graphics);
          int[] point = this.transformPoint(xCoord, yCoord);
          int baseX = (int) (point[0] - (stringBounds.getWidth() / 2));
  
          // correct the baseline by the ascent
          int baseY = (int) (point[1] + (fontMetrics.getAscent() - stringBounds.getHeight() / 2));
          return new Point(baseX, baseY);
      }
docs: Calculates the base point where text should be rendered, as text in Java
  is typically placed using the left-lower corner point in screen coordinates.
  However, because the Java coordinate system is inverted in the y-axis with
  respect to scientific coordinate systems (Java has 0,0 in the top left
  corner, while in science we have 0,0 in the lower left corner), some
  special action is needed, involving the size of the text.
  
  @param text     the text string
  @param xCoord   the world x-coordinate of where the text should be placed
  @param yCoord   the world y-coordinate of where the text should be placed
  @param graphics the graphics to which the text is provided as output
  @return         the screen coordinates