package Savage.Tools.Visualization;

import org.web3d.x3d.jsail.Core.*;
import org.web3d.x3d.jsail.EnvironmentalEffects.*;
import org.web3d.x3d.jsail.fields.*;
import org.web3d.x3d.jsail.Geometry3D.*;
import org.web3d.x3d.jsail.Grouping.*;
import org.web3d.x3d.jsail.Lighting.*;
import org.web3d.x3d.jsail.Navigation.*;
import org.web3d.x3d.jsail.Networking.*;
import org.web3d.x3d.jsail.Scripting.*;
import org.web3d.x3d.jsail.Shape.*;
import org.web3d.x3d.jsail.Text.*;

// Javadoc metadata annotations follow, see below for X3DJSAIL Java source code.
/**
 * <p> Reverse engineer and hopefully elaborate on Pajek visualization structures. </p>
 <p> Related links: Catalog page <a href="../../../../Tools/Visualization/PajekVisualizationPrototypesIndex.html" target="_blank">PajekVisualizationPrototypes</a>,  source <a href="../../../../Tools/Visualization/PajekVisualizationPrototypes.java">PajekVisualizationPrototypes.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="../../../../Tools/Visualization/PajekVisualizationPrototypes.x3d">PajekVisualizationPrototypes.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> description </i> </td>
			<td> Reverse engineer and hopefully elaborate on Pajek visualization structures </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> creator </i> </td>
			<td> Don Brutzman and Elaine Reid </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> created </i> </td>
			<td> 29 March 2011 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> modified </i> </td>
			<td> 4 October 2023 </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> reference </i> </td>
			<td> <a href="http://pajek.imfm.si" target="_blank">http://pajek.imfm.si</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> subject </i> </td>
			<td> network visualization </td>
		</tr>
		<tr style="color:burntorange">
			<td style="text-align:right; vertical-align: text-top;"> <i> warning </i> </td>
			<td> under development </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/Tools/Visualization/PajekVisualizationPrototypes.x3d" target="_blank">https://www.web3d.org/x3d/content/examples/Savage/Tools/Visualization/PajekVisualizationPrototypes.x3d</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> generator </i> </td>
			<td> X3D-Edit 4.0, <a href="https://www.web3d.org/x3d/tools/X3D-Edit" target="_blank">https://www.web3d.org/x3d/tools/X3D-Edit</a> </td>
		</tr>
		<tr>
			<td style="text-align:right; vertical-align: text-top;"> <i> license </i> </td>
			<td> <a href="../../../../Tools/Visualization/../../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 Don Brutzman and Elaine Reid
 */

