week 4 b mvc example
play

Week 4: b. MVC example (adapted from Swing version written by - PowerPoint PPT Presentation

Week 4: b. MVC example (adapted from Swing version written by David Bonnet, Cdric Fleury, Arnaud Prouzeau Model-View-Controller (MVC) Design Pattern TA Exercise 1. percentage pie chart 2. color chooser (MVC together) MVC Based on the


  1. Week 4: 
 b. MVC example (adapted from Swing version written by David Bonnet, Cédric Fleury, Arnaud Prouzeau

  2. Model-View-Controller (MVC) Design Pattern TA Exercise 1. percentage pie chart 2. color chooser (MVC together)

  3. MVC Based on the divide and conquer principle: Model Holds the abstract data (e.g. a number) and methods to handle it. View Defines the visual representation of a data (e.g. a slider to represent a number). Controller Manages the user input and sets the application behavior 
 (e.g. adds a listener to the slider that updates the number). � 3

  4. MVC Controller View Model � 4

  5. Example Controller Temperature 
 TemperatureController - Listeners on TextFields Converter - Listener on closeButton - Listener on resetButton View Model TemperatureModel TemperatureView - int celsius - int fahrenheit - TextField celsiusValue - TextField fahrenheitValue • setCelsiusValue(int value) - Button closeButton • setFahrenheitValue(int value) - Button resetButton • getCelsiusValue() • getFahrenheitValue() � 5

  6. Example Controller TemperatureController Temperature 
 - TemperatureModel model Converter - View[] views • setCelsiusValue(int value, Object caller) • setFahrenheitValue(int value, Object caller) • bind(View view) modify notify request update View Model TemperatureModel - int celsius input - int fahrenheit • setCelsiusValue(int value) • setFahrenheitValue(int value) User • getCelsiusValue() • getFahrenheitValue() update � 6

  7. MVC Controller References 
 between 
 View Model components 1 1 1+ View Model Model Controller 1 � 7

  8. In-class exercise

  9. In-class exercise Go to our website: http://www.lri.fr/~anab/teaching/HCID-ProgIS/ we start will start with TA on Colour Chooser � 9

  10. Example Controllers Color 
 Chooser Views Models � 10

  11. Example Controllers ColorController - ColorModel model ComponentController - CM red Color 
 - CM model - CM green - View[] views Chooser - CM blue • setValue(int Value, Object caller) • setRed(int value, Object caller) • addView(View view) • setGreen(int value, Object caller) • removeView(View view) • setBlue(int value, Object caller) modify • bind(View view) • bind(View view) notify request updates Views Models ColorModel - CM red ComponentModel (CM) - CM green 
 input - int value - CM blue - ColorModel parent • CM getRed() • setValue(int value) • CM getGreen() • int getValue() User • CM getBlue() updates • String toHex([int minLength]) • String toHex() � 11

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