Homework 2. 1) Rewrite your thermometer application from hw1 so that it incorporates the following changes:

Similar documents
CS 315 Software Design Homework 1 First Sip of Java Due: Sept. 10, 11:30 PM

Lab 5 Classy Chat. XMPP Client Implementation --- Part 2 Due Oct. 19 at 11PM

Programming Project 1

Intermediate Microsoft Word 2010

Programming Assignment 4 ( 100 Points )

Spring CS Homework 3 p. 1. CS Homework 3

DC2 File Format. 1. Header line 2. Entity line 3. Point line 4. String line

This assignment should give you practice with some aspects of working with graphics and windows in Java.

Adobe Flash CS3 Reference Flash CS3 Application Window

CISC 1600, Lab 3.1: Processing

CISC 1600, Lab 2.1: Processing

Creating Forms. Starting the Page. another way of applying a template to a page.

Basic Microsoft PowerPoint. Your First Slides. Adapted from Taskstream Word Tutorial (2003) < >

CS Problem Solving and Object-Oriented Programming

How to...create a Video VBOX Gauge in Inkscape. So you want to create your own gauge? How about a transparent background for those text elements?

Modify Panel. Flatten Tab

CS 201 Advanced Object-Oriented Programming Lab 1 - Improving Your Image Due: Feb. 3/4, 11:30 PM

This project covers the following design concepts:

Lesson 6 Adding Graphics

FrontPage 2000 Tutorial -- Advanced

Introduction to Microsoft Excel

Poster-making 101 for 1 PowerPoint slide

TWO-DIMENSIONAL FIGURES

CS 2110 Fall Instructions. 1 Installing the code. Homework 4 Paint Program. 0.1 Grading, Partners, Academic Integrity, Help

Word 2007: Flowcharts Learning guide

To gain experience using GUI components and listeners.

Week 5 Creating a Calendar. About Tables. Making a Calendar From a Table Template. Week 5 Word 2010

Part 1: Basics. Page Sorter:

ASIC-200 Version 5.0. integrated industrial control software. HMI Guide

CS7026 CSS3. CSS3 Graphics Effects

ADOBE DREAMWEAVER CS4 BASICS

CS 463 Project 1 Imperative/OOP Fractals

Excel 2013 Intermediate

MS WORD INSERTING PICTURES AND SHAPES

Introduction to LabVIEW

Lesson 3 Images and WordArt Basics

Excel Rest of Us! AQuick Reference. for the. Find the facts you need fast. FREE daily etips at dummies.com

CS143 Introduction to Computer Vision Homework assignment 1.

Lab 5 TOC to Me. IM Client Implementation --- Part 2

Document Editor Basics

Graphing Interface Overview

