Ejemplo n.º 1
0
 public static int CompareByValueDecreasing(WeightUIElement x, WeightUIElement y)
 {
     if (x == null)
     {
         if (y == null)
         {
             return(-1);
         }
         else
         {
             return(0);
         }
     }
     else
     {
         if (y == null)
         {
             return(1);
         }
         else
         {
             return(x.Weight.CompareTo(y.Weight) * -1);
         }
     }
 }
Ejemplo n.º 2
0
        private void PrepareItems()
        {
            _weightSum = 0;
            this.ManagedItems.Clear();


            foreach (UIElement child in this.Children)
            {
                WeightUIElement element = new WeightUIElement(child, TreeMapsPanel.GetWeight(child));
                if (this.IsValidItem(element))
                {
                    _weightSum += element.Weight;
                    this.ManagedItems.Add(element);
                }
                else
                {
                    element.ComputedSize     = Size.Empty;
                    element.ComputedLocation = new Point(0, 0);
                    element.UIElement.Measure(element.ComputedSize);
                    element.UIElement.Visibility = Visibility.Collapsed;
                }
            }

            this.ManagedItems.Sort(WeightUIElement.CompareByValueDecreasing);
        }
        private void Squarify(List <WeightUIElement> items, List <WeightUIElement> row, double sideLength)
        {
            if (items.Count == 0)
            {
                this.AddRowToLayout(row);
                return;
            }

            WeightUIElement        item = items[0];
            List <WeightUIElement> row2 = new List <WeightUIElement>(row);

            row2.Add(item);
            List <WeightUIElement> items2 = new List <WeightUIElement>(items);

            items2.RemoveAt(0);

            double worst1 = this.Worst(row, sideLength);
            double worst2 = this.Worst(row2, sideLength);

            if (row.Count == 0 || worst1 > worst2)
            {
                this.Squarify(items2, row2, sideLength);
            }
            else
            {
                this.AddRowToLayout(row);
                this.Squarify(items, new List <WeightUIElement>(), this.GetShortestSide());
            }
        }
Ejemplo n.º 4
0
 protected virtual Rect GetRectangle(RowOrientation orientation, WeightUIElement item, double x, double y, double width, double height)
 {
     if (orientation == RowOrientation.Horizontal)
     {
         return(new Rect(x, y, item.RealArea / height, height));
     }
     else
     {
         return(new Rect(x, y, width, item.RealArea / width));
     }
 }
Ejemplo n.º 5
0
 public static int CompareByValueDecreasing(WeightUIElement x, WeightUIElement y)
 {
   if (x == null)
   {
     if (y == null)
       return -1;
     else
       return 0;
   }
   else
   {
     if (y == null)
       return 1;
     else
       return x.Weight.CompareTo(y.Weight) * -1;
   }
 }
Ejemplo n.º 6
0
    private void PrepareItems()
    {

      _weightSum = 0;
      this.ManagedItems.Clear();


      foreach (UIElement child in this.Children)
      {
        WeightUIElement element = new WeightUIElement(child, TreeMapsPanel.GetWeight(child));
        if (this.IsValidItem(element))
          {
            _weightSum += element.Weight;
            this.ManagedItems.Add(element);
          }
          else
          {
            element.ComputedSize = Size.Empty;
            element.ComputedLocation = new Point(0, 0);
            element.UIElement.Measure(element.ComputedSize);
            element.UIElement.Visibility = Visibility.Collapsed;
          }
      }

      this.ManagedItems.Sort(WeightUIElement.CompareByValueDecreasing);
    }
Ejemplo n.º 7
0
 private bool IsValidItem(WeightUIElement item)
 {
   return (item != null && item.Weight != double.NaN && Math.Round(item.Weight, 0) != 0);
 }
Ejemplo n.º 8
0
 protected virtual Rect GetRectangle(RowOrientation orientation, WeightUIElement item, double x, double y, double width, double height)
 {
   if (orientation == RowOrientation.Horizontal)
     return new Rect(x, y, item.RealArea / height, height);
   else
     return new Rect(x, y, width, item.RealArea / width);
 }
Ejemplo n.º 9
0
 private bool IsValidItem(WeightUIElement item)
 {
     return(item != null && item.Weight != double.NaN && Math.Round(item.Weight, 0) != 0);
 }