Ejemplo n.º 1
0
        public IHttpActionResult Get(double width = 1.0d, double height = 1.0d, double scale = 10.0d, string filename = "eroticnovel")
        {
            var analysis = DataFile.GetContents(filename);

            var data = new HeatmapData
            {
                DataPoints = analysis.RankedSentences.Where(sentence => sentence.Arousal != 0.0d && sentence.Valence != 0.0d).ToArray()
            };

            //var noData = datapoints.Count(d => d.Arousal == 0.0d && d.Valence == 0.0d);
            //var poorData = datapoints.Count(d => d.Arousal == 0.0d || d.Valence == 0.0d);
            //var lowData = datapoints.Count(d => d.Arousal < 2.0d && d.Valence < 2.0d);

            var actualScale = scale / 10.0d;

            var response = data.ToSimpleHeatData(width, height, actualScale);

            return(Ok(response));
        }
Ejemplo n.º 2
0
 public Heatmap(string _name)
 {
     heatmapResolution = 64;
     flipAutoConstrain = false;
     autoConstrain     = false;
     alphaMapData      = null;
     heatmapValues     = null;
     lowerValueLimit   = 0;
     higherValueLimit  = 100;
     name              = _name;
     texSource         = TextureSource.DefaultColors;
     splatPrototypes   = null;
     interpolationMode = InterpolationMode.NearestNeighbor;
     heatmapDataPoints = null;
     dataType          = HeatmapData.HeightMap;
     heatmapSplatMaps  = new List <HeatmapSplatprototype>();
     baseValue         = 0.0f;
     filter            = "";
 }
Ejemplo n.º 3
0
    public void RefreshData()
    {
        // Calculates the dimensions of the grid, in units (but rounded to fit divisions correctly)
        if (File == null)
        {
            Data = new HeatmapData(
                Mathf.RoundToInt(Size.x / Division.x),
                Mathf.RoundToInt(Size.y / Division.y)
                );
        }
        else
        {
            // Or loads a file if there's one selected
            Data = HeatmapData.FromJSONFile(File);
        }

        _Size = new Vector3(Data.Width * Division.x, 0.0f, Data.Height * Division.y);

        RefreshPosition();
    }
Ejemplo n.º 4
0
    public void RefreshData()
    {
        // Calculates the dimensions of the grid, in units (but rounded to fit divisions correctly)
        if (File == null)
            Data = new HeatmapData(
                Mathf.RoundToInt(Size.x / Division.x),
                Mathf.RoundToInt(Size.y / Division.y)
            );
        else
            // Or loads a file if there's one selected
            Data = HeatmapData.FromJSONFile(File);

        _Size = new Vector3(Data.Width * Division.x, 0.0f, Data.Height * Division.y);

        RefreshPosition();
    }
    public void SetHeatmapData(string json)
    {
//		Debug.Log("json:"+json);
        SimpleJSON.JSONArray hms = (SimpleJSON.JSONArray)SimpleJSON.JSONArray.Parse(json).AsArray;         // get list of objects from string memory and convert to json array
        Debug.Log("heatmap obj:" + hms.ToString());
        foreach (SimpleJSON.JSONClass n in hms)
        {
            // Create a new heatmap avatar data class and populate it
            HeatmapData data = new HeatmapData();
            // Instantaite and
            data.avatar     = (HeatmapAvatar)Instantiate(avatarPrefab).GetComponent <HeatmapAvatar>() as HeatmapAvatar;
            data.avatarJson = n["avatarJson"];
            foreach (SimpleJSON.JSONClass nn in n["positions"]["points"].AsArray.Childs)
            {
                // Add all the heatmap posiitons to the avatar class list so we can iterate through them and move the 3d avatar around
                if (nn["pos"].ToString().Contains(","))
                {
                    data.avatar.positions.Add(JsonUtil.GetRealPositionFromTruncatedPosition(nn["pos"]));
                }
            }
            data.name = n["name"];
            data.cls  = n["class"];
            heatmaps.Add(data);


            // set costume and colors of 3d Avatar object
            data.avatar.transform.position = data.avatar.positions[1];
            SimpleJSON.JSONClass avatarJson = (SimpleJSON.JSONClass)SimpleJSON.JSONClass.Parse(data.avatarJson);
            Color bodyColor = PlayerCostumeController.inst.allMaterials[avatarJson["BodyColorIndex"].AsInt].color;

            data.avatar.SetHeatmapAvatarProperties(bodyColor, data.name);
            data.avatar.gameObject.name = "instnaced avatar ata time;" + Time.time;
            data.avatar.GetComponentInChildren <PlayerCostumeController>().SetCharacterMaterials(data.avatarJson);

            // Instantaite a 2d legend item for managing this avatar
            GameObject legendObj = (GameObject)Instantiate(legendObjectPrefab);
//			Debug.Log("made legend.:"+data.avatar.name);
            // Was a class already existing for this legend object?
            bool       parentWasSet   = false;
            GameObject legendObjClass = null;
            foreach (HeatmapLegendItemClass clss in FindObjectsOfType <HeatmapLegendItemClass>())
            {
                if (clss.className == data.cls)
                {
                    legendObjClass = clss.gameObject;
                    legendObj.transform.SetParent(clss.transform); // all avatar legend objs are children of classes
                    parentWasSet = true;                           // We are done, no need to create cls object
                }
            }
            if (!parentWasSet)
            {
                // no cls obj found, create cls object
                legendObjClass = (GameObject)Instantiate(legendObjectPrefabClass);
                HeatmapLegendItemClass clss = legendObjClass.GetComponent <HeatmapLegendItemClass>();
                clss.className          = data.cls;             // set the name of this class object (there will only be one class object with this name)
                clss.classNameText.text = data.cls;             // redundant but is the visiable 2d text obj not the hidden string ..lol
                legendObjClass.transform.SetParent(legendList); // classes are a child of the master legend list, all avatar legend objs are children of classes
                legendObj.transform.SetParent(legendObjClass.transform);
            }

            // Finally set the height of the class item based on number of items in that class, so that heights all line up
            if (legendObjClass)              // should have been set from either finidng the pre-existing class obj in the foreach, or creating on if !parentWasSet
            {
                legendObjClass.GetComponent <HeatmapLegendItemClass>().UpdateRectHeight();
            }

            HeatmapLegendItem legendItem = legendObj.GetComponent <HeatmapLegendItem>();
            string            totalTime  = Utils.DisplayAsTimeFromSeconds(data.avatar.positions.Count * heatmapTimeInterval);
            Color             hairColor  = PlayerCostumeController.inst.allMaterials[avatarJson["HairColorIndex"].AsInt].color;
            Color             headColor  = PlayerCostumeController.inst.allMaterials[avatarJson["HeadColorIndex"].AsInt].color;
            legendItem.SetHeatmapLegendProperties(data.avatar, data.name, data.cls, totalTime, bodyColor, headColor, hairColor);
            data.legendObject = legendObj;

            if (!snappedThisPlay)              //only do once.
            {
                snappedThisPlay = true;
                LevelBuilder.inst.SnapPanToPosition(data.avatar.transform.position);
            }
            if (debug)
            {
                WebGLComm.inst.Debug("Created;" + data.avatar.name);
            }

            // Create the objects from string memory.

            // Note that this creates the peice wherever it was in world space when the copy was made, so we'll reposition the items to current mouse pos after creation.
        }

        // Whew, we're done populating heatmap data and 2d and corresponding map 3d objects!
        // Now calculate how high the 2d content is so it all fits in the scrollRect!

        float avgChildHeight = 40f;
        float heatmapsHeight = 500 + Mathf.Max(0, (heatmaps.Count - 8) * avgChildHeight);    // each heatmap avatar 2d has a height about 40
        float classesHeight  = FindObjectsOfType <HeatmapLegendItemClass>().Length * 100f;   // classes have height too
        float totalHeight    = heatmapsHeight + classesHeight;

        legendScroll.content.sizeDelta = new Vector2(0, heatmapsHeight + classesHeight);
//		EnableControls();
    }