Exemple #1
0
        public override void draw(double x, double y, double contentsWidth,
                                  DrawCFGraph.LineDrawer lineDrawer, DrawCFGraph.TextDrawer textDrawer)
        {
            lineDrawer(x - contentsWidth / 2, y, x + contentsWidth / 2, y);

            lineDrawer(x - contentsWidth / 2, y, x - contentsWidth / 2, y + fontHeight + gap * 2);
            lineDrawer(x + contentsWidth / 2, y, x + contentsWidth / 2, y + fontHeight + gap * 2);

            lineDrawer(x - contentsWidth / 2, y + fontHeight + gap * 2,
                       x + contentsWidth / 2, y + fontHeight + gap * 2);

            textDrawer(this.codeString, fontHeight, x - contentsWidth / 2 + gap, y);

            lineDrawer(x, y + fontHeight + gap * 2, x, y + fontHeight + gap * 6);

            this.drawingComplete = true;

            this.height = fontHeight + gap * 6;

            if (this.nextStatement != null && this.textMeasurer != null)
            {
                this.nextStatement.draw(x, y + this.height, this.nextStatement.width(this.textMeasurer),
                                        lineDrawer, textDrawer);
            }
        }
Exemple #2
0
        public override void draw(double x, double y, double contentsWidth,
                                  DrawCFGraph.LineDrawer lineDrawer, DrawCFGraph.TextDrawer textDrawer)
        {
            if (this.textMeasurer != null)
            {
                double labelWidth = textMeasurer(this.codeString, fontHeight);

                lineDrawer(x - labelWidth / 2 - gap, y, x + labelWidth / 2 + 3 * gap, y);

                textDrawer(this.codeString, fontHeight, x - labelWidth / 2, y);

                lineDrawer(x - labelWidth / 2 - gap, y + fontHeight + gap * 2,
                           x + labelWidth / 2 + 3 * gap, y + fontHeight + gap * 2);


                lineDrawer(x + labelWidth / 2 + 3 * gap, y, x + labelWidth / 2 + 3 * gap, y + fontHeight + gap * 2);

                this.jumpTargetX = x - labelWidth / 2 - 3 * gap;
                this.jumpTargetY = y + fontHeight / 2 + gap;
                lineDrawer(x - labelWidth / 2 - gap, y, this.jumpTargetX, this.jumpTargetY);

                lineDrawer(this.jumpTargetX, this.jumpTargetY, x - labelWidth / 2 - gap, y + fontHeight + gap * 2);

                this.height = fontHeight + gap * 2;

                lineDrawer(x, y + this.height, x, y + this.height + gap * 4);

                this.height += gap * 4;

                if (this.jumpOrigintSet) /* some jumps expect this label to be drawn! */
                {
                    foreach (CJumpStatement jumpOrigin in this.jumpOrigins)
                    {
                        double delta1 = System.Math.Abs(this.jumpTargetX - jumpOrigin.jumpFromX1),
                                            delta2 = System.Math.Abs(this.jumpTargetX - jumpOrigin.jumpFromX2);

                        if (delta1 < delta2)
                        {
                            lineDrawer(jumpOrigin.jumpFromX1, jumpOrigin.jumpFromY, this.jumpTargetX, this.jumpTargetY);
                        }
                        else
                        {
                            lineDrawer(jumpOrigin.jumpFromX2, jumpOrigin.jumpFromY, this.jumpTargetX, this.jumpTargetY);
                        }
                    }
                }

                this.drawingComplete = true;

                if (this.labeledStatement != null)
                {
                    this.labeledStatement.draw(x, y + this.height, this.labeledStatement.width(this.textMeasurer),
                                               lineDrawer, textDrawer);

                    this.height += this.labeledStatement.height;
                }
            }
        }
        public override void draw(double x, double y, double contentsWidth,
                                  DrawCFGraph.LineDrawer lineDrawer, DrawCFGraph.TextDrawer textDrawer)
        {
            this.jumpFromY = y + fontHeight / 2 + gap;

            this.jumpFromX1 = x - contentsWidth / 2;

            this.jumpFromX2 = x + contentsWidth / 2;

            lineDrawer(this.jumpFromX1 + gap * 4, y, this.jumpFromX2 - gap * 4, y);

            lineDrawer(this.jumpFromX1 + gap * 4, y, this.jumpFromX1 + gap * 4, y + fontHeight + gap * 2);
            lineDrawer(this.jumpFromX2 - gap * 4, y, this.jumpFromX2 - gap * 4, y + fontHeight + gap * 2);


            lineDrawer(this.jumpFromX1, this.jumpFromY, this.jumpFromX1 + gap * 4, this.jumpFromY);

            lineDrawer(this.jumpFromX2, this.jumpFromY, this.jumpFromX2 - gap * 4, this.jumpFromY);

            textDrawer(this.codeString, fontHeight, this.jumpFromX1 + gap * 5, y + gap);

            this.height = fontHeight + gap * 7;

            this.drawingComplete = true;

            if (this.targetStatement != null)
            {
                if (this.targetStatement.drawingComplete)
                {
                    double delta1 = System.Math.Abs(this.targetStatement.jumpTargetX - this.jumpFromX1),
                           delta2 = System.Math.Abs(this.targetStatement.jumpTargetX - this.jumpFromX2);

                    if (delta1 < delta2)
                    {
                        lineDrawer(this.jumpFromX1, this.jumpFromY,
                                   this.targetStatement.jumpTargetX, this.targetStatement.jumpTargetY);
                    }
                    else
                    {
                        lineDrawer(this.jumpFromX2, this.jumpFromY,
                                   this.targetStatement.jumpTargetX, this.targetStatement.jumpTargetY);
                    }
                }
                else
                {
                    this.targetStatement.addJumpOrigin(this);
                }
            }

            if (this.nextStatement != null && this.textMeasurer != null)
            {
                this.nextStatement.draw(x, y + this.height, this.nextStatement.width(this.textMeasurer),
                                        lineDrawer, textDrawer);
            }
        }
