Example #1
0
 public void Assign(LayoutSettings settings)
 {
     TextColor = settings.TextColor;
     BackgroundColor = settings.BackgroundColor;
     BackgroundColor2 = settings.BackgroundColor2;
     ThinSeparatorsColor = settings.ThinSeparatorsColor;
     SeparatorsColor = settings.SeparatorsColor;
     PersonalBestColor = settings.PersonalBestColor;
     AheadGainingTimeColor = settings.AheadGainingTimeColor;
     AheadLosingTimeColor = settings.AheadLosingTimeColor;
     BehindGainingTimeColor = settings.BehindGainingTimeColor;
     BehindLosingTimeColor = settings.BehindLosingTimeColor;
     BestSegmentColor = settings.BestSegmentColor;
     NotRunningColor = settings.NotRunningColor;
     PausedColor = settings.PausedColor;
     ShadowsColor = settings.ShadowsColor;
     TimerFont = settings.TimerFont.Clone() as Font;
     TimesFont = settings.TimesFont.Clone() as Font;
     TextFont = settings.TextFont.Clone() as Font;
     ShowBestSegments = settings.ShowBestSegments;
     AlwaysOnTop = settings.AlwaysOnTop;
     AntiAliasing = settings.AntiAliasing;
     DropShadows = settings.DropShadows;
     Opacity = settings.Opacity;
     BackgroundGradient = settings.BackgroundGradient;
 }
Example #2
0
 public void SetFill(Control control, bool value)
 {
  LayoutSettings sets = null;
  if(_sets.TryGetValue(control, out sets) == false)
   _sets.Add(control, sets = new LayoutSettings());
  sets.Fill = value;
  if(sets.IsEmpty && _sets.ContainsKey(control))
   _sets.Remove(control); 
 } 
 public LiveSplitState(IRun run, Forms.Form form, ILayout layout, LayoutSettings layoutSettings, ISettings settings)
 {
     Run = run;
     Form = form;
     Layout = layout;
     Settings = settings;
     LayoutSettings = layoutSettings;
     StartTime = TimeStamp.Now;
     CurrentPhase = TimerPhase.NotRunning;
     CurrentSplitIndex = -1;
     //DrawLock = new ReaderWriterLockSlim();
 }
