code: protected void positionRectIdeally (Rectangle r, int type, Point speaker)
      {
          if (speaker != null) {
              // center it on top of the speaker (it'll be moved..)
              r.setLocation(speaker.x - (r.width / 2),
                            speaker.y - (r.height / 2));
              return;
          }
  
          // otherwise we have different areas for different types
          Rectangle vbounds = _target.getViewBounds();
          switch (ChatLogic.placeOf(type)) {
          case ChatLogic.INFO:
          case ChatLogic.ATTENTION:
              // upper left
              r.setLocation(vbounds.x + BUBBLE_SPACING,
                            vbounds.y + BUBBLE_SPACING);
              return;
  
          case ChatLogic.PLACE:
              log.warning("Got to a place where I shouldn't get!");
              break; // fall through
          }
  
          // put it in the center..
          log.debug("Unhandled chat type in getLocation()", "type", type);
          r.setLocation((vbounds.width - r.width) / 2,
                        (vbounds.height - r.height) / 2);
      }
docs: Position the rectangle in its ideal location given the type and speaker positon (which may
  be null).