[OpenMap Users] Adding OMText to Layer

From: Thomas Lepkowksi <javarun_at_gmail.com>
Date: Tue, 22 Mar 2005 13:57:25 -0500

Hello,

I have a Layer that works as expected, except for the part where I
want to display "Hello"
when the mouse is clicked. The mouseClicked method below prints "button"
on the console, but the OMText is not displayed on the map.

I have successfully changed the color of an existing OMGraphic
in another mouse even method, but I can't seem to add an OMGraphic to my
omgraphic list.

Can somebody give a tip on how to make the OMText be displayed?

Code snippet:

public class UnitLocationLayer extends Layer
        implements MapMouseListener {

... do stuff

        public boolean mouseClicked(MouseEvent e) {
            
            OMGraphic obj = omgraphics.findClosest(e.getX(), e.getY(), 4);
            
            if (obj != null) {
                    
                System.out.println("button");

                    // Display information

                    OMText textLabel = new OMText(30f, -80f, "Hello", MText.JUSTIFY_CENTER);
                    textLabel.setVisible(true);
                            
                // omgraphics is the global OMGraphicsList
                    omgraphics.add(textLabel);
                    repaint();
                            
            }

...
}

Thanks.
-Thomas

--
[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 Tue Mar 22 2005 - 14:07:34 EST

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