Package org.geoforge.guillcogcecl.wwd.rlrs

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

/*
*  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.GfrMdlDatSetTlosEclPnt;
import org.geoforge.worldwind.layer.GfrRlrObjTloAbs;
import org.geoforge.worldwindecl.layer.GfrRlrObjTloRndSngPntPnt;
import org.geoforge.wrpbasprssynecl.GfrWrpBasTopSynEclPnts;

/**
*
* @author bantchao
*/
abstract public class GfrSetRlrTopMainPntsAbs extends GfrSetRlrTopMainLclAbs
{
   // ----
    // begin: instantiate logger for this class
    final private static Logger _LOGGER_ = Logger.getLogger(GfrSetRlrTopMainPntsAbs.class.getName());

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

    // end: instantiate logger for this class
    // ----
   
   protected GfrSetRlrTopMainPntsAbs(WorldWindowGLCanvas cnv)
   {
      super(cnv);
     
      GfrMdlDatSetTlosEclPnt.getInstance().addObserver((Observer) this);
   }
  
   @Override
   public void addAllObjects() throws Exception
   {
      String[] strsUniqueId = GfrWrpBasTopSynEclPnts.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 GfrRlrObjTloRndSngPntPnt))
             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 GfrRlrObjTloRndSngPntPnt))
               continue;

         String strIdCur = ((GfrRlrObjTloAbs) lyrCur).getIdObjectGeoforgeWwdEarth();


         if (strIdCur.compareTo(strId) != 0)
               continue;

         // bug
         String str = "already loaded: " + strId;
         GfrSetRlrTopMainPntsAbs._LOGGER_.warning(str);
         return null;
      }


      // ----
      GfrRlrObjTloAbs lyr = new GfrRlrObjTloRndSngPntPnt(
               (PropertyChangeListener) this,
               strId);

      if (! lyr.init())
      {
         String str = "! lyr.init()";
         GfrSetRlrTopMainPntsAbs._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()
    {
       GfrMdlDatSetTlosEclPnt.getInstance().deleteObserver((Observer) this);
       super.destroy();
    }
}
TOP

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

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.