public void DateXDecimalYTest()
        {
            var xyPair1 = new XyPair <DateTime, decimal>("Some Legend A");

            xyPair1.AddX(new DateTime(2018, 11, 20));
            xyPair1.AddX(new DateTime(2018, 11, 21));
            xyPair1.AddX(new DateTime(2018, 11, 22));
            xyPair1.AddY(0.18m);
            xyPair1.AddY(0.32m);
            xyPair1.AddY(0.21m);
            xyPair1.HasScatter = true;

            IPythonProcess pythonProcess = new PythonProcess(PythonResources.GetPythonPath());
            ITitle         title         = new Title("This is a title", 16);
            IPlotColor     colors        = new PlotColor();

            colors.OutsideColor = "#979899";
            colors.InsideColor  = "#d1d1d1";

            IDesign <DateTime, decimal>          design       = new Design <DateTime, decimal>(title, colors, true, 0.5m, "&", "cccc", "dddd");
            ITickComposer <DateTime, decimal>    tickComposer = new TickComposer <DateTime, decimal>(false, pythonProcess);
            IGeneralComposer <DateTime, decimal> composer     = new GeneralComposer <DateTime, decimal>(pythonProcess, tickComposer);
            IPlotV3 <DateTime, decimal>          plot         = new PlotV3 <DateTime, decimal>(pythonProcess, design, composer);

            plot.AddSource(xyPair1);
            plot.Show();
        }
示例#2
0
        public void DrawBar(Cairo.Context cr, PlotColor color, int x, int y, int width, int height, bool is_focused)
        {
            // Draw the fill
            cr.Rectangle(x, y, width, height);
            Cairo.Color fill = colors[(int)color];
            fill.A = 0.6;
            //cr.Color = fill;
            cr.SetSourceRGBA(fill.R, fill.G, fill.B, fill.A);
            cr.Fill();

            // Stroke just the top, left and right sides
            cr.MoveTo(x - DEFUZZ, y + height - DEFUZZ);
            cr.RelLineTo(0, -height);
            cr.RelLineTo(width, 0);
            cr.RelLineTo(0, height);

            // decrease saturation by 40%
            //cr.Color = CairoHelper.Darken (colors[(int)color], 0.4f);
            cr.SetSourceRGBA(CairoHelper.Darken(colors[(int)color], 0.4f).R, CairoHelper.Darken(colors[(int)color], 0.4f).G, CairoHelper.Darken(colors[(int)color], 0.4f).B, CairoHelper.Darken(colors[(int)color], 0.4f).A);

            cr.LineWidth = 1.0f;

            cr.Stroke();

            if (is_focused)
            {
                DrawFocusRect(cr, x - FOCUS_BORDER, y - FOCUS_BORDER,
                              width + (FOCUS_BORDER * 2), height + FOCUS_BORDER);
            }
        }
