Package org.geoforge.guillcogcecl.wwd.rlrs

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

/*
*  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.GfrSetRlrTopMainLclAbs;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldatecl.GfrMdlDatSetTlosEclSegWiseYes;
import org.geoforge.worldwind.layer.GfrRlrObjTloAbs;
import org.geoforge.worldwindecl.layer.GfrRlrObjTloRndSngSurfaceLineSegWiseYesEcl;
import org.geoforge.wrpbasprssynecl.GfrWrpBasTopSynEclSegsWiseYes;

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

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

    // end: instantiate logger for this class
    // ----
   
   protected GfrSetRlrTopMainSegsWiseYesAbs(WorldWindowGLCanvas cnv)
   {
      super(cnv);
     
      GfrMdlDatSetTlosEclSegWiseYes.getInstance().addObserver((Observer) this);
   }
  
   @Override
   public void addAllObjects() throws Exception
   {
      String[] strsUniqueId = GfrWrpBasTopSynEclSegsWiseYes.getInstance().getIdsTlo();

      if (strsUniqueId == null || strsUniqueId.length < 1)
         return;
     
      for (int i=0; i<strsUniqueId.length; i++)
      {
         addObjectVariable(strsUniqueId[i]);
      }
     
      javax.swing.SwingUtilities.invokeLater(new Runnable()
      {
            @Override
            public void run()
            {
               if (_cnv != null)
                  _cnv.redraw();
            }
      });
   }
  
  
   @Override
   public void removeAllObjects() throws Exception
   {
      LayerList llt = super._cnv.getModel().getLayers();
      boolean blnGotIt = false;
       
      for (Layer lyrCur: llt)
      {
         if (! (lyrCur instanceof GfrRlrObjTloRndSngSurfaceLineSegWiseYesEcl))
             continue;

         GfrRlrObjTloAbs rlrCur = (GfrRlrObjTloAbs) lyrCur;
         llt.remove(rlrCur);
         rlrCur.removeAllRenderables();
         rlrCur.destroy();
          blnGotIt = true;
      }
    
      if (! blnGotIt)
         return;
     
      javax.swing.SwingUtilities.invokeLater(new Runnable()
      {
            @Override
            public void run()
            {
               if (_cnv != null)
                  _cnv.redraw();
            }
      });
   }

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

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

        // ----
        GfrRlrObjTloAbs lyr = new GfrRlrObjTloRndSngSurfaceLineSegWiseYesEcl(
                (PropertyChangeListener) this,
                strId);
       
        if (! lyr.init())
        {
           String str = "! lyr.init()";
            GfrSetRlrTopMainSegsWiseYesAbs._LOGGER_.severe(str);
            throw new Exception(str);
        }
       
        llt.add(lyr);
       
        javax.swing.SwingUtilities.invokeLater(new Runnable()
            {
                @Override
                public void run()
                {
                   if (_cnv != null)
                      _cnv.redraw();
                }
            });
       
       
        return lyr;
   }

  

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

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

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.