Software Design: Figures

Similar documents
5.17 GUI. Xiaoyi Jiang Informatik I Grundlagen der Programmierung

The Abstract Windowing Toolkit. Java Foundation Classes. Swing. In April 1997, JavaSoft announced the Java Foundation Classes (JFC).

CS 335 Lecture 06 Java Programming GUI and Swing

WPF Shapes. WPF Shapes, Canvas, Dialogs 1

Creating and Using Links and Bookmarks in PDF Documents

Steps to Create a Database

Word basics. Before you begin. What you'll learn. Requirements. Estimated time to complete:

Creating Fill-able Forms using Acrobat 8.0: Part 1

Module 1. 4 Login-Send Message to Teacher

GUIs with Swing. Principles of Software Construction: Objects, Design, and Concurrency. Jonathan Aldrich and Charlie Garrod Fall 2012

GUI Components: Part 2

Creating PDF Forms in Adobe Acrobat

Mouse Event Handling (cont.)

Joomla Article Advanced Topics: Table Layouts

Graphical User Interfaces

ImageNow Document Management Created on Friday, October 01, 2010

Click on various options: Publications by Wizard Publications by Design Blank Publication

Understand the Sketcher workbench of CATIA V5.

2. How to Use SMART Board as a Projector and Whiteboard

Acrobat PDF Forms - Part 2

Chapter 1. Creating Sketches in. the Sketch Mode-I. Evaluation chapter. Logon to for more details. Learning Objectives

Page Numbering for a Thesis or Dissertation

Using Acrobat Comment and Markup tools

Tutorials. If you have any questions, comments, or suggestions about these lessons, don't hesitate to contact us at

Spreadsheet - Introduction

JustClust User Manual

Updox, LLC

JIDE Action Framework Developer Guide

Adding a File Attachment to a CFS Requisition

Recipes4Success. Animate a Rocket Ship. Frames 6 - Drawing Tools

How to Develop Accessible Linux Applications

Creating Acrobat Forms Acrobat 9 Professional

Crop and Frame Your Photos

GFI FAXmaker 14 for Exchange/Lotus/SMTP. Fax-Client Manual. By GFI Software Ltd

Managing Payment Information

Acrobat X Pro Accessible Forms and Interactive Documents

Adobe Acrobat: Creating Interactive Forms

Using Clicker 5. Hide/View Explorer. Go to the Home Grid. Create Grids. Folders, Grids, and Files. Navigation Tools

Create a Simple Website. Intel Easy Steps Intel Corporation All rights reserved.

Plug-In How-To Guide

understand how image maps can enhance a design and make a site more interactive know how to create an image map easily with Dreamweaver

Table of Contents TASK 1: DATA ANALYSIS TOOLPAK... 2 TASK 2: HISTOGRAMS... 5 TASK 3: ENTER MIDPOINT FORMULAS... 11

Implementação. Interfaces Pessoa Máquina 2010/ Salvador Abreu baseado em material Alan Dix. Thursday, June 2, 2011

Business Bill Payment User Guide

Flash MX Image Animation

INTRODUCTION TO COMPUTER PROGRAMMING. Richard Pierse. Class 7: Object-Oriented Programming. Introduction

Working With Animation: Introduction to Flash

Introduction to Microsoft Word 2008

SMART Boards. If the board is connected to a different computer - Orientation is needed whenever you connect it to a new or different computer.

Karsten Lentzsch JGoodies SWING WITH STYLE

Canterbury Maps Quick Start - Drawing and Printing Tools

Solutions from SAP. SAP Business One 2005 SP01. User Interface. Standards and Guidelines. January 2006

Create a Poster Using Publisher

Welcome! Nice to see you.

Intellect Platform - Tables and Templates Basic Document Management System - A101

Microsoft Access 2010 handout

DIA Creating Charts and Diagrams

Florence School District #1

Introduction to Microsoft Word 2003

Hands-On Practice. Using Notebook Software in the Office

