DOC PREVIEW
SJSU CMPE 196G - Lexi Case Study
Pages 54

This preview shows page 1-2-3-4-25-26-27-51-52-53-54 out of 54 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 54 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Lexi Case StudyDocument StructureRecursive CompositionGlyph ClassGlyph Interface and responsibilitiesFormattingComposition & CompositorCompositor & CompositionEmbellishmentsTransparent EnclosureMonoGlyphSupporting Multiple Window SystemsMultiple Look-and-Feel StandardsObject FactoriesProduct ObjectsBuilding the FactoryMultiple GUI LibrariesWindow ImplementationsWindow Implementation Code SampleConfiguring ‘imp’RecapUser OperationsCommandsCommand HierarchyInvoking CommandsUndo/RedoSpell Checking & HyphenationAccessing Scattered InformationEncapsulating Access & TraversalsIterator HierarchyUsing IteratorsInitializing IteratorsPre-order IteratorApproachImplementing a Complex IteratorImplementing a Complex Iterator (cont’d)Slide 37Slide 38Slide 39Slide 40Slide 41Slide 42Slide 43Slide 44Traversal ActionsActions in IteratorsAvoiding DowncastsAccepting VisitorsVisitor & SubclassesSpellingVisitorUsing SpellingVisitorVisitor Activity DiagramHyphenationVisitorSummaryLEXI CmpE196G 1Lexi Case Study•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.•Going through the design, we will see many patterns in action.•History: Ph.D. thesis of Paul Calder (s. Mark Linton) 1993LEXI CmpE196G 2Document Structure•A hierarchical arrangement of shapes.•Viewed as lines, columns, figures, tables, …•UI should allow manipulations as a group–E.g. refer to a table as a whole•Internal representation should support–Maintaining the physical structure–Generating and presenting the visuals–Reverse mapping positions to elements•Want to treat text and graphics uniformly•No distinction between single elements or groups.–E.g. the 10th element in line 5 could be an atomic character, or a complex figure comprising nested sub-parts.LEXI CmpE196G 3Recursive Composition•Building more complex elements out of simpler ones.•Implications:–Each object type needs a corresponding class–All must have compatible interfaces (inheritance)–Performance issues.LEXI CmpE196G 4Glyph ClassAn Abstract class for all objects that can appear in a document.–Both primitive and composed.LEXI CmpE196G 5Glyph Interface and responsibilities•Glyphs know how to draw themselves•Glyphs know what space they occupy•Glyphs know their children and parentspublic abstract class Glyph { // appearance public abstract void draw(Window w); public abstract Rect getBounds(); // hit detection public abstract boolean 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();}LEXI CmpE196G 6Formatting•Breaking up a document into lines.–Many different algorithms•trade off quality for speed–Complex algorithms•Want to keep the formatting algorithm well-encapsulated.–independent of the document structure•can add formatting algorithm without modifying Glyphs•can add Glyphs without modifying the formatting algorithm.•Want to make it dynamically changeable.LEXI CmpE196G 7Composition & Compositor•Initially, an unformatted Composition object contains only the visible child Glyphs.•After running a Compositor, it will also contain invisible, structural glyphs that define the format.LEXI CmpE196G 8Compositor & Composition•Compositor class will encapsulate a formatting algorithm.•Glyphs it formats are all children of CompositionLEXI CmpE196G 9Embellishments•Wish to add visible borders and scroll-bars around pages.•Inheritance is one way to do it.–leads to class proliferation•BorderedComposition, ScrollableComposition, BorderedScrollableComposition–inflexible at run-time•Will have classes–Border–Scroller•They will be Glyphs–they are visible–clients shouldn’t care if a page has a border or not•They will be composed.–but in what order?LEXI CmpE196G 10Transparent Enclosure•single-child composition•compatible interfaces•Enclosure will delegate operations to single child, but can–add state–augment by doing work before or after delegating to the child.LEXI CmpE196G 11MonoGlyph•Border calls { MonoGlyph.draw(); drawBorder(); }LEXI CmpE196G 12Supporting Multiple Window Systems•Want the application to be portable across diverse user interface libraries.•Every user interface element will be a Glyph.•Some will delegate to appropriate platform-specific operations.LEXI CmpE196G 13Multiple Look-and-Feel Standards•Goal is to make porting to a different windowing system as easy as possible.–one obstacle is the diverse look-and-feel standards–want to support run-time switching of l&f.–Win, Motif, OpenLook, Mac, …•Need 2 sets of widget glyph classes–abstract•ScrollBar, Button, …–concrete•MotifScrollBar, WinScrollBar, MacScrollBar, MotifButton, …•Need indirect instantiation.LEXI CmpE196G 14Object FactoriesUsual method:ScrollBar sb = new MotifScrollBar();Factory method:ScrollBar sb = guiFactory.createScrollBar();LEXI CmpE196G 15Product Objects•The output of a factory is a product.abstractconcreteLEXI CmpE196G 16Building the Factory•If known at compile time (e.g., Lexi v1.0 – only Motif implemented).GUIFactory guiFactory = new MotifFactory(); •Set at startup (Lexi v2.0)String LandF = appProps.getProperty("LandF");GUIFactory guiFactory;if( LandF.equals("Motif") )guiFactory = new MotifFactory();...•Changeable by a menu command (Lexi v3.0)–re-initialize ‘guiFactory’–re-build the UILEXI CmpE196G 17Multiple GUI Libraries•Can we apply Abstract Factory?–Each GUI library will define its own concrete classes.–Cannot have them all inherit from a common, abstract base.–but, all have common principles•Start with an abstract Window hierarchy (does not depend on GUI library)LEXI CmpE196G 18Window Implementations•Defined interface Lexi deals with, but where does the real windowing library come into it?•Could define alternate Window classes & subclasses.–At build time can substitute the appropriate one•Could subclass the Window hierarchy.•Or …LEXI CmpE196G 19Window Implementation Code Samplepublic class Rectangle extends Glyph { public void draw(Window w) { w.drawRect(x0,y0,x1,y1); } ...}public class Window { public void drawRect(Coord x0,y0,x1,y1) { imp.drawRect(x0,y0,x1,y1); } ...}public class XWindowImp extends WindowImp { public void


View Full Document

SJSU CMPE 196G - Lexi Case Study

Download Lexi Case Study
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lexi Case Study and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lexi Case Study 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?