示例#3
0
        public void DrawEventTag(Cairo.Context cr, PlotColor color,
                                 int x, int y, Orientation orientation)
        {
            cr.MoveTo(x + DEFUZZ, y);

            if (orientation == Orientation.Vertical)
            {
                cr.RelLineTo(-1 * EVENT_TAG_HALF_WIDTH, -1 * EVENT_TAG_SEGMENT_HEIGHT);
                cr.RelLineTo(0, -2 * EVENT_TAG_SEGMENT_HEIGHT);
                cr.RelLineTo(EVENT_TAG_HALF_WIDTH * 2, 0);
                cr.RelLineTo(0, 2 * EVENT_TAG_SEGMENT_HEIGHT);
            }
            else
            {
                cr.RelLineTo(EVENT_TAG_SEGMENT_HEIGHT, -1 * EVENT_TAG_HALF_WIDTH);
                cr.RelLineTo(EVENT_TAG_SEGMENT_HEIGHT * 2, 0);
                cr.RelLineTo(0, EVENT_TAG_HALF_WIDTH * 2);
                cr.RelLineTo(-2 * EVENT_TAG_SEGMENT_HEIGHT, 0);
            }

            cr.ClosePath();
            //cr.Color = CairoHelper.GetCairoColor (gtk_style.Base (state));
            cr.SetSourceRGBA(CairoHelper.GetCairoColor(gtk_style.Base(state)).R, CairoHelper.GetCairoColor(gtk_style.Base(state)).G, CairoHelper.GetCairoColor(gtk_style.Base(state)).B, CairoHelper.GetCairoColor(gtk_style.Base(state)).A);

            cr.FillPreserve();

            cr.LineWidth = 1.0f;
            //cr.Color = colors[(int)color];
            cr.SetSourceRGBA(colors[(int)color].R, colors[(int)color].G, colors[(int)color].B, colors[(int)color].A);

            cr.Stroke();
        }
        public void DateTimeXPlot()
        {
            var xyPair1 = new XyPair <DateTime, long>("AAAAA");

            xyPair1.AddX(new DateTime(2018, 11, 20, 2, 0, 0));
            xyPair1.AddX(new DateTime(2018, 11, 20, 4, 0, 0));
            xyPair1.AddX(new DateTime(2018, 11, 20, 8, 0, 0));
            xyPair1.AddY(18);
            xyPair1.AddY(32);
            xyPair1.AddY(21);
            xyPair1.HasScatter = true;

            IPythonProcess pythonProcess = new PythonProcess(PythonResources.GetPythonPath());
            ITitle         title         = new Title("BBBBB", 32);
            IPlotColor     colors        = new PlotColor();

            colors.OutsideColor = "#979899";
            colors.InsideColor  = "#d1d1d1";

            IDesign <DateTime, long>          design       = new Design <DateTime, long>(title, colors, true, 16m, "▬", "CCCCC", "DDDDD");
            ITickComposer <DateTime, long>    tickComposer = new TickComposer <DateTime, long>(true, pythonProcess);
            IGeneralComposer <DateTime, long> composer     = new GeneralComposer <DateTime, long>(pythonProcess, tickComposer);
            IPlotV3 <DateTime, long>          plot         = new PlotV3 <DateTime, long>(pythonProcess, design, composer);

            plot.AddSource(xyPair1);
            plot.Show();
        }
示例#5
0
 public static void Winner(PlotColor color)
 {
     lock (m_uiWorkQueue)
     {
         m_uiWorkQueue.Add(color + " wins!");
     }
 }
        public void DateXDLongYTest()
        {
            var xyPair1 = new XyPair <DateTime, long>("Some Legend A");

            xyPair1.AddX(new DateTime(2018, 11, 20));
            xyPair1.AddX(new DateTime(2018, 11, 21));
            xyPair1.AddX(new DateTime(2018, 11, 22));
            xyPair1.AddY(18);
            xyPair1.AddY(32);
            xyPair1.AddY(21);
            xyPair1.HasScatter = true;

            IPythonProcess pythonProcess = new PythonProcess(PythonResources.GetPythonPath());
            ITitle         title         = new Title("This is a title", 32);
            IPlotColor     colors        = new PlotColor();

            colors.OutsideColor = "#979899";
            colors.InsideColor  = "#d1d1d1";

            IDesign <DateTime, long>          design       = new Design <DateTime, long>(title, colors, true, 16m, "▬", "aaa", "bbbb");
            ITickComposer <DateTime, long>    tickComposer = new TickComposer <DateTime, long>(false, pythonProcess);
            IGeneralComposer <DateTime, long> composer     = new GeneralComposer <DateTime, long>(pythonProcess, tickComposer);
            IPlotV3 <DateTime, long>          plot         = new PlotV3 <DateTime, long>(pythonProcess, design, composer);

            plot.AddSource(xyPair1);
            plot.Show();
        }
