Package org.geoforge.guillcogcecl.wwd.rlrs

Source Code of org.geoforge.guillcogcecl.wwd.rlrs.GfrSetRlrTopSecEclSpns

/*
*  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 2
*  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, write to the Free Software
*  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/
package org.geoforge.guillcogcecl.wwd.rlrs;

import gov.nasa.worldwind.awt.WorldWindowGLCanvas;
import gov.nasa.worldwind.layers.Layer;
import gov.nasa.worldwind.layers.LayerList;
import java.beans.PropertyChangeListener;
import java.util.Observer;
import java.util.logging.Logger;
import org.geoforge.guillc.wwd.rlrs.GfrSetRlrTopSecLclAbs;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldatecl.GfrMdlDatSetTlosEclSpn;
import org.geoforge.worldwind.layer.GfrRlrObjTloAbs;
import org.geoforge.worldwindecl.layer.GfrRlrObjTloRndMltPntCircleSpn;
import org.geoforge.wrpbasprsdsp.state.multiple.run.GfrWrpBasPrsDspPrjObjSecMltTogCbx;
import org.geoforge.wrpbasprsdsp.state.singleton.selecttlo.GfrWrpObjSttSngSelTlo;
import org.geoforge.wrpbasprssynecl.GfrWrpBasTopSynEclSpns;

/**
*
* @author bantchao
*
* email: bantchao_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*
*/
public class GfrSetRlrTopSecEclSpns extends GfrSetRlrTopSecLclAbs
{
   // ----
    // begin: instantiate logger for this class
    final private static Logger _LOGGER_ = Logger.getLogger(GfrSetRlrTopSecEclSpns.class.getName());

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

    // end: instantiate logger for this class
    // ----
   
   public GfrSetRlrTopSecEclSpns(WorldWindowGLCanvas cnv, String strIdViewer)
   {
      super(cnv, strIdViewer);
     
      GfrMdlDatSetTlosEclSpn.getInstance().addObserver((Observer) this);
   }
  
  
  
   @Override
   public void addAllObjects() throws Exception
   {
      String[] strsUniqueId = GfrWrpBasTopSynEclSpns.getInstance().getIdsTlo();

      if (strsUniqueId == null || strsUniqueId.length < 1)
         return;
     
      for (int i=0; i<strsUniqueId.length; i++)
      {
         Object objCur = addObjectVariable(strsUniqueId[i]);
      }
    
   }
  
  
   @Override
   public void removeAllObjects() throws Exception
   {
      LayerList llt = super._cnv.getModel().getLayers();
       
      for (Layer lyrCur: llt)
      {
         if (! (lyrCur instanceof GfrRlrObjTloRndMltPntCircleSpn))
             continue;

         GfrRlrObjTloAbs rlrCur = (GfrRlrObjTloAbs) lyrCur;
         llt.remove(rlrCur);
         rlrCur.removeAllRenderables();
         rlrCur.destroy();
      }
    
   }

   @Override
   public Object addObjectVariable(String strId) throws Exception
   {     
      LayerList llt = super._cnv.getModel().getLayers();
       
        for (Layer lyrCur: llt)
        {
            if (! (lyrCur instanceof GfrRlrObjTloRndMltPntCircleSpn))
                continue;
           
            String strIdCur = ((GfrRlrObjTloAbs) lyrCur).getIdObjectGeoforgeWwdEarth();

           
            if (strIdCur.compareTo(strId) != 0)
                continue;
           
            // bug
            String str = "already loaded: " + strId;
            GfrSetRlrTopSecEclSpns._LOGGER_.warning(str);
            return null;
        }


        // ----
        GfrRlrObjTloAbs lyr = new GfrRlrObjTloRndMltPntCircleSpn(
                (PropertyChangeListener) this,
                strId);
       
        if (! lyr.init())
        {
           String str = "! lyr.init()";
            GfrSetRlrTopSecEclSpns._LOGGER_.severe(str);
            throw new Exception(str);
        }
       
        llt.add(lyr);
       
        if (! GfrWrpObjSttSngSelTlo.getInstance().isEnabled(strId))
        {
            lyr.setEnabled(false);
            return lyr;
        }
       
        if (! GfrWrpBasPrsDspPrjObjSecMltTogCbx.getInstance().isEnabled(super._strIdViewer, strId))
        {
            lyr.setEnabled(false);
            return lyr;
        }
       
        // ending
        return lyr;
   }

  

   @Override
    public void destroy()
    {
       GfrMdlDatSetTlosEclSpn.getInstance().deleteObserver((Observer) this);
       super.destroy();
    }
}
TOP

Related Classes of org.geoforge.guillcogcecl.wwd.rlrs.GfrSetRlrTopSecEclSpns

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.