/** * @file Instance.java * @author Robert S Laramee * @version 1.0 * @see DrawCanvas, SolidObject.java, OutSerialize.java *
* start date Friday, 27 Nov 98 * finish date Thursday, 03 Dec 98 *
* description This class contains the methods and data necessary for * saving an instance of a solid object */ import java.awt.*; // for Color Class import java.util.*; // for Vector class import java.io.*; // for PrintWriter class //import matrix.*; // for Matrix4, Point4 class public class Instance { /** * What information is contained in an instance? * Remember, the faces and darken ratio specifications are stored in the * solid object definition. * 1 a color specification * 2 the name of the object * 3 the transformation matrix */ private String name; private Matrix4 xform; private double darkenRatio; private Color color; // the color private int red; // the red component of this color private int green; // the green component of this color private int blue; // the blue component of this color /** * constructor */ public Instance(String n, Matrix4 x, Color c) { name = new String(n); xform = new Matrix4(x); color = c; red = color.getRed(); green = color.getGreen(); blue = color.getBlue(); } /** * return the transformation name, matrix, color */ public String getName() { return name; } public Matrix4 getXform() { return xform; } public Color getColor() { return color; } /** * print this instance to standard output */ public void print() { System.out.println("c " + red + " " + green + " " + blue); System.out.println("i " + name); System.out.println(xform); } /** * print this instance to the give output file */ public void printToFile(PrintWriter output) { output.println("c " + red + " " + green + " " + blue); output.println("i " + name); output.println(xform); } }