Package org.geoforge.guillcogceclgsi.panel

Source Code of org.geoforge.guillcogceclgsi.panel.GfrPnlMainWwdOgcManEclGsiMovObjs

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.geoforge.guillcogceclgsi.panel;

import gov.nasa.worldwind.event.SelectEvent;
import gov.nasa.worldwind.event.SelectListener;
import gov.nasa.worldwind.geom.LatLon;
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.layers.Layer;
import gov.nasa.worldwind.pick.PickedObject;
import gov.nasa.worldwind.util.BasicDragger;
import java.awt.event.ActionListener;
import java.awt.geom.Point2D;
import java.util.ArrayList;
import java.util.logging.Logger;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldatecl.*;
import org.geoforge.worldwind.animation.ViewController;
import org.geoforge.worldwind.layer.*;
import org.geoforge.worldwindecl.layer.*;

/**
*
* @author robert
*/
public class GfrPnlMainWwdOgcManEclGsiMovObjs extends GfrPnlMainWwdOgcManEclGsi implements
        SelectListener
{
   // ----
    // begin: instantiate logger for this class
    final private static Logger _LOGGER_ = Logger.getLogger(GfrPnlMainWwdOgcManEclGsiMovObjs.class.getName());

    static
    {
        GfrPnlMainWwdOgcManEclGsiMovObjs._LOGGER_.addHandler(FileHandlerLogger.s_getInstance());
    }

    // end: instantiate logger for this class
    // ----
  
  
   private ViewController _vcrViewController_;
   private BasicDragger dragger = null;
  
   private Layer _lyrDragged_ = null;
  
   public GfrPnlMainWwdOgcManEclGsiMovObjs() throws Exception
   {
      super(
              (ActionListener) null, //alrController
              false // blnIsSerializableStateOrbit
              );
     
      this._vcrViewController_ = new ViewController(super._cnv);
      dragger = new BasicDragger(super._cnv);
      super._cnv.addSelectListener((SelectListener) this);
   }
  
   @Override
   public void destroy()
   {
      this.dragger = null;
      this._lyrDragged_ = null;
      super._cnv.removeSelectListener((SelectListener) this);
     
      super.destroy();
   }

   @Override
   public void selected(SelectEvent evtSelect)
   {
      this.dragger.selected(evtSelect);
     
      if (evtSelect.getEventAction().equals(SelectEvent.DRAG))
      {
         _vcrViewController_.sceneChanged();
        
         if (this._lyrDragged_ != null)
            return;
        
         java.util.List<PickedObject> lstPickedObjects = evtSelect.getAllTopPickedObjects();
        
         if (lstPickedObjects!=null && !lstPickedObjects.isEmpty())
         {
            for (PickedObject potCur:lstPickedObjects )
            {
               Layer lyrCur = potCur.getParentLayer();

               if (lyrCur == null)
                  continue;
              
               this._lyrDragged_ = lyrCur;
              
               // hide label if any
              
               if (this._lyrDragged_ instanceof GfrRlrObjTloRndSngPntAbs)
               {
                  ((GfrRlrObjTloRndSngPntAbs) this._lyrDragged_).setVisibleAnnotation(false);
               }
              
               else if (this._lyrDragged_ instanceof GfrRlrObjTloRndMltAbs)
               {
                  ((GfrRlrObjTloRndMltAbs) this._lyrDragged_).setVisibleAnnotation(false);
               }
              
               else if (this._lyrDragged_ instanceof GfrRlrObjTloRndSngSurfaceAbs)
               {
                  ((GfrRlrObjTloRndSngSurfaceAbs) this._lyrDragged_).setVisibleAnnotation(false);
               }
              
               else
               {
                  // tbrls
                  System.err.println(">> started dragging tbrls: lyrCur.getClass().toString()=" + lyrCur.getClass().toString());
               }

               break;  
            }
         }
        
         // ---
         return;
      }
     
      if (evtSelect.getEventAction().equals(SelectEvent.DRAG_END))
      {
        
         // show label if any, should be invokedLater!
              
         if (this._lyrDragged_ instanceof GfrRlrObjTloRndSngPntAbs)
         {
            ((GfrRlrObjTloRndSngPntAbs) this._lyrDragged_).setVisibleAnnotation(true);
         }

         else if (this._lyrDragged_ instanceof GfrRlrObjTloRndMltAbs)
         {
            ((GfrRlrObjTloRndMltAbs) this._lyrDragged_).setVisibleAnnotation(true);
         }

         else if (this._lyrDragged_ instanceof GfrRlrObjTloRndSngSurfaceAbs)
         {
            ((GfrRlrObjTloRndSngSurfaceAbs) this._lyrDragged_).setVisibleAnnotation(true);
         }

         else
         {
            System.err.println(">> stopped dragging, tbrls: this._lyrDragged.getClass().toString()=" + this._lyrDragged_.getClass().toString());
         }
        
         _updateGeometry_(this._lyrDragged_);
        
         this._lyrDragged_ = null;
        
         // ---
         return;
      }
   }
  
   private void _updateGeometry_(Layer lyr)
   {
      try
      {
         if (! (lyr instanceof GfrRlrObjTloAbs))
         {
            GfrPnlMainWwdOgcManEclGsiMovObjs._LOGGER_.warning("Uncaught instanceof lyr: " + lyr.getClass().getName());
            return;
         }
        
         GfrRlrObjTloAbs rlrGfr = (GfrRlrObjTloAbs) lyr;
         String strId = rlrGfr.getIdObjectGeoforgeWwdEarth();
        
         if (lyr instanceof GfrRlrObjTloRndMltPntCircleAbs)
         {
            ArrayList<Position> altPos = ((GfrRlrObjTloRndMltPntCircleAbs) lyr).getPositionsRenderableObjects();
           
            // beg ecl
            if (lyr instanceof GfrRlrObjTloRndMltPntCircleSpn)
            {
               GfrMdlDatIdObjTloEclSpn.getInstance().changeGeometry(strId, altPos);
               return;
            }
            // end ecl
           
            // beg gsi
            // end gsi
         }
        
         if (lyr instanceof GfrRlrObjTloRndSngSurfaceAbs)
         {
            Iterable<? extends LatLon> itrLatLon = ((GfrRlrObjTloRndSngSurfaceAbs) lyr).getLocationsRenderableObject();
            ArrayList<Point2D.Double> altPoint2d = new ArrayList<Point2D.Double>();
           
            for (LatLon llnCur: itrLatLon)
            {
               Point2D.Double p2dCur = new Point2D.Double();
               p2dCur.x = llnCur.longitude.degrees;
               p2dCur.y = llnCur.latitude.degrees;
               altPoint2d.add(p2dCur);
            }
           
           
            // beg ecl
            if (lyr instanceof GfrRlrObjTloRndSngSurfaceSectorSct)
            {
               GfrMdlDatIdObjTloEclSct.getInstance().changeGeometry(strId, altPoint2d);
               return;
            }
           
            if (lyr instanceof GfrRlrObjTloRndSngSurfacePolygonAre)
            {
               GfrMdlDatIdObjTloEclAre.getInstance().changeGeometry(strId, altPoint2d);
               return;
            }
           
            if (lyr instanceof GfrRlrObjTloRndSngSurfaceLineSegWiseYesEcl)
            {
               GfrMdlDatIdObjTloEclSegWiseYes.getInstance().changeGeometry(strId, altPoint2d);
               return;
            }
           
            if (lyr instanceof GfrRlrObjTloRndSngSurfacePolylinePth)
            {
               GfrMdlDatIdObjTloEclPth.getInstance().changeGeometry(strId, altPoint2d);
               return;
            }
            // end ecl
           
            GfrPnlMainWwdOgcManEclGsiMovObjs._LOGGER_.warning("uncaught instanceof GfrRlrShpTloSingleAbs: " + lyr.getClass().getName());
            return;
         }
        
         if (lyr instanceof GfrRlrObjTloRndSngPntAbs)
         {
            Position posNew = ((GfrRlrObjTloRndSngPntAbs) lyr).getPositionRenderableObject();
            Point2D.Double dou = new Point2D.Double();
            dou.x = posNew.longitude.degrees;
            dou.y = posNew.latitude.degrees;
        
            // beg ecl
            if (lyr instanceof GfrRlrObjTloRndSngPntPnt)
            {
               GfrMdlDatIdObjTloEclPnt.getInstance().changeGeometry(strId, dou);
               return;
            }
           
            if (lyr instanceof GfrRlrObjTloRndSngPntPlc)
            {
               GfrMdlDatIdObjTloEclPlc.getInstance().changeGeometry(strId, dou);
               return;
            }
            // end ecl
           
            // beg gsi
            // end gsi
           
           
            GfrPnlMainWwdOgcManEclGsiMovObjs._LOGGER_.warning("uncaught instanceof GfrRlrPptSinglePointAbs: " + lyr.getClass().getName());
            return;
         }
        
         GfrPnlMainWwdOgcManEclGsiMovObjs._LOGGER_.warning("uncaught instanceof GfrRlrAbs: " + lyr.getClass().getName());
      }
     
      catch(Exception exc)
      {
         exc.printStackTrace();
      }
   }
}
TOP

Related Classes of org.geoforge.guillcogceclgsi.panel.GfrPnlMainWwdOgcManEclGsiMovObjs

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.