Exemple #4
0
        public override void draw(double x, double y, double contentsWidth,
                                  DrawCFGraph.LineDrawer lineDrawer, DrawCFGraph.TextDrawer textDrawer)
        {
            lineDrawer(x, y + fontHeight + gap * 2, x, y + fontHeight + gap * 5);

            if (this.textMeasurer != null)
            {
                double conditionWidth = this.textMeasurer(this.codeString, fontHeight);

                lineDrawer(x - conditionWidth / 2 - gap, y, x + conditionWidth / 2 + gap, y);

                lineDrawer(x - conditionWidth / 2 - gap, y, x - conditionWidth / 2 - gap, y + fontHeight + gap * 2);
                lineDrawer(x + conditionWidth / 2 + gap, y, x + conditionWidth / 2 + gap, y + fontHeight + gap * 2);

                lineDrawer(x - conditionWidth / 2 - gap, y + fontHeight + gap * 2,
                           x + conditionWidth / 2 + gap, y + fontHeight + gap * 2);

                textDrawer(this.codeString, fontHeight, x - conditionWidth / 2, y);

                this.height = fontHeight + gap * 5;


                if (this.switchStatement != null)
                {
                    this.switchStatement.draw(x, y + this.height, this.switchStatement.width(this.textMeasurer),
                                              lineDrawer, textDrawer);

                    this.height += this.switchStatement.height;
                }

                /* jumps to cases */

                lineDrawer(x - conditionWidth / 2 - gap, y + fontHeight / 2 + gap,
                           x - conditionWidth / 2 - gap * 8, y + fontHeight / 2 + gap);

                foreach (CLabeledStatement caseTarget in this.jumpTargets)
                {
                    if (caseTarget != null)
                    {
                        lineDrawer(x - conditionWidth / 2 - gap * 8, y + fontHeight / 2 + gap,
                                   caseTarget.jumpTargetX, caseTarget.jumpTargetY);
                    }
                }
            }

            this.drawingComplete = true;

            if (this.nextStatement != null)
            {
                this.nextStatement.draw(x, y + this.height, this.nextStatement.width(this.textMeasurer),
                                        lineDrawer, textDrawer);
            }
        }
Exemple #5
0
        public void draw(double x, double y, double contentsWidth,
                         DrawCFGraph.LineDrawer lineDrawer, DrawCFGraph.TextDrawer textDrawer)
        {
            if (this.textMeasurer != null)
            {
                textDrawer("function: " + this.functionName, CStatement.fontHeight,
                           x - textMeasurer("function: " + this.functionName, CStatement.fontHeight) / 2, y);

                this.drawingComplete = true;

                this.functionBody.draw(x, y + CStatement.fontHeight + CStatement.gap * 2,
                                       this.functionBody.width(this.textMeasurer), lineDrawer, textDrawer);

                this.height = CStatement.fontHeight + CStatement.gap * 2 + this.functionBody.height;
            }
        }
Exemple #6
0
        public override void draw(double x, double y, double contentsWidth,
                                  DrawCFGraph.LineDrawer lineDrawer, DrawCFGraph.TextDrawer textDrawer)
        {
            lineDrawer(x - contentsWidth / 2, y, x + contentsWidth / 2, y);

            lineDrawer(x, y, x, y + fontHeight + gap * 2);

            lineDrawer(x - contentsWidth / 2, y, x - contentsWidth / 2, y + fontHeight + gap * 2);
            lineDrawer(x + contentsWidth / 2, y, x + contentsWidth / 2, y + fontHeight + gap * 2);

            this.height = fontHeight + gap * 2;

            if (this.textMeasurer != null && this.statementList.Length > 0 && this.statementList[0] != null)
            {
                this.statementList[0].draw(x, y + this.height,
                                           this.statementList[0].width(this.textMeasurer), lineDrawer, textDrawer);
            }

            foreach (CStatement currStatement in this.statementList)
            {
                if (currStatement != null && currStatement.drawingComplete)
                {
                    this.height += currStatement.height;
                }
            }

            lineDrawer(x - contentsWidth / 2, y + this.height,
                       x - contentsWidth / 2, y + this.height - fontHeight - gap * 2);
            lineDrawer(x + contentsWidth / 2, y + this.height,
                       x + contentsWidth / 2, y + this.height - fontHeight - gap * 2);

            lineDrawer(x - contentsWidth / 2, y + this.height,
                       x + contentsWidth / 2, y + this.height);

            lineDrawer(x, y + this.height, x, y + this.height + gap * 4);

            this.height += gap * 4;

            this.drawingComplete = true;

            if (this.nextStatement != null && this.textMeasurer != null)
            {
                this.nextStatement.draw(x, y + this.height, this.nextStatement.width(this.textMeasurer),
                                        lineDrawer, textDrawer);
            }
        }