Managing Food Service Payment Information

MyOra 3.0. User Guide. SQL Tool for Oracle. Jayam Systems, LLC

Using an Access Database

ADMINISTRATORS GUIDE EPISUITE 6

WebSphere Business Monitor V6.2 KPI history and prediction lab

SMART Board Interactive Whiteboard Basics Tip Sheet for ABP Faculty

Adobe InDesign Creative Cloud

Getting Started With DraftSight A Guide For AEC Users

SketchUp Instructions

emarketing Manual- Creating a New

Software Application & Operating Systems Checklist

WEBTrader. User Guide

Creating Personal Web Sites Using SharePoint Designer 2007

Lab 7 Keyboard Event Handling Mouse Event Handling

How Scala Improved Our Java

Petrel TIPS&TRICKS from SCM

Basic Microsoft Excel 2007

Creating a Logo in CorelDRAW

Adobe Acrobat 9 Pro Accessibility Guide: Creating Accessible Forms

Tutorial Reference Manual. Java WireFusion 4.1

Sharing Files and Whiteboards

Using SSH Secure File Transfer to Upload Files to Banner

With a wide variety of drag and drop widgets, adding and updating information on your website will be a snap!

Drawing a histogram using Excel

Executive Dashboard. User Guide

STATGRAPHICS Online. Statistical Analysis and Data Visualization System. Revised 6/21/2012. Copyright 2012 by StatPoint Technologies, Inc.

Chapter 15 Using Forms in Writer

Tutorial: BlackBerry Application Development. Sybase Unwired Platform 2.0

Introduction to Microsoft Access 2003

Virtual Communities Operations Manual

Learning ReportBuilder

InDesign for Beginners Step-By-Step Guide

DESIGN A WEB SITE USING PUBLISHER Before you begin, plan your Web site

QUICK REFERENCE: ADOBE ILLUSTRATOR CS2 AND CS3 SECTION 1: CS3 TOOL BOX: PAGE 2 SECTION 2: CS2 TOOL BOX: PAGE 11

Adobe Dreamweaver CC 14 Tutorial

Transcription:

Software Design: Figures

Today ColorPicker Layout Manager Observer Pattern Radio Buttons Prelimiary Discussion Exercise 5

ColorPicker They don't teach you the facts of death, Your mum and dad. They give you pets. Terry Pratchett (at age 13)

ColorPicker : Layout JPanel(new GridLayout(1, 2, 5, 5)) BorderLayout.NORTH rows=1 cols=2 hgap=5 vgap=5 JPanel(new FlowLayout()) BorderLayout.CENTER

ColorPicker : Layout JPanel(new GridLayout(3, 1, 3, 3)) JPanel(new GridLayout(3, 2)) JPanel(new GridLayout(2, 1, 5, 5)) JPanel(new GridLayout(0, 1))