public class PajekVisualizationPrototypes
{
	/** Default constructor to create this object. */
	public PajekVisualizationPrototypes ()
	{
	  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_2)
  .setHead(new head()
    .addMeta(new meta().setName(meta.NAME_TITLE      ).setContent("PajekVisualizationPrototypes.x3d"))
    .addMeta(new meta().setName(meta.NAME_DESCRIPTION).setContent("Reverse engineer and hopefully elaborate on Pajek visualization structures"))
    .addMeta(new meta().setName(meta.NAME_CREATOR    ).setContent("Don Brutzman and Elaine Reid"))
    .addMeta(new meta().setName(meta.NAME_CREATED    ).setContent("29 March 2011"))
    .addMeta(new meta().setName(meta.NAME_MODIFIED   ).setContent("4 October 2023"))
    .addMeta(new meta().setName(meta.NAME_REFERENCE  ).setContent("http://pajek.imfm.si"))
    .addMeta(new meta().setName(meta.NAME_SUBJECT    ).setContent("network visualization"))
    .addMeta(new meta().setName(meta.NAME_WARNING    ).setContent("under development"))
    .addMeta(new meta().setName(meta.NAME_IDENTIFIER ).setContent("https://www.web3d.org/x3d/content/examples/Savage/Tools/Visualization/PajekVisualizationPrototypes.x3d"))
    .addMeta(new meta().setName(meta.NAME_GENERATOR  ).setContent("X3D-Edit 4.0, https://www.web3d.org/x3d/tools/X3D-Edit"))
    .addMeta(new meta().setName(meta.NAME_LICENSE    ).setContent("../../license.html")))
  .setScene(new Scene()
    .addChild(new WorldInfo().setTitle("PajekVisualizationPrototypes.x3d"))
    .addChild(new ProtoDeclare("Arc").setName("Arc").setAppinfo("Arc is a network connection between Vertex nodes, displayed using Cylinder/Cone (arrow/arrowhead) geometry with modifiable color and transparency")
      .setProtoInterface(new ProtoInterface()
        .addField(new field().setName("name").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue("TODOprovideInitialValue").setAppinfo("name to identify this Arc"))
        .addField(new field().setName("description").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue("TODO customize this Arc description").setAppinfo("popup text describing this Arc"))
        .addField(new field().setName("cylinderHeight").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(1).setAppinfo("length of Arc between Vertex locations"))
        .addField(new field().setName("url").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("link to some other resource"))
        .addField(new field().setName("cylinderTranslation").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new SFVec3f(0.0,0.0,0.0)).setAppinfo("location of Arc"))
        .addField(new field().setName("coneTranslation").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new SFVec3f(0.0,0.0,0.0)).setAppinfo("see TODO items in ArcScript"))
        .addField(new field().setName("rotation").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new SFRotation(0.0,1.0,0.0,0.0)).setAppinfo("orientation of Arc"))
        .addField(new field().setName("displayMode").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue("BallAndStick").setAppinfo("rendering choices: BallAndStick, Ball, Stick"))
        .addField(new field().setName("diffuseColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new SFColor(0.0,0.0,0.0)).setAppinfo("diffuseColor of Arc"))
        .addField(new field().setName("transparency").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(0.0).setAppinfo("transparency of Arc"))
        .addField(new field().setName("ballRadius").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(1).setAppinfo("offset distance for Cone arrowhead; TODO this needs to match values in the Vertex protopye, which is iniitialized separately"))
        .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(false).setAppinfo("debug trace to Browser output console")))
      .setProtoBody(new ProtoBody()
        .addComments(" First node determines node type of this prototype ")
        .addChild(new Anchor("ArcPrototypeRootNode")
          .setIS(new IS()
            .addConnect(new connect().setNodeField("description").setProtoField("description"))
            .addConnect(new connect().setNodeField("url").setProtoField("url")))
          .addChild(new Group()
            .addChild(new Transform("CylinderTransform").setRotation(-0.4367,0.0,0.8996,1.60563).setTranslation(-1.166,0.60861,-2.23229)
              .setIS(new IS()
                .addConnect(new connect().setNodeField("translation").setProtoField("cylinderTranslation"))
                .addConnect(new connect().setNodeField("rotation").setProtoField("rotation")))
              .addChild(new Shape()
                .setAppearance(new Appearance()
                  .setMaterial(new Material("CylinderMaterial").setDiffuseColor(0.0,0.0,0.0).setShininess(0.8).setSpecularColor(0.8,0.8,0.8)))
                .addComments(" TODO these trial values are from Arc 1.6, radius is a candidate parameter ")
                .setGeometry(new Cylinder().setRadius(0.02)
                  .setIS(new IS()
                    .addConnect(new connect().setNodeField("height").setProtoField("cylinderHeight"))))))
            .addChild(new Transform("ConeTransform").setRotation(-0.4367,0.0,0.8996,1.6056).setTranslation(-1.49373,0.59592,-2.39136)
              .setIS(new IS()
                .addConnect(new connect().setNodeField("translation").setProtoField("coneTranslation"))
                .addConnect(new connect().setNodeField("rotation").setProtoField("rotation")))
              .addChild(new Shape()
                .setGeometry(new Cone().setBottomRadius(0.06).setHeight(0.1))
                .setAppearance(new Appearance()
                  .setMaterial(new Material("ConeMaterial").setDiffuseColor(0.0,0.0,0.0).setShininess(.8).setSpecularColor(.8,.8,.8)
                    .setIS(new IS()
                      .addConnect(new connect().setNodeField("transparency").setProtoField("transparency")))))))))
        .addChild(new Script("ArcScript").setSourceCode("""
ecmascript:
function initialize ()
{
    // TODO? potential visualization improvment (at possible cost of breaking simple 1:1 mapping)
    // compute Cone translation (and perhaps cone size) based on Cylinder size
    // then send result to the Cone parent transform

    // conceivably this extended Cylinder length is a feature, not a bug...
    // if the Cylinder goes to the center of the ball, then you can turn off both
    // balls and Cone arrowheads to yield a simple stick-only model
    // so we need to consider this as an animation/visualization feature as well

    tracePrint ('ArcScript ' + name + ': ' initialization() successful');
}
function set_name (eventValue)
{
    // input eventValue received for inputOutput field name
    name = eventValue;
    tracePrint ('name = ' + name);
}
function set_description (eventValue)
{
    // input eventValue received for inputOutput field description
    description = eventValue;
    tracePrint ('description = ' + description);
}
function set_cylinderTranslation (eventValue)
{
    // input eventValue received for inputOutput field cylinderTranslation
    cylinderTranslation = eventValue;
    tracePrint ('cylinderTranslation = ' + cylinderTranslation);

    // TODO author code (if any) goes here
}
function set_coneTranslation (eventValue)
{
    // input eventValue received for inputOutput field coneTranslation
    coneTranslation = eventValue;
    tracePrint ('coneTranslation = ' + coneTranslation);

    // TODO author code (if any) goes here
}
function set_rotation (eventValue)
{
    // input eventValue received for inputOutput field rotation
    rotation = eventValue;
    tracePrint ('rotation = ' + rotation);

    // TODO author code (if any) goes here
}
function set_displayMode (eventValue)
{
    // input eventValue received for inputOutput field displayMode
    displayMode = eventValue;
    tracePrint ('displayMode = ' + displayMode);

    // TODO author code (if any) goes here
}
function set_color (eventValue)
{
    // input eventValue received for inputOutput field color
    color = eventValue;
    tracePrint ('color = ' + color);

    // TODO author code (if any) goes here
}
function set_transparency (eventValue)
{
    // input eventValue received for inputOutput field transparency
    transparency = eventValue;
    tracePrint ('transparency = ' + transparency);

    // TODO author code (if any) goes here
}
function set_ballRadius (eventValue)
{
    // input eventValue received for inputOutput field ballRadius
    ballRadius = eventValue;
    tracePrint ('ballRadius = ' + ballRadius);

    // TODO author code (if any) goes here
}
// ================== Trace output functions ==================

function tracePrint (outputString)
{
   // if traceEnabled is true, print outputString on X3D browser console
   if (traceEnabled)
      Browser.println ('[Arc ' + name + ': ' + outputString + ']');
}
function alwaysPrint (outputString)
{
      // always print outputString on X3D browser console
      Browser.println ('[Arc ' + name + ': ' + outputString + ']');
}
function set_traceEnabled (eventValue)
{
    // input eventValue received for inputOutput field
    traceEnabled = eventValue;
}
// ===========================================================

function set_website (eventValue)
{
    // input eventValue received for inputOutput field website
    website = eventValue;
    tracePrint ('website = ' + website);

    // TODO author code (if any) goes here
}
//============================================================
""")
          .addField(new field().setName("name").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("name to identify this Arc"))
          .addField(new field().setName("description").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("popup text describing this Arc"))
          .addField(new field().setName("cylinderHeight").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setAppinfo("length of Arc between Vertex locations"))
          .addField(new field().setName("website").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("link to some other resource"))
          .addField(new field().setName("cylinderTranslation").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("location of Arc"))
          .addField(new field().setName("coneTranslation").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("see TODO items in ArcScript"))
          .addField(new field().setName("rotation").setType(field.TYPE_SFROTATION).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("orientation of Arc"))
          .addField(new field().setName("displayMode").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("rendering choices: BallAndStick, Ball, Stick"))
          .addField(new field().setName("diffuseColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("diffuseColor of Arc"))
          .addField(new field().setName("transparency").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("transparency of Arc"))
          .addField(new field().setName("ballRadius").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("offset distance for Cone arrowhead; TODO this needs to match values in the Vertex protopye, which is iniitialized separately"))
          .addField(new field().setName("traceEnabled").setType(field.TYPE_SFBOOL).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("debug trace to Browser output console"))
          .setIS(new IS()
            .addConnect(new connect().setNodeField("name").setProtoField("name"))
            .addConnect(new connect().setNodeField("description").setProtoField("description"))
            .addConnect(new connect().setNodeField("cylinderHeight").setProtoField("cylinderHeight"))
            .addConnect(new connect().setNodeField("website").setProtoField("url"))
            .addConnect(new connect().setNodeField("cylinderTranslation").setProtoField("cylinderTranslation"))
            .addConnect(new connect().setNodeField("coneTranslation").setProtoField("coneTranslation"))
            .addConnect(new connect().setNodeField("rotation").setProtoField("rotation"))
            .addConnect(new connect().setNodeField("displayMode").setProtoField("displayMode"))
            .addConnect(new connect().setNodeField("diffuseColor").setProtoField("diffuseColor"))
            .addConnect(new connect().setNodeField("transparency").setProtoField("transparency"))
            .addConnect(new connect().setNodeField("ballRadius").setProtoField("ballRadius"))
            .addConnect(new connect().setNodeField("traceEnabled").setProtoField("traceEnabled"))))
        .addComments(" Add any ROUTEs here that connect Script to/from prior nodes within ProtoBody ")))
    .addChild(new ProtoDeclare("Vertex").setName("Vertex").setAppinfo("Vertex is a node, typically connected by zero or more Arc segments, and displayed using Sphere geometry with modifiable color and transparency")
      .setProtoInterface(new ProtoInterface()
        .addField(new field().setName("name").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue("TODOprovideVertexName").setAppinfo("name to identify this Vertex"))
        .addField(new field().setName("description").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue("TODO customize this Vertex description").setAppinfo("popup text describing this Vertex"))
        .addField(new field().setName("url").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("link to some other resource"))
        .addField(new field().setName("radius").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INITIALIZEONLY).setValue(1).setAppinfo("size of Vertex ball"))
        .addField(new field().setName("displayMode").setType(field.TYPE_SFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue("BallAndStick").setAppinfo("rendering choices: BallAndStick, Ball, Stick"))
        .addField(new field().setName("diffuseColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new SFColor(0.8,0.8,0.8)).setAppinfo("diffuseColor of Vertex"))
        .addField(new field().setName("transparency").setType(field.TYPE_SFFLOAT).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(0.0).setAppinfo("transparency of Vertex"))
        .addField(new field().setName("translation").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new SFVec3f(0.0,0.0,0.0)).setAppinfo("location of Vertex"))
        .addField(new field().setName("vertexText").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("labels to identify Vertex"))
        .addField(new field().setName("textTranslation").setType(field.TYPE_SFVEC3F).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new SFVec3f(0.0,0.0,0.0)).setAppinfo("location of Text"))
        .addField(new field().setName("textColor").setType(field.TYPE_SFCOLOR).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setValue(new SFColor(0.0,0.0,0.0)).setAppinfo("diffuseColor of Text")))
      .setProtoBody(new ProtoBody()
        .addComments(" First node determines node type of this prototype ")
        .addChild(new Group("VertexPrototypeRootNode")
          .addChild(new WorldInfo()
            .setIS(new IS()
              .addConnect(new connect().setNodeField("title").setProtoField("displayMode"))))
          .addChild(new Anchor()
            .setIS(new IS()
              .addConnect(new connect().setNodeField("name").setProtoField("name"))
              .addConnect(new connect().setNodeField("description").setProtoField("description"))
              .addConnect(new connect().setNodeField("url").setProtoField("url")))
            .addChild(new Group()
              .addChild(new Transform()
                .setIS(new IS()
                  .addConnect(new connect().setNodeField("translation").setProtoField("translation")))
                .addChild(new Shape()
                  .setAppearance(new Appearance()
                    .setMaterial(new Material()
                      .setIS(new IS()
                        .addConnect(new connect().setNodeField("diffuseColor").setProtoField("diffuseColor"))
                        .addConnect(new connect().setNodeField("transparency").setProtoField("transparency")))))
                  .setGeometry(new Sphere()
                    .setIS(new IS()
                      .addConnect(new connect().setNodeField("radius").setProtoField("radius"))))))
              .addComments(" TODO for future work: Billboard for text visibility ")
              .addChild(new Transform()
                .setIS(new IS()
                  .addConnect(new connect().setNodeField("translation").setProtoField("textTranslation")))
                .addChild(new Shape()
                  .setAppearance(new Appearance()
                    .setMaterial(new Material()
                      .setIS(new IS()
                        .addConnect(new connect().setNodeField("diffuseColor").setProtoField("textColor")))))
                  .setGeometry(new Text()
                    .setIS(new IS()
                      .addConnect(new connect().setNodeField("string").setProtoField("vertexText")))
                    .addComments(" TODO do we really want to honor Pajek's default Text family? ")
                    .setFontStyle(new FontStyle().setFamily(new String[] {"SANS"}).setSize(0.20000))))))))
        .addComments(" Subsequent nodes do not render, but still must be a valid X3D subgraph ")))
    .addChild(new ProtoDeclare("NetworkText").setName("NetworkText").setAppinfo("Text describing what the Vertices and Arcs are about")
      .setProtoInterface(new ProtoInterface()
        .addField(new field().setName("text").setType(field.TYPE_MFSTRING).setAccessType(field.ACCESSTYPE_INPUTOUTPUT).setAppinfo("information to identify the Integral Network")))
      .setProtoBody(new ProtoBody()
        .addChild(new Transform()
          .addChild(new Group()
            .addChild(new Transform()
              .addChild(new Shape()
                .setAppearance(new Appearance()
                  .setMaterial(new Material().setDiffuseColor(0.9,0.9,0.9)))
                .setGeometry(new Text("NetworkTextHolder")
                  .setIS(new IS()
                    .addConnect(new connect().setNodeField("string").setProtoField("text")))
                  .setFontStyle(new FontStyle()))))))))
    .addChild(new Background().setGroundAngle(new double[] {1.309,1.570796}).setGroundColor(new MFColor(new double[] {0.0,0.5,0.7,0.0,0.4,0.7,0.6,0.5,0.7})).setSkyAngle(new double[] {1.309,1.571}).setSkyColor(new MFColor(new double[] {0.0,0.5,0.8,0.0,0.6,0.7,0.6,0.6,0.7})))
    .addChild(new PointLight().setAmbientIntensity(1).setLocation(0.0,0.0,5.0).setRadius(30))
    .addChild(new NavigationInfo().setTransitionType(new String[] {"ANIMATE"}).setType(new String[] {"EXAMINE","FLY","ANY"}))
    .addChild(new Viewpoint().setDescription("Inspect 15JAN2010Newman").setOrientation(1.0,0.0,0.0,-0.0997).setPosition(0.0,2.0,20.0))
    .addComments(" type=\"3D\" <date day =\"3\" month=\"5\" year=\"2011\"/> ")
    .addChild(new Transform("infogroup").setTranslation(-8.0,2.0,-4.0)
      .addChild(new Transform("NetText").setTranslation(0.0,6.0,0.0)
        .addChild(new ProtoInstance("NetworkText").setContainerField("children")
          .addFieldValue(new fieldValue().setName("text").setValue(new String[] {"15JAN2010"})))))
    .addChild(new Group()
      .addChild(new Transform()
        .addChild(new ProtoInstance("Vertex").setContainerField("children")
          .addFieldValue(new fieldValue().setName("name").setValue("Vertex 1"))
          .addFieldValue(new fieldValue().setName("description").setValue("2010-01-15-ARMY.MIL"))
          .addFieldValue(new fieldValue().setName("vertexText").setValue(new String[] {"2010-01-15-ARMY.MIL"}))
          .addFieldValue(new fieldValue().setName("textTranslation").setValue(new SFVec3f(0.06344,-0.26178,-0.55101)))
          .addFieldValue(new fieldValue().setName("textColor").setValue(new SFColor(0.0,0.0,0.0)))
          .addFieldValue(new fieldValue().setName("url").setValue(new String[] {"http://www.army.mil"}))
          .addFieldValue(new fieldValue().setName("translation").setValue(new SFVec3f(0.06344,-0.26178,-0.55101)))
          .addFieldValue(new fieldValue().setName("radius").setValue(.1500))
          .addFieldValue(new fieldValue().setName("displayMode").setValue("BallAndStick"))
          .addFieldValue(new fieldValue().setName("diffuseColor").setValue(new SFColor(0.0,0.0,0.0)))
          .addFieldValue(new fieldValue().setName("transparency").setValue(0)))
        .addChild(new ProtoInstance("Arc").setContainerField("children")
          .addFieldValue(new fieldValue().setName("name").setValue("1.24"))
          .addFieldValue(new fieldValue().setName("description").setValue("From blah to blah"))
          .addFieldValue(new fieldValue().setName("url").setValue(new String[] {"http://www.google.com"}))
          .addFieldValue(new fieldValue().setName("cylinderHeight").setValue(0.64770))
          .addFieldValue(new fieldValue().setName("cylinderTranslation").setValue(new SFVec3f(-0.35062,-0.44066,-0.60713)))
          .addFieldValue(new fieldValue().setName("coneTranslation").setValue(new SFVec3f(-.48422,-.53116,-.63552)))
          .addFieldValue(new fieldValue().setName("rotation").setValue(new SFRotation(-11.22472,0.0,52.81325,2.15598)))
          .addFieldValue(new fieldValue().setName("displayMode").setValue("BallAndStick"))
          .addFieldValue(new fieldValue().setName("diffuseColor").setValue(new SFColor(0.0,0.0,0.0)))
          .addFieldValue(new fieldValue().setName("transparency").setValue(0))
          .addFieldValue(new fieldValue().setName("ballRadius").setValue(1)))
        .addChild(new ProtoInstance("Vertex").setContainerField("children")
          .addFieldValue(new fieldValue().setName("name").setValue("Vertex 2"))
          .addFieldValue(new fieldValue().setName("description").setValue("2010-01-15BLOGS.STATE.GOV-INDEX.PHP"))
          .addFieldValue(new fieldValue().setName("vertexText").setValue(new String[] {"2010-01-15BLOGS.STATE.GOV-INDEX.PHP"}))
          .addFieldValue(new fieldValue().setName("textTranslation").setValue(new SFVec3f(1.43526,1.19707,0.67279)))
          .addFieldValue(new fieldValue().setName("textColor").setValue(new SFColor(0.0,0.0,0.0)))
          .addFieldValue(new fieldValue().setName("url").setValue(new String[] {"http://www.state.gov"}))
          .addFieldValue(new fieldValue().setName("translation").setValue(new SFVec3f(1.28526,1.19707,0.67279)))
          .addFieldValue(new fieldValue().setName("radius").setValue(0.1500))
          .addFieldValue(new fieldValue().setName("displayMode").setValue("BallAndStick"))
          .addFieldValue(new fieldValue().setName("diffuseColor").setValue(new SFColor(0.5020,0.0,0.0)))
          .addFieldValue(new fieldValue().setName("transparency").setValue(0)))
        .addChild(new ProtoInstance("Arc").setContainerField("children")
          .addFieldValue(new fieldValue().setName("name").setValue("1.26"))
          .addFieldValue(new fieldValue().setName("description").setValue("From blah1 to blah1"))
          .addFieldValue(new fieldValue().setName("url").setValue(new String[] {"http://www.google.com"}))
          .addFieldValue(new fieldValue().setName("cylinderHeight").setValue(1.28361))
          .addFieldValue(new fieldValue().setName("cylinderTranslation").setValue(new SFVec3f(-0.12911,0.32068,-0.81718)))
          .addFieldValue(new fieldValue().setName("coneTranslation").setValue(new SFVec3f(-0.16106,0.75793,-1.01700)))
          .addFieldValue(new fieldValue().setName("rotation").setValue(new SFRotation(-53.23500,0.0,8.51149,0.43344)))
          .addFieldValue(new fieldValue().setName("displayMode").setValue("BallAndStick"))
          .addFieldValue(new fieldValue().setName("diffuseColor").setValue(new SFColor(0.0,0.0,0.0)))
          .addFieldValue(new fieldValue().setName("transparency").setValue(0))
          .addFieldValue(new fieldValue().setName("ballRadius").setValue(1)))
        .addChild(new ProtoInstance("Vertex").setContainerField("children")
          .addFieldValue(new fieldValue().setName("name").setValue("Vertex 3"))
          .addFieldValue(new fieldValue().setName("description").setValue("2010-01-15-FEEDS.FEEDBURNER.COM-DIPNOTE"))
          .addFieldValue(new fieldValue().setName("vertexText").setValue(new String[] {"2010-01-15-FEEDS.FEEDBURNER.COM-DIPNOTE"}))
          .addFieldValue(new fieldValue().setName("textColor").setValue(new SFColor(0.0,0.0,0.0)))
          .addFieldValue(new fieldValue().setName("textTranslation").setValue(new SFVec3f(0.08377,1.98542,-1.19849)))
          .addFieldValue(new fieldValue().setName("url").setValue(new String[] {"http://www.feedburner.com"}))
          .addFieldValue(new fieldValue().setName("translation").setValue(new SFVec3f(-0.06623,1.98542,-1.19849)))
          .addFieldValue(new fieldValue().setName("radius").setValue(.1500))
          .addFieldValue(new fieldValue().setName("displayMode").setValue("BallAndStick"))
          .addFieldValue(new fieldValue().setName("diffuseColor").setValue(new SFColor(1.0000,0.0,0.0)))
          .addFieldValue(new fieldValue().setName("transparency").setValue(0)))
        .addChild(new ProtoInstance("Arc").setContainerField("children")
          .addFieldValue(new fieldValue().setName("name").setValue("1.39"))
          .addFieldValue(new fieldValue().setName("description").setValue("From blah2 to blah2"))
          .addFieldValue(new fieldValue().setName("url").setValue(new String[] {"http://www.google.com"}))
          .addFieldValue(new fieldValue().setName("cylinderHeight").setValue(1.12537))
          .addFieldValue(new fieldValue().setName("cylinderTranslation").setValue(new SFVec3f(-0.35500,-0.38541,-1.02982)))
          .addFieldValue(new fieldValue().setName("coneTranslation").setValue(new SFVec3f(-0.54712,-0.47389,-1.37249)))
          .addFieldValue(new fieldValue().setName("rotation").setValue(new SFRotation(-95.76386,0.0,53.68924,1.79233)))
          .addFieldValue(new fieldValue().setName("displayMode").setValue("BallAndStick"))
          .addFieldValue(new fieldValue().setName("diffuseColor").setValue(new SFColor(0.0,0.0,0.0)))
          .addFieldValue(new fieldValue().setName("transparency").setValue(0))
          .addFieldValue(new fieldValue().setName("ballRadius").setValue(1))))));
            }
            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 PajekVisualizationPrototypes 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 PajekVisualizationPrototypes().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.Tools.Visualization.PajekVisualizationPrototypes\" 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.Tools.Visualization.PajekVisualizationPrototypes self-validation test confirmation: ");
                if (!validationResults.equals("success"))
                    System.out.println();
                System.out.println(validationResults.trim());

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