Esempio n. 1
0
        public static Texture2D Legend(List <Duodata <string, int> > DuodataList1, List <Duodata <string, int> > DuodataList2, GraphicsDevice graphDevice, SpriteBatch spriteBatch, string name1, string name2, Color color1, Color color2)
        {
            List <Duodata <Duodata <string, int>, Duodata <string, int> > > linked = linkGroup(DuodataList1, DuodataList2);



            int   width           = 500;
            int   lineheight      = 40;
            int   height          = lineheight * (linked.Count + 4);
            Color BackgroundColor = new Color(0, 0, 0, 0);
            int   colorsquaresize = 40;

            RenderTarget2D target = new RenderTarget2D(graphDevice, width, height);

            graphDevice.SetRenderTarget(target);
            graphDevice.Clear(BackgroundColor);

            spriteBatch.Begin();

            for (int i = 0; i < linked.Count; i++)
            {
                TextDrawing.Drawtext(new Point(0, lineheight * i), ((char)(65 + i)).ToString() + "  :  " + linked[i].GetAttr1().GetAttr1(), spriteBatch);
            }

            TextDrawing.Drawtext(new Point(colorsquaresize * 2, lineheight * (linked.Count + 2)), name1, spriteBatch);
            TextDrawing.Drawtext(new Point(colorsquaresize * 2, lineheight * (linked.Count + 3)), name2, spriteBatch);
            spriteBatch.Draw(Pixel, new Rectangle(new Point(0, lineheight * (linked.Count + 2)), new Point(colorsquaresize)), color1);
            spriteBatch.Draw(Pixel, new Rectangle(new Point(0, lineheight * (linked.Count + 3)), new Point(colorsquaresize)), color2);
            spriteBatch.End();
            graphDevice.SetRenderTarget(null);
            return(target);
        }
Esempio n. 2
0
        public void Draw(SpriteBatch spriteBatch, Point offset)
        {
            Rectangle dimentions = calculateDimentions();

            spriteBatch.Draw(Texture, new Rectangle(dimentions.X + offset.X, dimentions.Y + offset.Y, dimentions.Width, dimentions.Height), Color.White);
            TextDrawing.Drawtext(new Point((int)(ScreenDimentions.X * LeftPercentage + ScreenDimentions.X * (RightPercentage - LeftPercentage) / 10), YPositionTop + height / 10) + offset, Text, spriteBatch);
        }
Esempio n. 3
0
        //Axes logic
        private static RenderTarget2D Axis(List <Duodata <string, int> > aDuodataList, Texture2D target, GraphicsDevice graphdevice, SpriteBatch spriteBatch, int heighestvalue)
        {
            int   axisthickness   = 3;
            int   paddingx        = 100;
            int   paddingy        = 200;
            int   marklenght      = 5;
            int   textoffset      = -80;
            int   textoffsetxaxis = 10;
            Color backgroundColor = new Color(0, 0, 0, 0);

            drawline(new Point(0), new Point(0, target.Height), spriteBatch, axisthickness, Pixel);
            drawline(new Point(0, target.Height - axisthickness), new Point(target.Width, target.Height - axisthickness), spriteBatch, axisthickness, Pixel);
            spriteBatch.End();
            spriteBatch.Begin();
            RenderTarget2D newRenderTarget = new RenderTarget2D(graphdevice, target.Width + paddingx * 2, target.Height + paddingy);

            graphdevice.SetRenderTarget(newRenderTarget);
            graphdevice.Clear(backgroundColor);
            spriteBatch.Draw(target, new Rectangle(new Point(paddingx, 0), new Point(target.Width, target.Height)), Color.White);

            for (int i = 0; i < 10; i++)
            {
                drawline(new Point(paddingx - marklenght, i * target.Height / 10), new Point(paddingx, i * target.Height / 10), spriteBatch, axisthickness, Pixel);
                TextDrawing.Drawtext(new Point(paddingx + textoffset, i * target.Height / 10), (heighestvalue - heighestvalue / 10 * i).ToString(), spriteBatch);
            }

            for (int i = 0; i < aDuodataList.Count; i++)
            {
                drawline(new Point(paddingx + i * (target.Width / (aDuodataList.Count - 1)), target.Height), new Point(paddingx + i * (target.Width / (aDuodataList.Count - 1)), target.Height + marklenght), spriteBatch, axisthickness, Pixel);
                TextDrawing.Drawtext(new Point(paddingx + i * (target.Width / (aDuodataList.Count - 1)) - textoffsetxaxis, target.Height + textoffsetxaxis), ((char)(65 + i)).ToString(), spriteBatch);
            }

            return(newRenderTarget);
        }