示例#7
0
        public bool Configure(PlotColor color, string script, out string transaction)
        {
            int[][] coords;
            coords = new int[(int)PlotColor.Yellow + 1][];
            coords[(int)PlotColor.Clear]  = new int[] { 0, 0 };
            coords[(int)PlotColor.Red]    = new int[] { 0, m_field.Width - 1 };
            coords[(int)PlotColor.Blue]   = new int[] { m_field.Height - c_initialIndividuals, 0 };
            coords[(int)PlotColor.Green]  = new int[] { m_field.Height - c_initialIndividuals, m_field.Width - 1 };
            coords[(int)PlotColor.Yellow] = new int[] { 0, 0 };

            transaction = "";

            lock (m_field)
            {
                // reset transaction
                m_field.ResetTransaction();

                // setup the swarm
                m_swarm[(int)color].Script = script;

                // initial swarms
                for (int i = 0; i < c_initialIndividuals; i++)
                {
                    m_field.ChangeState(color, coords[(int)color][0] + i, coords[(int)color][1], PlotState.Occupied);
                }

                transaction = SwarmUtil.Seperator + m_field.Transaction;
            }

            return(true);
        }
示例#8
0
        public int Step(int step)
        {
            int wraps;

            this._color = PlotColors.Colors.GetNextPlotColor(this._color, step, out wraps);
            return(wraps);
        }
示例#9
0
        public void TransferFrom(IPlotGroupStyle fromb)
        {
            ColorGroupStyle from = (ColorGroupStyle)fromb;

            System.Diagnostics.Debug.WriteLine(string.Format("ColorTransfer: myIni={0}, myCol={1}, fromI={2}, fromC={3}", _isInitialized, (_color == null?null:_color.Color.ToString()), from._isInitialized, (from._color == null?null:from._color.Color.ToString())));
            this._isInitialized = from._isInitialized;
            this._color         = from._color;
        }
示例#10
0
文件: Field.cs 项目: speedyjeff/swarm
 public int Count(PlotColor color)
 {
     if (PlotColor.Clear <= color && color <= PlotColor.Yellow)
     {
         return(m_count[(int)color]);
     }
     return(0);
 }
示例#11
0
        /* public methods */
        public ReferenceRangePlot(IComparable min, IComparable max, int dimension, PlotColor color)
        {
            this.ref_min       = min;
            this.ref_max       = max;
            this.ref_dimension = dimension;

            this.color = color;
        }
示例#12
0
 public static void PostMessage(PlotColor color, string msg)
 {
     // paint to screen
     lock (m_uiWorkQueue)
     {
         m_uiWorkQueue.Add(msg);
     }
 }
示例#13
0
        private void UpdateScript(PlotColor color, string controlName)
        {
            string value;

            value = GetRadioValue(controlName);

            m_scripts[(int)color] = GetScript(color, value);
        }
示例#14
0
        public void DrawLine(Cairo.Context cr, PlotColor color, int x1, int y1, int x2, int y2)
        {
            cr.MoveTo(x1 + DEFUZZ, y1 + DEFUZZ);
            cr.LineTo(x2 + DEFUZZ, y2 + DEFUZZ);

            //cr.Color = colors[(int)color];
            cr.SetSourceRGBA(colors[(int)color].R, colors[(int)color].G, colors[(int)color].B, colors[(int)color].A);

            cr.LineWidth = 1.0f;
            cr.Stroke();
        }
示例#15
0
        public bool Configure(PlotColor color, string script, SwarmGame sg)
        {
            string transaction;

            m_color = color;
            m_sg    = sg;

            m_sg.Configure(color, script, out transaction);
            MainWindow.PostMessage(color, transaction);

            return(true);
        }
示例#16
0
        private void StartPlayer(PlotColor color, SwarmGame swarmGame)
        {
            Thread      thread;
            SwarmWorker sw;

            // create the worker thread
            sw = new SwarmWorker();
            sw.Configure(color, m_scripts[(int)color], swarmGame);

            // kick off the thread
            thread = new Thread(new ThreadStart(sw.RunGame));
            thread.Start();
        }
示例#17
0
        public void DrawReferenceRectangle(Cairo.Context cr, PlotColor color,
                                           int x, int y, int width, int height)
        {
            cr.Rectangle(x, y, width, height);

            Cairo.Color c = colors[(int)color];
            c.A = 0.4f;
            //cr.Color = c;
            cr.SetSourceRGBA(c.R, c.G, c.B, c.A);


            cr.Fill();
        }
