Package org.geoforge.worldwindecl.render

Source Code of org.geoforge.worldwindecl.render.GfrRndSurfacePolylineWisNoTloPth

/*
*  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.worldwindecl.render;

import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.geom.Position;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.geoforge.worldwind.render.GfrRndSurfacePolylineWisNoTloAbs;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.java.lang.string.GfrUtlString;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatAddedLloVarImg;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatRemovedAllLloImgs;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatRemovedLloVarImg;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatRenamedLloVar;
import org.geoforge.mdldatecl.GfrMdlDatIdObjTloEclPth;
import org.geoforge.mdldspecl.render.wwd.GfrMdlDspRndWwdEarthShpDimOneLineEclPth;
import org.geoforge.worldwind.awt.annotation.GfrCtrAnnCntImgs;
import org.geoforge.worldwind.handler.IGfrHandlerPhotoAlbumRender;
import org.geoforge.wrpbasprssynecl.GfrWrpBasSynObjNameTloEclPth;

/**
*
* @author bgwilliams71
*
* email: bgwilliams71_AT_gmail.com
* ... please remove "_AT_" from the above string to get the right email address
*/
public class GfrRndSurfacePolylineWisNoTloPth extends GfrRndSurfacePolylineWisNoTloAbs implements
        IGfrHandlerPhotoAlbumRender
{
   // ----
   // begin: instantiate logger for this class

   final private static Logger _LOGGER_ = Logger.getLogger(GfrRndSurfacePolylineWisNoTloPth.class.getName());

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

   // end: instantiate logger for this class
   // ----
   public GfrRndSurfacePolylineWisNoTloPth(
           PropertyChangeListener lstShouldRedraw,
           String strId)
           throws Exception
   {
      super(lstShouldRedraw,
              strId,
              GfrWrpBasSynObjNameTloEclPth.getInstance().getName(strId),
              GfrWrpBasSynObjNameTloEclPth.getInstance().getGeometry(strId));

      GfrMdlDatIdObjTloEclPth.getInstance().addObserver((Observer) this);
      GfrMdlDspRndWwdEarthShpDimOneLineEclPth.getInstance().addObserver((Observer) this);

      // ---
      List<String> lstPathAbsImages = GfrWrpBasSynObjNameTloEclPth.getInstance().getPathAbsoluteImages(strId);
      HashMap<String, String> mapSourceToTitle = GfrWrpBasSynObjNameTloEclPth.getInstance().getMapPathAbsToNameImages(strId);

      _updateImagesAnnotation(lstPathAbsImages, mapSourceToTitle);
   }

   @Override
   public void destroy()
   {
      GfrMdlDatIdObjTloEclPth.getInstance().deleteObserver((Observer) this);
      GfrMdlDspRndWwdEarthShpDimOneLineEclPth.getInstance().deleteObserver((Observer) this);

      super.destroy();
   }

   @Override
   public void _clearImagesAnnotation_() throws Exception
   {
      super.setValue(AVKey.DATA_TYPE, "_void");
   }

   @Override
   public void _updateImagesAnnotation() throws Exception
   {
      _updateImagesAnnotation(
              GfrWrpBasSynObjNameTloEclPth.getInstance().getPathAbsoluteImages(super.getIdObjectGeoforgeWwdEarth()),
              GfrWrpBasSynObjNameTloEclPth.getInstance().getMapPathAbsToNameImages(super.getIdObjectGeoforgeWwdEarth()));
   }

   @Override
   public void _updateImagesAnnotation(
           List<String> lstPathAbsImages,
           HashMap<String, String> mapSourceToTitle) throws Exception
   {
      if (lstPathAbsImages == null || lstPathAbsImages.isEmpty())
      {
         _clearImagesAnnotation_();
         return;
      }

      if (mapSourceToTitle == null || mapSourceToTitle.isEmpty())
      {
         _clearImagesAnnotation_();
         return;
      }

      if (mapSourceToTitle.size() != mapSourceToTitle.size())
      {
         String strError = "mapSourceToTitle.size() != mapSourceToTitle.size()";
         GfrRndSurfacePolylineWisNoTloPth._LOGGER_.severe(strError);
         throw new Exception(strError);
      }

      String title = "dummy title";
      super.setValue(AVKey.DATA_TYPE, GfrCtrAnnCntImgs.IMAGES);
      super.setValue(AVKey.TITLE, title);
      super.setValue(AVKey.URL, (Object) lstPathAbsImages);
      super.setValue(GfrCtrAnnCntImgs.KEY_MAP_SOURCE_TO_TITLE, (Object) mapSourceToTitle);
   }

   @Override
   public void update(Observable obs, Object objEvt)
   {
      // beg images
      try
      {
         if (objEvt instanceof GfrEvtMdlIdDatRemovedLloVarImg)
         {
            GfrEvtMdlIdDatRemovedLloVarImg evt = (GfrEvtMdlIdDatRemovedLloVarImg) objEvt;
            String strIdParent = evt.getIdParent();

            if (strIdParent.compareTo(super.getIdObjectGeoforgeWwdEarth()) != 0)
               return;

            _updateImagesAnnotation();

            return;
         }

         if (objEvt instanceof GfrEvtMdlIdDatAddedLloVarImg)
         {
            GfrEvtMdlIdDatAddedLloVarImg evt = (GfrEvtMdlIdDatAddedLloVarImg) objEvt;
            String strIdParent = evt.getIdParent();

            if (strIdParent.compareTo(super.getIdObjectGeoforgeWwdEarth()) != 0)
               return;

            _updateImagesAnnotation();

            return;
         }

         if (objEvt instanceof GfrEvtMdlIdDatRenamedLloVar)
         {
            GfrEvtMdlIdDatRenamedLloVar evt = (GfrEvtMdlIdDatRenamedLloVar) objEvt;
            String strIdParent = evt.getIdParent();

            if (strIdParent.compareTo(super.getIdObjectGeoforgeWwdEarth()) != 0)
               return;

            _updateImagesAnnotation();

            return;
         }
         //

         if (objEvt instanceof GfrEvtMdlIdDatRemovedAllLloImgs)
         {
            GfrEvtMdlIdDatRemovedAllLloImgs evt = (GfrEvtMdlIdDatRemovedAllLloImgs) objEvt;
            String strIdParent = evt.getId();

            if (strIdParent.compareTo(super.getIdObjectGeoforgeWwdEarth()) != 0)
               return;

            _clearImagesAnnotation_();

            return;
         }
      }
      catch (Exception exc)
      {
         exc.printStackTrace();
         String strError = exc.getMessage();
         GfrRndSurfacePolylineWisNoTloPth._LOGGER_.severe(strError);

         //--
         strError = GfrUtlString.s_formatExceptionMessageForDialog(strError);
         JOptionPane.showMessageDialog(null, strError, "Dev coding error", JOptionPane.ERROR_MESSAGE);
         return;
      }
      // end images


      // ---
      super.update(obs, objEvt);
   }

   @Override
   public Position getPosition()
   {
      try
      {
         return super.getPositionBarycentricObjectGeoforgeWwdEarth();
      }
      catch (Exception exc)
      {
         exc.printStackTrace();
         String strError = exc.getMessage();
         GfrRndSurfacePolylineWisNoTloPth._LOGGER_.severe(strError);

         //--
         strError = GfrUtlString.s_formatExceptionMessageForDialog(strError);
         JOptionPane.showMessageDialog(null, strError, "Exception caught", JOptionPane.ERROR_MESSAGE);
         return null;
      }
   }

}
TOP

Related Classes of org.geoforge.worldwindecl.render.GfrRndSurfacePolylineWisNoTloPth

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.