Package org.geoforge.worldwind.render

Source Code of org.geoforge.worldwind.render.GfrRndSurfaceSegmentWiseYesTloAbs

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

import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.render.BasicShapeAttributes;
import gov.nasa.worldwind.render.Material;
import java.awt.Color;
import java.awt.geom.Point2D;
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Observable;
import org.geoforge.mdl.event.GfrEvtMdlIdAbs;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatChangedGeometry;
import org.geoforge.mdldat.event.GfrEvtMdlIdDatRenamedTlo;
import org.geoforge.mdldsp.event.render.wwd.EnuEvtDspRndWwdEarthShp;
import org.geoforge.mdldsp.event.render.wwd.EnuEvtDspRndWwdEarthShpDimOne;
import org.geoforge.mdldsp.event.render.wwd.EnuEvtDspRndWwdEarthShpDimOneSegmentWise;
import org.geoforge.mdldsp.event.render.wwd.GfrEvtMdlIdDspRndWwdEarthShpDimOneSegWise;
import org.geoforge.wrpbasprsdsp.render.wwd.GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneSegmentWiseYes;

/**
*
* @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 GfrRndSurfaceSegmentWiseYesTloAbs extends GfrRndSurfaceSegmentWiseYesAbs
{

   public GfrRndSurfaceSegmentWiseYesTloAbs(
           PropertyChangeListener lstShouldRedraw,
           String strId,
           String strName,
           List<Position> positions) throws Exception
   {
      super(lstShouldRedraw,
              strId,
              strName,
              positions);
   }

  
    @Override
    public void update(Observable obs, Object objEvt)
    {
       // beg display
      
       if (objEvt instanceof GfrEvtMdlIdDspRndWwdEarthShpDimOneSegWise)
       {
          GfrEvtMdlIdDspRndWwdEarthShpDimOneSegWise evt = (GfrEvtMdlIdDspRndWwdEarthShpDimOneSegWise) objEvt;
         
          String strId = evt.getId();
         
          if (strId.compareTo(super._strId) != 0)
             return;
         
          Object objWhat = evt.getWhat();
         
          if (objWhat == EnuEvtDspRndWwdEarthShp.TOOLTIP)
          {
             Boolean boo = (Boolean) evt.getValue();
             super.setValue(GfrKeysRnd.STR_HAS_TOOLTIP, boo.booleanValue());
             // memo: no need to send event to redraw!
             return;
          }
         

         
          if (objWhat == EnuEvtDspRndWwdEarthShpDimOne.COLOR)
          {
             Color col = (Color) evt.getValue();
             BasicShapeAttributes bsa = (BasicShapeAttributes) super.getAttributes();
             bsa.setOutlineMaterial(new Material(col));
             this.firePropertyChange(GfrShouldRedrawRnd.STR, null, null);
             return;
          }
         
          if (objWhat == EnuEvtDspRndWwdEarthShpDimOne.TRANSPARENCY)
          {
             Float flo = (Float) evt.getValue();
             float fltAlpha = flo.floatValue();
             BasicShapeAttributes bsa = (BasicShapeAttributes) super.getAttributes();
             bsa.setOutlineOpacity((double) fltAlpha);
             this.firePropertyChange(GfrShouldRedrawRnd.STR, null, null);
             return;
          }
         
          if (objWhat == EnuEvtDspRndWwdEarthShpDimOneSegmentWise.THICKNESS)
          {
             Integer itg = (Integer) evt.getValue();
             BasicShapeAttributes bsa = (BasicShapeAttributes) super.getAttributes();
             bsa.setOutlineWidth(itg.doubleValue());
             this.firePropertyChange(GfrShouldRedrawRnd.STR, null, null);
             return;
          }
         
         
          return;
       }
      
       // end display
      
      
       // beg data
      
       GfrEvtMdlIdAbs objId = (GfrEvtMdlIdAbs) objEvt;
      
       String strIdEvt = objId.getId();
      
       if (strIdEvt.compareTo(super._strId) != 0)
          return;
      
       if (objId instanceof GfrEvtMdlIdDatChangedGeometry)
       {
          GfrEvtMdlIdDatChangedGeometry evt = (GfrEvtMdlIdDatChangedGeometry) objEvt;
          List<Point2D.Double> lstP2d = (List<Point2D.Double>) evt.getGeometry();
          List<Position> lstPosition = new ArrayList<Position>();
         
          for (Point2D.Double p2dCur: lstP2d)
          {
             Position posCur = Position.fromDegrees(p2dCur.y, p2dCur.x);
             lstPosition.add(posCur);
          }
         
          super.setPositions(lstPosition);
          this.firePropertyChange(GfrShouldRedrawRnd.STR, null, null);
          return;
       }
      
       if (objId instanceof GfrEvtMdlIdDatRenamedTlo)
       {
          GfrEvtMdlIdDatRenamedTlo objRename = (GfrEvtMdlIdDatRenamedTlo) objId;
          super.setValue(gov.nasa.worldwind.avlist.AVKey.DISPLAY_NAME, objRename.getValueNew());
         // memo: no need to redraw, coz of just handling toolTip
          return;
       }
      
       // end data
    }
   
   @Override
    public void setAttributesThis() throws Exception
    {
       BasicShapeAttributes bsa = new BasicShapeAttributes();

       bsa.setDrawOutline(true);
       double dblWidthOut = (double) GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneSegmentWiseYes.getInstance().getThickness(_strId);
       bsa.setOutlineWidth(dblWidthOut);
     
       Color colRgbOut = GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneSegmentWiseYes.getInstance().getColor(super._strId)
       bsa.setOutlineMaterial(new Material(colRgbOut));
    
       float fltAlphaOut = GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneSegmentWiseYes.getInstance().getTransparency(super._strId);
       bsa.setOutlineOpacity((double) fltAlphaOut);
    
       super.setAttributes(bsa);
    }
  
   @Override
    public void setEnabledTooltipThis() throws Exception
    {
       boolean blnIsToolTip = GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneSegmentWiseYes.getInstance().isTooltip(super._strId);
       super.setValue(GfrKeysRnd.STR_HAS_TOOLTIP, blnIsToolTip);
    }
}
TOP

Related Classes of org.geoforge.worldwind.render.GfrRndSurfaceSegmentWiseYesTloAbs

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.