public void CanCallFactoryMethodWithoutArgument()
        {
            var obj = new ModelInstantiator().CallFactoryMethod(null, typeof(MyBO), "NewMyBO", null);

            Assert.IsInstanceOfType(obj, typeof(MyBO));
            Assert.AreEqual(0, ((MyBO)obj).ID);
        }
Exemple #2
0
    //function called from a button

    /*public void ButtonShare ()
     * {
     *      shareGraph.SetActive(false);
     *      if(!isProcessing){
     *              StartCoroutine( ShareScreenshot() );
     *      }
     * }
     * public IEnumerator ShareScreenshot()
     * {
     *      isProcessing = true;
     *      // wait for graphics to render
     *      yield return new WaitForEndOfFrame();
     *      //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PHOTO
     *      // create the texture
     *      Texture2D screenTexture = new Texture2D(Screen.width, Screen.height,TextureFormat.RGB24,true);
     *      // put buffer into texture
     *      screenTexture.ReadPixels(new Rect(0f, 0f, Screen.width, Screen.height),0,0);
     *      // apply
     *      screenTexture.Apply();
     *      //----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- PHOTO
     *      byte[] dataToSave = screenTexture.EncodeToPNG();
     *      string destination = Path.Combine(Application.persistentDataPath,System.DateTime.Now.ToString("yyyy-MM-dd-HHmmss") + ".png");
     *      File.WriteAllBytes(destination, dataToSave);
     *      if(!Application.isEditor)
     *      {
     *              // block to open the file and share it ------------START
     *              AndroidJavaClass intentClass = new AndroidJavaClass("android.content.Intent");
     *              AndroidJavaObject intentObject = new AndroidJavaObject("android.content.Intent");
     *              intentObject.Call<AndroidJavaObject>("setAction", intentClass.GetStatic<string>("ACTION_SEND"));
     *              AndroidJavaClass uriClass = new AndroidJavaClass("android.net.Uri");
     *              AndroidJavaObject uriObject = uriClass.CallStatic<AndroidJavaObject>("parse","file://" + destination);
     *              intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_STREAM"), uriObject);
     *
     *              intentObject.Call<AndroidJavaObject> ("setType", "text/plain");
     *              intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_TEXT"), ""+ message);
     *              intentObject.Call<AndroidJavaObject>("putExtra", intentClass.GetStatic<string>("EXTRA_SUBJECT"), "SUBJECT");
     *
     *              intentObject.Call<AndroidJavaObject>("setType", "image/jpeg");
     *              AndroidJavaClass unity = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
     *              AndroidJavaObject currentActivity = unity.GetStatic<AndroidJavaObject>("currentActivity");
     *
     *              currentActivity.Call("startActivity", intentObject);
     *      }
     *      isProcessing = false;
     *      shareGraph.SetActive(true);
     * }*/

    public void resetApp()
    {
        ModelInstantiator.resetGraph();

        int scene = SceneManager.GetActiveScene().buildIndex;

        SceneManager.LoadScene(scene, LoadSceneMode.Single);
    }
 public void CheckUI()
 {
     if (ServerStream.dataList != null)
     {
         if (ServerStream.dataList.Count == 0)
         {
             displayParallelCoord();
             //displayLayers();
             //scatterplot.read();
             //ENVmds.read();
             FilteringTypes.filter_nodes(filterPrefab, textPrefab);
             //datasetB();
             //stopTracking();
             //LayeredMapping.furtherData();
             //LayeredMapping.hideLayers();
             //initHistory(false);
             //initHistory(true);
             //initHistory(false);
             //initHistory(false);
             //makeENVlayer(1);
             //makeENVlayer(2);
             //makeENVlayer(3);
             //SetEdgeBundle();
             //print("MI count" + instantiators.Count);
             //smokey_minimize();  // initialize the view
         }
         if (ServerStream.dataList.Count != 0)
         {
             specie_name = ServerStream.dataList[0];
             ServerStream.LoadNext();
             BuildInstantiator();
             if (ServerStream.dataList.Count == 0 && ONCEE == false)
             {
                 ServerStream.newData();
                 displayLayers();
                 instantiators.Clear();
                 if (ONCEE == false)
                 {
                     //print("sdsad"+instantiators.Count);
                     //instantiators.Clear();
                 }
                 batchCount = allHabitats.Count;
                 AllbatchCounts.Add(eachSpecieCount);
                 print(eachSpecieCount);
                 //eachSpecieCount = 0;
                 ModelInstantiator.hideAll();
             }
             if (ServerStream.dataList.Count == 0 && ONCEE == true)
             {
                 displayLayers();
                 AllbatchCounts.Add(eachSpecieCount);
                 print(eachSpecieCount);
                 //instantiators.Clear();
             }
             CheckUI();
         }
     }
 }
 public void datasetB()
 {
     ModelInstantiator.hideAll();
     for (int i = AllbatchCounts[2]; i < AllbatchCounts[3]; i++)
     {
         allHabitats[i].SetActive(true);
         LayeredHabitats[i].SetActive(true);
     }
     activeData = 4;
 }
        public void CanCallFactoryMethodWithArgument()
        {
            var objType = typeof(MyBO);
            var mtd     = "GetMyBO";

            object[] argValues = { 1 };

            var obj = new ModelInstantiator().CallFactoryMethod(objType, objType, mtd, argValues);

            Assert.IsInstanceOfType(obj, typeof(MyBO));
            Assert.AreEqual(1, ((MyBO)obj).ID);
        }
        public void CanCallGetMethodByConventionWhenActionMethodIsEdit()
        {
            var action = "Edit";
            var type   = typeof(MyBO);

            object[] argValues = { 10 };

            var obj = new ModelInstantiator().CallFactoryMethod(action, type, type, argValues);

            Assert.IsInstanceOfType(obj, typeof(MyBO));
            Assert.AreEqual(10, ((MyBO)obj).ID);
        }
 public void trial6()
 {
     writer.WriteLine("TRIAL 6");
     ModelInstantiator.hideAll();
     for (int i = AllbatchCounts[4]; i < AllbatchCounts[5]; i++)
     {
         allHabitats[i].SetActive(true);
         LayeredHabitats[i].SetActive(true);
     }
     activeData = 6;
     LayeredMapping.hideOthers(10);
     ENVmds.hideScatter();
 }
        public void CanCallMethodWithinFactoryClassWithoutArgument()
        {
            var fType = typeof(MyFactory);
            var oType = typeof(MyBO);
            var mtd   = "NewMyBO";

            object[] argValues = {};

            var obj = new ModelInstantiator().CallFactoryMethod(fType, oType, mtd, argValues);

            Assert.IsInstanceOfType(obj, typeof(MyBO));
            Assert.AreEqual(0, ((MyBO)obj).ID);
        }
        public void CanCallMethodWithinFactoryClassWithUnknownButConvertibleTypeArgumentLongToInt()
        {
            var fType = typeof(MyFactory);
            var oType = typeof(MyBO);
            var mtd   = "GetMyBO";

            object[] argValues = { new[] { 5L } };

            var obj = new ModelInstantiator().CallFactoryMethod(fType, oType, mtd, argValues);

            Assert.IsInstanceOfType(obj, typeof(MyBO));
            Assert.AreEqual(5, ((MyBO)obj).ID);
        }
        public void CanAddFactoryMapPatternNewPattern()
        {
            FactoryMethodLocator.PatternMappings.Add(new PatternMap {
                ActionPattern = "f*", MethodPatterns = new[] { "Get.*ByX" }
            });

            var action = "FooFoo";
            var type   = typeof(MyBO);

            object[] argValues = { "100" };

            var obj = new ModelInstantiator().CallFactoryMethod(action, type, type, argValues);

            Assert.IsInstanceOfType(obj, typeof(MyBO));
            Assert.AreEqual(100, ((MyBO)obj).ID);
        }
    public void BuildInstantiator()
    {
        const int MaxLength = 19;           // setting a limit to the length of specie name

        if (nodePrefab != null)
        {
            dataColor  = FindColor();                   // assigning a color to each specie
            MI         = new ModelInstantiator();
            MI.dataSet = DataManager.dataSet;
            MI.color   = dataColor;
            if (specie_name.Length > MaxLength)
            {
                MI.name1 = specie_name.Substring(0, MaxLength);
            }
            else
            {
                MI.name1 = specie_name;
            }

            MI.InstantiateDataPoints(DataManager.longitude, DataManager.lattitude, whitePrefab);
            allNames.Add(MI.name1);
            instantiators.Add(MI);
        }
    }
 void Update()
 {
     if (yessplus == true)
     {
         sub.transform.parent        = all_targets[detectedImageCount].transform;
         sub.transform.localPosition = new Vector3(0, -0.3f, 4);
         sub.transform.localRotation = Quaternion.Euler(90, 0, 0);
         yessplus = false;
     }
     if (yess == true)
     {
         oldFocusedObject = FocusedObject;
         oldDirection     = newDirection;
         oldPosition      = newPosition;
         sub.GetComponent <TextMesh>().text = (Camera.main.transform.position - difference).ToString() + '\n' + Camera.main.transform.up + '\n' + Camera.main.transform.forward;
         if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hitInfo))
         {
             FocusedObject = hitInfo.collider.gameObject;
             if (FocusedObject != oldFocusedObject)
             {
                 focusedobjectName = FocusedObject.name;
                 print(FocusedObject.name);
             }
         }
         else
         {
             FocusedObject     = null;
             focusedobjectName = "none";
         }
         newPosition  = Camera.main.transform.position - difference;
         newDirection = Camera.main.transform.forward;
         if (newPosition != oldPosition)
         {
             writer.WriteLine(focusedobjectName + "," + newPosition.ToString() + "," + Camera.main.transform.position + "," + difference + "," + Camera.main.transform.forward + ',' + Camera.main.transform.up + ',' + Time.time);
         }
         if (newDirection != oldDirection)
         {
             writer.WriteLine(focusedobjectName + "," + newPosition.ToString() + "," + Camera.main.transform.position + "," + difference + "," + Camera.main.transform.forward + ',' + Camera.main.transform.up + ',' + Time.time);
         }
     }
     if (update == true)
     {
         CheckUI();
         update = false;
     }
     if (Input.GetKeyDown("m"))
     {
         Subspaces.merge_spaces();
     }
     if (Input.GetKeyDown("1"))
     {
         writer.WriteLine("TRIAL 1");
         ModelInstantiator.hideAll();
         for (int i = 0; i < AllbatchCounts[0]; i++)
         {
             allHabitats[i].SetActive(true);
             LayeredHabitats[i].SetActive(true);
         }
         activeData = 1;
         LayeredMapping.hideOthers(0);
         ENVmds.hideScatter();
     }
     if (Input.GetKeyDown("2"))
     {
         writer.WriteLine("TRIAL 2");
         ModelInstantiator.hideAll();
         for (int i = AllbatchCounts[0]; i < AllbatchCounts[1]; i++)
         {
             allHabitats[i].SetActive(true);
             LayeredHabitats[i].SetActive(true);
         }
         activeData = 2;
         LayeredMapping.hideOthers(0);
         ENVmds.hideScatter();
     }
     if (Input.GetKeyDown("3"))
     {
         writer.WriteLine("TRIAL 3");
         ModelInstantiator.hideAll();
         for (int i = AllbatchCounts[1]; i < AllbatchCounts[2]; i++)
         {
             allHabitats[i].SetActive(true);
             LayeredHabitats[i].SetActive(true);
         }
         activeData = 3;
         LayeredMapping.hideOthers(0);
         ENVmds.hideScatter();
     }
     if (Input.GetKeyDown("4"))
     {
         writer.WriteLine("TRIAL 4");
         ModelInstantiator.hideAll();
         for (int i = AllbatchCounts[2]; i < AllbatchCounts[3]; i++)
         {
             allHabitats[i].SetActive(true);
             LayeredHabitats[i].SetActive(true);
         }
         activeData = 4;
         LayeredMapping.hideOthers(3);
         ENVmds.hideScatter();
     }
     if (Input.GetKeyDown("5"))
     {
         writer.WriteLine("TRIAL 5");
         ModelInstantiator.hideAll();
         for (int i = AllbatchCounts[3]; i < AllbatchCounts[4]; i++)
         {
             allHabitats[i].SetActive(true);
             LayeredHabitats[i].SetActive(true);
         }
         activeData = 5;
         LayeredMapping.hideOthers(6);
         ENVmds.hideScatter();
     }
     if (Input.GetKeyDown("6"))
     {
         writer.WriteLine("TRIAL 6");
         ModelInstantiator.hideAll();
         for (int i = AllbatchCounts[4]; i < AllbatchCounts[5]; i++)
         {
             allHabitats[i].SetActive(true);
             LayeredHabitats[i].SetActive(true);
         }
         activeData = 6;
         LayeredMapping.hideOthers(10);
         ENVmds.hideScatter();
     }
     if (Input.GetKeyDown("7"))
     {
         writer.WriteLine("TRIAL 7");
         LayeredMapping.hideOthers(0);
         ENVmds.hideScatter();
         ENVmds.read1();
     }
     if (Input.GetKeyDown("8"))
     {
         writer.WriteLine("TRIAL 8");
         LayeredMapping.hideOthers(0);
         ENVmds.hideScatter();
         ENVmds.read2();
     }
     if (Input.GetKeyDown("9"))
     {
         writer.WriteLine("TRIAL 9");
         LayeredMapping.hideOthers(0);
         ENVmds.hideScatter();
         ENVmds.read3();
     }
     if (Input.GetKeyDown("0"))
     {
         writer.WriteLine("TRIAL 10");
         DeleteAllENV();
         LayeredMapping.hideOthers(0);
         ENVmds.hideScatter();
         makeENVlayer(1);
         makeENVlayer(0);
         makeENVlayer(3);
     }
     if (Input.GetKeyDown("-"))
     {
         writer.WriteLine("TRIAL 11");
         DeleteAllENV();
         LayeredMapping.hideOthers(0);
         ENVmds.hideScatter();
         makeENVlayer(4);
         makeENVlayer(5);
         makeENVlayer(6);
         makeENVlayer(7);
         makeENVlayer(10);
         makeENVlayer(2);
     }
     if (Input.GetKeyDown("="))
     {
         writer.WriteLine("TRIAL 12");
         DeleteAllENV();
         LayeredMapping.hideOthers(0);
         ENVmds.hideScatter();
         makeENVlayer(10);
         makeENVlayer(9);
         makeENVlayer(8);
         makeENVlayer(15);
         makeENVlayer(17);
         makeENVlayer(20);
         makeENVlayer(21);
         makeENVlayer(11);
         makeENVlayer(22);
         makeENVlayer(23);
     }
     if (Input.GetKeyDown("b"))
     {
         ParallelCoordInstantiator.delete();
     }
     if (Input.GetKeyDown("z"))
     {
         //Subspaces.Highlight();
         //initHistory();
         //for (int i = 0; i < allHabitats.Count; i++)
         //{
         //    allHabitats[i].SetActive(true);
         //    //LayeredHabitats[i].SetActive(true);
         //}
     }
 }
        public void MustAtLeastPassReturnTypeAndFactoryMethod()
        {
            var obj = new ModelInstantiator().CallFactoryMethod(null, typeof(MyBO), "NewMyBO", null);

            Assert.IsInstanceOfType(obj, typeof(MyBO));
        }
    void Update()
    {
        if (Input.GetKeyDown("l"))
        {
            sub.GetComponent <TextMesh>().color = Color.green;
            difference = Camera.main.transform.position;
            yessplus   = true;
        }
        if (yessplus == true)
        {
            sub.transform.parent        = all_targets[detectedImageCount].transform;
            sub.transform.localPosition = new Vector3(0, -0.3f, 2);
            sub.transform.localRotation = Quaternion.Euler(90, 0, 0);
            yessplus       = false;
            subspaceWeight = true;
        }
        if (yess == true)
        {
            oldFocusedObject = FocusedObject;
            oldDirection     = newDirection;
            oldPosition      = newPosition;
            //sub.GetComponent<TextMesh>().text = (Camera.main.transform.position - difference).ToString();
            sub.GetComponent <TextMesh>().text = (Camera.main.transform.position - difference).ToString() + '\n' + Camera.main.transform.forward;
            if (Physics.Raycast(Camera.main.transform.position, Camera.main.transform.forward, out hitInfo))
            {
                FocusedObject = hitInfo.collider.gameObject;
                if (FocusedObject != oldFocusedObject)
                {
                    focusedobjectName = FocusedObject.name;
                    //print(FocusedObject.name);
                }
            }
            else
            {
                FocusedObject     = null;
                focusedobjectName = "none";
            }
            newPosition  = Camera.main.transform.position - difference;
            newDirection = Camera.main.transform.forward;
            if (newPosition != oldPosition)
            {
                //writer.WriteLine(focusedobjectName + "," + newPosition.ToString() + "," + Camera.main.transform.position + "," + difference + "," + Camera.main.transform.forward + ',' + Time.time);
            }
            if (newDirection != oldDirection)
            {
                //writer.WriteLine(focusedobjectName + "," + newPosition.ToString() + "," + Camera.main.transform.position + "," + difference + "," + Camera.main.transform.forward + ',' + Time.time);
            }
        }
        if (update == true)
        {
            CheckUI();
            update = false;
        }

        if (Input.GetKeyDown("m"))
        {
            Subspaces.merge_spaces();
        }
        if (Input.GetKeyDown("1"))
        {
            ModelInstantiator.hideAll();
            //for (int i = 0; i < allHabitats.Count; i++)
            //{
            //    allHabitats[i].SetActive(false);
            //    LayeredHabitats[i].SetActive(false);
            //}
            for (int i = 0; i < AllbatchCounts[0]; i++)
            {
                allHabitats[i].SetActive(true);
                LayeredHabitats[i].SetActive(true);
            }
            activeData = 1;
            ParallelCoordInstantiator.delete();
            DataManager.LoadEnvData("species_parallel_allSpecies", 49, ServerStream.dataList1);
            displayParallelCoord();
        }
        if (Input.GetKeyDown("2"))
        {
            ModelInstantiator.hideAll();
            for (int i = AllbatchCounts[0]; i < AllbatchCounts[1]; i++)
            {
                allHabitats[i].SetActive(true);
                LayeredHabitats[i].SetActive(true);
            }
            activeData = 2;
            ParallelCoordInstantiator.delete();
            DataManager.LoadEnvData("species_parallel_allSpecies", 49, ServerStream.Reptile1);
            displayParallelCoord();
        }
        if (Input.GetKeyDown("3"))
        {
            ModelInstantiator.hideAll();
            for (int i = AllbatchCounts[1]; i < AllbatchCounts[2]; i++)
            {
                allHabitats[i].SetActive(true);
                LayeredHabitats[i].SetActive(true);
            }
            activeData = 3;
            ParallelCoordInstantiator.delete();
            DataManager.LoadEnvData("species_parallel_allSpecies", 49, ServerStream.algae1);
            displayParallelCoord();
        }
        if (Input.GetKeyDown("4"))
        {
            ModelInstantiator.hideAll();
            for (int i = AllbatchCounts[2]; i < AllbatchCounts[3]; i++)
            {
                allHabitats[i].SetActive(true);
                LayeredHabitats[i].SetActive(true);
            }
            activeData = 4;
            ParallelCoordInstantiator.delete();
            DataManager.LoadEnvData("species_parallel_allSpecies", 49, ServerStream.Amphibian1);
            displayParallelCoord();
        }
        if (Input.GetKeyDown("5"))
        {
            ModelInstantiator.hideAll();
            for (int i = AllbatchCounts[3]; i < AllbatchCounts[4]; i++)
            {
                allHabitats[i].SetActive(true);
                LayeredHabitats[i].SetActive(true);
            }
            activeData = 5;
            ParallelCoordInstantiator.delete();
            DataManager.LoadEnvData("species_parallel_allSpecies", 49, ServerStream.Fish1);
            displayParallelCoord();
        }
        if (Input.GetKeyDown("6"))
        {
            ModelInstantiator.hideAll();
            for (int i = AllbatchCounts[4]; i < AllbatchCounts[5]; i++)
            {
                allHabitats[i].SetActive(true);
                LayeredHabitats[i].SetActive(true);
            }
            activeData = 6;
            ParallelCoordInstantiator.delete();
            DataManager.LoadEnvData("species_parallel_allSpecies", 49, ServerStream.Mammal1);
            displayParallelCoord();
        }
        if (Input.GetKeyDown("7"))
        {
            ModelInstantiator.hideAll();
            for (int i = AllbatchCounts[5]; i < AllbatchCounts[6]; i++)
            {
                allHabitats[i].SetActive(true);
                LayeredHabitats[i].SetActive(true);
            }
            activeData = 7;
            ParallelCoordInstantiator.delete();
            DataManager.LoadEnvData("species_parallel_allSpecies", 49, ServerStream.Bird1);
            displayParallelCoord();
        }
        if (Input.GetKeyDown("8"))

        {
            ModelInstantiator.hideAll();
            for (int i = AllbatchCounts[6]; i < AllbatchCounts[7]; i++)
            {
                allHabitats[i].SetActive(true);
                LayeredHabitats[i].SetActive(true);
            }
            activeData = 8;
            ParallelCoordInstantiator.delete();
            DataManager.LoadEnvData("species_parallel_allSpecies", 49, ServerStream.Plant11);
            displayParallelCoord();
        }
        if (Input.GetKeyDown("9"))
        {
            ModelInstantiator.hideAll();
            for (int i = AllbatchCounts[7]; i < AllbatchCounts[8]; i++)
            {
                allHabitats[i].SetActive(true);
                LayeredHabitats[i].SetActive(true);
            }
            activeData = 9;
            ParallelCoordInstantiator.delete();
            DataManager.LoadEnvData("species_parallel_allSpecies", 49, ServerStream.Plant21);
            displayParallelCoord();
        }
        if (Input.GetKeyDown("0"))
        {
            ModelInstantiator.hideAll();
            for (int i = AllbatchCounts[8]; i < AllbatchCounts[9]; i++)
            {
                allHabitats[i].SetActive(true);
                LayeredHabitats[i].SetActive(true);
            }
            activeData = 10;
            ParallelCoordInstantiator.delete();
            DataManager.LoadEnvData("species_parallel_allSpecies", 49, ServerStream.Plant31);
            displayParallelCoord();
        }
        if (Input.GetKeyDown("b"))
        {
            ParallelCoordInstantiator.delete();
        }
        if (Input.GetKeyDown("z"))
        {
            //Subspaces.Highlight();
            //initHistory();
            //for (int i = 0; i < allHabitats.Count; i++)
            //{
            //    allHabitats[i].SetActive(true);
            //    //LayeredHabitats[i].SetActive(true);
            //}
        }
    }