Package org.geoforge.worldwind.render

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

/*
*  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.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 java.util.logging.Logger;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
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.EnuEvtDspRndWwdEarthShpDimOneLine;
import org.geoforge.mdldsp.event.render.wwd.GfrEvtMdlIdDspRndWwdEarthShpDimOneLine;
import org.geoforge.wrpbasprsdsp.render.wwd.GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneLineWiseNo;



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

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

    // end: instantiate logger for this class
    // ----
   
    protected GfrRndSurfacePolylineWisNoTloAbs(
            PropertyChangeListener lstShouldRedraw,
            String strId,
            String strName,
            List<Position> lstPosition)
            throws Exception
    {
        super(lstShouldRedraw, strId, strName, lstPosition);
    }
   
    @Override
    public void update(Observable obs, Object objEvt)
    {
       // beg display
      
       if (objEvt instanceof GfrEvtMdlIdDspRndWwdEarthShpDimOneLine)
       {
          GfrEvtMdlIdDspRndWwdEarthShpDimOneLine evt = (GfrEvtMdlIdDspRndWwdEarthShpDimOneLine) 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 == EnuEvtDspRndWwdEarthShpDimOneLine.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.setLocations(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) GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneLineWiseNo.getInstance().getThickness(_strId);
       bsa.setOutlineWidth(dblWidthOut);
     
       Color colRgbOut = GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneLineWiseNo.getInstance().getColor(super._strId)
       bsa.setOutlineMaterial(new Material(colRgbOut));
    
       float fltAlphaOut = GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneLineWiseNo.getInstance().getTransparency(super._strId);
       bsa.setOutlineOpacity((double) fltAlphaOut);
    
       super.setAttributes(bsa);
    }
  
   @Override
    public void setEnabledTooltipThis() throws Exception
    {
       boolean blnIsToolTip = GfrWrpBasPrsDspPrjRndWwdEarthShpDimOneLineWiseNo.getInstance().isTooltip(super._strId);
       super.setValue(GfrKeysRnd.STR_HAS_TOOLTIP, blnIsToolTip);
    }
}
TOP

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

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.