private static void CenterGraph(PlotGraph graph, Size modelDimensions)
 {
     foreach (PlotPoint p in graph.PlotPoints)
     {
         p.X = modelDimensions.Width / 2;
         p.Y = modelDimensions.Height / 2;
         p.MovePoint();
     }
 }
        public PlotGraph CreateNewGraph(NewPlotEventArgs graphData)
        {
            //Have to reset the storyboard each time we create a new graph
            PlotPointViewRenderer.ResetStoryboard();

            currentGraph = new PlotGraph(graphData.PlotPointCount, graphData.PointRadius, graphData.PointOpacity, graphData.Border);
            double aspectRatio = graphData.PlotDimensions.Width / graphData.PlotDimensions.Height;
            this.layoutNewGraph(currentGraph, graphData.InitialLayout, aspectRatio);
            this.initializeColors(currentGraph);
            this.initializeGraphProperties();
            return currentGraph;
        }
        private static void CircleGraph(PlotGraph graph, Size modelDimensions)
        {
            double centerX = modelDimensions.Width / 2;
            double centerY = modelDimensions.Height / 2;
            int length = graph.PlotPoints.Length;

            //0.85 is so the circle doesn't go all the way to the edge
            double radius = (int)(Math.Min(centerX, centerY) * 0.85);
            double radiansPerPoint = (2 * Math.PI) / length;

            for (int i = 0; i < length; i++)
            {
                graph.PlotPoints[i].X = centerX + radius * Math.Cos(radiansPerPoint * i);
                graph.PlotPoints[i].Y = centerY + radius * Math.Sin(radiansPerPoint * i);
                graph.PlotPoints[i].MovePoint();

            }
        }
 internal void SortGraph(PlotChangedEventArgs e)
 {
     currentGraph = e.Graph;
     currentSortType = e.SortType;
     currentDimensions = e.PlotDimensions;
     int maxPointsPerSort = SortThrottle.GetMaxPointsPerPass(SortAlgorithms[currentSortType].AlgorithmComplexity,
                                                               PlotPointViewRenderer.AnimationEnabled, e.Graph.PlotPoints.Length);
     if (e.Graph.PlotPoints.Length > maxPointsPerSort)// && maxPointsPerSort != 0)
     {
         this.currentSortPasses = (int)Math.Ceiling(e.Graph.PlotPoints.Length / maxPointsPerSort);
     }
     else
     {
         this.currentSortPasses = 1;
     }
     this.currentSortPass = 0;
     timer.Start();
     sortStarted = true;
 }
예제 #5
0
 internal void view_onNewGraph(object sender, NewPlotEventArgs e)
 {
     e.PointOpacity = view.plotManipulationPanel.PointOpacityValue;
     e.PointRadius = view.plotManipulationPanel.PointRadiusValue;
     e.Border = view.plotManipulationPanel.PointBorderValue;
     currentGraph = this.creationController.CreateNewGraph(e);
     DeltaCalculator.plotPoints = currentGraph.PlotPoints;
     view.CreatePlotGraph(currentGraph);
     view.plotManipulationPanel.IsEnabled = true;
     if (e.PlotPointCount > PointAnimationThreshold)
     {
         view.plotManipulationPanel.SetAnimationCheckbox(false);
         PlotPointViewRenderer.AnimationEnabled = false;
     }
     manipulationController.StopSort();
 }
예제 #6
0
        internal void CreatePlotGraph(PlotGraph plotGraph)
        {
            this.ResetPlotGraph();
            foreach (PlotPoint point in plotGraph.PlotPoints)
            {
                Ellipse e = new Ellipse();
                PlotPointViewRenderer pointRenderer = new PlotPointViewRenderer(this, point);
                this.BindEllipse(e, pointRenderer);

                this.CnvsPlotGraph.Children.Add(e);
            }
        }
 private static void GridGraph(PlotGraph graph, Size modelDimensions)
 {
     int length = graph.PlotPoints.Length;
     int columns = (int)Math.Round(Math.Sqrt(length));
     int rows = (int)Math.Ceiling((double)length / (double)columns);
     //add 2 so we can put space between the outside points and the
     //borders of the plotGraph
     double columnWidth = modelDimensions.Width / (columns + 1);
     double rowHeight = modelDimensions.Height / (rows + 1);
     int index = 0;
     for (int j = 0; j < rows && index < length; j++)
     {
         for (int i = 0; i < columns && index < length; i++)
         {
             graph.PlotPoints[index].X = columnWidth * (i + 1);
             graph.PlotPoints[index].Y = rowHeight * (j + 1);
             graph.PlotPoints[index].MovePoint();
             index++;
         }
     }
 }
 private void layoutNewGraph(PlotGraph graph, PlotLayouts plotLayout, double aspectRatio)
 {
     double modelHeight = PlotPointUtil.ModelHeight;
     double modelWidth = modelHeight * aspectRatio;
     plotLayoutFunctions[plotLayout](graph, new Size(modelWidth, modelHeight));
 }
 private void initializeColors(PlotGraph graph)
 {
     foreach (PlotPoint point in graph.PlotPoints)
     {
         point.AssignRandomColor();
     }
 }
        private static void TwoCirclesGraph(PlotGraph graph, Size modelDimensions)
        {
            double centerX = modelDimensions.Width / 2;
            double centerY = modelDimensions.Height / 2;
            int originalLength = graph.PlotPoints.Length;

            int length = (int)Math.Floor((double)originalLength * 2 / 3);

            //outer cirle
            //0.85 is so the circle doesn't go all the way to the edge
            double radius = (int)(Math.Min(centerX, centerY) * 0.85);
            double radiansPerPoint = (2 * Math.PI) / length;
            int index = 0;
            for (int i = 0; i < length; i++)
            {
                graph.PlotPoints[index].X = centerX + radius * Math.Cos(radiansPerPoint * i);
                graph.PlotPoints[index].Y = centerY + radius * Math.Sin(radiansPerPoint * i);
                graph.PlotPoints[index].MovePoint();
                index++;
            }

            //inner circle
            length = (int)Math.Ceiling((double)originalLength * 1 / 3);
            radius = radius / 2;
            radiansPerPoint = (2 * Math.PI) / length;

            for (int i = 0; i < length; i++)
            {
                graph.PlotPoints[index].X = centerX + radius * Math.Cos(radiansPerPoint * i);
                graph.PlotPoints[index].Y = centerY + radius * Math.Sin(radiansPerPoint * i);
                graph.PlotPoints[index].MovePoint();
                index++;
            }
        }
 private static void TopLeftGraph(PlotGraph graph, Size modelDimensions)
 {
     foreach (PlotPoint p in graph.PlotPoints)
     {
         p.X = 0;
         p.Y = 0;
         p.MovePoint();
     }
 }