示例#18
0
        /// <summary>
        /// Constroi o Gráfico do tipo HistogramPlot
        /// </summary>
        /// <param name="graph"></param>
        /// <param name="sql"></param>
        public void HistogramPlot(Graph graph, DateTime date)
        {
            PlotColor plotColors = new PlotColor();

            plotColors = PlotColor.Green;
            HistogramPlot plot = new HistogramPlot(
                CreateModel(date),
                plotColors);

            plot.Name       = "Vendas por Mês";
            plot.ShowValues = true;

            plot.SetValueDataColumn(0, 0);
            plot.SetValueDataColumn(1, 1);
            graph.AddPlot(plot, graph.Axes);
        }
示例#19
0
        public void DrawSelectedPoint(Cairo.Context cr, PlotColor color,
                                      PointShape type, int x, int y)
        {
            DrawPointGlyph(cr, type, x, y, POINT_SIZE);

            //cr.Color = CairoHelper.GetCairoColor (gtk_style.Base (state));
            cr.SetSourceRGBA(CairoHelper.GetCairoColor(gtk_style.Base(state)).R, CairoHelper.GetCairoColor(gtk_style.Base(state)).G, CairoHelper.GetCairoColor(gtk_style.Base(state)).B, CairoHelper.GetCairoColor(gtk_style.Base(state)).A);

            cr.FillPreserve();

            //cr.Color = colors[(int)color];
            cr.SetSourceRGBA(colors[(int)color].R, colors[(int)color].G, colors[(int)color].B, colors[(int)color].A);

            cr.LineWidth = 2.0f;
            cr.Stroke();
        }
示例#20
0
        public void DrawPoint(Cairo.Context cr, PlotColor color,
                              PointShape type, int x, int y, bool is_focused)
        {
            DrawPointGlyph(cr, type, x, y, POINT_SIZE);

            //cr.Color = colors[(int)color];
            cr.SetSourceRGBA(colors[(int)color].R, colors[(int)color].G, colors[(int)color].B, colors[(int)color].A);
            cr.FillPreserve();
            cr.Stroke();

            if (is_focused)
            {
                float size = POINT_SIZE + FOCUS_BORDER;
                DrawFocusRect(cr, x - (size / 2), y - (size / 2),
                              size, size);
            }
        }
示例#21
0
        public static string Encode(PlotColor color, int h, int w, PlotState state, int waitTime)
        {
            string str;

            // height
            str = Seperator + h.ToString();

            // color
            switch (color)
            {
            case PlotColor.Clear: str += "c"; break;

            case PlotColor.Red: str += "r"; break;

            case PlotColor.Blue: str += "b"; break;

            case PlotColor.Green: str += "g"; break;

            case PlotColor.Yellow: str += "y"; break;
            }

            // waittime
            str += waitTime;

            // state
            switch (state)
            {
            case PlotState.Forbidden: str += "f"; break;

            case PlotState.Unoccupied: str += "u"; break;

            case PlotState.Occupied: str += "o"; break;

            case PlotState.Defended: str += "e"; break;

            case PlotState.Duplication: str += "d"; break;

            case PlotState.Visited: str += "v"; break;
            }

            // width
            str += w;

            return(str);
        }
示例#22
0
        private void FlipColor(PlotColor color, int height, int width, float opacity)
        {
            string controlName = "Transparent";

            /*
             * controlName = "";
             * switch (color)
             * {
             *  case PlotColor.Red: controlName = "Red"; break;
             *  case PlotColor.Blue: controlName = "Blue"; break;
             *  case PlotColor.Green: controlName = "Green"; break;
             *  case PlotColor.Yellow: controlName = "Yellow"; break;
             *  case PlotColor.Clear: controlName = "Transparent"; break;
             * }
             */
            controlName += "_" + height + "_" + width;

            ModifyRectangle(controlName, opacity, m_rectColors[(int)color]);
        }
