コード例 #1
0
ファイル: DrawTree.cs プロジェクト: JohnHartley/argumentative
        /// <summary>
        /// save as bmp file
        /// </summary>
        /// <param name="n"></param>
        /// <returns>Bitmap of current Node and children</returns>
        public Bitmap drawTree(Node n)
        {
            Bitmap   b;
            Graphics g;

            Options.OptionsData d = Options.OptionsData.Instance;
            // set drawing options
            justification       = d.Justification;
            join                = d.Join;
            treeOrientation     = d.TreeOrientation;
            useRnotation        = d.Notation;
            dropShadow          = d.DropShadow;
            boxShading          = d.BoxShading;
            showLegend          = d.ShowLegend;
            arrows              = d.Arrow;
            marker              = d.Marker;
            helpersAsCoPremises = d.HelpersAsCoPremises;
            // Width and height calculation should only be a cross check
            maxWidth  = 0;
            maxHeight = 0;

            recalc(n);

            b = new Bitmap((int)maxWidth + 20, (int)maxHeight + 20); // 20 pixel border
            g = Graphics.FromImage(b);                               // gets the graphics drawing object
            g.Clear(Color.White);                                    // clears the background
            drawTree(g, n);

            return(b);
        }
コード例 #2
0
ファイル: DrawTree.cs プロジェクト: JohnHartley/argumentative
        /// <summary>
        /// Draws the tree from the specified node
        /// </summary>
        /// <param name="g">The Drawing GDI object</param>
        /// <param name="n">Root Node</param>
        public void drawTree(Graphics g, Node n)
        {
            graphics = g;

            Options.OptionsData d = Options.OptionsData.Instance;
            // set drawing options
            justification       = d.Justification;
            join                = d.Join;
            treeOrientation     = d.TreeOrientation;
            useRnotation        = d.Notation;
            dropShadow          = d.DropShadow;
            boxShading          = d.BoxShading;
            showLegend          = d.ShowLegend;
            arrows              = d.Arrow;
            marker              = d.Marker;
            helpersAsCoPremises = d.HelpersAsCoPremises;
            // Width and height calculation should only be a cross check
            maxWidth    = 0;
            maxHeight   = 0;
            g.PageScale = zoom;

            // if(needsRecalc)
            recalc(n);

            // calcStartXY(n,ref x,ref y);

            // for debug
            // g.DrawRectangle(new Pen(Color.Bisque),0,0,maxWidth,maxHeight);
            // g.DrawString("maxHeight & maxWidth:"+maxWidth+" : "+maxHeight,new Font("Courier",8F),new SolidBrush(Color.Black),offsetX,offsetY+maxHeight+margin);

            drawNode(n.x, n.y, n, 0);

            legendY = maxHeight - legendHeight;
            drawLegend(n, true);
        }
コード例 #3
0
        public void Load(IO.IPersistStream stream)
        {
            this.JoinName = (string)stream.Load("joinname", "Join");
            this.Field    = (string)stream.Load("field", String.Empty);
            this.JoinType = (joinType)stream.Load("jointype", (int)joinType.LeftOuterJoin);

            _joinLayerId   = (int)stream.Load("joinlayerid", -1);
            this.JoinField = (string)stream.Load("joinfield", String.Empty);
        }
