第一范文网 - 专业文章范例文档资料分享平台

编译原理经典算法的可视化实现 - 图文

来源:用户分享 时间:2025/5/29 4:50:26 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

编译原理经典算法的可视化实现 Rectangle rect5 = new Rectangle(x + 200, y + 140, 50, 50); Rectangle rect51 = new Rectangle(x + 210, y + 150, 35, 35); g.DrawEllipse(p, rect5); g.DrawEllipse(p, rect51); Brush brush5 = new SolidBrush(Color.LawnGreen); Font font5 = new Font(\楷体GB-2312\, 25, FontStyle.Bold); g.DrawString(\, font5, brush5, x + 210, y + 150); //画线 Pen pline = new Pen(Color.Black, 5); pline.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; pline.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor; //画s->A g.DrawLine(pline, x + 80, y + 70, x + 120, y + 70); g.DrawString(\, font, bru, x +80, y + 35); //画s->c g.DrawLine(pline, x + 80, y + 70, x + 120, y + 155); g.DrawString(\, font, bru, x + 70, y + 90); //A->B g.DrawLine(pline, x + 170, y + 70, x + 200, y +70); g.DrawString(\, font, bru, x + 170, y + 35); //C->D g.DrawLine(pline, x + 170, y + 165, x + 200, y + 165); g.DrawString(\, font, bru, x + 170, y + 130); //画A->A Point[] points = new Point[3]; points[0] = new Point(x + 124, y + 55); points[1] = new Point(x + 140, y + 25); points[2] = new Point(x + 165, y + 55); g.DrawString(\, font, bru, x + 100, y-5 ); g.DrawCurve(pline, points); //画C->C Point[] point = new Point[3]; point[0] = new Point(x + 124, y + 150); point[1] = new Point(x + 140, y + 120); point[2] = new Point(x + 165, y + 150); g.DrawString(\, font, bru, x + 130, y +90); g.DrawCurve(pline, point);

//解释语句

Font fontt = new Font(\楷体GB-2312\, 10, FontStyle.Bold); Brush brush6 = new SolidBrush(Color.OrangeRed); g.DrawString(\单词\, fontt, brush6, x + 300, y +10); g.DrawString(\标识符\, fontt, brush6, x + 300, y +40); g.DrawString(\无符号整数\, fontt, brush6, x + 300, y +70);

41

编译原理经典算法的可视化实现 g.DrawString(\字母\, fontt, brush6, x + 300, y +100); g.DrawString(\数字\, fontt, brush6, x + 300, y +130); g.DrawString(\非字母数字\, fontt, brush6, x + 300, y +160); g.DrawString(\非数字\, fontt, brush6, x + 300, y +190); base.OnPaint(e); } protected override void OnResize(EventArgs e) { Invalidate(); base.OnResize(e); } //动态画线

void drawDirectly(Point start, Point end) {

Graphics g = this.CreateGraphics(); int length = end.X - start.X; int ave = length / 5; int len = start.X;

Pen pline = new Pen(Color.Red , 5);

pline.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; while (len < end.X) {

g.DrawLine(pline, start.X ,start.Y , len + ave-5, end.Y);

System.Threading.Thread.Sleep(speed);//参数以毫秒为单位 len += ave; }

Pen pline1 = new Pen(Color.Orange, 5);

pline1.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; pline1.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor; g.DrawLine(pline1, start, end); }

void draw2(Point []point) {

Graphics g = this.CreateGraphics(); Pen pline = new Pen(Color.Red, 5);

pline.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; pline.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor; g.DrawCurve(pline, point);

System.Threading.Thread.Sleep(speed); Pen pline1 = new Pen(Color.Orange, 5);

pline1.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; pline1.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;

42

编译原理经典算法的可视化实现 g.DrawCurve(pline1, point); // g.DrawCurve(pline, point); } void draw4(Point start, Point end) { Graphics g = this.CreateGraphics(); Pen pline = new Pen(Color.Red, 5); pline.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; int avex = (end.X - start.X) / 5; int avey = (end.Y - start.Y) / 5; for (int i = 1; i <= 5; i++) {

g.DrawLine(pline, start.X, start.Y,start.X +(i*avex),start.Y+(i*avey)); System.Threading.Thread.Sleep(speed);//参数以毫秒为单位 }

Pen pline1 = new Pen(Color.Orange, 5);

pline1.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid; pline1.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor; g.DrawLine(pline1, start, end);

}

43

编译原理经典算法的可视化实现 - 图文.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c3s3oq73jzx7u3cn9al3b_12.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top