Example #1
0
        public int CompareTo(object obj)
        {
            HREntry hre = (HREntry)obj;

            if (dist < hre.dist)
            {
                return(-1);
            }
            else if (dist > hre.dist)
            {
                return(1);
            }

            return(0);
        }
Example #2
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            if (e.OldElement != null || e.NewElement == null)
            {
                return;
            }


            element = (HREntry)this.Element;

            var editText = this.Control;

            if (!string.IsNullOrEmpty(element.Image))
            {
                switch (element.ImageAlignment)
                {
                case ImageAlignment.Left:
                    editText.SetCompoundDrawablesWithIntrinsicBounds(GetDrawable(element.Image), null, null, null);
                    break;

                case ImageAlignment.Right:
                    editText.SetCompoundDrawablesWithIntrinsicBounds(null, null, GetDrawable(element.Image), null);
                    break;
                }
            }
            editText.CompoundDrawablePadding = 25;


            if (Control != null)
            {
                var background      = ContextCompat.GetDrawable(Context, Resource.Drawable.RoundedCornerEntry);
                GradientDrawable gd = new GradientDrawable();
                //if (Control.IsFocused)
                //	gd.SetColor(new Android.Graphics.Color(255, 255, 255));
                //else
                //	gd.SetColor(new Android.Graphics.Color(242, 242, 242));

                //gd.SetCornerRadius(25);

                //gd.SetStroke(2, new Android.Graphics.Color(204, 204, 204));
                //Control.Background = gd;

                Control.Background = background;
                //Control.SetPaddingRelative(10, 10, 10, 10);
            }
        }
Example #3
0
    private IKDTreeDomain NearestNeighbourListBBFI(SortedLimitedList best,
                                                   int q, IKDTreeDomain target, HyperRectangle hr, int maxDistSq,
                                                   out int resDistSq, SortedLimitedList searchHr, ref int searchSteps)
    {
        resDistSq = Int32.MaxValue;

        IKDTreeDomain pivot = dr;

        best.Add(new BestEntry(dr, KDTree.DistanceSq(target, dr), true));

        HyperRectangle leftHr  = hr;
        HyperRectangle rightHr = leftHr.SplitAt(splitDim,
                                                pivot.GetDimensionElement(splitDim));

        HyperRectangle nearerHr, furtherHr;
        KDTree         nearerKd, furtherKd;

        if (target.GetDimensionElement(splitDim) <=
            pivot.GetDimensionElement(splitDim))
        {
            nearerKd  = left;
            nearerHr  = leftHr;
            furtherKd = right;
            furtherHr = rightHr;
        }
        else
        {
            nearerKd  = right;
            nearerHr  = rightHr;
            furtherKd = left;
            furtherHr = leftHr;
        }

        IKDTreeDomain nearest = null;
        int           distSq;

        searchHr.Add(new HREntry(furtherHr, furtherKd, pivot,
                                 furtherHr.Distance(target)));

        if (nearerKd == null)
        {
            distSq = Int32.MaxValue;
        }
        else
        {
            nearest = nearerKd.NearestNeighbourListBBFI(best, q, target, nearerHr,
                                                        maxDistSq, out distSq, searchHr, ref searchSteps);
        }

        if (best.Count >= q)
        {
            maxDistSq = ((BestEntry)best[q - 1]).DistanceSq;
        }
        else
        {
            maxDistSq = Int32.MaxValue;
        }

        if (searchHr.Count > 0)
        {
            HREntry hre = (HREntry)searchHr[0];
            searchHr.RemoveAt(0);

            furtherHr = hre.HR;
            furtherKd = hre.Tree;
            pivot     = hre.Pivot;
        }

        searchSteps -= 1;
        if (searchSteps > 0 &&
            furtherHr.IsInReach(target, Math.Sqrt(maxDistSq)))
        {
            int ptDistSq = KDTree.DistanceSq(pivot, target);
            if (ptDistSq < distSq)
            {
                nearest = pivot;
                distSq  = ptDistSq;

                maxDistSq = distSq;
            }

            int           tempDistSq;
            IKDTreeDomain tempNearest = null;
            if (furtherKd == null)
            {
                tempDistSq = Int32.MaxValue;
            }
            else
            {
                tempNearest = furtherKd.NearestNeighbourListBBFI(best, q,
                                                                 target, furtherHr, maxDistSq, out tempDistSq, searchHr,
                                                                 ref searchSteps);
            }

            if (tempDistSq < distSq)
            {
                nearest = tempNearest;
                distSq  = tempDistSq;
            }
        }

        resDistSq = distSq;
        return(nearest);
    }