public void actionPerformed(ActionEvent e) {
JFrame frame = JmeClientMain.getFrame().getFrame();
// Form a placemark with the current position about the avatar's
// location.
Placemark placemark = getCurrentPlacemark(sessionManager);
// Fetch the list of known USER Placemark names
PlacemarkRegistry registry =
PlacemarkRegistryFactory.getInstance();
Set<Placemark> placemarkSet =
registry.getAllPlacemarks(PlacemarkType.USER);
// Display a dialog with the values in the Placemark. And if we
// wish to update the values, then re-add the placemark.
// (Re-adding the placemark should have the effect of updating
// its values.
AddEditPlacemarkJDialog dialog = new AddEditPlacemarkJDialog(
frame, true, placemark, placemarkSet);
dialog.setTitle(BUNDLE.getString("Add_Placemark"));
dialog.setLocationRelativeTo(frame);
dialog.pack();
dialog.setVisible(true);
if (dialog.getReturnStatus() ==
AddEditPlacemarkJDialog.RET_OK) {
// Create a new placemark with the new information.
String name = dialog.getPlacemarkName();
String url = dialog.getServerURL();
float x = dialog.getLocationX();
float y = dialog.getLocationY();
float z = dialog.getLocationZ();
float angle = dialog.getLookAtAngle();
ColorRGBA backColor = dialog.getBackgroundColor();
ColorRGBA textColor = dialog.getTextColor();
String imageURL = dialog.getImageURL();
String message = dialog.getMessage();
Placemark newPlacemark = new Placemark(name, url, x, y, z, angle,
backColor, textColor, imageURL, message);
try {
PlacemarkUtils.addUserPlacemark(newPlacemark);
} catch (Exception excp) {
LOGGER.log(Level.WARNING, "Unable to add " + name +
" to user's placemarks", excp);
return;
}
// Tell the client-side registry of placemarks that a new
// one has been added
registry.registerPlacemark(newPlacemark, PlacemarkType.USER);
}
}
});
// Menu item to take avatar to starting location
startingLocationMI = new JMenuItem(BUNDLE.getString("Starting_Location"));
startingLocationMI.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Vector3f position = new Vector3f();
Quaternion look = new Quaternion();
String prop = System.getProperty("Placemark.CoverScreen");
if(prop == null) {
prop="";
}
if(!prop.equalsIgnoreCase("off")) {
if(!(ClientContextJME.getViewManager()
.getPrimaryViewCell().getWorldTransform().getTranslation(null).x==position.x &&
ClientContextJME.getViewManager()
.getPrimaryViewCell().getWorldTransform().getTranslation(null).z==position.z)) {
Placemark pl = new Placemark("", sessionManager.getServerURL()
, position.x, position.y, position.z, 0);
if(systemPlacemarkMenuItems!=null && systemPlacemarkMenuItems.keySet()!=null) {
Iterator<Placemark> sysItr = systemPlacemarkMenuItems.keySet().iterator();
while(sysItr.hasNext()) {
Placemark p = sysItr.next();
if(p.getX()==0 && p.getZ()==0) {
pl = p;
}
}
}