Hello Harpreet,
If your layer is receiving and processing mouse events then you can do
something like this:-
/**
**************************************************************************
* The popup menu for the right click on the plot point
*/
private JPopupMenu popup = null;
.
.
.
In the constructor ...
// Build the popup menu for this layer //
popup = new JPopupMenu(); //
Create the layer popup
JMenuItem deleteItem = new JMenuItem("Delete Symbol"); //
Create a Delete menu item
deleteItem.addActionListener(new ActionListener() { //
Create its action listener
public void actionPerformed(ActionEvent evt) { //
deleteItemAction(evt); //
Execute the method
} //
}); //
popup.add(deleteItem); //
Add item to popup menu
.
.
.
public boolean mouseClicked(MouseEvent e) { /////////////////////////
mouseClicked()
//
if ((e.getSource() instanceof MapBean) == false) //
If not from a MapBean
return true; //
Then return
//
Context.debug(getClick(e)); //
Debug mouseClicked
//
characteriseClick(e); //
Figure out the click type
//
// If there is any marqueed symbol then remove the marquee. //
if (marqueed >= 0) { //
If have marqueed one
drawMarquee(marqueed, e.getX(), e.getY()); //
Remove marquee
marqueed = -1; //
Flag none marqueed
} //
if (vanillaClick && rightClick && (gList.size() > 0)) { //
If popup and have symbols
thisIcon = null; thisText = null; //
Nothing selected
thisIndex = findNearest(e.getX(), e.getY(), clickRange); //
Find nearest symbol
if (thisIndex != OMGraphicList.NONE) { //
If found one
netINFO.setStatus("Selected symbol " + thisIndex); //
Update status
thisIcon = (OMRaster)gList.getOMGraphicAt(thisIndex); //
Get icon reference
thisText = (OMText)tList.getOMGraphicAt(thisIndex); // Get
caption reference
popup.show(e.getComponent(), e.getX(), e.getY()); // Bring
up popup
} //
} //
So this bit of code in the mouse event handler just looks for a right
click to activate the popup menu. From there it's down to the menu item
action event handler to implement whatever you want to do.
You can plot anything you like. You just need to relate the click point to
whatever is one the map in some way. In the code above I look for an item
in an OMGraphicList that is within range of the click. In this case I have
two lists, one holding images and one holding text labels.
Hope that helps,
with best regards,
Adrian
_____________________________________________
Adrian Lumsden
Product Specialist
Scientific Software and Systems Limited
Tel: +64 4 917-6680 (direct)
+64 4 917-6670 (reception)
Fax: +64 4 917-6671
E-mail: Adrian.Lumsden@sss.co.nz
Visit us on the Web at: http://www.sss.co.nz
_____________________________________________
This e-mail passed SSS's content security scan.
It is covered by the confidentiality clauses at
http://www.sss.co.nz/content_and_confidentiality
Harpreet <harpreet@logiceastern.com>
Sent by: owner-openmap-users@bbn.com
27/11/03 17:56
To: openmap-users@bbn.com
cc:
Subject: [OpenMap Users] popupmenus for my iamges?????????
hi there
i am making a layer that will plot some images(ImageIcon) on the openmap
on the basis of lat/lon using OMGraphics and when a right click is made on
the image a popup menu shoild appear....
i know this can also be done with the CSVLocationHandler class and the
Gestures mode, but......,the problem part is that in the gestures mode
there are 2 types of popupmenus one is set city locs and other on the
panel area
now wut i want to know from u is that in my class how can i set the popup
for the images(ImageIcon), as there is no such event for images
pls tell me wut approach should i follow
guide me if there are any such API's in ur application
or should i plot something other than a iamge
pls guide me in some simple steps
if any of you have done anything in related to this then pls give some
tips
thanxxx
Harpreet
-- [To unsubscribe to this list send an email to "majdart@bbn.com" with the following text in the BODY of the message "unsubscribe openmap-users"]Received on Thu Nov 27 15:21:05 2003
This archive was generated by hypermail 2.1.8 : Thu May 12 2005 - 07:18:37 EDT