/** * Class p1info.java -- an information file for assignment 1 in * CS4812. This file is formatted as a .java file, with extensive * comment fields, so that it might be harmlessly added to a project * file in most popular IDEs. This allows for more convenient * consultation of the assignment specifications during development. * */ class p2nfo { public static void main(String arg[]) { System.err.println ("This class does nothing!"); System.exit(1); } } //p1info /* CS 4812: "Stealth" JAVA! Programming Assignment 1 - Summer Quarter, 1998. Program Title: A Java Applet Assigned: July 15, 1998 Design Doc Due: N/A, though recommended Program Due: FILE PROVIDED ============== For this assignment, you are provided two files: o p2nfo.java - this file. o p2.java - a simple applet DELIVERABLES (what you need to turn in) ======================================== o All source files created for this program, or modified by you o Turnin materials in using e-mail, or some other means that provides a time-stamp. LEARNING GOALS ============== o Exposure to Java Threads. (Note: Students can thwart this learning objective by not using threads, as discussed below.) o Expert command of the JDK 1.1 event model o Experience creating custom light-weight components *NOTE: The focus of this project is on object light-weight components; please don't get distracted by the math. HEADER FILE =========== o Before beginning work, please create a header for your source files. You might find it convenient to use the file provided to CS1502 students. If you don't have a copy of this file, it is reprinted below: */ /** * CS1502: Program/Design Doc #XX * *
* Enter a brief description here * * Revisions: 1.0 DATE, 1998 * Created class XXXXX ** * @author YOUR NAME GOES HERE * @version Version 1.0, DATE, 1998 */ /* GENERAL OVERVIEW: CONSTRUCTING AN APPLET ============================================= For this programming assignment, you must create an applet that allows a user to view a set of points rotating in three dimensions. The file, PointRotation.java, contains an example of the visual display. Your primary goal should be the creation of a user-interface using light- weight components and (if absolutely necessary) a few heavy-weight components. At a minimum, the controls should allow the user to: 1) individually manipulate the x, y, and z angles of rotation (or rate or rotation), using some kind of slider, spinner, non-heavy weight slidebar or similar widget. This is the key aspect of the assignment. Try to make your widget in such a manner as to allow its use in a variety of circumstances. For example, if you display a scale, perhaps you should create methods to adjust the extent of the scale, or calculate the scale based on parameters passed in with a constructor. The idea is to create widget that works well in your project, but could also find use in other programs. 2) display information about the rotating points adjacent to their location on screen (e.g., a lettered label, or information about their location in space). The user should be able to toggle this information on and off by clicking some kind of button, switch, or other widget. Ideally, the controls should also allow the user to: 3) read in a serialized instance of the Dots.java file. If you are still not comfortable with the Java IO class, and how decorator classes work, you might have a look at the following method: public void readInURL() { URL fileURL = null; try { fileURL = new URL (getCodeBase()+"dots.dat"); } catch (MalformedURLException dammit) { showStatus ("Exception: " + dammit.toString()); } Object oTemp; Dots d1=null; InputStream input; ObjectInputStream dataInput; try { input = fileURL.openStream(); dataInput = new ObjectInputStream(input); oTemp = dataInput.readObject(); if (oTemp instanceof Dots) d1 = (Dots) oTemp; dataInput.close(); } catch (IOException dammitAll) { showStatus ("Exception: " + dammitAll.toString()); } catch (ClassNotFoundException err) { err.printStackTrace(); } this.xs = d1.xs; this.ys = d1.ys; this.zs = d1.zs; } // readInURL This method, if added to the PointRotation.java file, with the appropriate import statements ("import java.net.*;" and "import.java.io.*;") should allow you to read in a serialized object from a URL. (Of course, you would have to call this method from init() or some other appropriate location in PointRotation.java). Obviously there's much to criticize about this method. (For example, it doesn't even allow the user to change the file name!) But it should give you direction on how to open and read a serialized object from within your applet. ** NOTE re: Modifications of P1. The artificial restriction on the modification of the file Dots.java is listed for this assignment. If you change Dots.java, please be sure to turnin a copy. ** CAUTIONARY NOTE: Some versions of Netscape and other browsers will throw a security violation, and refuse to allow you access to java.io package classes and methods. Your applet will be tested using JDK 1.1.6 with no specified security manager, so you should have access to serialized objects that reside in the same folder as your code base. If you encounter significant problems with this method, I suggest you skip it, and help yourself to some extra credit instead . . . EXTRA CREDIT ================ Significant quantities of extra credit are available for this program. Suggestions include: 1) Allowing the user to click a point to freeze the rotation of the point, or perhaps all the points, so long as the mouse button is depressed. 2) Allowing the user to click and drag on a point to change its location. 3) Allowing the user to adjust the color of the dots, or background, or both. A clickable color wheel or gradient might be a nice change from plain old slidebars . . . 4) Allowing the user to cycle between various wire frame objects loaded from the URL (perhaps stored in an array or Vector). 5) Any other device, feature or widget that improves the ability of the user to interact with your applet.