Package org.geoforge.guillcogcecl.wwd.rlrs

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

/*
*  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.util.Observable;
import java.util.Observer;
import java.util.logging.Logger;
import org.geoforge.guillc.frame.GfrFrmAbs;
import org.geoforge.guillc.optionpane.GfrOptionPaneAbs;
import org.geoforge.guillc.panel.GfrPnlStatusBarMain;
import org.geoforge.worldwind.layer.GfrRlrObjTloAbs;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.mdldsp.event.state.singleton.selecttlo.GfrEvtMdlSttSngSelTlo;
import org.geoforge.mdldsp.state.singleton.selecttlo.GfrMdlSttSngSelTlo;
import org.geoforge.worldwindecl.layer.GfrRlrObjTloRndSngPntPlc;
import org.geoforge.wrpbasprsdsp.state.singleton.selecttlo.GfrWrpObjSttSngSelTlo;

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

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

    // end: instantiate logger for this class
    // ----
   
   public GfrSetRlrTopMainPlcsSel(WorldWindowGLCanvas cnv)
   {
      super(cnv);
     
      GfrMdlSttSngSelTlo.getInstance().addObserver((Observer) this);
   }
  
   @Override
    public void destroy()
    {
       GfrMdlSttSngSelTlo.getInstance().deleteObserver((Observer) this);
       super.destroy();
    }
  
   @Override
   public void update(Observable obs, Object objEvt)
   {
      try
      {
         if (objEvt instanceof GfrEvtMdlSttSngSelTlo)
         {
            GfrEvtMdlSttSngSelTlo evt = (GfrEvtMdlSttSngSelTlo) objEvt;
            String strId = evt.getKey();
            boolean bln = evt.getValue();
            _selectObject_(strId, bln);
            // ending
            return;
         }
      }
      catch (Exception exc)
      {
         exc.printStackTrace();
         String str = exc.getMessage();
         GfrSetRlrTopMainPlcsSel._LOGGER_.severe(str);
         GfrOptionPaneAbs.s_showDialogError(GfrFrmAbs.s_getFrameOwner(GfrPnlStatusBarMain.s_getInstance()), str);
         return;
      }

      super.update(obs, objEvt);
   }
  
   @Override
   public Object addObjectVariable(String strId) throws Exception
   {  
      Object obj = super.addObjectVariable(strId);
     
      if (obj == null)
         return null;
     
      boolean bln = GfrWrpObjSttSngSelTlo.getInstance().isEnabled(strId);
     
      if (bln)
         return obj;
     
      GfrRlrObjTloAbs lyr = (GfrRlrObjTloAbs) obj;
      lyr.setEnabled(false);
     
      return obj;
   }
  
   private boolean _selectObject_(String strId, boolean bln) throws Exception
   {     
      LayerList llt = super._cnv.getModel().getLayers();
       
        for (Layer lyrCur: llt)
        {
            if (! (lyrCur instanceof GfrRlrObjTloRndSngPntPlc))
                continue;
           
            String strIdCur = ((GfrRlrObjTloAbs) lyrCur).getIdObjectGeoforgeWwdEarth();

           
            if (strIdCur.compareTo(strId) != 0)
                continue;
           
            if (bln && lyrCur.isEnabled())
               return false;
           
            if (!bln && !lyrCur.isEnabled())
               return false;
           
            lyrCur.setEnabled(bln);
           
            if (_cnv != null)
                   _cnv.redraw();
            return true;
        }


        return false;
   }
}
TOP

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

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.