lexi设计案例分析.ppt
《lexi设计案例分析.ppt》由会员分享,可在线阅读,更多相关《lexi设计案例分析.ppt(76页珍藏版)》请在优知文库上搜索。
1、1第2章 实例研究:Lexi 文档编辑器 A WYSIWYG document editor. Mix text and graphics freely in various formatting styles. The usual Pull-down menus Scroll bars Page icons for jumping around the document. 通过本实例设计,学习设计模式的实际应用22.1 设计问题 Lexi设计的7个问题 1 文档结构:对文档内部表示的选择几乎影响Lexi设计的每个方面。 2 格式化 3 修饰用户界面 4 支持多种视感标准 5 支持多种窗口系统
2、 6 用户操作 7 拼写检查 上述每个问题都有一组相关联的目标集合和限制条件集合。32.2 文档结构 目标 保持文档的物理结构。即将文本和图形安排到行、列和表等。 可视化生成和显示文档。 根据显示位置来映射文档内部表示的元素。 限制条件 应该一致地对待文本和图形。 应该一致地对待简单元素和复合元素。 但文本分析依赖于被分析对象的类型。4解决方案:递归组合递归组合:Building more complex elements out of simpler ones. 行列(段落)页 (P24 第2段第2行)第5行第2列的第10个元素 The tenth element in line five
3、of column two,隐含: Each object type needs a corresponding class All must have compatible interfaces (inheritance)图2 包含正文和图形的递归组合图3 递归组合的对象结构5Glyph (图元类)Base class for composable graphical objectsAn Abstract class for all objects that can appear in a document. Both primitive and composed.void insert(G
4、lyph)void remove(Glyph)Glyph child(int)Glyph parent()管理子图元的接口boolean intersects(Coord, Coord)判断一个指定的点是否与图元相交void draw(Window*)Void Bounds(Rect)在窗口上表示自己返回图元占用的矩形面积操作任务基本接口:子类: Character, Image, Space, Row, Column 6图元类层次Note the inherent recursion in this hierarchywi.e., a Row is a Glyph & a Row also
5、has Glyphs!7Glyph Interface and responsibilitiesGlyphs know how to draw themselvesGlyphs know what space they occupyGlyphs know their children and parentspublic abstract class Glyph / appearance public abstract void draw(Window w); public abstract Rect getBounds(); / hit detection public abstract bo
6、olean intersects(Point); / structure public abstract void insert(Glyph g, int i); public abstract void remove(Glyph g); public abstract Glyph child(int i); public abstract Glyph parent();8COMPOSITE 模式 object structural意图treat individual objects & multiple, recursively-composed objects uniformly适用obj
7、ects must be composed recursively,and no distinction between individual & composed elements,and objects in structure can be treated uniformlyStructure9COMPOSITE 模式(contd) object structural效果+uniformity: treat components the same regardless of complexity+extensibility: new Component subclasses work w
8、herever old ones do实现do Components know their parents?保持从子部件到父部件的引用能简化组合结构的遍历和管理uniform interface for both leaves & composites?最大化Component接口dont allocate storage for children in Component base classresponsibility for deleting children由Composite负责删除其子节点102.3 格式化 格式化:将一个图元集合分解为若干行 目标:自动换行 Breaking up
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- lexi 设计 案例 分析