示例#23
0
文件: Field.cs 项目: speedyjeff/swarm
        public bool ChangeState(PlotColor color, int h, int w, PlotState state, int waitTime)
        {
            if (h >= 0 && h < m_field.GetLength(0) && w >= 0 && w < m_field.GetLength(1))
            {
                // append transaction
                m_transaction += SwarmUtil.Encode(color, h, w, state, waitTime);

                // upate color counts
                m_count[(int)m_field[h, w].Color]--;
                m_count[(int)color]++;

                m_field[h, w].State        = state;
                m_field[h, w].Color        = color;
                m_field[h, w].WaitDuration = waitTime;
                return(true);
            }

            return(false);
        }
示例#24
0
        private List <Coordinate> GetSwarm(PlotColor color)
        {
            // review the field and return a list of coordinates for the given color
            List <Coordinate> coords;

            coords = new List <Coordinate>();

            for (int i = 0; i < m_field.Height; i++)
            {
                for (int j = 0; j < m_field.Width; j++)
                {
                    if (color == m_field[i, j].Color && (PlotState.Occupied == m_field[i, j].State || PlotState.Defended == m_field[i, j].State || PlotState.Duplication == m_field[i, j].State))
                    {
                        coords.Add(new Coordinate(i, j));
                    }
                }
            }

            return(coords);
        }
示例#25
0
        private string GetScript(PlotColor color, string player)
        {
            OpenFileDialog dialog;
            string         script;

            // set it to the default
            script = "";

            // get the real implementation
            switch (player)
            {
            case "User":
                // this is a human, so go get the script
                dialog = new OpenFileDialog();
                if (true == dialog.ShowDialog())
                {
                    using (Stream stream = dialog.OpenFile())
                    {
                        using (StreamReader reader = new StreamReader(stream))
                        {
                            script = reader.ReadToEnd();
                        }
                    }
                }
                break;

            case "Easy":
                script = GetManifestResource(m_scriptsEasy[(int)color]);
                break;

            case "Hard":
                script = GetManifestResource(m_scriptsHard[(int)color]);
                break;

            case "Random":
                script = GetManifestResource(m_scriptRandom);
                break;
            }

            return(script);
        }
示例#26
0
        private int[,] GetFieldView(PlotColor color, int w, int h)
        {
            int[,] field;

            field = new int[2 * c_fieldView + 1, 2 * c_fieldView + 1];

            for (int i = -1 * c_fieldView; i < c_fieldView; i++)
            {
                for (int j = -1 * c_fieldView; j < c_fieldView; j++)
                {
                    if (PlotState.Forbidden == m_field[i + w, j + h].State)
                    {
                        // outside the bounds of the field
                        field[i + c_fieldView, j + c_fieldView] = (int)PlotState.Forbidden;
                    }
                    else if (m_field[i + w, j + h].Color == color)
                    {
                        // colors match
                        field[i + c_fieldView, j + c_fieldView] = (int)m_field[i + w, j + h].State;
                    }
                    else
                    {
                        if (PlotColor.Clear == m_field[i + w, j + h].Color)
                        {
                            // unoccupied
                            field[i + c_fieldView, j + c_fieldView] = (int)PlotState.Unoccupied;
                        }
                        else
                        {
                            // enemy
                            field[i + c_fieldView, j + c_fieldView] = (int)PlotState.Enemy;
                        }
                    }
                }
            }

            return(field);
        }