Exemple #7
0
 public abstract void draw(double x, double y, double contentsWidth,
                           DrawCFGraph.LineDrawer lineDrawer, DrawCFGraph.TextDrawer textDrawer);
Exemple #8
0
        public override void draw(double x, double y, double contentsWidth,
                                  DrawCFGraph.LineDrawer lineDrawer, DrawCFGraph.TextDrawer textDrawer)
        {
            lineDrawer(x, y + fontHeight + gap * 2, x, y + fontHeight + gap * 5);

            if (this.textMeasurer != null)
            {
                double conditionWidth = this.textMeasurer(this.codeString, fontHeight),
                       ifTrueWidth    = this.ifTrueStatement.width(this.textMeasurer);

                lineDrawer(x - conditionWidth / 2 - gap, y, x + conditionWidth / 2 + gap, y);

                lineDrawer(x - conditionWidth / 2 - gap, y, x - conditionWidth / 2 - gap, y + fontHeight + gap * 2);
                lineDrawer(x + conditionWidth / 2 + gap, y, x + conditionWidth / 2 + gap, y + fontHeight + gap * 2);

                lineDrawer(x - conditionWidth / 2 - gap, y + fontHeight + gap * 2,
                           x + conditionWidth / 2 + gap, y + fontHeight + gap * 2);

                textDrawer(this.codeString, fontHeight, x - conditionWidth / 2, y);

                lineDrawer(x, y + fontHeight + gap * 5, x - gap * 4 - ifTrueWidth / 2, y + fontHeight + gap * 5);

                lineDrawer(x - gap * 4 - ifTrueWidth / 2, y + fontHeight + gap * 5,
                           x - gap * 4 - ifTrueWidth / 2, y + fontHeight + gap * 7);

                textDrawer("true", fontHeight,
                           x - gap * 4 - ifTrueWidth / 2 - this.textMeasurer("true", fontHeight) / 2, y + fontHeight + gap * 6);

                this.height = fontHeight * 2 + gap * 7;

                this.drawingComplete = true;

                /* ... */

                this.ifTrueStatement.draw(x - gap * 4 - ifTrueWidth / 2, y + this.height,
                                          this.ifTrueStatement.width(this.textMeasurer), lineDrawer, textDrawer);

                if (!(this.ifTrueStatement is CJumpStatement))
                {
                    lineDrawer(x - gap * 4 - ifTrueWidth / 2, y + this.height + ifTrueStatement.height,
                               x, y + this.height + ifTrueStatement.height);
                }

                if (this.elseStatement != null)
                {
                    double elseWidth = this.elseStatement.width(this.textMeasurer);

                    lineDrawer(x, y + fontHeight + gap * 5, x + gap * 4 + elseWidth / 2, y + fontHeight + gap * 5);

                    lineDrawer(x + gap * 4 + elseWidth / 2, y + fontHeight + gap * 5,
                               x + gap * 4 + elseWidth / 2, y + fontHeight + gap * 7);

                    textDrawer("false", fontHeight,
                               x + gap * 4 + elseWidth / 2 - this.textMeasurer("false", fontHeight) / 2, y + fontHeight + gap * 6);

                    this.elseStatement.draw(x + gap * 4 + elseWidth / 2, y + this.height,
                                            this.elseStatement.width(this.textMeasurer), lineDrawer, textDrawer);

                    if (!(this.elseStatement is CJumpStatement))
                    {
                        lineDrawer(x + gap * 4 + elseWidth / 2, y + this.height + elseStatement.height,
                                   x, y + this.height + elseStatement.height);
                    }

                    if (ifTrueStatement.height > elseStatement.height)
                    {
                        this.height += ifTrueStatement.height + gap * 4;
                    }
                    else
                    {
                        this.height += elseStatement.height + gap * 4;
                    }
                }
                else
                {
                    this.height += ifTrueStatement.height + gap * 4;
                }

                lineDrawer(x, y + fontHeight + gap * 3, x, y + this.height);

                if (this.nextStatement != null)
                {
                    this.nextStatement.draw(x, y + this.height, this.nextStatement.width(this.textMeasurer),
                                            lineDrawer, textDrawer);
                }
            }
        }