Package org.geoforge.guillcogc.panel

Source Code of org.geoforge.guillcogc.panel.GfrPnlMainWwdOgcSecMovObjAbs

/*
*  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.guillcogc.panel;

import gov.nasa.worldwind.event.SelectEvent;
import gov.nasa.worldwind.event.SelectListener;
import gov.nasa.worldwind.layers.Layer;
import gov.nasa.worldwind.pick.PickedObject;
import gov.nasa.worldwind.util.BasicDragger;
import org.geoforge.guillc.wwd.util.OurToolTipControllerSecMovObjs;
import org.geoforge.guillcogc.wwd.rlrs.GfrSetRlrTopSecOgcWmss;
import org.geoforge.io.serial.GfrSerializeStateWwdSec;
import org.geoforge.worldwind.animation.ViewController;
import org.geoforge.worldwind.layer.GfrRlrObjTloRndMltAbs;
import org.geoforge.worldwind.layer.GfrRlrObjTloRndSngPntAbs;
import org.geoforge.worldwind.layer.GfrRlrObjTloRndSngSurfaceAbs;
import org.geoforge.worldwind.util.GfrCtrMenContextAbs;

/**
*
* @author bantchao
*/

abstract public class GfrPnlMainWwdOgcSecMovObjAbs extends GfrPnlMainWwdOgcAbs implements
        SelectListener
{
   private String _strIdViewer_ = null;
   private ViewController _vcrViewController_;
   private BasicDragger _bdrDragger_ = null;
   private Layer _lyrDragged_ = null;
  
   abstract protected void _updateGeometry(Layer lyr);
  
   protected GfrPnlMainWwdOgcSecMovObjAbs(String strIdViewerSource) throws Exception
   {
      super(
              (GfrCtrMenContextAbs) null, // object
              (GfrCtrMenContextAbs) null, // void
              false // blnIsSerializableStateOrbit
              );

      this._strIdViewer_ = strIdViewerSource;
     
      super._topWmss = new GfrSetRlrTopSecOgcWmss(super._cnv, strIdViewerSource);
     
      super._ctrTooltip = new OurToolTipControllerSecMovObjs(this._cnv);
     
      this._vcrViewController_ = new ViewController(super._cnv);
      this._bdrDragger_ = new BasicDragger(super._cnv);
      super._cnv.addSelectListener((SelectListener) this);
   }
  
   @Override
   public void selected(SelectEvent evtSelect)
   {
      this._bdrDragger_.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
               {
                  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;
      }
   }
  
    @Override
   public void destroy()
   {
      this._bdrDragger_ = null;
      this._lyrDragged_ = null;
      super._cnv.removeSelectListener((SelectListener) this);
     
      super.destroy();
   }
   
    @Override
    public boolean init()
    {
       if (! super.init())
            return false;
       
        String strState = GfrSerializeStateWwdSec.s_read(this._strIdViewer_);

       if (strState != null)
       {
         super.restoreStateOrbitView(strState);
       }

        return true;
    }
}
TOP

Related Classes of org.geoforge.guillcogc.panel.GfrPnlMainWwdOgcSecMovObjAbs

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.