Paint Tutorial (Project #14a)

A Step-by-step guide to creating a Professional PowerPoint Presentation

Command-Line Applications. GUI Libraries GUI-related classes are defined primarily in the java.awt and the javax.swing packages.

Making the Gradient. Create a Linear Gradient Swatch. Follow these instructions to complete the Making the Gradient assignment:

Motic Images Plus 3.0 ML Software. Windows OS User Manual

Let s Make a Front Panel using FrontCAD

National Weather Map

Java How to Program, 9/e. Copyright by Pearson Education, Inc. All Rights Reserved.

Creating a Title Block & Border Using Chief Architect. Architectural Design & Residential Construction Penncrest High School

KEY TERMS chart chart body Chart Wizard client object legend PDF XPS

Office Excel. Charts

Creating a Website in Schoolwires

Drawing Tools. Drawing a Rectangle

-Using Excel- *The columns are marked by letters, the rows by numbers. For example, A1 designates row A, column 1.

P2: Collaborations. CSE 335, Spring 2009

1.00/1.001 Introduction to Computers and Engineering Problem Solving Fall 2002 Problem Set 3 Due: Day 11. Problem 1. Finding the Median (15%)

Excel Basics Fall 2016

Paint/Draw Tools. Foreground color. Free-form select. Select. Eraser/Color Eraser. Fill Color. Color Picker. Magnify. Pencil. Brush.

Contents. Foreword. Examples of GeoGebra Applet Construction 1 A Straight Line Graph... 1 A Quadratic Graph... 6 The Scalar Product...

CS Homework 10 p. 1. CS Homework 10

Using Charts in a Presentation 6

1. Complete these exercises to practice creating user functions in small sketches.

EDITOR GUIDE. Button Functions:...2 Inserting Text...4 Inserting Pictures...4 Inserting Tables...8 Inserting Styles...9

Creating a Newsletter

Corel Draw 11. What is Vector Graphics?

TSM Report Designer. Even Microsoft Excel s Data Import add-in can be used to extract TSM information into an Excel spread sheet for reporting.

Chapter 7 Applets. Answers

Using PowerPoint XP. What can I do with PowerPoint? A Brief Introduction. Create a lesson with handouts. You can even use it to create

Beginning Paint 3D A Step by Step Tutorial. By Len Nasman

CS Programming Exercise:

Information Technology and Media Services. Office Excel. Charts

How to create shapes. Drawing basic shapes. Adobe Photoshop Elements 8 guide

Starting Out with Java: From Control Structures Through Objects Sixth Edition

The Figure module. Use Figure to manipulate, edit and plot figure and phase diagrams already calculated by FactSage.

Introduction to Kaltura

How to lay out a web page with CSS

GCSE CCEA GCSE EXCEL 2010 USER GUIDE. Business and Communication Systems

Creating a Brochure. The right side of your Publisher screen will now change to Brochures.

Creating a Basic Chart in Excel 2007

CS 101 Computer Science I Fall Instructor Muller. stddraw API. (DRAFT of 1/15/2013)

CSE 142 Su 02 Homework 4

OpenPilot Gauge Version Technical Documentation. Gauge Widget Plugin API Details

Laboratory IV LCD Framebuffer

Introduction to Plot.ly: Customizing a Stacked Bar Chart

Clip Art and Graphics. Inserting Clip Art. Inserting Other Graphics. Creating Your Own Shapes. Formatting the Shape

Using Microsoft Excel

Graphic Design & Digital Photography. Photoshop Basics: Working With Selection.

CS 201 Advanced Object-Oriented Programming Lab 10 - Recursion Due: April 21/22, 11:30 PM

3. Prepare all your graphs, illustrations and text by cutting them to size. For straight lines use a guillotine.

File Cabinet Manager

Adobe Dreamweaver CS5 Tutorial

More Skills 11 Format and Position Report Controls

Introduction to Recursion

Web Manager 2.0 User s Manual Table of Contents

Section 2-2 Frequency Distributions. Copyright 2010, 2007, 2004 Pearson Education, Inc

Unit 21 - Creating a Navigation Bar in Macromedia Fireworks

Introducing Gupta Report Builder

Chapter 10 Working with Graphs and Charts

Figure 1: NC > 2 Axis menu > Options

Transcription:

Homework 2 I have created two sample classes in /home/bvz/gui/hw/hw2 called templateapplication.java and templateview.java that create a basic application and a basic view respectively. The constructor for the templateapplication class shows you how to create model and view classes and tie them together. You can modify these classes to fit your needs for the following problems. I have not over- specified the problems by telling you what the exact sizes of all the objects and windows are. Unless I specify precise sizes for windows or objects, use your best judgment. 1) Rewrite your thermometer application from hw1 so that it incorporates the following changes: a) TemperatureApplication should now take only three arguments, the minimum temperature, the maximum temperature, and the starting temperature. The label should be omitted. b) the model uses the observer pattern described in class and the model supports the following methods: i) void setvalue(int degrees) ii) int getminvalue() iii) int getmaxvalue() iv) int getvalue() c) use an Area object to create the filled bulb and stem portion of the thermometer in the original thermometer view. d) add the following views: 1) A temperature gauge with a chorded half oval and an arrow line that goes from the minimum value (right side of the gauge) to the maximum value (left side of the gauge). It should resemble the gauge shown below. Note that the arrow is filled. Select appropriate values for the width and length of the arrow and use whatever color, line style, and width you prefer. It s okay to use a semi- circle. Should you decide to use an oval, it s easiest to make the angle of the arrowline be proportional to the ratio of the current value to the temperature range.