Example #4
0
        static void Main(string[] args)
        {
            // load documents
            Utils.VerboseLine("Loading documents ...");
            string[] docs = File.ReadAllLines("C:\\newwork\\testclustering\\data\\yahoofinance.txt");
            BowSpace bowSpace = new BowSpace();
            bowSpace.StopWords = StopWords.EnglishStopWords;
            bowSpace.Stemmer = new PorterStemmer();
            bowSpace.WordWeightType = WordWeightType.TfIdf;
            RegexTokenizer tokenizer = new RegexTokenizer();
            tokenizer.IgnoreUnknownTokens = true;
            bowSpace.Tokenizer = tokenizer;
            bowSpace.Initialize(docs);
            // compute layout
            SemanticSpaceLayout semSpc = new SemanticSpaceLayout(bowSpace);
            Vector2D[] coords = semSpc.ComputeLayout();
            // build spatial index
            //Utils.VerboseLine("Building spatial index ...");
            //SpatialIndex2D spatIdx = new SpatialIndex2D();
            //spatIdx.BuildIndex(coords);
            //spatIdx.InsertPoint(9000, new Vector2D(1000, 1000));
            //ArrayList<IdxDat<Vector2D>> points = spatIdx.GetPoints(new Vector2D(0.5, 0.5), 0.1);
            //Utils.VerboseLine("Number of retrieved points: {0}.", points.Count);

            ArrayList<Vector2D> tmp = new ArrayList<Vector2D>(coords);
            tmp.Shuffle();
            //tmp.RemoveRange(1000, tmp.Count - 1000);

            // compute elevation
            StreamWriter writer = new StreamWriter("c:\\elev.txt");
            LayoutSettings ls = new LayoutSettings(800, 600);
            ls.AdjustmentType = LayoutAdjustmentType.Soft;
            ls.StdDevMult = 2;
            ls.FitToBounds = true;
            ls.MarginVert = 50;
            ls.MarginHoriz = 50;
            double[,] zMtx = VisualizationUtils.ComputeLayoutElevation(tmp, ls, 150, 200);
            VisualizationUtils.__DrawElevation__(tmp, ls, 300, 400).Save("c:\\elev.bmp");
            for (int row = 0; row < zMtx.GetLength(0); row++)
            {
                for (int col = 0; col < zMtx.GetLength(1); col++)
                {
                    writer.Write("{0}\t", zMtx[row, col]);
                }
                writer.WriteLine();
            }
            writer.Close();

            // output coordinates
            StreamWriter tsvWriter = new StreamWriter("c:\\layout.tsv");
            for (int i = 0; i < coords.Length; i++)
            {
                //if (i < points.Count)
                //{
                //    tsvWriter.WriteLine("{0}\t{1}\t{2}\t{3}", coords[i].X, coords[i].Y, points[i].Dat.X, points[i].Dat.Y);
                //}
                //else
                {
                    tsvWriter.WriteLine("{0}\t{1}", coords[i].X, coords[i].Y);
                }
            }
            tsvWriter.Close();
            //// get document names
            //int k = 0;
            //ArrayList<Pair<string, Vector2D>> layout = new ArrayList<Pair<string, Vector2D>>();
            //foreach (string doc in docs)
            //{
            //    string[] docInfo = doc.Split(' ');
            //    layout.Add(new Pair<string, Vector2D>(docInfo[0], coords[k++]));
            //}
            //Console.WriteLine(coords.Length);
            //Console.WriteLine(layout.Count);
            //StreamWriter writer = new StreamWriter("c:\\vidCoords.txt");
            //foreach (Pair<string, Vector2D> docPos in layout)
            //{
            //    writer.WriteLine("{0}\t{1}\t{2}", docPos.First, docPos.Second.X, docPos.Second.Y);
            //}
            //writer.Close();
        }
Example #5
0
        public NodeTreeLayout(AdvTree treeControl, Rectangle clientArea, LayoutSettings layoutSettings)
            : base(treeControl, clientArea, layoutSettings)
		{
		}
Example #6
0
 public void LoadLayout()
 {
     var settings = new LayoutSettings(GetSettingsKey());
     if (!settings.IsDefault && !string.IsNullOrEmpty(settings.LayoutXml))
         SetLayout(settings.LayoutXml);
 }
