1 / 14

CGLIB - Constraint-based Graphics Library

CGLIB - Constraint-based Graphics Library. Features Use constraints to specify the layouts of objects Use action rules to specify interactions Implementation Implemented in B-Prolog, Java, and C Applications

gitano
Download Presentation

CGLIB - Constraint-based Graphics Library

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CGLIB - Constraint-based Graphics Library • Features • Use constraints to specify the layouts of objects • Use action rules to specify interactions • Implementation • Implemented in B-Prolog, Java, and C • Applications • Drawing editors, interactive user interfaces, document authoring, animation, information visualization, intelligent agents, and games.

  2. An Illustrative Example go:- cgButton(B), (1) B^text #= “Hello World!”, (2) handleButtonClick(B), (3) cgShow(B). (4) handleButtonClick(B), (5) {actionPerformed(B)} (6) => (7) halt. (8)

  3. cgButton(X) Create a button X cgButton([X1,…,Xn]) Create a list of buttons Objects

  4. Base Derivative Attributes of Objects B is a button y B^window B^x B^y B^width B^height B^text B^color B^font B^rightX B^bottomY B^centerX B^centerY B^leftTopPoint B^leftBottomPoint B^rightTopPoint B^rightBottomPoint B^center x height width

  5. Constraints • Arithmetic constraints • O1^x +O1^width//2 #= O2^x • O1^centerX #= O2^x • Positioning constraints • cgLeft(O1,O2) • Same property constraints • cgSame([O1,O2],size) • cgSame([O1,O2],width,100)

  6. Constraints (Cont.) • Grid constraints cgGrid([[_, S1,_], [S2,S3,S4], [_,S5,_]]) cgGrid([[Bc,Bdiv,Bmul,Bsub], [B7,B8, B9, Badd], [B4,B5, B6, Badd], [B1,B2, B3, Beq], [B0,B0, Bdot,Beq]],1,1),

  7. Constraints (Cont.) • Table constraints cgTable([[Larc,Arc,Button,Lbutton], [Lcheckbox, Checkbox, Choice, Lchoice], [Lcircle,Circle,Image,Limage], [Llabel,Label,Line,Lline], [Llist,List,Oval,Loval], [Lrrectangle,Rrectangle,Rectangle,Lrectangle], [Lpolygon,Polygon,Square,Lsquare], [Lstar,Star,TextArea,Ltextarea], [Ltextfield,TextField,TextBox,Ltextbox], [Ltriangle,Triangle,_,_]],20,20),

  8. Constraints (Cont.) • Tree constraints T=node(C0,[node(C1,[node(C3,[] node(C4,[])]), node(C2,[node(C5,[]), node(C6,[])])]), cgTree(T,top_down,10,10,centered).

  9. Event Handling • Action rule • Examples Agent ConditionSeq {Event} => ActionSeq handleButtonClick(B),{actionPerformed(B)} => … handleMousePress(O),{mousePressed(O,E)} => E^x #= X, E^y #= Y, write(mouse_pressed_at(X,Y)),nl. handleKeyType(O),{keyTyped(O,E)} => E^char #= Char, write(Char).

  10. Other Primitives in CGLIB • Packing and showing objects • cgPack(O)& cgShow(O) • Altering and moving objects • O^attr #:= Value • cgScale(O,F)& cgResize(O,W,H) • cgMove(O,X,Y) • Animation • cgSleep(Time) • Generating Java applets • cgStartRecord(FileName) & cgStopRecord

  11. Demo of CGLIB

  12. Related Work • Postscript & Latex • Every detail must be specified • Java & Tcl/Tk • Layout managers are helpful for certain layouts • Functional programming • New data types and functions for events, time, and behaviors • Constraints & Constraint programming • Sketchpad, ThinkLab, Amulet, SubArctic

  13. Further Work • Extension of the set of base objects • Application-specific objects • 3D objects • Constructs for users to define their own objects • Non-linear and soft constraints • Improving the performance • Constraint solving • Graphics rendering

  14. Papers • N.F. Zhou: CGLIB - A Constraint-based Graphics Library, Software - Practice and Experience, Vol. 33, No.13, pp.1199-1216, 2003. • N.F. Zhou: Authoring Graphics-rich and Interactive Documents in CGLIB - A Constraint-based Graphics Library, Proceedings of the ACM Symposium on Document Engineering, pp.28-38, November, 2001.

More Related