2) (CS567 students only; CS494 students can get 10 points of extra credit by doing this part of the problem). A filled pie arc whose arc is equal to the percentage of the current value as a function of the maximum value. For example, if the minimum temperature is 32 and the maximum temperature is 212, then the arc below represents a temperature of roughly 57 degrees, because 57 degrees is roughly 1/8 of the way between 32 and 212, and a 45 degree arc is roughly 1/8 of the way between 0 and 360. Fill the arc with the color blue. e) In /home/bvz/gui/hw/hw2 you will find a class named TemperatureController. This class creates a slider that you can use to control the model (i.e., it will allow you to set the model to a certain temperature). Your main method in TemperatureApplication should create an instance of TemperatureController after creating instances of the model and the views. The constructor for TemperatureController takes a single argument, which is a pointer to the model object. You will need to add the TemperatureController to your main application window. When you manipulate the TemperatureController slider, the slider updates the model. Your model should in turn notify the views, which should change in response to changes in the temperature. I have used a rough heuristic to calculate the correct size for the slider, based on the minimum and maximum values of your temperatures. You may need to resize the slider s window if it is to small to accommodate all the labels on the slider. f) You should place your views in the same window, using the following layout: a. Thermometer: BorderLayout.NORTH b. Gauge: BorderLayout.WEST c. Pie: BorderLayout.EAST (if it s in your program) d. TemperatureController: BorderLayout.SOUTH

If you have questions about how your program should look or run, you can try my executable, /home/bvz/gui/hw/hw2/temperature.jar. It can be run as follows: java jar temperature.jar mintemp maxtemp starttemp true/false where mintemp and maxtemp are the minimum and maximum temperatures, starttemp is the starting temperature. A value of true for the fourth command line argument indicates a pie view should be created and a value of false indicates that a pie view should not be created. Your application will not have the fourth argument, because your application with either create a pie view, if you are taking CS567, or not create a pie view, if you are taking CS494. My jar file allows you to test either case. A sample invocation might be: java jar temperature.jar - 50 150 75 true 2) Write a class named DisplayImage that displays an image and centers a text caption horizontally beneath the image that describes the image. Your program should take two command line arguments, the name of the image file and a string for the caption. You should make the window be wide enough to accommodate the image and just tall enough to accommodate the image and the caption. There should be a little vertical padding, use your judgment, between the caption and the image and between the caption and the bottom of the window. You should make sure that the width of the caption is less than the width of the image. A sample invocation for your program might be: java DisplayImage smokeysonavc.jpg Great Smoky Mountains, NC I have an example executable in image.jar in the hw2 directory that you can experiment with, along with a sample.jpg named smokeysonavc.jpg. For example: java jar image.jar smokeysonavc.jpg Great Smoky Mountains, NC When you are finished, you should also create a jar file named image.jar that contains your DisplayImage source and class files. 3) In this problem you are going to display a set of text strings, find the character at a given mouse coordinate and place a cursor before that character. Your program should meet the following specifications:

a) It should be placed in a package named textselection and the file containing main should be named selecttext.java. You should have additional files for the model and the view/controller. b) It should take a point size, an (x,y) point, and a series of strings as command line arguments. You can create a multiple word string by putting quotes around it. For example: java textselection.selecttext 20 30 50 "Vander Zanden" "Hooty And The Blowfish" "Boo Hoo" c) Your application will display each string on a separate line, in a SERIF font, putting 10 pixels between each line. d) The window that displays the text strings should be just large enough to accommodate all the text strings with a 10 pixel border of whitespace around the entire window. e) Once the text strings are drawn, your code should determine which one of the strings contains the (x,y) point, and then draw a line between that character and the previous character. f) If the (x,y) coordinate is within five pixels of the rightmost character in any line, then the cursor line should be drawn after the last character in the line. g) If the (x,y) coordinate is between lines, above any of the lines, below any of the lines, to the left of any of the lines, or more than 5 pixels to the right of any of the lines, then no line should be drawn. Hint: The Drawing Basics lecture notes contain a pseudo- code algorithm for determining where a cursor should be placed within multiple lines of text. Problem restriction: You may not use the TextLayout class for this problem. If you have questions about how your program should look or run, you can try my executable, /home/bvz/gui/hw/hw2/textselection.jar. What To Submit For each of the three problems, jar up your source and class files into the named jar file shown below and include a manifest.txt file so that we can execute your jar file: 1) temperature.jar 2) image.jar 3) textselection.jar

Submit your jar files using the submission instructions shown on the homework page.