Lab 5: drawing and output User Interface Lab: GUI Lab Sep. 25 th, 2013.

Slides:



Advertisements
Similar presentations
Chapter 18 Building the user interface. This chapter discusses n Javas graphical user interface. n Swing: an enhancement of a library called the Abstract.
Advertisements

View-Based Application Development Lecture 1 1. Flows of Lecture 1 Before Lab Introduction to the Game to be developed in this workshop Comparison between.
2D Graphics Drawing Things. Graphics In your GUI, you might want to draw graphics E.g. draw lines, circles, shapes, draw strings etc The Graphics class.
Graphics Shapes. Setup for using graphics You have to import the graphics library You can use either “import graphics” or “from graphics import *” or.
Lab 9: Code Organization User Interface Lab: GUI Lab October 23 rd, 2013.
Chapter 16 Graphical User Interfaces John Keyser’s Modifications of Slides by Bjarne Stroustrup
Lab 10: Images and Skinning, Sound and Assets User Interface Lab: GUI Lab Oct. 30 th, 2013.
Laboratory Study II October, Java Programming Assignment  Write a program to calculate and output the distance traveled by a car on a tank of.
Gayle J Yaverbaum, PhD Professor of Information Systems Penn State Harrisburg.
Chapter 5 Programming Graphics. Chapter Goals To be able to write applications with simple graphical user interfaces To display graphical shapes such.
Lecture 28: Abstract Classes & Inheritance Announcements & Review Lab 8 Due Thursday Image and color effects with 2D arrays Read: –Chapter 9 Cahoon & Davidson.
CS 106 Introduction to Computer Science I 11 / 26 / 2007 Instructor: Michael Eckmann.
More about classes and objects Classes in Visual Basic.NET.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Chapter 71 Inheritance Chapter 7. 2 Reminders Project 4 was due last night Project 5 released: due Oct 10:30 pm Project 2 regrades due by midnight.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Java Applets What is an Applet? How do you create.
Chapter Day 10. © 2007 Pearson Addison-Wesley. All rights reserved4-2 Agenda Day 10 Questions from last Class?? Problem set 2 posted  10 programs from.
ObjectDraw and Objects Early Chris Nevison Barbara Wells.
© The McGraw-Hill Companies, 2006 Chapter 10 Graphics and event- driven programs.
1 Python Programming: An Introduction to Computer Science Chapter 3 Objects and Graphics.
Java Review Structure of a graphics program. Computer Graphics and User Interfaces Java is Object-Oriented A program uses objects to model the solution.
Chapter Day 9. © 2007 Pearson Addison-Wesley. All rights reserved4-2 Agenda Day 8 Questions from last Class?? Problem set 2 posted  10 programs from.
Programing App Inventor. Variable Declaration App Inventor: Declare Variables using the “Define Variable As” Block – Find the Blocks Editor (top-left),
Graphical User Interfaces A Quick Outlook. Interface Many methods to create and “interface” with the user 2 most common interface methods: – Console –
Chapter 5 - Making Music: An On-Screen Piano
Quiz-Warm Up! Remember 5 minutes only!
Using Jeroo To Teach Object-Oriented Concepts By Christian Digout.
Lab 2: Interface Building User Interface Lab: GUI Lab Sep. 4 th, 2012.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
Introduction to GUI in Java 1. Graphical User Interface Java is equipped with many powerful,easy to use GUI component such as input and output dialog.
Lab 6: event & input intro User Interface Lab: GUI Lab Oct. 2 nd, 2013.
Java GUI’s are event driven, meaning they generate events when the user interacts with the program. Typical events are moving the mouse, clicking a mouse.
Lab 3: Actionscript User Interface Lab: GUI Lab Sep. 11 th, 2012.
Graphic User Interface. Graphic User Interface (GUI) Most of us interact with computers using GUIs. GUIs are visual representations of the actions you.
Programming for Artists ART 315 Dr. J. R. Parker Art/Digital Media Lab Lec 10 Fall 2010.
Inheritance Chapter 10 Programs built from objects/instances of classes An O.O. approach – build on earlier work. Use classes in library and ones you have.
Exploring the Macromedia Flash Workspace – Lesson 2 1 Exploring the Macromedia Flash Workspace Lesson 2.
Lab 7: Tree & Forest. Drawing a Forest Created by Emily Hill & Jerry Alan Fails.
Graphics Concepts CS 2302, Fall /17/20142 Drawing in Android.
Chapter 5 Introduction to Defining Classes
Lab 7: BoxCar Class. Drawing a BoxCar Step 1:Create classes for Circle & Rectangle (done!) Step 2:Create a BoxCarPart class that can draw this part at.
Review_6 AWT, Swing, ActionListener, and Graphics.
Graphical User Interfaces Tonga Institute of Higher Education.
Documenting a function. Documenting a function definition We have a template for information that we need you to put at the top of each function - if.
Video in Macromedia Flash (Optional) – Lesson 121 Video in Macromedia Flash (Optional) Lesson 12.
CISC 110 Day 8 “The Outliers, Part 2” Frames, Classes, Vectors, String Manipulation, File I/O, Downloading Images.
CompSci Reading from Files  import java.io.File;  Declare a file File fileOfCats = new File(”cats.txt”);  Use file – pass it as an argument to.
Object-Oriented Programming: Polymorphism Chapter 10.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
CS 115 Lecture 7 Graphics – coordinate systems, Text, Entry, aliases Taken from notes by Dr. Neil Moore.
Graphics Lab: MyPaint Dan Maselko 1. MyPaint Description  For this assignment you will be implementing a very simple paint program.  You should be able.
Basic Graphics 03/03/16 & 03/07/16 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
CS 115 Lecture 6 Graphics Taken from notes by Dr. Neil Moore.
Prepared by: Dr. Abdallah Mohamed, AOU-KW Unit7: Event-driven programming 1.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
10/20/2005week71 Graphics, mouse and mouse motion events, KeyEvent Agenda Classes in AWT for graphics Example java programs –Graphics –Mouse events –Mouse.
Basic Graphics Chapter 5 3/19/15 Thursday Section Only
Miscellaneous Topics #6: Polygons GUI Components and Event Handlers
Chapter 14 JavaFX Basics Dr. Clincy - Lecture.
Inheritance, Polymorphism, and Interfaces
Inheritance Chapter 7 Chapter 7.
4.14 GUI and Graphics Case Study: Creating Simple Drawings (Cont.)
AWT Components and Containers
Interfaces.
Announcements & Review
Lecture 9 GUI and Event Driven CSE /16/2019.
Topics Graphical User Interfaces Using the tkinter Module
Constructors, GUI’s(Using Swing) and ActionListner
JavaScript – Let’s Draw!
Presentation transcript:

Lab 5: drawing and output User Interface Lab: GUI Lab Sep. 25 th, 2013

Lab 5 goals Review of some Programming Concepts – Ascii code Creating New UIComponents – Triangle, circle, smiley face External Classes and Interfaces

Create a new flex project File -> New -> Flex project Name: Lab5ICP Click “Finish” Enter source view

Interface An abstract type that used to specify an interface that classes must implement. Only contains method signature (in Flex). – function addOne(x:int):int; – What the function actually does is written in the class that implements the interface. A typical use case: communication – “Here’s the requirement of this class…”

Create an actionscript interface File -> New -> Actionscript Interface Name it “IGUI_Shape” Suppose we want all our shape classes to have two functions: draw():void and getName():String – Declare them in the interface function draw():void; function getName():String;

Create an actionscript class “GUI_Rectangle” extends UIComponent implements IGUI_Shape Constructor: Control+Space to auto-import super(); addEventListener(FlexEvent.CREATION_COMPLETE, function(event:FlexEvent):void { draw(); });

Create an actionscript class “GUI_Rectangle” Declare a public function draw():void (width & height inherited) Declare a public function getName():String that returns “Rectangle” graphics.beginFill(0x000000); graphics.drawRect(0, 0, width, height); graphics.endFill();

Add a GUI_Rectangle to the mxml First, declare a VGroup as the parent object – Because the class is in the default package Set width and height both to 100

graphics class methods beginFill(color, opacity): start drawing shape moveTo(x,y): move drawing position lineTo(x,y): move drawing position & draw endFill(): fills shape drawn with color

Drawing coordinates

Create an actionscript class “GUI_Triangle” extends UIComponent implements IGUI_Shape Constructor: same as GUI_Rectangle Declare a public function getName():String that returns “Triangle” Declare a public function draw():void that draws a red triangle (0, height), (width, height), (width/2, 0)

Add a GUI_Triangle to the mxml Put it inside

Create a GUI_Smiley class extends UIComponent implements IGUI_Shape Constructor: Same getName: return “Smiley”’ Stroke size 2: graphics.lineStyle(2); Yellow: 0xFFFF00 Face: center (x, y), radius = 50 Eyes: center (x-r/2, y-r/2)&(x+r/2,y-r/2), r=r/10 Smile: Curve graphics.moveTo(x-r/2,y+r/2); graphics.curveTo(x, y+r,x+r/2, y+r/2);

Add a GUI_Smiley to the mxml Same way (w&h: 100x100) What if most of the time, I want my GUI_Smiley to have a label below it showing its name? – I’ll drag a label every time when I add a smiley face. – I’ll create a MXML component that contains a smiley face and a label and add that component to the main mxml.

Create a MXML component “Smiley_and_Label” File -> New -> MXML Component Based on spark.components.VGroup – The root object will be a Vgroup Put a label and a GUI_Smiley in the MXML Add the component to your main mxml file (100x120).

FlexEvent.CREATION_COMPLETE Fires when all objects in the application finished layout. Remember to assign a width and height to the object in MXML files, so it can be drawn in the right place.

Next time: Events & input