/*
* Copyright (C) 2011-2014 GeoForge Project
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.geoforge.guillcogcecl.wwd.util;
import gov.nasa.worldwind.avlist.AVList;
import gov.nasa.worldwind.event.SelectEvent;
import java.awt.Component;
import java.awt.event.ActionListener;
import java.util.logging.Logger;
import org.geoforge.guillc.enumeration.GfrEnuValuesKindTargetWindow;
import org.geoforge.guillc.popupmenu.GfrPmuCtlDspWwdAbs;
import org.geoforge.guillc.wwd.util.GfrCtrMenContextObjectSecRunAbs;
import org.geoforge.guillcogcecl.popupmenu.*;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.worldwind.handler.IGfrHandlerWwdEarthObjectGeoforgeAbs;
import org.geoforge.worldwind.render.GfrKeysRnd;
import org.geoforge.worldwindecl.render.*;
/**
*
* @author bill
*/
public class GfrCtrMenContextObjectSecRunOgcEcl extends GfrCtrMenContextObjectSecRunAbs
{
// ----
// begin: instantiate logger for this class
final private static Logger _LOGGER_ = Logger.getLogger(GfrCtrMenContextObjectSecRunOgcEcl.class.getName());
static
{
GfrCtrMenContextObjectSecRunOgcEcl._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
}
// end: instantiate logger for this class
// ----
public GfrCtrMenContextObjectSecRunOgcEcl(
ActionListener alrController,
String strIdViewer)
{
super(alrController, strIdViewer);
}
@Override
protected void _showContextextualMenu(SelectEvent evt) throws Exception
{
Object objTopWwd = evt.getTopObject();
if (! (objTopWwd instanceof AVList))
{
return;
}
AVList lstTopWwd = (AVList) objTopWwd;
Object objHasContext = lstTopWwd.getValue(GfrKeysRnd.STR_HAS_CONTEXTUAL_MENU);
if (objHasContext == null)
return;
Boolean booHasContextMenu = (Boolean) objHasContext;
if (! booHasContextMenu.booleanValue())
return;
GfrPmuCtlDspWwdAbs pop = null;
if (lstTopWwd instanceof GfrRndSurfaceSectorTloSct)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclSct(super._alrController, strId,
GfrEnuValuesKindTargetWindow.VIEWER_TOP_WORLDWIND.name());
}
else if (lstTopWwd instanceof GfrRndSurfacePolygonTloAre)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclAre(super._alrController, strId,
GfrEnuValuesKindTargetWindow.VIEWER_TOP_WORLDWIND.name());
}
else if (lstTopWwd instanceof GfrRndSurfacePolylineWisNoTloPth)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclPth(super._alrController, strId,
GfrEnuValuesKindTargetWindow.VIEWER_TOP_WORLDWIND.name());
}
else if (lstTopWwd instanceof GfrRndSurfaceSegmentWiseYesTloEcl)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclSegWiseYes(super._alrController, strId,
GfrEnuValuesKindTargetWindow.VIEWER_TOP_WORLDWIND.name());
}
else if (lstTopWwd instanceof GfrRndPointPlacemarkPushpinTloPlc)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclPlc(super._alrController, strId,
GfrEnuValuesKindTargetWindow.VIEWER_TOP_WORLDWIND.name());
}
else if (lstTopWwd instanceof GfrRndPointPlacemarkCircleLloSpn)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclSpn(super._alrController, strId,
GfrEnuValuesKindTargetWindow.VIEWER_TOP_WORLDWIND.name());
}
else if (lstTopWwd instanceof GfrRndPointPlacemarkCircleTloPnt)
{
String strId = ((IGfrHandlerWwdEarthObjectGeoforgeAbs) lstTopWwd).getIdObjectGeoforgeWwdEarth();
pop = new GfrPmuCtlDspWwdTloEclPnt(super._alrController, strId,
GfrEnuValuesKindTargetWindow.VIEWER_TOP_WORLDWIND.name());
}
else
{
String str = "Uncaught instanceof lstTopWwd: " + lstTopWwd.getClass().toString();
GfrCtrMenContextObjectSecRunOgcEcl._LOGGER_.severe(str);
throw new Exception(str);
}
if (! pop.init())
{
String str = "! pop.init()";
GfrCtrMenContextObjectSecRunOgcEcl._LOGGER_.severe(str);
throw new Exception(str);
}
Component cmpSource = (Component) evt.getSource();
pop.show(cmpSource, evt.getMouseEvent().getX(), evt.getMouseEvent().getY());
}
}