Package org.geoforge.worldwind.builder.factory

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

/*
*  Copyright (C) 2011-2013 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.builder.factory;

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.Polyline;
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 Amadeus.Sowerby
*
* email: Amadeus.Sowerby_AT_gmail.com ... please remove "_AT_" from the above
* string to get the right email address
*/
public class GfrFactoryObjShpSegWiseYes extends GfrFactoryObjShpPlnAbs
{
    // ----
    // begin: instantiate logger for this class
    final private static Logger _LOGGER_ = Logger.getLogger(GfrFactoryObjShpSegWiseYes.class.getName());

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

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


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

        return poly;
    }
   
   

    private void _initializePolygon_(WorldWindow wwd, Polyline 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_createPositionTriangleInViewport(wwd, position, heading,
            heightInMeters);
       
        polygon.setPositions(locations);
        //polygon.setExtrude(true);

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

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

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

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.