Example #7
0
 public object Clone()
 {
     var settings = new LayoutSettings();
     settings.Assign(this);
     return settings;
 }
 public static double[,] ComputeLayoutElevation(IEnumerable<Vector2D> layout, LayoutSettings layoutSettings, int matrixRows, int matrixCols,
     double sigma, double r, bool normalize, bool cut, double cutStdevMult)
 {
     Utils.ThrowException(layout == null ? new ArgumentNullException("layout") : null);
     Utils.ThrowException(layoutSettings == null ? new ArgumentNullException("layoutSettings") : null);
     Utils.ThrowException(matrixRows < 1 ? new ArgumentOutOfRangeException("matrixRows") : null);
     Utils.ThrowException(matrixCols < 1 ? new ArgumentOutOfRangeException("matrixCols") : null);
     Utils.ThrowException(sigma <= 0 ? new ArgumentOutOfRangeException("sigma") : null);
     LayoutSettings nrmLayoutSettings = layoutSettings.Clone();
     double fX = 1.0 / (layoutSettings.Width - 2.0 * layoutSettings.MarginHoriz);
     double fY = 1.0 / (layoutSettings.Height - 2.0 * layoutSettings.MarginVert);
     nrmLayoutSettings.Width *= fX;
     nrmLayoutSettings.MarginHoriz *= fX;
     nrmLayoutSettings.Height *= fY;
     nrmLayoutSettings.MarginVert *= fY;
     Vector2D[] nrmLayout = nrmLayoutSettings.AdjustLayout(layout);
     LayoutIndex layoutIndex = new LayoutIndex();
     layoutIndex.MaxPointsPerLeaf = 100; // *** hardcoded max points per leaf
     if (r > 0)
     {
         layoutIndex.BuildIndex(nrmLayout);
     }
     double[,] zMtx = new double[matrixRows, matrixCols];
     Vector2D pixSz = new Vector2D(nrmLayoutSettings.Width / (double)matrixCols, nrmLayoutSettings.Height / (double)matrixRows);
     double maxZ = 0;
     double avgZ = 0;
     int row = 0;
     for (double y = pixSz.Y / 2.0; y < nrmLayoutSettings.Height; y += pixSz.Y, row++)
     {
         int col = 0;
         for (double x = pixSz.X / 2.0; x < nrmLayoutSettings.Width; x += pixSz.X, col++)
         {
             Vector2D pt0 = new Vector2D(x, y);
             double z = 0;
             if (r <= 0)
             {
                 foreach (Vector2D pt in nrmLayout)
                 {
                     double dist = (pt - pt0).GetLength();
                     z += Math.Exp(-sigma * dist * dist);
                 }
             }
             else
             {
                 foreach (IdxDat<Vector2D> pt in layoutIndex.GetPoints(pt0, r))
                 {
                     double dist = (pt.Dat - pt0).GetLength();
                     z += Math.Exp(-sigma * dist * dist);
                 }
             }
             zMtx[row, col] = z;
             if (z > maxZ) { maxZ = z; }
             avgZ += z;
         }
     }
     avgZ /= (double)(matrixRows * matrixCols);
     if (avgZ > 0)
     {
         if (cut)
         {
             double stdev = 0;
             for (row = 0; row < zMtx.GetLength(0); row++)
             {
                 for (int col = 0; col < zMtx.GetLength(1); col++)
                 {
                     stdev += (zMtx[row, col] - avgZ) * (zMtx[row, col] - avgZ);
                 }
             }
             stdev = Math.Sqrt(stdev / (double)(matrixRows * matrixCols));
             maxZ = avgZ + stdev * cutStdevMult;
             for (row = 0; row < zMtx.GetLength(0); row++)
             {
                 for (int col = 0; col < zMtx.GetLength(1); col++)
                 {
                     if (zMtx[row, col] > maxZ) { zMtx[row, col] = maxZ; }
                 }
             }
         }
         if (normalize && maxZ > 0)
         {
             for (row = 0; row < zMtx.GetLength(0); row++)
             {
                 for (int col = 0; col < zMtx.GetLength(1); col++)
                 {
                     zMtx[row, col] /= maxZ;
                 }
             }
         }
     }
     return zMtx;
 }
 public static double[,] ComputeLayoutElevation(IEnumerable<Vector2D> layout, LayoutSettings layoutSettings, int matrixRows, int matrixCols)
 {
     return ComputeLayoutElevation(layout, layoutSettings, matrixRows, matrixCols, /*sigma=*/500, /*r=*/0.1, /*normalize=*/true, /*cut=*/false, 2);
 }
 // *** Layout utils ***
 // *** experimental
 public static Bitmap __DrawElevation__(IEnumerable<Vector2D> layout, LayoutSettings layoutSettings, int matrixRows, int matrixCols)
 {
     double[,] elevData = ComputeLayoutElevation(layout, layoutSettings, matrixRows, matrixCols);
     Bitmap bmp = new Bitmap((int)Math.Ceiling(layoutSettings.Width), (int)Math.Ceiling(layoutSettings.Height));
     Graphics gfx = Graphics.FromImage(bmp);
     Vector2D pixSz = new Vector2D(layoutSettings.Width / (double)matrixCols, layoutSettings.Height / (double)matrixRows);
     int row = 0;
     int oldY = 0;
     for (double y = pixSz.Y; row < elevData.GetLength(0); row++, y += pixSz.Y)
     {
         int _y = (int)Math.Round(y);
         int col = 0;
         int oldX = 0;
         for (double x = pixSz.X; col < elevData.GetLength(1); col++, x += pixSz.X)
         {
             int _x = (int)Math.Round(x);
             Brush brush = new SolidBrush(Color.FromArgb(255, 0, 0, (int)Math.Round(255.0 * elevData[row, col])));
             gfx.FillRectangle(brush, oldX, oldY, _x - oldX, _y - oldY);
             brush.Dispose();
             oldX = _x;
         }
         oldY = _y;
     }
     return bmp;
 }
 public Vector2D[] ComputeLayout(LayoutSettings settings, Vector2D[] initLayout)
 {
     if (settings == null) { settings = new LayoutSettings(); }
     if (mNumPoints == 1) { return settings.AdjustLayout(new Vector2D[] { new Vector2D() }); } // trivial case
     const double eps = 0.00001;
     Vector2D[] layout = new Vector2D[mNumPoints];
     // initialize layout
     if (initLayout != null)
     {
         int initLen = Math.Min(mNumPoints, initLayout.Length);
         Array.Copy(initLayout, layout, initLen);
         for (int i = initLayout.Length; i < mNumPoints; i++)
         {
             layout[i] = new Vector2D(mRnd.NextDouble(), mRnd.NextDouble());
         }
     }
     else
     {
         for (int i = 0; i < mNumPoints; i++)
         {
             layout[i] = new Vector2D(mRnd.NextDouble(), mRnd.NextDouble());
         }
     }
     // main optimization loop
     double globalStress = 0, stressDiff = 0;
     double oldGlobalStress = double.MaxValue;
     for (int step = 0; step < mMaxSteps; step++)
     {
         globalStress = 0;
         for (int i = 0; i < mNumPoints; i++)
         {
             double div = 0;
             Vector2D newPos = new Vector2D(0, 0);
             for (int j = 0; j < mNumPoints; j++)
             {
                 if (i != j)
                 {
                     double dIj = mDistFunc.GetDistance(i, j);
                     if (dIj < eps) { dIj = eps; }
                     double wIj = 1.0 / Math.Pow(dIj, 2);
                     double xIMinusXJ = layout[i].X - layout[j].X;
                     double yIMinusYJ = layout[i].Y - layout[j].Y;
                     double denom = Math.Sqrt(Math.Pow(xIMinusXJ, 2) + Math.Pow(yIMinusYJ, 2));
                     if (denom < eps) { denom = eps; } // avoid dividing by zero
                     div += wIj;
                     newPos.X += wIj * (layout[j].X + dIj * (xIMinusXJ / denom));
                     newPos.Y += wIj * (layout[j].Y + dIj * (yIMinusYJ / denom));
                     if (i < j)
                     {
                         Vector2D diff = layout[i] - layout[j];
                         globalStress += wIj * Math.Pow(diff.GetLength() - dIj, 2);
                     }
                 }
             }
             layout[i].X = newPos.X / div;
             layout[i].Y = newPos.Y / div;
         }
         stressDiff = oldGlobalStress - globalStress;
         if ((step - 1) % 100 == 0)
         {
             mLogger.Info("ComputeLayout", "Global stress: {0:0.00} Diff: {1:0.0000}", globalStress, stressDiff);
         }
         oldGlobalStress = globalStress;
         if (stressDiff <= mMinDiff) { break; }
     }
     mLogger.Info("ComputeLayout", "Final global stress: {0:0.00} Diff: {1:0.0000}", globalStress, stressDiff);
     return settings.AdjustLayout(layout);
 }
 public Vector2D[] ComputeLayout(LayoutSettings settings)
 {
     return ComputeLayout(settings, /*initLayout=*/null);
 }