RE: [OpenMap Users] Left Click Menu for Mouse Click on OMLine and Passing of OMLine specific values to a JPanel to display

From: Gatrell, Mark (UK) <"Gatrell,>
Date: Tue, 25 Jan 2005 07:10:37 +0000

Hi Klaus
            If youre graphics layer has in turn extended a OMGraphicsHandlerLayer, you can use the existing mode listener methods to transfer data to your jpanel. Something like this :-


// **********************************************************************
//
// <copyright>
//
// BBN Technologies, a Verizon Company
// 10 Moulton Street
// Cambridge, MA 02138
// (617) 873-8000
//
// Copyright (C) BBNT Solutions LLC. All rights reserved.
//
// </copyright>
// **********************************************************************
//
// $Source: C:\\CVSMapping/openmap/src/com/bbn/openmap/layer/BAElayer.java,v $
// $RCSfile: BAElayer.java,v $
// $Revision: 1.1.1.1 $
// $Date: 2004/02/06 12:41:05 $
// $Author: Mark $
//
// **********************************************************************

package com.baesystems.mapping.demo;

/**
 * This layer has extended the OpenMap OMGraphicHandlerLayer to place various
 * Icons on the map
 */

public class BAElayer extends com.bbn.openmap.layer.OMGraphicHandlerLayer implements ActionListener,
                MapMouseListener
{



    ////////////////////////////###mouse stuff ############

    ////////////////////////
    // Mouse Listener events
    ////////////////////////

    /**
     * Returns self as the <code>MapMouseListener</code> in order to receive
     * <code>MapMouseEvent</code>s. If the implementation would prefer to
     * delegate <code>MapMouseEvent</code>s, it could return the delegate
     * from this method instead.
     *
     * _at_return MapMouseListener this
     */
    public MapMouseListener getMapMouseListener ()
    {
        return this;
    }


    /**
     * Return a list of the modes that are interesting to the MapMouseListener.
     * The source MouseEvents will only get sent to the MapMouseListener if the
     * mode is set to one that the listener is interested in. Layers interested
     * in receiving events should register for receiving events in "select"
     * mode. <code>
     * <pre>
     * return new String[1] { SelectMouseMode.modeID };
     * </pre>
     * <code>
     * _at_see NavMouseMode#modeID
     * _at_see SelectMouseMode#modeID
     * _at_see NullMouseMode#modeID
     */
    public String[] getMouseModeServiceList ()
    {
        return new String[] { SelectMouseMode.modeID };
    }


    /**
     * Invoked when a mouse button has been pressed on a component.
     *
     * _at_param e MouseEvent
     * _at_return true if the listener was able to process the event.
     */
    public boolean mousePressed (MouseEvent e)
    {

        return true;
    }


    /**
     * Invoked when a mouse button has been released on a component.
     *
     * _at_param e MouseEvent
     * _at_return true if the listener was able to process the event.
     */
    public boolean mouseReleased (MouseEvent e)
    {

        return true;
    }


    /**
     * Invoked when the mouse has been clicked on a component. The listener will
     * receive this event if it successfully processed
     * <code>mousePressed()</code>, or if no other listener processes the
     * event. If the listener successfully processes mouseClicked(), then it
     * will receive the next mouseClicked() notifications that have a click
     * count greater than one.
     *
     * _at_param e MouseListener MouseEvent to handle.
     * _at_return true if the listener was able to process the event.
     */
    public boolean mouseClicked (MouseEvent e)
    {
        // find the closest target icon


       
        if (e.getModifiers() == Integer.parseInt( StaticValues.ALT_RIGHT_BUTTON.toString() ))// test
        // for
        // alt
        // +
        // right
        // click
        {
            OMGraphicList MainGraphicList = (OMGraphicList) getList(); // grab
            // the
            // main
            // list
           
            // bae
            // list
            OMGraphic selectedOmGraphic = ((OMGraphicList) getList()).findClosest( e.getX(), e.getY(), 4 );
            if (selectedOmGraphic != null)
            // Determine what list the object belongs to
            {
                // Test your list First
               
                OMGraphicList BaeGraphicList = (OMGraphicList) MainGraphicList.getOMGraphicWithAppObject( ListName );// find
               
                for (int i = 0 ; i < BaeGraphicList.size() ;i++)
                {
                    String selectedObjectName = selectedOmGraphic.getAppObject().toString() ;
                    String listName = BaeGraphicList.getOMGraphicAt(i).getAppObject().toString() ;
                    if (selectedObjectName.equals (listName) )
                    {
                        BaeOMText localOmGraphic;
                        localOmGraphic = (BaeOMText) selectedOmGraphic ;
               
                                               
                        TargetDetailPopUpWindow newTargetDetailPopUpWindow = new TargetDetailPopUpWindow();
                        newTargetDetailPopUpWindow.setModal( true );
                        newTargetDetailPopUpWindow.show();
                        // populate the display
                        newTargetDetailPopUpWindow.jlNodeName.setText(selectedObjectName );
                        newTargetDetailPopUpWindow.Wgs84LatitudeValue.setText(String.valueOf( localOmGraphic.getLat()));
                        newTargetDetailPopUpWindow.Wgs84LongitudeValue.setText(String.valueOf( localOmGraphic.getLon()));
                        String osgb36Position[] = new String[2];
                        osgb36Position=(localOmGraphic.getObjectOSGB36Position());
                        newTargetDetailPopUpWindow.Osgb36NorthingsValue.setText(osgb36Position[0] );
                        newTargetDetailPopUpWindow.Osgb36EastingsValue.setText(osgb36Position[1]);
                        newTargetDetailPopUpWindow.eventLevelValue.setText(String.valueOf(localOmGraphic.getEventValue() ));
                        newTargetDetailPopUpWindow.eventTimeValue.setText(localOmGraphic.getEventTime() );
                    }
                }
               
               
            }

        }
        return true;
    }


    /**
     * Invoked when the mouse enters a component.
     *
     * _at_param e MouseListener MouseEvent to handle.
     */
    public void mouseEntered (MouseEvent e)
    {

    }


    /**
     * Invoked when the mouse exits a component.
     *
     * _at_param e MouseListener MouseEvent to handle.
     */
    public void mouseExited (MouseEvent e)
    {

    }


    // Mouse Motion Listener events
    ///////////////////////////////

    /**
     * Invoked when a mouse button is pressed on a component and then dragged.
     * The listener will receive these events if it successfully processes
     * mousePressed(), or if no other listener processes the event.
     *
     * _at_param e MouseMotionListener MouseEvent to handle.
     * _at_return true if the listener was able to process the event.
     */
    public boolean mouseDragged (MouseEvent e)
    {

        return true;
    }


    /**
     * Invoked when the mouse button has been moved on a component (with no
     * buttons no down).
     *
     * _at_param e MouseListener MouseEvent to handle.
     * _at_return true if the listener was able to process the event.
     */
    public boolean mouseMoved (MouseEvent e)
    {
        return true;
    }


    /**
     * Handle a mouse cursor moving without the button being pressed. This event
     * is intended to tell the listener that there was a mouse movement, but
     * that the event was consumed by another layer. This will allow a mouse
     * listener to clean up actions that might have happened because of another
     * motion event response.
     */
    public void mouseMoved ()
    {

    }


    /**
     * _at_param listName
     * _at_param ObjectName
     * _at_return
     */
    private OMGraphic GetObjectFromList (Object listName, String ObjectName)
    {
        OMGraphicList MainGraphicList = (OMGraphicList) getList(); // grab
        // the
        // main
        // list
        OMGraphicList BaeGraphicList = (OMGraphicList) MainGraphicList.getOMGraphicWithAppObject( listName );// find
        // bae
        // list

        return BaeGraphicList.getOMGraphicWithAppObject( ObjectName );
    }


}


Hope it helps

Regards


Mark.



-----Original Message-----
From: owner-openmap-users_at_bbn.com [mailto:owner-openmap-users_at_bbn.com]On Behalf Of Klaus, Erich P.
Sent: 24 January 2005 16:19
To: openmap-users_at_bbn.com
Subject: [OpenMap Users] Left Click Menu for Mouse Click on OMLine and Passing of OMLine specific values to a JPanel to display


*** WARNING *** This mail has originated outside your organization, either from an external partner or the Global Internet. Keep this in mind if you answer this message.

Hello,



I have an instance of a class I extended; an OMLine with extra member variables. It's name is MyOMLine for simplicity.



I need to have a JPanel Displayed with information a MyOMLine object when a user "left-clicks" on it in the map.



Do I create a new Mouse Mode?



A) I'd like to do as little modifications as possible.



B) I need to have a response to the left click.



C) I need to pass MyOMLine member variable values to the JPanel displayed.



Thanks for any ideas,



Erich Klaus





********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

--
[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 Jan 25 2005 - 02:11:49 EST

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