Пример #1
0
        public override bool HitTest(NPoint point)
        {
            this.SelectedPoint = null;
            this.IsSelected    = false;
            this.MouseState    = NMouseState.NONE;

            if (NMathHelper.Distance(this.Model.StartPoint, point) <= NConfig.HIT_DISTANCE)
            {
                this.SelectedPoint = this.Model.StartPoint;
                this.IsSelected    = true;
                this.MouseState    = NMouseState.RESIZE;
            }
            else if (NMathHelper.Distance(this.Model.EndPoint, point) <= NConfig.HIT_DISTANCE)
            {
                this.SelectedPoint = this.Model.EndPoint;
                this.IsSelected    = true;
                this.MouseState    = NMouseState.RESIZE;
            }
            else if (HitTestNodeX(EndNode, point))
            {
                this.IsSelected = true;
                this.MouseState = NMouseState.MOVE;
            }
            return(this.IsSelected);
        }
Пример #2
0
        static void Main(string[] args)
        {
            CountryStatistics[] countryStatistics;

            using (StreamReader sr = new StreamReader(@"..\..\CountryData.txt"))
            {
                string serializedStatistics = sr.ReadToEnd();
                countryStatistics =
                    JsonConvert.DeserializeObject <CountryStatistics[]>(serializedStatistics);
            }

            ConsoleWriter.WriteSystemMessage("Original data:");
            ConsoleWriter.WriteCoutryStatistics(countryStatistics);

            var normalizator = new Normalizator(countryStatistics);

            normalizator.Normalize(100);
            ConsoleWriter.WriteSystemMessage("Normalized data:");
            ConsoleWriter.WriteCoutryStatistics(countryStatistics);

            ConsoleWriter.WriteSystemMessage("Drawing the diagram for displaying normalized data...");
            ChartCreator.CreateChart(countryStatistics, "clusters");
            ConsoleWriter.WriteSystemMessage("Saved on the app resources directory as 'chart.png'.");

            var nMathHelper = new NMathHelper(countryStatistics);

            nMathHelper.GetAnalysisResults();

            nMathHelper.GetCopheneticCorrelations();

            int clusterCount;

            do
            {
                ConsoleWriter.WriteSystemMessage($"Set clusters amount ({countryStatistics.Length} max):");
                clusterCount = Convert.ToInt32(Console.ReadLine());
                if (clusterCount > countryStatistics.Length)
                {
                    clusterCount = countryStatistics.Length;
                }
                Console.WriteLine();

                nMathHelper.GetClustersByAmount(clusterCount);
            }while (Console.ReadLine() != "");

            double clusterDistance;

            do
            {
                ConsoleWriter.WriteSystemMessage("Set distance");
                clusterDistance = Convert.ToDouble(Console.ReadLine());
                Console.WriteLine();

                nMathHelper.GetClustersByDistance(clusterDistance);
            }while (Console.ReadLine() != "");

            Console.ReadLine();
        }
Пример #3
0
 private bool HitTestNodeX(NNodeX node, NPoint point)
 {
     if (node != null && node.Parent != null)
     {
         if (NMathHelper.Distance(node.Point, point) <= NConfig.HIT_DISTANCE)
         {
             return(true);
         }
         else
         {
             return(HitTestNodeX(node.Parent, point));
         }
     }
     return(false);
 }
Пример #4
0
        public override void MouseUp(MouseEventArgs mouseEvent)
        {
            float w = NMathHelper.MRound(this.Width, NConfig.BLOCK_SIZE_2);
            float h = NMathHelper.MRound(this.Height, NConfig.BLOCK_SIZE_2);

            this.X = NMathHelper.MRound(this.X, NConfig.BLOCK_SIZE_2);
            this.Y = NMathHelper.MRound(this.Y, NConfig.BLOCK_SIZE_2);

            this.Width  = w;
            this.Height = h;

            this.RecomputeConnectPoints();

            this.OnVertexMoved(this.SelectedPoint);
        }
Пример #5
0
        public override void Visit(NBox component)
        {
            component.IsCloseEnough = false;

            for (int i = 0; i < component.ConnectPoints.Length; i++)
            {
                double d = NMathHelper.Distance(SelectedPoint, component.ConnectPoints[i]);
                if (d <= NConfig.CONNECT_DISTANCE)
                {
                    component.IsCloseEnough = true;
                    if (Connect)
                    {
                        if (Connector.Model.StartPoint == SelectedPoint)
                        {
                            Connector.StartBox            = component;
                            Connector.Model.StartBoxIndex = i;
                            Connector.Model.StartBoxID    = component.Model.ID;
                        }
                        else
                        {
                            Connector.EndBox            = component;
                            Connector.Model.EndBoxIndex = i;
                            Connector.Model.EndBoxID    = component.Model.ID;
                        }
                        SelectedPoint.Set(component.ConnectPoints[i]);


                        PathResolver.Connector  = Connector;
                        PathResolver.StartPoint = Connector.Model.StartPoint;
                        PathResolver.EndPoint   = Connector.Model.EndPoint;

                        PathResolver.RebuildGraph();
                        PathResolver.Resolve();

                        return;
                    }
                }
            }
        }