ColorPicker UML : ColorModel public class ColorModel { private Color color; private List<ColorListener> listeners = new LinkedList<ColorListener>(); public void addcolorlistener(colorlistener l) { listeners.add(l); public void setcolor(color color) { if (!color.equals(this.color)) { this.color = color; for (ColorListener l : listeners){ l.colorvaluechanged(color); Avoid cycles! infinite recursion

has ColorPicker UML Example: Scrollbar <<interface>> Java.util.EventListener <<interface>> ColorListener CScrollBar <<interface>> AdjustmentListener JScrollBar 0..n 0..n updates contained in 1 1 ColorModel 1 1 ColorFrame JComponent etc.

ColorPicker UML : CScrollBar public interface ColorListener { void colorvaluechanged (Color c); <<interface>> ColorListener CScrollBar class CScrollBar extends JScrollBar implements AdjustmentListener, ColorListener { <<interface>> AdjustmentListener CScrollBar(ColorModel model, int type, int orientation, int val) { super(orientation, val, 0, 0, 255); this.model = model; this.type = type; addadjustmentlistener(this); model.addcolorlistener(this); public void adjustmentvaluechanged(adjustmentevent e) { // update model -> model.setcolor(c); public void colorvaluechanged(color color) { // set scrollbar value, e.g., setvalue(color.getred());

RadioButtons in Java/Swing (1) Definition: Radio buttons are groups of buttons in which, by convention, only one button at a time can be selected. JRadioButton yellow = new JRadioButton("yellow"); JRadioButton black = new JRadioButton("black"); JRadioButton white = new JRadioButton("white"); ButtonGroup bm = new ButtonGroup(); bm.add(yellow); bm.add(black); bm.add(white); How can we unselect a button?

RadioButtons in Java/Swing (2) ButtonGroup JavaDoc: "There is no way to turn a button programmatically to "off", in order to clear the button group. " Implementation with setselected without ButtonGroup

AWT vs. SWING Abstract Windowing Toolkit (ab java 1.0) Uses components (Button,...) of the operating system Swing (ab java 1.2) Only the windows are from the operating system The content of the window is drawn by java All component classes start with "J" (JButton,...) Mixing AWT and SWING Swing 'recycles' some classes from AWT (Graphics, LayoutManager, etc) Do not mix components Heavyweight / Leightweight

Exercise 5 Overview 1. Implementation of DrawModel 2. Implementation of some figures Line Oval... 3. Implementation of the corresponding tools LineTool, OvalTool,... 4. Registration of the Tools in class StdContext doregisterdrawtools () (Line 151) 5. Extraction of the commonalities from the figure and tool classes into abstract base classes.. ex. 4 ex. 5

Exercise 5: Classes to create <<interface>> jdraw.framework.drawmodel <<interface>> FigureListener DrawView DrawModelListener * * 1 1 DrawModel 0..1 * <<interface>> Figure your job New Change prepared in ex. 4 Line Rect Oval creates creates LineTool RectTool OvalTool StdContext registrates «interface» DrawTool

1. Tool selection Drawing of figures deactivate() method of previous tool is called activate() method of next tool is called Call to showstatustext ( Line Tool selected ) of DrawEditor sets Statusbar 2. Mouse-Down Click (inside DrawTool::mouseDown()) Creates new figure with current mouse position as origin (widht & height are zero). Adds new figure to draw model Calls showstatustext ( Adding Line ) in DrawEditor to set status bar 3. Dragging the mouse (inside DrawTool::mouseDrag()) Calls setbounds(mousedown-coordinates, current mouse coordinates) Calls showstatustext (currentfigure.tostring()) displays current figure properties in status bar Careful: overwrite tostring() 4. Release of mouse button (inside DrawTool::mouseUp()) Delete figure if mousedown == mouseup coordinates Call showstatustext ( Line Tool selected );

Implementation of own figure class 1. Figure must implement the Figure interface 2. Definition of figures Line: Start and end points Oval/Ellipse: Defined over corner points of the bounding box Question: What have those two figures in common? They are both describable by their bounding box 3. Figures draw themselfes in the draw(graphics g) method 4. Figure is an Observable Implements notification: E.g. in move(x,y) notifies listeners (your DrawModel) via FigureListener method 5. Figure::clone() and Figure::getHandles() may return null in this exercise (will be part of a later exercise).

Implementation of figure tools Tools create figures and are visible in the toolbar with an icon. Tools implement the interface DrawTool see RectTool. Tools know the controller (StdContext) are activated/deactivated set mouse cursor and status bar process mouse events have a name have an icon Icons for ellipse, line, and rectangle are in res/images see RectTool for an example

Registration of the tool Add them near line 151 in StdContext @Override protected void doregisterdrawtools() { DrawTool rectangletool = new RectTool(this); addtool(rectangletool); // add more tools here new tools then appear in the tool bar

Tips Reuse existing AWT classes such as java.awt.geom.line2d and java.awt.geom.ellipse2d. Think about how you can extract common behaviour into common base classes to avoid code duplication