package Savage.ShipsMilitary.DDGArleighBurkeUnitedStates;

import org.web3d.x3d.jsail.Core.*;
import org.web3d.x3d.jsail.fields.*;
import org.web3d.x3d.jsail.Grouping.*;
import org.web3d.x3d.jsail.Networking.*;

// Javadoc metadata annotations follow, see below for X3DJSAIL Java source code.
/**
 * <p> Prototype for an Arleigh Burke (DDG51) Class Navy Destroyer. Proto allows weapon placements, hull number, and ship name markings. </p>
 <p> Related links: Catalog page <a href="../../../../ShipsMilitary/DDGArleighBurkeUnitedStates/ArleighBurkeHighDetailPrototypeIndex.html" target="_blank">ArleighBurkeHighDetailPrototype</a>,  source <a href="../../../../ShipsMilitary/DDGArleighBurkeUnitedStates/ArleighBurkeHighDetailPrototype.java">ArleighBurkeHighDetailPrototype.java</a>, <a href="https://www.web3d.org/x3d/content/examples/X3dResources.html" target="_blank">X3D Resources</a>, <a href="https://www.web3d.org/x3d/content/examples/X3dSceneAuthoringHints.html" target="_blank">X3D Scene Authoring Hints</a>, and <a href="https://www.web3d.org/x3d/content/X3dTooltips.html" target="_blank">X3D Tooltips</a>. </p>
	<table style="color:black; border:0px solid; border-spacing:10px 0px;">
        <caption>Scene Meta Information</caption>
		<tr style="background-color:silver; border-color:silver;">
			<td style="text-align:center; padding:10px 0px;"><i>meta tags</i></td>
			<td style="text-align:left;   padding:10px 0px;">&nbsp; Document Metadata </td>
		</tr>

		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> title </i> </td>
			<td> <a href="../../../../ShipsMilitary/DDGArleighBurkeUnitedStates/ArleighBurkeHighDetailPrototype.x3d">ArleighBurkeHighDetailPrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> description </i> </td>
			<td> Prototype for an Arleigh Burke (DDG51) Class Navy Destroyer. Proto allows weapon placements, hull number, and ship name markings </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> creator </i> </td>
			<td> Patrick Sullivan </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> created </i> </td>
			<td> 27 May 2006 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> modified </i> </td>
			<td> 20 October 2019 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> subject </i> </td>
			<td> Prototypes, DDG51, Arleigh Burke destroyer </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> identifier </i> </td>
			<td> <a href="https://www.web3d.org/x3d/content/examples/Savage/ShipsMilitary/DDGArleighBurkeUnitedStates/ArleighBurkeHighDetailPrototype.x3d" target="_blank">https://www.web3d.org/x3d/content/examples/Savage/ShipsMilitary/DDGArleighBurkeUnitedStates/ArleighBurkeHighDetailPrototype.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> license </i> </td>
			<td> <a href="../../../../ShipsMilitary/DDGArleighBurkeUnitedStates/../../license.html">../../license.html</a> </td>
		</tr>
		<tr style="background-color:silver; border-color:silver;">
			<td style="text-align:center;" colspan="2">  &nbsp; </td>
		</tr>
	</table>

	<p>
		This program uses the
		<a href="https://www.web3d.org/specifications/java/X3DJSAIL.html" target="_blank">X3D Java Scene Access Interface Library (X3DJSAIL)</a>.
		It has been produced using the 
		<a href="https://www.web3d.org/x3d/stylesheets/X3dToJava.xslt" target="_blank">X3dToJava.xslt</a>
		stylesheet
	       (<a href="https://sourceforge.net/p/x3d/code/HEAD/tree/www.web3d.org/x3d/stylesheets/X3dToJava.xslt" target="_blank">version control</a>)
                which is used to create Java source code from an original <code>.x3d</code> model.
	</p>

	* @author Patrick Sullivan
 */

public class ArleighBurkeHighDetailPrototype
{
	/** Default constructor to create this object. */
	public ArleighBurkeHighDetailPrototype ()
	{
	  initialize();
	}