コード例 #4
0
ファイル: DrawTree.cs プロジェクト: JohnHartley/argumentative
        /// <summary>
        /// Draws the optional Reason or Objection tag in the appropriate spot
        /// </summary>
        /// <param name="n">Node being designated</param>
        /// <param name="join"></param>
        /// <param name="x">x-axis location</param>
        /// <param name="y">y-axis location</param>
        /// <param name="pen">pen to use</param>
        /// <param name="brush">Brush to use</param>
        private void drawElementMarker(Node n, joinType join, float x, float y, Pen pen, Brush brush)
        {
            // x,y is the base mid point of the indicator
            // if(this.showElement == showElementType.roundBox)
            {
                string text;
                text = n.ArgumentNodeTypeString();
                text = text.Substring(0, 1);

                GraphicsPath path = new GraphicsPath();
                if (this.marker == markerType.lines)
                {
                    // path.AddLine(x-5,y-5,x+5,y+5);
                    if (this.treeOrientation == treeOrientationType.top_down)
                    {
                        if (n.nodeType == Node.ArgumentNodeType.reason)
                        {
                            path.AddLine(x - 10F, y - 5, x, y - 5);                     // single bar left
                        }
                        if (n.nodeType == Node.ArgumentNodeType.objection)
                        {
                            path.AddLine(x, y - 5, x + 10F, y - 5);                    // bar right
                        }
                        if (n.nodeType == Node.ArgumentNodeType.helper)
                        {
                            path.AddLine(x - 10F, y - 5, x + 10F, y - 5);                  // bar across
                        }
                    }
                    // TODO Add markers for other orientations
//					else if(this.treeOrientation == treeOrientationType.bottom_up)
//					{
//						if(n.nodeType == Node.ArgumentNodeType.reason)
//							path.AddLine(x-10F,y+5+n.height,x,y+5+n.height);  // single bar left
//						if(n.nodeType == Node.ArgumentNodeType.objection)
//							path.AddLine(x,y+5+n.height,x+10F,y+5+n.height); // bar right
//						if(n.nodeType == Node.ArgumentNodeType.helper)
//							path.AddLine(x-10F,y+5+n.height,x+10F,y+5+n.height); // bar across
//					}
                }


                if (this.marker == markerType.letters)
                {
                    FontFamily   family    = new FontFamily("Arial");
                    int          fontStyle = (int)FontStyle.Regular;
                    int          emSize    = 24;
                    Point        origin    = new Point((int)x - emSize / 2, (int)y - emSize - 5);
                    StringFormat format    = StringFormat.GenericDefault;
                    if (this.treeOrientation == treeOrientationType.top_down)
                    {
                        path.AddString(text, family, fontStyle, emSize, origin, format);
                    }
                }
                graphics.DrawPath(Pens.Black, path);
                // drawFancyRectangle(x,y,15,10,pen,true);
            }
        }
コード例 #5
0
        public void Load(IO.IPersistStream stream)
        {
            this.JoinName = (string)stream.Load("joinname", "Join");
            this.Field    = (string)stream.Load("field", String.Empty);

            this.JoinConnectionString = (string)stream.Load("joinconnectionstring", String.Empty);
            this.JoinTable            = (string)stream.Load("jointable", String.Empty);
            this.JoinField            = (string)stream.Load("joinfield", String.Empty);
            _fields   = stream.Load("Fields", null, new Fields()) as Fields;
            _joinType = (joinType)stream.Load("jointype", (int)joinType.LeftOuterJoin);
        }
コード例 #6
0
ファイル: DrawTree.cs プロジェクト: JohnHartley/argumentative
        /// <summary>
        /// New drawing object for the argument map
        /// </summary>
        /// <param name="offsetX">Offset from the left</param>
        /// <param name="offsetY">Offset from the top</param>
        /// <param name="zoom">Magnification</param>
        public DrawTree(float offsetX, float offsetY, float zoom)
        {
            // Create font and brush.
            drawFont      = new Font("Arial", 16);
            drawFontSmall = new Font("Arial", 8);
            drawBrush     = new SolidBrush(Color.Black);

            justification       = justificationType.jCentre;
            join                = joinType.dogleg;
            arrows              = arrowType.none;
            marker              = markerType.none;
            helpersAsCoPremises = false;

            this.offsetX = offsetX; this.offsetY = offsetY;
            this.zoom    = zoom;
            System.Diagnostics.Debug.Assert(zoom > 0F, "Zoom cannot be zero or less");
        }
コード例 #7
0
 joins.Add(new JoinQueryItem(joinType, leftTable, rightTable, columnConnection, columnsConnection));