示例#27
0
        public void DrawSelectedBar(Cairo.Context cr, PlotColor color, int x, int y, int width, int height)
        {
            // Draw the fill
            cr.Rectangle(x, y, width, height);
            cr.SetSourceRGBA(CairoHelper.GetCairoColor(gtk_style.Base(state)).R, CairoHelper.GetCairoColor(gtk_style.Base(state)).G, CairoHelper.GetCairoColor(gtk_style.Base(state)).B, CairoHelper.GetCairoColor(gtk_style.Base(state)).A);
            //cr.Color = CairoHelper.GetCairoColor (gtk_style.Base (state));
            cr.Fill();

            // Stroke just the top, left and right sides
            cr.MoveTo(x, y + height);
            cr.RelLineTo(0, -height);
            cr.RelLineTo(width, 0);
            cr.RelLineTo(0, height);

            // darken by 40%
            //cr.Color = CairoHelper.Darken (colors[(int)color], 0.4f);

            cr.SetSourceRGBA(CairoHelper.Darken(colors[(int)color], 0.4f).R, CairoHelper.Darken(colors[(int)color], 0.4f).G, CairoHelper.Darken(colors[(int)color], 0.4f).B, CairoHelper.Darken(colors[(int)color], 0.4f).A);

            cr.LineWidth = 2.0f;

            cr.Stroke();
        }
 public void Initialize(PlotColor c)
 {
   _isInitialized = true;
   _color = c;
   //System.Diagnostics.Debug.WriteLine(string.Format("ColorGroup.Initialize, col={0}", _color.Color));
 }
 public int Step(int step)
 {
   int wraps;
   this._color = PlotColors.Colors.GetNextPlotColor(this._color, step, out wraps);
   return wraps;
 }
示例#30
0
 public SwarmEngine(PlotColor color)
 {
     m_color    = color;
     m_script   = "";
     m_executed = false;
 }
示例#31
0
 /* public methods */
 public EventPlot(TreeModel model, PlotColor color, PointShape shape)
 {
     this.model = model;
     this.color = color;
     this.shape = shape;
 }
 public ColorGroupStyle(ColorGroupStyle from)
 {
   this._isStepEnabled = from._isStepEnabled;
   this._isInitialized = from._isInitialized;
   this._color = from._color;
 }
 public void TransferFrom(IPlotGroupStyle fromb)
 {
   ColorGroupStyle from = (ColorGroupStyle)fromb;
   System.Diagnostics.Debug.WriteLine(string.Format("ColorTransfer: myIni={0}, myCol={1}, fromI={2}, fromC={3}", _isInitialized, (_color==null?null:_color.Color.ToString()), from._isInitialized, (from._color==null?null:from._color.Color.ToString())));
   this._isInitialized = from._isInitialized;
   this._color = from._color;
 }
示例#34
0
        public static bool Decode(string str, out PlotColor color, out int h, out int w, out PlotState state, out int waitTime)
        {
            // the rest should follow this format
            //  HEIGHTcolorWAITDURATIONstateWIDTH
            int    part;
            string numStr;

            char[] chArray;

            part     = 0;
            numStr   = "";
            color    = PlotColor.Clear;
            h        = w = 0;
            state    = PlotState.Forbidden;
            waitTime = 0;
            chArray  = str.ToCharArray();

            // check that this is a valid message
            if (0 == chArray.Length || !Char.IsDigit(chArray[0]))
            {
                return(false);
            }

            foreach (char c in chArray)
            {
                switch (part)
                {
                case 0:
                    if (Char.IsDigit(c))
                    {
                        numStr += c;
                    }
                    else
                    {
                        // height
                        h      = Convert.ToInt32(numStr);
                        numStr = "";
                        // color
                        switch (c)
                        {
                        case 'r': color = PlotColor.Red; break;

                        case 'b': color = PlotColor.Blue; break;

                        case 'g': color = PlotColor.Green; break;

                        case 'y': color = PlotColor.Yellow; break;

                        case 'c': color = PlotColor.Clear; break;
                        }
                        part = 1;
                    }
                    break;

                case 1:
                    if (Char.IsDigit(c))
                    {
                        numStr += c;
                    }
                    else
                    {
                        // wait time
                        waitTime = Convert.ToInt32(numStr);
                        numStr   = "";
                        // state
                        switch (c)
                        {
                        case 'f': state = PlotState.Forbidden; break;

                        case 'u': state = PlotState.Unoccupied; break;

                        case 'o': state = PlotState.Occupied; break;

                        case 'e': state = PlotState.Defended; break;

                        case 'd': state = PlotState.Duplication; break;

                        case 'v': state = PlotState.Visited; break;
                        }
                        part = 2;
                    }
                    break;

                case 2:
                    numStr += c;
                    break;
                }
            }
            // width
            w = Convert.ToInt32(numStr);

            return(true);
        }