Esempio n. 4
0
        //Legend logic
        public static Texture2D Legenda(List <Duodata <string, int> > aDuodataList, GraphicsDevice graphdevice, SpriteBatch spriteBatch)
        {
            int            Lineheight      = 40;
            int            width           = 500;
            int            height          = Lineheight * aDuodataList.Count;
            Color          backgroundColor = new Color(0, 0, 0, 0);
            RenderTarget2D Target          = new RenderTarget2D(graphdevice, width, height);

            graphdevice.SetRenderTarget(Target);
            graphdevice.Clear(backgroundColor);
            spriteBatch.Begin();
            for (int i = 0; i < aDuodataList.Count; i++)
            {
                TextDrawing.Drawtext(new Point(0, Lineheight * i), ((char)(65 + i)).ToString() + "  :  " + aDuodataList[i].GetAttr1(), spriteBatch);
            }
            spriteBatch.End();
            graphdevice.SetRenderTarget(null);
            return(Target);
        }
Esempio n. 5
0
        //draw legend
        public static void DrawLegenda(List <Duodata <string, int> > aDuodataList, Point position, GraphicsDevice graphDevice, SpriteBatch spritebatch)
        {
            int sizeSqaures = 30;
            int spacing     = 50;

            Texture2D Pixel = new Texture2D(graphDevice, 1, 1);

            Color[] temp2 = new Color[1];
            temp2[0] = Color.White;
            Pixel.SetData <Color>(temp2);
            Color todrawin;
            ARGB  coloroo;

            for (int i = 0; i < aDuodataList.Count; i++)
            {
                coloroo  = ListOfColorsToUse[i];
                todrawin = new Color(coloroo.r, coloroo.g, coloroo.b);
                spritebatch.Draw(Pixel, new Rectangle(position + new Point(0, i * 2 * sizeSqaures), new Point(sizeSqaures)), todrawin);
                TextDrawing.Drawtext(position + new Point(spacing, i * 2 * sizeSqaures), aDuodataList[i].GetAttr1(), spritebatch);
            }
        }
Esempio n. 6
0
        private static RenderTarget2D Axis(List <Duodata <Duodata <string, int>, Duodata <string, int> > > groupedvalues, RenderTarget2D target, SpriteBatch spriteBatch, GraphicsDevice graphDevice, int maxvalue, string namegroup1, string group2)
        {
            int   paddingx        = 100;
            int   paddingy        = 200;
            int   linethickness   = 5;
            int   marklenght      = 5;
            int   textoffsetyaxis = 80;
            int   textoffsetxaxis = 10;
            int   widthofColumn   = target.Width / (groupedvalues.Count * 3);
            Color backgroundColor = new Color(0, 0, 0, 0);

            RenderTarget2D NewTarget = new RenderTarget2D(graphDevice, target.Width + paddingx * 2, target.Height + paddingy * 2);

            LineChart.drawline(new Point(0), new Point(0, target.Height), spriteBatch, linethickness, Pixel);
            LineChart.drawline(new Point(0, target.Height - linethickness), new Point(target.Width, target.Height - linethickness), spriteBatch, linethickness, Pixel);

            spriteBatch.End();
            graphDevice.SetRenderTarget(NewTarget);
            graphDevice.Clear(backgroundColor);
            spriteBatch.Begin();

            spriteBatch.Draw(target, new Rectangle(new Point(paddingx, 0), new Point(target.Width, target.Height)), Color.White);


            for (int i = 0; i < 10; i++)
            {
                LineChart.drawline(new Point(paddingx - marklenght, i * target.Height / 10), new Point(paddingx, i * target.Height / 10), spriteBatch, linethickness, Pixel);
                TextDrawing.Drawtext(new Point(paddingx - textoffsetyaxis, i * target.Height / 10), (maxvalue - maxvalue / 10 * i).ToString(), spriteBatch);
            }


            for (int i = 0; i < groupedvalues.Count; i++)
            {
                LineChart.drawline(new Point((i * 3 + 2) * widthofColumn + paddingx, target.Height), new Point((i * 3 + 2) * widthofColumn + paddingx, target.Height + marklenght), spriteBatch, linethickness, Pixel);
                TextDrawing.Drawtext(new Point((i * 3 + 2) * widthofColumn + paddingx - textoffsetxaxis, target.Height + textoffsetxaxis), ((char)(65 + i)).ToString(), spriteBatch);
            }

            return(NewTarget);
        }