	/** Create and initialize the X3D model for this object. */
	public final void initialize()
	{
            try { // catch-all
  x3dModel = new X3D().setProfile(X3D.PROFILE_IMMERSIVE).setVersion(X3D.VERSION_3_0)
  .setHead(new head()
    .addMeta(new meta().setName(meta.NAME_TITLE      ).setContent("ArleighBurkeHighDetailPrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_DESCRIPTION).setContent("Prototype for an Arleigh Burke (DDG51) Class Navy Destroyer. Proto allows weapon placements, hull number, and ship name markings"))
    .addMeta(new meta().setName(meta.NAME_CREATOR    ).setContent("Patrick Sullivan"))
    .addMeta(new meta().setName(meta.NAME_CREATED    ).setContent("27 May 2006"))
    .addMeta(new meta().setName(meta.NAME_MODIFIED   ).setContent("20 October 2019"))
    .addMeta(new meta().setName(meta.NAME_SUBJECT    ).setContent("Prototypes, DDG51, Arleigh Burke destroyer"))
    .addMeta(new meta().setName(meta.NAME_IDENTIFIER ).setContent("https://www.web3d.org/x3d/content/examples/Savage/ShipsMilitary/DDGArleighBurkeUnitedStates/ArleighBurkeHighDetailPrototype.x3d"))
    .addMeta(new meta().setName(meta.NAME_LICENSE    ).setContent("../../license.html")))
  .setScene(new Scene()
    .addChild(new WorldInfo().setTitle("ArleighBurkeHighDetailPrototype.x3d"))
    .addChild(new ExternProtoDeclare("HullNumber").setName("HullNumber").setUrl(new String[] {"../../../Savage/ModelDetailing/HullNumbers/HullNumberPrototype.x3d#HullNumber","https://www.web3d.org/x3d/content/examples/Savage/ModelDetailing/HullNumbers/HullNumberPrototype.x3d#HullNumber"})
      .addField(new field().setName("FirstNumber").setType(field.TYPE_SFINT32).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("[0-9] (-1 will prevent rendering)"))
      .addField(new field().setName("SecondNumber").setType(field.TYPE_SFINT32).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("[0-9] (-1 will prevent rendering)")))
    .addChild(new ProtoDeclare("DDG51").setName("DDG51").setAppinfo("Prototype of a DDG51 Class Destroyer")
      .setProtoInterface(new ProtoInterface()
        .addField(new field().setName("ISIC").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new String[] {"none"}).setAppinfo("URL for the ISIC seal that is found on the side of most navy ships (e.g. \"../../ShipCrests/COMDESRON31/DESRON31.x3d\")"))
        .addField(new field().setName("HullNumber1").setType(field.TYPE_SFINT32).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(-1).setAppinfo("The first (or only) digit of the ship's hull number [0-9]. Note -1 for no number"))
        .addField(new field().setName("HullNumber2").setType(field.TYPE_SFINT32).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(-1).setAppinfo("The second digit of the ship's hull number [0-9]. Note: -1 for no number"))
        .addField(new field().setName("ForwardBowWeapon").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new String[] {"none"}).setAppinfo("URL for the model that represents the weapon at this location. [example \"https://www.web3d.org/content/examples/Savage/Weapons/50Cal.x3d\")"))
        .addField(new field().setName("StarboardBowWeapon").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new String[] {"none"}).setAppinfo("URL for the model that represents the weapon at this location. [example \"https://www.web3d.org/content/examples/Savage/Weapons/50Cal.x3d\")"))
        .addField(new field().setName("PortBowWeapon").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new String[] {"none"}).setAppinfo("URL for the model that represents the weapon at this location. [example \"https://www.web3d.org/content/examples/Savage/Weapons/50Cal.x3d\")"))
        .addField(new field().setName("StarboardBridgeWeapon").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new String[] {"none"}).setAppinfo("URL for the model that represents the weapon at this location. [example \"https://www.web3d.org/content/examples/Savage/Weapons/50Cal.x3d\")"))
        .addField(new field().setName("PortBridgeWeapon").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new String[] {"none"}).setAppinfo("URL for the model that represents the weapon at this location. [example \"https://www.web3d.org/content/examples/Savage/Weapons/50Cal.x3d\")"))
        .addField(new field().setName("StarboardMidshipWeapon").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new String[] {"none"}).setAppinfo("URL for the model that represents the weapon at this location. [example \"https://www.web3d.org/content/examples/Savage/Weapons/50Cal.x3d\")"))
        .addField(new field().setName("PortMidshipWeapon").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new String[] {"none"}).setAppinfo("URL for the model that represents the weapon at this location. [example \"https://www.web3d.org/content/examples/Savage/Weapons/50Cal.x3d\")"))
        .addField(new field().setName("StarboardFlightDeckWeapon").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new String[] {"none"}).setAppinfo("URL for the model that represents the weapon at this location. [example \"https://www.web3d.org/content/examples/Savage/Weapons/50Cal.x3d\")"))
        .addField(new field().setName("PortFlightDeckWeapon").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new String[] {"none"}).setAppinfo("URL for the model that represents the weapon at this location. [example \"https://www.web3d.org/content/examples/Savage/Weapons/50Cal.x3d\")"))
        .addField(new field().setName("SternFlightDeckWeapon").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new String[] {"none"}).setAppinfo("URL for the model that represents the weapon at this location. [example \"https://www.web3d.org/content/examples/Savage/Weapons/50Cal.x3d\")")))
      .setProtoBody(new ProtoBody()
        .addChild(new Transform()
          .addComments(" Ship Model ")
          .addChild(new Transform("DDG51ShipModel")
            .addChild(new Inline().setUrl(new String[] {"../../../Savage/ShipsMilitary/DDGArleighBurkeUnitedStates/ArleighBurkeHighDetail.x3d","https://www.web3d.org/x3d/content/examples/Savage/ShipsMilitary/DDGArleighBurkeUnitedStates/ArleighBurkeHighDetail.x3d"})))
          .addComments(" Hull Numbers ")
          .addChild(new Transform("StarboardBowHullNumber").setRotation(0.85,0.499,-0.163,.729).setTranslation(70.513,5.099,2.082)
            .addChild(new ProtoInstance("HullNumber", "ShipNumber").setContainerField("children")
              .setIS(new IS()
                .addConnect(new connect().setNodeField("FirstNumber").setProtoField("HullNumber1"))
                .addConnect(new connect().setNodeField("SecondNumber").setProtoField("HullNumber2")))))
          .addChild(new Transform("PortBowHullNumber").setRotation(.047,.967,-.249,2.776).setTranslation(71.44,5.429,-3.826)
            .addChild(new ProtoInstance("HullNumber").setContainerField("children")
              .setIS(new IS()
                .addConnect(new connect().setNodeField("FirstNumber").setProtoField("HullNumber1"))
                .addConnect(new connect().setNodeField("SecondNumber").setProtoField("HullNumber2")))))
          .addComments(" ISIC Seals ")
          .addChild(new Transform("StarboardSeal").setRotation(1.0,0.0,0.0,-.249).setTranslation(16.615,16.528,1.856)
            .addChild(new Transform()
              .addChild(new Inline("ISICSeal")
                .setIS(new IS()
                  .addConnect(new connect().setNodeField("url").setProtoField("ISIC"))))))
          .addChild(new Transform("PortSeal").setRotation(1.0,0.0,0.0,.251).setTranslation(16.615,16.528,-3.808)
            .addChild(new Transform().setRotation(0.0,1.0,0.0,-3.14)
              .addChild(new Inline().setUSE("ISICSeal"))))
          .addComments(" Weapon Placements ")
          .addChild(new Transform("ForwardBowWeapon").setRotation(0.0,1.0,0.0,3.14).setTranslation(75.405,10.171,2.394)
            .addChild(new Inline()
              .setIS(new IS()
                .addConnect(new connect().setNodeField("url").setProtoField("ForwardBowWeapon")))))
          .addChild(new Transform("StarboardBowWeapon").setRotation(0.0,1.0,0.0,3.14).setTranslation(43.981,7.816,8.47)
            .addChild(new Inline()
              .setIS(new IS()
                .addConnect(new connect().setNodeField("url").setProtoField("StarboardBowWeapon")))))
          .addChild(new Transform("PortBowWeapon").setTranslation(43.981,7.816,-10.049)
            .addChild(new Inline()
              .setIS(new IS()
                .addConnect(new connect().setNodeField("url").setProtoField("PortBowWeapon")))))
          .addChild(new Transform("StarboardBridgeWeapon").setRotation(0.0,1.0,0.0,-1.57).setTranslation(29.833,16.4,7.702)
            .addChild(new Inline()
              .setIS(new IS()
                .addConnect(new connect().setNodeField("url").setProtoField("StarboardBridgeWeapon")))))
          .addChild(new Transform("PortBridgeWeapon").setRotation(0.0,1.0,0.0,1.57).setTranslation(30.399,16.4,-9.104)
            .addChild(new Inline()
              .setIS(new IS()
                .addConnect(new connect().setNodeField("url").setProtoField("PortBridgeWeapon")))))
          .addChild(new Transform("StarboardMidshipWeapon").setRotation(0.0,1.0,0.0,-1.57).setTranslation(10.066,6.2,8.632)
            .addChild(new Inline()
              .setIS(new IS()
                .addConnect(new connect().setNodeField("url").setProtoField("StarboardMidshipWeapon")))))
          .addChild(new Transform("PortMidshipWeapon").setRotation(0.0,1.0,0.0,1.57).setTranslation(10.066,6.2,-9.793)
            .addChild(new Inline()
              .setIS(new IS()
                .addConnect(new connect().setNodeField("url").setProtoField("PortMidshipWeapon")))))
          .addChild(new Transform("StarboardFlightDeckWeapon").setRotation(0.0,1.0,0.0,3.14).setTranslation(-51.47,3.922,8.129)
            .addChild(new Inline()
              .setIS(new IS()
                .addConnect(new connect().setNodeField("url").setProtoField("StarboardFlightDeckWeapon")))))
          .addChild(new Transform("PortFlightDeckWeapon").setTranslation(-51.686,3.922,-9.088)
            .addChild(new Inline()
              .setIS(new IS()
                .addConnect(new connect().setNodeField("url").setProtoField("PortFlightDeckWeapon")))))
          .addChild(new Transform("SternFlightDeckWeapon").setRotation(0.0,1.0,0.0,1.57).setTranslation(-71.592,3.922,6.292)
            .addChild(new Inline()
              .setIS(new IS()
                .addConnect(new connect().setNodeField("url").setProtoField("SternFlightDeckWeapon")))))))));
            }
            catch (Exception ex)
            {       
                System.err.println ("*** Further hints on X3DJSAIL errors and exceptions at");
                System.err.println ("*** https://www.web3d.org/specifications/java/X3DJSAIL.html");
                throw (ex);
            }
	}
	// end of initialize() method

	/** The initialized model object, created within initialize() method. */
	private X3D x3dModel;

	/** 
	 * Provide a 
	 * <a href="https://dzone.com/articles/java-copy-shallow-vs-deep-in-which-you-will-swim" target="_blank">shallow copy</a>
	 * of the X3D model.
	 * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html">X3D</a>
	 * @return ArleighBurkeHighDetailPrototype model
	 */
	public X3D getX3dModel()
	{	  
		return x3dModel;
	}
	   
    /** 
     * Default main() method provided for test purposes, uses CommandLine to set global ConfigurationProperties for this object.
     * @param args array of input parameters, provided as arguments
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html#handleArguments-java.lang.String:A-">X3D.handleArguments(args)</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/Core/X3D.html#validationReport--">X3D.validationReport()</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/CommandLine.html">CommandLine</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/CommandLine.html#USAGE">CommandLine.USAGE</a>
     * @see <a href="https://www.web3d.org/specifications/java/javadoc/org/web3d/x3d/jsail/ConfigurationProperties.html">ConfigurationProperties</a>
     */
    public static void main(String args[])
    {
        System.out.println("Build this X3D model, showing validation diagnostics...");
        X3D thisExampleX3dModel = new ArleighBurkeHighDetailPrototype().getX3dModel();
//      System.out.println("X3D model construction complete.");
	
        // next handle command line arguments
        boolean hasArguments = (args != null) && (args.length > 0);
        boolean validate = true; // default
        boolean argumentsLoadNewModel = false;
        String  fileName = new String();

        if (args != null)
        {
                for (String arg : args)
                {
                        if (arg.toLowerCase().startsWith("-v") || arg.toLowerCase().contains("validate"))
                        {
                                validate = true; // making sure
                        }
                        if (arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_X3D) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_CLASSICVRML) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_X3DB) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_VRML97) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_EXI) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_GZIP) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_ZIP) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_HTML) ||
                                arg.toLowerCase().endsWith(X3D.FILE_EXTENSION_XHTML))
                        {
                                argumentsLoadNewModel = true;
                                fileName = arg;
                        }
                }
        }
        if      (argumentsLoadNewModel)
                System.out.println("WARNING: \"Savage.ShipsMilitary.DDGArleighBurkeUnitedStates.ArleighBurkeHighDetailPrototype\" model invocation is attempting to load file \"" + fileName + "\" instead of simply validating itself... file loading ignored.");
        else if (hasArguments) // if no arguments provided, this method produces usage warning
                thisExampleX3dModel.handleArguments(args);
	
        if (validate)
        {
            //  System.out.println("--- TODO fix duplicated outputs ---"); // omit when duplicated outputs problem is solved/refactored
		String validationResults = thisExampleX3dModel.validationReport();
            //  System.out.println("-----------------------------------"); // omit when duplicated outputs problem is solved/refactored
                System.out.print("Savage.ShipsMilitary.DDGArleighBurkeUnitedStates.ArleighBurkeHighDetailPrototype self-validation test confirmation: ");
                if (!validationResults.equals("success"))
                    System.out.println();
                System.out.println(validationResults.trim());

                // experimental: test X3DJSAIL output files
                // ShipsMilitary/DDGArleighBurkeUnitedStates/ArleighBurkeHighDetailPrototype_JavaExport.* file validation is checked when building X3D Example Archives
                String filenameX3D  = "ShipsMilitary/DDGArleighBurkeUnitedStates/ArleighBurkeHighDetailPrototype_JavaExport.x3d"; 
                String filenameX3DV = "ShipsMilitary/DDGArleighBurkeUnitedStates/ArleighBurkeHighDetailPrototype_JavaExport.x3dv"; 
                String filenameJSON = "ShipsMilitary/DDGArleighBurkeUnitedStates/ArleighBurkeHighDetailPrototype_JavaExport.json";
                thisExampleX3dModel.toFileX3D        (filenameX3D);
                thisExampleX3dModel.toFileClassicVRML(filenameX3DV);
// TODO         thisExampleX3dModel.toFileJSON       (filenameJSON);
        }
    }
}
