wimp interfaces
play

WIMP interfaces Graphical interfaces WIMP: Window, Icons, Menus and - PowerPoint PPT Presentation

Assignment 1 is out! Design and implement an interactive tool for creating the layout of comic strips UI Programming (part of this content is based on previous classes from Anastasia, S. Huot, M. Beaudouin-Lafon, N.Roussel, O.Chapuis)


  1. Assignment 1 is out! Design and implement an interactive tool for creating the layout of comic strips UI Programming (part of this content is based on previous classes from Anastasia, S. Huot, M. Beaudouin-Lafon, N.Roussel, O.Chapuis) https://www.lri.fr/~fanis/teaching/ISI2014/assignments/ass1/ WIMP interfaces Graphical interfaces WIMP: Window, Icons, Menus and Pointing Presentation GUIs: input is specified w.r.t. output � Windows, icons and other graphical objects Input peripherals specify commands at specific Interaction locations on the screen ( pointing ), where � Menus, dialog boxes, text input fields, etc specific objects are drown by the system. Input Familiar behavior from physical world � pointing, selection, ink/path Perception-action loop � feedback

  2. Software layers Software layers Application Application Applications/Communication (MacApp) Interface Tools & Toolkits Builders, Java Swing, JavaFX, Qt (C++), Interface Tools & Toolkits GTK+, MFC, Cocoa Graphics Library Graphics Library GDI+, Quartz, GTK+/Xlib, OpenGL Windowing System Windowing System X Windows (+KDE or GNU) Input/Output Input/Output Operating System Operating System Windows, Mac OS, Unix, Linux, Android, iOS, WindowsCE Interactivity vs. computing Input/output peripherals Closed systems (computation): Input: where we give commands � read input, compute, produce result � final state (end of computation) Output: where the system shows information & reveals its state Open systems (interaction): � events/changes caused by environment � infinite loop, non-deterministic

  3. Problem Problem We learn to program algorithms (computational) Treating input/output during computation (interrupting computation) … Most languages (C/C++, Java, Lisp, Scheme, � write instructions ( print, put, send,… ) to send data to Pascal, Fortran, ...) designed for algorithmic output peripherals computations, not interactive systems � read instructions ( read, get, receive,… ) to read the state or state changes of input peripherals Managing input Problem Querying Polling Events Query & wait Active wait Wait queue To program IS in algorithmic/computational form 1 device at a time Polling in sequence CPU cost two buttons B1 and B2 � finish <- false � while not finish do � � � button <- waitClick () //interruption, blocked comp. � � � if button � � � � B1 : print « Hello World » � � � � B2 : finish <- true � � � end � end

  4. Event based (driven) Event based (driven) programming programming while active � while active � if queue is not empty � if queue is not empty � event <- queue.dequeue() � event <- queue.dequeue() � Source: Mouse Click Source: Mouse Click source <- findSource(event) � source <- findSource(event) � source.processEvent(event) � source.processEvent(event) � end if � end if � event (waiting) queue event (waiting) queue end while � end while � queue.enqueue(event) queue.enqueue(event) processEvent(event) � target <- FindTarget (event) � if (target ≠ NULL) � Target: Button � target.processEvent(event) � « Cancel » Example: Swing (and AWT) Software layers Application AWT Event Queue 3 threads Interface Tools & Toolkits � Initial thread: main () � EDT manages the events queue: Graphics Library Event Dispacher Thread sends events to listeners (functions (EDT) dealing with events) and calls paint Windowing System methods (drawing functions) � Worker (or background) threads, where Input/Output time-consuming tasks are executed Listeners paint () Operating System

  5. Interface builders Interface builders Can be used to � create prototypes (but attention it looks real) � get the « look » right � be part of final product � design is fast � modest technical training needed � can write user manuals from it But: still need to program (and clean code …) Examples : MS Visual Studio (C++, C#, etc.), NetBeans (Java), Interface Builder (ObjectiveC), Android Layout Editor Interface toolkits Interface toolkits Libraries of interactive objects (« widgets », e.g., Toolkit Platform Language buttons) that we use to construct interfaces Qt multiplatform C++ GTK+ multiplatform C Functions to help programming of GUIs MFC later WTL Windows C++ WPF (subset of WTL) Windows (any .Net language) ...usually also handle input events (later) FLTK multiplatform C++ AWT / Swing multiplatform Java Cocoa MacOs Objective C Gnustep Linux, Windows Objective C Motif Linux C JQuery UI Web javascript Problem with toolkits? ….

  6. Why Java Swing? Why Java Swing? Based on Java (any platform, plenty of libraries) Based on Java (any platform, plenty of libraries) A lot of online resources and examples A lot of online resources and examples Other alternatives for Java? � JavaFX: soon becomes the new standard for Java UI programming, supporting a variety of different devices « widgets » (window gadgets) Swing widgets window pallet menu button tab label text zone radio button list scroll bar slider

  7. Swing widgets Widget complexity Simple widgets � buttons, scroll bars, labels, … Composite/complex widgets � contain other widgets (simple or complex) � dialog boxes, menus, color pickers, … Widget tree Swing widget classes Hierarchical representation of the widget structure A GUI application has a top-level (container) widget that includes all others � a widget can belong to only one « container » Root (complex) Window application window In Swing there are 3 types: JFrame, JDialog and JApplet JFrame UI Components They all contain other widgets (simple or complex), that are Nodes (complex) Visual or functional JPanel declared in the field content pane grouping of widgets Text zone Tool bar JTextArea JToolBar Button 3 Button 2 JButton Button 1 Leaf (simple) JButton user can interact JButton with these

  8. Swing widget classes Swing JFrame Partial object hierarchy of Swing widgets a window with a basic bar Base class for all public static void main(String[] args) { � Swing components JFrame jf = new JFrame(”Ta ta!"); � (exept for top-level jf.setVisible( true ); � containers) jf.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE ); � System. out .println(”finished ? ! ?"); � System. out .println(”no, still running …"); � } � Useful functions public JFrame(); public JFrame(String name); public Container getContentPane(); public void setJMenuBar(JMenuBar menu); http://docs.oracle.com/javase/tutorial/ui/features/components.html public void setTitle(String title); public void setIconImage(Image image); This program does not terminate after “no, still running …” � Swing JDialog Widget placement a message window (dialog) can be “modal” (blocks UI toolkits control widget placement: interaction) usually attached to another window (when that closes, � should be independent of widget size so does the dialog) (menu at least as big as its largest item, change of scrollbar size with document size, public static void main(String[] args) { � adjusting text flow) JFrame jf = new JFrame(”ta ta!"); � jf.setVisible( true ); � � done in layout managers that can be jf.setDefaultCloseOperation(JFrame. EXIT_ON_CLOSE ); � � JDialog jd = new JDialog(jf,”A dialog", true ); � added to container widgets modal � � jd.setVisible( true ); � } � attached to

  9. import javax.swing.*; Widget placement import java.awt.*; public class SwingDemo2 extends JFrame { public void init() { General guides this.setTitle("example 2"); � embed geometry of a «child» widget to its parent getContentPane().add(new JLabel("Swing Demo 2")); � parent controls the placement of its children Container contentPane = this.getContentPane(); contentPane.setLayout setLayout(new FlowLayout()); Layout algorithm this.setDefaultCloseOperation(EXIT_ON_CLOSE); � natural size for each child (to fit content) contentPane.add(new JButton("clique ici")); contentPane.add(new JButton("clique là")); � size and position imposed by parent } � constraints: grid, form, etc. public static void main(String[] args) { SwingDemo2 frame = new SwingDemo2(); frame.init(); frame.setSize(200,200); frame.setVisible(true); } } Bruce Eckel, Thinking in Java, 2 nd edition Layout managers (in Swing) import javax.swing.*; import java.awt.*; public class SwingDemo4 extends JFrame { public void init() { Container cp = getContentPane(); this.setTitle("example 4"); this.setDefaultCloseOperation(EXIT_ON_CLOSE); BorderLayout FlowLayout cp.setLayout setLayout(new FlowLayout()); for(int i = 0; i < 20; i++) cp.add(new JButton("Button " + i)); } public static void main(String[] args) { SwingDemo4 frame = new SwingDemo4(); frame.init(); frame.setSize(200,700); frame.setVisible(true); } } BoxLayout GridLayout GroupLayout http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html Bruce Eckel, Thinking in Java, 2 nd edition

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend