Dealing with more complex models

Slides:



Advertisements
Similar presentations
Intermediate Level Course. Text Format The text styles, bold, italics, underlining, superscript and subscript, can be easily added to selected text. Text.
Advertisements

Chapter 13: Advanced GUIs and Graphics J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition.
With Alex Conger – President of Webmajik.com FrontPage 2002 Level I (Intro & Training) FrontPage 2002 Level I (Intro & Training)
Microsoft Visual Basic 2012 CHAPTER TWO Program and Graphical User Interface Design.
Web Design HTML, Frontpage, DreamWeaver μέρος β ΠΡΥ019 - Πληροφορική Δρ.Βάσος Βασιλείου.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
MVC and Swing IAT 351 Week 7 Lecture/tutorial Lyn Bartram.
Advanced Project Plan Formatting Lesson 14. Skills Matrix SkillsMatrix Skill Customize the calendar view Format bar styles for tasks in the Calendar view.
Visual Basic 2005 CHAPTER 2 Program and Graphical User Interface Design.
Key Applications Module Lesson 21 — Access Essentials
Sports Website Creation. In this project you will design and produce your own website.
Chapter 2 – Introduction to the Visual Studio .NET IDE
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
Topics Introduction Scene Graphs
Layout How multiple components are composed to build interfaces.
Page Designer Storyboard J. A. Fitzpatrick December 2004.
Swinging in Your Java Playground. Background Swing is a part of the Java Foundation Classes (JFC). The JFC is made up of features intended to give a programmer.
Swing - 2 Session 13. Swing - 2 / 2 of 38 Objectives (1) Discuss trees and tables Discuss progress bars Discuss MVC architecture Describe menus.
Microsoft Visual Basic 2010 CHAPTER TWO Program and Graphical User Interface Design.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
User Interface Design Patterns Part II Presented by: Mohammed CS2310 April 15, 2008.
Positioning Objects with CSS and Tables
 2002 Prentice Hall. All rights reserved. 1 Introduction to the Visual Studio.NET IDE Outline Introduction Visual Studio.NET Integrated Development Environment.
Abstract Widgets Dealing with more complex models.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
XP New Perspectives on Microsoft Office FrontPage 2003 Tutorial 5 1 Microsoft Office FrontPage 2003 Tutorial 5 – Creating Tables and Frames.
Pasewark & Pasewark 1 Windows Vista Lesson 1 Windows Vista Basics Microsoft Office 2007: Introductory.
Chapter 2 – Introduction to Windows Operating System II Manipulating Windows GUI 1CMPF112 Computing Skills for Engineers.
Dive Into® Visual Basic 2010 Express
Working with Links and Navigation
Creating a Presentation
Java FX: Scene Builder.
Working in the Forms Developer Environment
Building a User Interface with Forms
Chapter 2 – Introduction to the Visual Studio .NET IDE
An Introduction to Computers and Visual Basic
Program and Graphical User Interface Design
An Introduction to Computers and Visual Basic
Microsoft Excel 101.
Chap 7. Building Java Graphical User Interfaces
Office 2010 and Windows 7: Essential Concepts and Skills
Chapter 13: Advanced GUIs and Graphics
Access Lesson 1 Understanding Access Fundamentals
Graphical User Interfaces -- Introduction
Fundamentals of Python: From First Programs Through Data Structures
Program and Graphical User Interface Design
IVend Retail 6.5 Dashboard Designer.
Lesson 9 Windows Management
The structure of Interactive Software
Design Patterns A Case Study: Designing a Document Editor
Chapter 2 – Introduction to the Visual Studio .NET IDE
Chapter 2: System Structures
Microsoft Windows 7 Basics
Exploring the Basics of Windows XP
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
Lesson 6: Working with Layout and Graphics
Lesson 6: Working with Layout and Graphics
Introduction to PowerPoint
An Introduction to Computers and Visual Basic
Using Templates and Library Items
Fundamentals of Using Microsoft Windows XP
Project 4 Creating an Image Map.
HIBBs is a program of the Global Health Informatics Partnership Learning the Basics of Microsoft Word 2019 and Microsoft office support TFN
Programming with Microsoft Visual Basic 2008 Fourth Edition
Key Applications Module Lesson 14 — Working with Tables
Advanced GUIs and Graphics
Lab 08 Introduction to Spreadsheets MS Excel
Chapter 4 Enhancing the Graphical User Interface
An Introduction to the Windows Operating System
Presentation transcript:

Dealing with more complex models Abstract Widgets Dealing with more complex models

Abstract Widgets Most widgets limited in terms of the complexity of the model they can handle Need to consider how we might use widgets where the model is external to the widget Abstract widgets handle this arrangement by supported common models Tree widget handles hierarchy Table widget handles tabular structured data

Widgets Windowing System Graphics View Essential Geometry Model Controller Input

Widgets Abstraction of the Model View Controller Arrangement Property Settings Windowing System WIDGET Graphics View Essential Geometry Model Model Change Events Controller Input Abstraction of the Model View Controller Arrangement

Widgets Windowing System WIDGET Graphics View ABSTRACT MODEL INTERFACE Property Settings Windowing System WIDGET Graphics View ABSTRACT MODEL INTERFACE Essential Geometry Model Controller Input

Abstract Widgets Separates the model from the widget through a well know abstract model interface Model is implemented externally needs to respond to the abstract interface This allows widgets to be used to control deeper more complex systems Filestores Databases

Windowing System WIDGET Graphics View ABSTRACT MODEL INTERFACE Property Settings Windowing System WIDGET Graphics View ABSTRACT MODEL INTERFACE Essential Geometry Translator Object Controller Input Model

Translator Object Translates between the abstract model interface and the means of driving existing APIs for the model The translator class accepts the model in its constructor implements all of the widget abstract model methods, passing them on to the appropriate model methods. Translator is not another model It will need to hide complexity of the underlying system but should seek to be “as thin as possible”

Tree Widgets Tree are one of the classic abstract model widgets Provide an interactive interface onto hierarchical structures Browsing through the structure Amending nodes in the structure Model is external to the widget Networks systems File stores Interactive elements separated from the underlying model through an abstracted interface

File store Hierarchy reflects file store Nodes are Each Node has Directories Files Each Node has Label Icon Open Close Box Changed Icon

Favourites Hierarchy reflects user structuring Nodes are Each Node has Folders URLS of each site Each Node has Label Icon Open Close Box

Software Packages Hierarchy reflects software structure Nodes are Package names Files defining classes Each Node has Label Icon Open Close Box

Mail Boxes Hierarchy reflects user structuring Nodes are Each Node has Folders of mailboxes Mailboxes containing email Each Node has Label Icon Open Close Box

Similarities All represent a tree as an indented outline using the same layout. Every node of the tree has a textual name and one or two icons. Containers have two icons, one for open and one for closed. They all use little plus/minus boxes to open/close the container Clicking on the name allows the user to change the name of any of the nodes

Differences Containers have variable numbers of children arranged in varying depths in the tree. Every node has a different name. There are different icons for different applications and for different items within those applications. Some use faint gray lines to indicate which nodes are siblings but some do not. The may use a different type and size of font.

Abstract Widget Structure Similarities handled by the widget Differences managed by either the model or properties Properties focus on appearance Font face, size and style boolean to display sibling lines number of pixels to indent at each level External models handle content differences.

Abstract Widget Interface Interface provides all of the information the widget needs to know about the tree Two main components to the interface The model itself that our widget will manipulate to interact with the structure The second is the notification mechanism for the widget to learn about external model changes.

TreeNode public interface TreeNode { int numberOfChildren(); // how many children nodes are there. Zero for leaf nodes TreeNode getChild(int childIdx); // get one of this node’s children Image getIcon(); // gets the primary icon for this node Image getOpenIcon(); // if this is a container this returns the icon for when it is open String getName() // gets the name of this node void setName(String name); // changes the name of this node }

TreeNode Interface -- Browse the Model Provides all the information to move through hierarchical structure allowing the widget to display it. Can recursive tour through the tree and present it as needed. Does not make the widget aware of changes to the underlying model so other elements of the interface are needed

Notification of Model Change Changes can occur at any point in the tree We can locate any node in the tree with a path each container provides access to its children by an index Sequence of indices that leads from the root of the tree to the desired node. Treewidget implements this to allow model to notify view of changes public class TreeWidget extends Widget { public void nodeChanged (List<int> pathToChangedNode){ . . . } public void nodeToInsert (List<int> insertLocation) { . . . } public void nodeToDelete (List<int> deleteLocation) { . . . } }

Model Change through the view Provide methods that let the widget alter the model public interface TreeRoot { public TreeNode root; public void addListenerWidget(TreeWidget widget); public void removeListenerWidget(TreeWidget widget); public void deleteNode(List<int> deleteLocation); public void moveNode(List<int> fromLocation, List<int> toLocation); public void changeName(List<int> nodeToChange, String newName); }

File browsing The entire file system is obviously too large to copy into the tree widget model. The abstract interface technique provides us the advantage of pre-built widgets on a signification model. Access to file system through an API and to provide tree browser will need three translator classes. a FileRoot class that implements TreeRoot. This class can have a constructor that accepts a path name for the root folder. a TreeFolder class and a TreeFile class to interface to folders and files respectively that implement TreeNode interface A TreeFolder would find out the number of files and folders that it contains and report them as children. Using the file system API the TreeFolder class will create TreeFolder or TreeFile classes for the folders and files that it contains.

Cone Trees

Hyberbolic Trees

Treeviz Maps Exploits size associated with each node to drive layout Need to amend the abstract model with a getSize() method in the treenode interface

Degree of Interest Trees Exploits a degree of interest per node to drvie presentation to users

Microsoft File Table

Eclipse Error Log

Email List

Email List Music Player List

Similarities to be handled by Widget A fixed set of columns each with a title and/or possibly an icon. An arbitrary number of rows that will probably require scrolling. Every cell of the table has a string and/or an icon for its content. If the icon and string occur together the icon is first. Rows can be sorted based on any of the column contents. Rows can be selected and that selection used elsewhere. Selecting a song in will play that song. Selecting a message will display the contents of the message. It is possible to hide or show and resize the width of columns.

Differences to be handled by model and properties The number of columns is fixed but there are varying numbers of columns between applications. Columns have different names, icons and widths. The contents of rows and cells are all different. There are differences in font and background colour.

Table Widget The key is the communication between the widget and the model to retrieve and change model information to be notified of changes to the model. In most cases the table is used primarily for viewing of information rather than editing it. BUT, selected rows can be deleted and frequently cell string contents can be edited and changed. More complex manipulations of the table model are generally handled by other widgets and then notifications forwarded to the widget.

Abstract Model public interface TableModel { } public void addTableListener(TableListener listener); public void removeTableListener(TableListener listener); public int nRows(); // returns the number of rows public TableColumn [] getColumns(); // returns descriptors for all of the columns public String getCellString(int rowIndex, int columnID); public void setCellString(int rowIndex, int columnID,String newCellValue); public Image getCellIcon(int rowIndex, int columnID); public void selectRow(int rowIndex); // notifies the model when a row is selected public void deleteRow(int rowIndex); } public enum ColumnJustify{LEFT, CENTER, RIGHT} public interface TableColumn public int columnID(); public ColumnJustify justification(); public String getColumnName(); public void setColumnName(String newName); public Image getColumnIcon(); public int getColumnWidth(); public void setColumnWidth(int widthInPixels); public boolean isReadOnly();

Table Listener Interface public interface TableListener { public void cellToChange(int rowIndex, int columnID, String newCellValue); public void rowChanged(int rowIndex); public void rowsToDelete(int firstRowIndex, int nRowsToDelete); public void rowsInserted(int firstRowIndex, int nRowsInserted); public void columnDescChanged(int columnID); publis void tableChanged(); } Provides Notification at Different Levels of Scope (Table, Row, Cell, Labels)

Table Properties Our Table widget also needs properties. header font, cell font, background colour, Also alternating line background colour to highlight rows with slightly different colours. May also need column properties balance between the properties for columns and things placed in the model Alignment could be a property but is placed in model as columns are already defined Deciding between properties and model elements based on how often you see changes occurring and by whom

Drawing Widget More complex model than regularly structured tree and table Want to explore how we may have a model to support some form of shared drawing interface Placement of entities within some form of canvas will be vital But what else

Similarities The model is fundamentally a list of objects to be drawn on a surface. There is a menu of objects that can be selected and placed in the drawing area. Creating new objects uses the same event sequence and interactive behaviour. click to place an item, down-drag-up to create two control points, placement of multiple control points. Selection works by clicking on objects, shift-clicking to select multiple objects and rubberband rectangles to select a group of objects. Objects can be dragged around the draw area. Object are manipulated by dragging control points and those control points are displayed in a similar way. Deleting objects is the same.

Obvious Differences Set of objects to be created is very different as is their appearance on the menu How each object is drawn and how it relates to its control points is differen The Geometry for selection objects differs

Drawing Model Drawing model is simple BUT the model is strongly linked with the presentation. Objects in the drawing model differ in the way that they draw themselves and in the way that they handle their geometry. This fuzzy relationship between the model and the presentation The model for a drawing is simply a sequence of drawing objects that can be pained in order and a list of possible classes for drawing objects.

public interface DrawingModel { public void addDrawingListener( DrawingListener listener); public void removeDrawingListener(DrawingListener listener); public int nDrawingObjects(); public DrawingObject getDrawingObject(int index); public void deleteDrawingObject(int index); public void addDrawingObject(DrawingObject newObject); public int nDrawingClasses(); public DrawingClass getDrawingClass(int index); } pubic interface DrawingObject public void redraw(Graphics g); public boolean isSelected(Point mousePoint); public Rectangle getBounds(); public int nControlPoints(); public Point getControlPoint(int index); public void setControlPoint(int index, Point newPoint); public void addControlPoint(Point newPoint); public void move(int dX, int dY); public enum InputSyntax{SINGLEPOINT, DRAGPOINT, MULTIPOINT} public interface DrawingClass public Image getIcon(); public String getName(); public DrawingObject createNew(); public InputSyntax getSyntax();

The DrawingModel itself consists of only three parts: the registration of listeners the list of drawing objects with means for deleting and adding them a list of object classes that can be created. A DrawingObject needs a means for drawing itself to a Graphics object (redraw), support for selection(isSelected and getBounds) and mechanisms for manipulating control points. The DrawingClass contains the necessary information to create the menu and to create new objects.

Widget tasks 6 basic tasks that a widget must perform in either object creation mode (when one of the object classes is selected in the menu) or selection mode (when the pointer is selected in the menu) Redraw the drawing from the model. Create new objects on the drawing surface Select objects Drag objects around Drag control points Delete objects

Redrawing public class DrawingWidget { private DrawingModel myModel; private int[] selectedObjects; . . . . public void redraw(Graphics g) { for (int i=0;i<myModel.nDrawingObjects();i++) { myModel.getDrawingObject(i).redraw(g); } for (int i=0;i<selectedObjects.length; i++) { DrawingObject so=myModel.getDrawingObject(i); for (int cp=0;cp<so.nControlPoints();cp++) { Point p=so.getControlPoint(cp); draw control point at point p }

Creating new Drawing Objects nDrawingClasses() and getDrawingClass() methods give us the information that we need to build the menu of objects that we are offering to the user. For each DrawingClass the getIcon() and getName() methods give us the information that we need to fill the menu. Enumaration InputSyntax informs how the item is to be drawn Single Click Two Point Drag Multi-point input

Single Click Strategy DrawingObject newObj; on mouse down DrawingClass dc = object class selected in the menu; newObj = dc.createNew(); newObj.setControlPoint(0, current mouse position ); myModel.addDrawingObject(do); on mouse move newObj.setControlPoint(0,current mouse position ); on mouse up newObj.setContolPoint(0,current mouse position );

Two Point Drag DrawingObject newObj; on mouse down on mouse move DrawingClass dc = object class selected in the menu; newObj = dc.createNew(); newObj.setControlPoint(0, current mouse position ); newObj.setControlPoint(1, current mouse position ); myModel.addDrawingObject(do); on mouse move newObj.setControlPoint(1,current mouse position ); on mouse up newObj.setContolPoint(1,current mouse position );

Selecting Objects Most of the work done by geometry calculations is in the drawing object method do.isSelected(selectPoint) public class DrawingWidget { public DrawingModel myModel; public int selectObject(Point selectPoint) { for (int i=myModel.nDrawingObjects()-1;i>=0;i--) DrawingObject do=myModel.getDrawingObject(i); if (do.isSelected(selectPoint) ) return i; } return -1; // no selection . . . .

Rectangle Selection public class DrawingWidget { . . . public IndexList selectObjects(Rectangle select) IndexList result= empty list of object indices; for (int i=0;i<myModel.nDrawingObjects();i++) DrawingObject do=myModel.getDrawingObject(i); if (do.getBounds().isInsideOf(select)) result.add(i); } return result;

Summary Abstract widgets allow GUI to be linked with more complex models Exploit comonalities across different infromation structures Trees Tables Can be used to provide interfaces to more complex structures Drawing widget Next : Examples of the use of JTable and JTree widgets Read through the swing tutorials.