private void EnableThresholdFilter(JSONNode axisSpecs, DxR.Scale scale) { Transform slider = gameObject.transform.Find("AxisLine/Slider"); slider.gameObject.SetActive(true); SetFilterLength(axisSpecs["length"].AsFloat); DxR.SliderGestureControlBothSide sliderControl = slider.GetComponent <DxR.SliderGestureControlBothSide>(); if (sliderControl == null) { return; } float domainMin = float.Parse(scale.domain[0]); float domainMax = float.Parse(scale.domain[1]); // TODO: Check validity of specs. sliderControl.SetSpan(domainMin, domainMax); sliderControl.SetSliderValue1(domainMin); sliderControl.SetSliderValue2(domainMax); slider.gameObject.name = dataField; interactionsObject.EnableAxisThresholdFilter(dataField); if (interactionsObject != null) { sliderControl.OnUpdateEvent.AddListener(interactionsObject.ThresholdFilterUpdated); } }
public void ConstructTicks(JSONNode axisSpecs, DxR.Scale scale) { bool showTickLabels = false; if (axisSpecs["labels"] != null) { showTickLabels = axisSpecs["labels"].AsBool; } Transform parent = gameObject.transform.Find("Ticks"); GameObject tickPrefab = Resources.Load("Axis/Tick") as GameObject; if (tickPrefab == null) { throw new Exception("Cannot find tick prefab."); } for (int i = 0; i < axisSpecs["values"].Count; i++) { string domainValue = axisSpecs["values"][i].Value; float pos = float.Parse(scale.ApplyScale(domainValue)) * DxR.Vis.SIZE_UNIT_SCALE_FACTOR; string label = showTickLabels ? domainValue : ""; AddTick(axisSpecs["face"], axisSpecs["orient"], pos, label, tickPrefab, parent); } }
public void UpdateSpecs(JSONNode axisSpecs, DxR.Scale scale) { if (axisSpecs["title"] != null) { SetTitle(axisSpecs["title"].Value); } if (axisSpecs["titlePadding"] != null) { SetTitlePadding(axisSpecs["titlePadding"].Value); } float axisLength = 0.0f; if (axisSpecs["length"] != null) { axisLength = axisSpecs["length"].AsFloat; SetLength(axisLength); } if (axisSpecs["orient"] != null && axisSpecs["face"] != null) { SetOrientation(axisSpecs["orient"].Value, axisSpecs["face"].Value); } if (axisSpecs["ticks"].AsBool && axisSpecs["values"] != null) { ConstructTicks(axisSpecs, scale); } if (axisSpecs["color"] != null) { SetColor(axisSpecs["color"].Value); } if (axisSpecs["filter"] != null) { if (axisSpecs["filter"].AsBool) { EnableThresholdFilter(axisSpecs, scale); } } }