RE: [OpenMap Users] pop up text (over map location)

From: Chris Hopkins <chopkins_at_cra.com>
Date: Mon, 9 Aug 2004 16:51:29 -0400

Hi Ben -

Here is what we have done for tooltips. Now that you are dealing with mouse
clicks, implement the mouseMoved method similar to this:

  /**
   * We implement this so that we can display tooltips for the various
   * assets. We display information like name, altitude, type and role
   * for each asset.
   *
   * _at_param e a <code>MouseEvent</code> value
   * _at_return a <code>boolean</code> value
   */
  public boolean mouseMoved(MouseEvent e)
  {
    OMGraphic omgr = findClosest(DEFAULT_GRAPHICS, e.getX(), e.getY(),
2.0f);

    if(omgr != null)
    {
      Object ob = omgr.getAppObject();
      if(ob == null)
      {
        return false;
      }

      if(ob instanceof Entity)
      {
        String text = null;
        Entity entity = (Entity)ob;
        Object userOb = entity.getUserObject();
        if(userOb != null && userOb instanceof TooltipProvider)
        {
          text = ((TooltipProvider)userOb).getTooltipText(entity);
        }

        if(text == null)
        {
          StringBuffer buf = new StringBuffer("");
          buf.append("<html>");
          buf.append("Name = ");
          buf.append(entity.getName());
          buf.append("<br>");
          buf.append("Initial Altitude = ");
          buf.append(entity.getLocation().getAltitude().getValue());
          buf.append("<br>");
          buf.append("Type = ");
// buf.append(DisplaySettings.getDisplayName(t.getTypeName()));
          buf.append(entity.getEntityType().getName());
          buf.append("</html>");

          text = buf.toString();
        }

        fireRequestToolTip(text);
        return true;
      }
    }
    else
    {
      fireHideToolTip();
    }

    return false;
  }

The findClosest method is just our convenience method for the findClosest
method of the OMGraphicList (we maintain a hash table of OMGraphicList
objects for each of our layers). The key here is the call to the
fireRequestToolTip method (you can ignore the building of the tooltip in the
above example as this is specific to our implementation). This fires off a
timed tooltip that displays when you hover over a graphic. The nice thing
about this is that you can use HTML to display multi-line tooltips.

Feel free to plunder the above code.

  - Chris

> -----Original Message-----
> From: Ben Podoll [mailto:benjamin.podoll_at_und.edu]
> Sent: Monday, August 09, 2004 4:25 PM
> To: openmap-users_at_bbn.com
> Subject: [OpenMap Users] pop up text (over map location)
>
>
> Now that I have been able to capture mouse clicks on
> locations on the map,
> how do I go about getting a tooltip of sorts when a click
> occurs? Do I just
> have to implement a tooltip on the screen near the location
> of my cursor? Or
> is there a API already in place for this sort of thing?
>
> And to further the question, what about a tooltip (without
> clicking)? Is
> there a method to set a tooltip for a graphic?
>
>
> --
> [To unsubscribe to this list send an email to "majdart_at_bbn.com"
> with the following text in the BODY of the message
> "unsubscribe openmap-users"]
>
--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Mon Aug 09 2004 - 16:52:24 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:05 EDT