private static string GetIcon(Highlight hl, string value) { return string.Format("{0}_{1}.png", hl.SelectionCriteria, value); }
private static Color GetHighlightColor(Highlight hl, double value) { if (hl.Palette == null) return Colors.Black; //if (hl.TempBrush == null) hl.TempBrush = hl.Palette.GetBrush(); var linbrush = hl.Palette.GetBrush(); var p = (value - hl.MinValue) / (hl.MaxValue - hl.MinValue); var c = ColorHelper.GetColorAtPoint(linbrush, new Point(p, 0.0)); return c; }
private static double GetOpacity(Highlight hl, double value) { try { var p = Math.Max(0, Math.Min(0.9, (value - hl.MinValue) / (hl.MaxValue - hl.MinValue))); return p; } catch (Exception) { return 0.0; } }
private static double GetSymbolSize(Highlight hl, double value) { try { var p = Math.Max(0.4, 0.4 + Math.Min(1.0, (value - hl.MinValue) / (hl.MaxValue - hl.MinValue))); var r = Math.Sqrt(Math.Max(1.0, p * 1000.0)); return r; } catch (Exception) { return 0.0; } }
private static double GetStrokeWidth(Highlight hl, double value) { try { var p = Math.Max(0.1, 0.1 + Math.Min(1.0, (value - hl.MinValue) / (hl.MaxValue - hl.MinValue))); var r = Math.Max(1.0, p * 10.0); return r; } catch (Exception) { return 0.0; } }
private static Color GetStringHighlightColor(Highlight hl, string value) { if (hl.Palette == null) return Colors.Black; var linbrush = hl.Palette.GetBrush(); var hist = Histogram.IndexOf(k => k.Key.ToString() == value); var count = linbrush.GradientStops.Count > 9 ? linbrush.GradientStops.Count/2 : linbrush.GradientStops.Count; var p = (double) (hist)/count + .1/count; var c = ColorHelper.GetColorAtPoint(linbrush, new Point(p, 0.0)); return c; }
public Highlight AddFilter(string title, string label, string stringvalue = "", double numbervalue = 0) { var mi = MetaInfo.FirstOrDefault(k => k.Label == label); if (mi == null) return null; var hl = new Highlight { Title = title, HighlighterType = HighlighterTypes.FilterThreshold, StringValue = stringvalue, ThresholdType = ThresholdTypes.Equal, PoiType = ContentId, SelectionCriteria = label, SelectionType = (mi.Type == MetaTypes.sensor) ? SelectionTypes.Sensor : SelectionTypes.Label, }; switch (mi.Type) { case MetaTypes.text: hl.ValueType = ValueTypes.String; break; case MetaTypes.number: hl.ValueType = ValueTypes.Number; hl.ThresHoldValue = numbervalue; hl.ThresholdType = ThresholdTypes.Greater; hl.CalculateMax((PoiService)Service); hl.CalculateMin((PoiService)Service); break; } //var pt = ((PoiService) service).PoITypes.FirstOrDefault(k => k.ContentId == PoiTypeId); Style?.Analysis.Highlights.Add(hl); return hl; }
/// <summary> /// Create a highlighter. /// Note that you still need to add it to the Style.Analysis. /// </summary> /// <param name="title"></param> /// <param name="label"></param> /// <param name="stringvalue"></param> /// <returns></returns> public Highlight AddHighlighter(string title, string label, string stringvalue = "") { var mi = MetaInfo.FirstOrDefault(k => k.Label == label); if (mi == null) return null; var hl = new Highlight { Title = title, HighlighterType = HighlighterTypes.Highlight, PoiType = PoiTypeId, SelectionCriteria = label, SelectionType = (mi.Type == MetaTypes.sensor) ? SelectionTypes.Sensor : SelectionTypes.Label, }; return hl; }
public void FromXml(XElement res, string directoryName, bool catchException) { try { Folder = directoryName; BaseStyle = res.GetString("BaseStyle"); FillColor = res.GetNullColor("FillColor"); StrokeColor = res.GetNullColor("StrokeColor"); var dm = res.GetString("DrawingMode"); if (!string.IsNullOrEmpty(dm)) DrawingMode = (DrawingModes) Enum.Parse(typeof (DrawingModes), dm); strokeWidth = res.GetNullDouble("StrokeWidth"); IconWidth = res.GetNullDouble("IconWidth"); IconHeight = res.GetNullDouble("IconHeight"); Icon = res.GetString("IconUri"); Category = res.GetString("Category"); CallOutFillColor = res.GetNullColor("CallOutFillColor"); CallOutForeground = res.GetNullColor("CallOutForeground"); var tm = res.GetString("TapMode"); if (tm!=null) TapMode = (TapMode) Enum.Parse(typeof (TapMode), tm); var ttm = res.GetString("TitleMode"); if (ttm != null) TitleMode = (TitleModes) Enum.Parse(typeof (TitleModes), ttm); MinResolution = res.GetNullDouble("MinResolution"); MaxResolution = res.GetNullDouble("MaxResolution"); NameLabel = res.GetString("NameLabel"); AutoCallOutLabels = res.GetNullBool("AutoCallOutLabels"); StrokeOpacity = res.GetNullDouble("StrokeOpacity"); FillOpacity = res.GetNullDouble("FillOpacity"); Visible = res.GetNullBool("Visible"); Name = res.GetString("Name"); CanRotate = res.GetNullBool("CanRotate"); CanMove = res.GetNullBool("CanMove"); CanEdit = res.GetNullBool("CanEdit"); CanDelete = res.GetNullBool("CanDelete"); CallOutTimeOut = res.GetNullInt("CallOutTimeOut"); ShowOnTimeline = res.GetString("ShowOnTimeline"); MaxTitleResolution = res.GetNullDouble("MaxTitleResolution"); CallOutMaxWidth = res.GetNullDouble("CallOutMaxWidth"); CallOutMinHeight = res.GetNullDouble("CallOutMinHeight"); InnerTextLabel = res.GetString("InnerTextLabel"); InnerTextColor = res.GetNullColor("InnerTextColor"); Cluster = res.GetBool("Cluster"); ScalePoi = res.GetNullBool("ScalePoi"); ScaleStartResolution = res.GetNullDouble("ScaleStartResolution"); ScaleUnits = res.GetNullDouble("ScaleUnits"); MaxScale = res.GetNullDouble("MaxScale"); SubTitles = res.GetString("SubTitles"); var am = res.GetString("AddMode"); if (am!=null) AddMode = (AddModes) Enum.Parse(typeof (AddModes), am); var coo = res.GetString("CallOutOrientation"); if (coo!=null) CallOutOrientation = (CallOutOrientation)Enum.Parse(typeof (CallOutOrientation),coo); var tb = res.GetString("TimelineBehaviour"); if (tb != null) TimelineBehaviour = (TimelineBehaviours) Enum.Parse(typeof (TimelineBehaviours), tb); var ami = res.Element("AnalysisMetaInfo"); if (ami == null) return; Analysis = new AnalysisMetaInfo(); var hlx = ami.Element("Highlights"); if (hlx == null) return; Analysis.Highlights = new List<Highlight>(); foreach (var hx in hlx.Elements()) { var h = new Highlight(); h.FromXml(hx); h.Style = this; Analysis.Highlights.Add(h); } } catch (Exception e) { if (!catchException) { throw e; } Logger.Log("Poi Parser", "Error parsing style", e.Message, Logger.Level.Warning); } }