Package org.geoforge.worldwind.builder.factory

Source Code of org.geoforge.worldwind.builder.factory.GfrFactoryObjShpPlnCls

/* Copyright (C) 2001, 2011 United States Government as represented by
the Administrator of the National Aeronautics and Space Administration.
All Rights Reserved.
*/
package org.geoforge.worldwind.builder.factory;

import gov.nasa.worldwind.WorldWind;
import gov.nasa.worldwind.WorldWindow;
import gov.nasa.worldwind.avlist.AVKey;
import gov.nasa.worldwind.geom.Angle;
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.render.ExtrudedPolygon;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import org.geoforge.lang.util.GfrResBundleLang;
import org.geoforge.java.util.logging.filehandler.FileHandlerLogger;
import org.geoforge.worldwind.builder.utils.GfrShapeUtils;

/**
* @author pabercrombie
* @version $Id: ExtrudedPolygonEditor.java 1 2011-07-16 23:22:47Z dcollins $
*
* modified, inner-class extracted, bantchao
*/

public class GfrFactoryObjShpPlnCls extends GfrFactoryObjShpPlnAbs
{
    // ----
    // begin: instantiate logger for this class
    final private static Logger _LOGGER_ = Logger.getLogger(GfrFactoryObjShpPlnCls.class.getName());

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

    // end: instantiate logger for this class
    // ----
  
    
   
    static private GfrFactoryObjShpPlnCls _INSTANCE_ = null;
   
    static public GfrFactoryObjShpPlnCls s_getInstance()
    {
        if (GfrFactoryObjShpPlnCls._INSTANCE_ == null)
        {
            GfrFactoryObjShpPlnCls._INSTANCE_ = new GfrFactoryObjShpPlnCls();
           
            if (! GfrFactoryObjShpPlnCls._INSTANCE_.init())
            {
                String str = "! OurExtrudedPolygonFactory._INSTANCE_.init()";
                GfrFactoryObjShpPlnCls._LOGGER_.severe(str);
                JOptionPane.showMessageDialog(null,
                    str, GfrResBundleLang.s_getInstance().getValue("word.error"), JOptionPane.ERROR_MESSAGE);
                System.exit(1);
            }
        }
       
        return GfrFactoryObjShpPlnCls._INSTANCE_;
    }
   
    private static long _LNG_NEXT_ENTRY_ = 1;
   
    static private String _s_getNextName_(String base)
    {
        StringBuilder sb = new StringBuilder();
        sb.append(base);
        sb.append(GfrFactoryObjShpPlnCls._LNG_NEXT_ENTRY_++);
        return sb.toString();
    }

   
   
    // end static
   
   
    private GfrFactoryObjShpPlnCls()
    {
       super();
    }
   

    public ExtrudedPolygon create(WorldWindow wwd, boolean blnFitObjectToViewport)
    {
        ExtrudedPolygon poly = new ExtrudedPolygon();
        poly.setAttributes(GfrFactoryObjShpPlnAbs._s_getDefaultAttributes());
        poly.setValue(AVKey.DISPLAY_NAME, GfrFactoryObjShpPlnCls._s_getNextName_(toString()));
        this._initializePolygon_(wwd, poly, blnFitObjectToViewport);

        return poly;
    }
   
   
    private void _initializePolygon_(WorldWindow wwd, ExtrudedPolygon polygon, boolean fitShapeToViewport)
    {
        // Creates a rectangle in the center of the viewport. Attempts to guess at a reasonable size and height.

        Position position = GfrShapeUtils.s_getNewShapePosition(wwd);
        Angle heading = GfrShapeUtils.s_getNewShapeHeading(wwd, true);
       
        double heightInMeters = fitShapeToViewport?
            GfrShapeUtils.s_getViewportScaleFactor(wwd):
                GfrFactoryObjShpPlnAbs._DBL_DEFAULT_SHAPE_SIZE_METERS;
    
        java.util.List<Position> locations = GfrShapeUtils.s_createPositionSquareInViewport(wwd, position, heading,
            heightInMeters);

        polygon.setOuterBoundary(locations);
       
        polygon.setHeight(1000
                //heightInMeters
                );
       
        polygon.setAltitudeMode(WorldWind.RELATIVE_TO_GROUND);
        //polygon.setAltitudeMode(WorldWind.CONSTANT);
    }

   @Override
    public String toString()
    {
       return "ClosedPolyline";
    }
   
}
TOP

Related Classes of org.geoforge.worldwind.builder.factory.GfrFactoryObjShpPlnCls

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.