noope.output
Class OutputProjection

java.lang.Object
  |
  +--noope.laws.Law
        |
        +--noope.output.OutputProjection

public class OutputProjection
extends Law

This is an output class that can be used to display in real-time an orthogonal projection onto a plane of all the Entity objects in Entities. The plane is specified by its normal (the projection onto all such planes is the same) and is then chosen to pass through the origin for simplicity. If the plane is the x-y plane, the x and y axes are used as the coordinate axes. Otherwise, the x-axis is the intersection of the plane with the x-y plane, the origin is the origin of the 3-d space we are representing and the y-axis is perpendicular to the x-axis. The positive x direction is the one which has a positive x component in the old coordinates. The positive y direction is the vector/cross product of the unit-normal and the new x unit vector.

Version:
26-Apr-2001 changed to use BufferedFrame [Miklos Reiter], a subclass of Frame, so we can use buffering with AWT; and added a call to windowFrame.pack() before resizing it, so it can determine the width needed for the border 22-Apr-2001: changed to access drawingWindow in a synchronized way [Miklos Reiter]
Author:
Miklos Reiter, this class is based on OutputText by James Kermode

Field Summary
static int defaultHeight
          The width of the image used by default if nothing is provided in the BlockReader object passed to the constructor.
static int defaultWidth
          The height of the image used by default if nothing is provided in the BlockReader object passed to the constructor.
static int defaultXpos
          The default x position at which the window should appear.
static int defaultYpos
          The default y position at which the window should appear.
protected  boolean disabled
          True after the window has been disabled (by the user closing it or by dispose()).
protected  java.lang.String gifComments
          String representing the comments written into the gif file.
protected  int gifLoopCount
          How many times to play sequence.
protected  java.lang.String gifName
          The name of the gif file used for outputting the animation, null if animation is displayed directly on screen.
protected  int gifUniformDelay
          Number of centiseconds to wait between two frames.
protected  int height
          The height of the image we are displaying.
protected  double lastTime
          Last time an output was made.
protected  Vector3D normal
          The unit normal to the plane we are projecting on.
protected  AnimationListener outputObject
          The AnimationListener used to display the animation.
protected  double period
          The time between two consecutive outputs.
protected  int width
          The width of the image we are displaying.
protected  BufferedFrame windowFrame
          The JFrame used to display window.
protected  double xmax
          xmin, xmax, ymin and ymax describe the range of new coordinates to draw.
protected  double xmin
          xmin, xmax, ymin and ymax describe the range of new coordinates to draw.
protected  Vector3D xnew
          The new x and y unit vectors.
protected  int xpos
          The x-coordinate of the position at which we are displaying the window.
protected  double ymax
          xmin, xmax, ymin and ymax describe the range of new coordinates to draw.
protected  double ymin
          xmin, xmax, ymin and ymax describe the range of new coordinates to draw.
protected  Vector3D ynew
          The new x and y unit vectors.
protected  int ypos
          The y-coordinate of the position at which we are displaying the window.
 
Fields inherited from class noope.laws.Law
physics
 
Constructor Summary
OutputProjection(BlockReader br, int lawnumber, Physics phys)
          Constructs a new OutputProjection object from the given BlockReader with the given lawnumber.
 
Method Summary
 void act()
          Does not exert a force on any objects, just outputs.
 LawPropertyRecord constructNewPropertyRecord(BlockReader br, Entity ent)
          Constructs a new OutputProjectionPropertyRecord object.
 void dispose()
          Closes the windows opened, then calls the inherited method.
protected  void outputPosition(Entity e, double x, double y)
          Outputs the position of the Entity e at x, y in the coordinates of the plane we are projecting onto.
 
Methods inherited from class noope.laws.Law
getName, getNumber, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

gifName

protected java.lang.String gifName
The name of the gif file used for outputting the animation, null if animation is displayed directly on screen.

gifComments

protected java.lang.String gifComments
String representing the comments written into the gif file. Only meaningful if gifName is set.

gifLoopCount

protected int gifLoopCount
How many times to play sequence. Written into gif. Default is 1, 0 represents indefinite looping.

gifUniformDelay

protected int gifUniformDelay
Number of centiseconds to wait between two frames. Default = 0. Written into gif.

disabled

protected boolean disabled
True after the window has been disabled (by the user closing it or by dispose()).

period

protected double period
The time between two consecutive outputs.

lastTime

protected double lastTime
Last time an output was made. Output will occur the first time the act method is called.

outputObject

protected AnimationListener outputObject
The AnimationListener used to display the animation.

windowFrame

protected BufferedFrame windowFrame
The JFrame used to display window. Only used if gifName == null.

width

protected int width
The width of the image we are displaying.

height

protected int height
The height of the image we are displaying.

xpos

protected int xpos
The x-coordinate of the position at which we are displaying the window.

ypos

protected int ypos
The y-coordinate of the position at which we are displaying the window.

xmin

protected double xmin
xmin, xmax, ymin and ymax describe the range of new coordinates to draw.

xmax

protected double xmax
xmin, xmax, ymin and ymax describe the range of new coordinates to draw.

ymin

protected double ymin
xmin, xmax, ymin and ymax describe the range of new coordinates to draw.

ymax

protected double ymax
xmin, xmax, ymin and ymax describe the range of new coordinates to draw.

normal

protected Vector3D normal
The unit normal to the plane we are projecting on.

xnew

protected Vector3D xnew
The new x and y unit vectors. These give us the direction of the positive coordinate axes in the plane we are projecting on. xnew and ynew are orthogonal and are oriented according to the right-handed corkscrew rule with respect to normal.

ynew

protected Vector3D ynew
The new x and y unit vectors. These give us the direction of the positive coordinate axes in the plane we are projecting on. xnew and ynew are orthogonal and are oriented according to the right-handed corkscrew rule with respect to normal.

defaultWidth

public static int defaultWidth
The height of the image used by default if nothing is provided in the BlockReader object passed to the constructor.

defaultHeight

public static int defaultHeight
The width of the image used by default if nothing is provided in the BlockReader object passed to the constructor.

defaultXpos

public static int defaultXpos
The default x position at which the window should appear. Can be overridden by giving a value explicitly in the BlockReader object passed to the constructor.

defaultYpos

public static int defaultYpos
The default y position at which the window should appear. Can be overridden by giving a value explicitly in the BlockReader object passed to the constructor.
Constructor Detail

OutputProjection

public OutputProjection(BlockReader br,
                        int lawnumber,
                        Physics phys)
                 throws BRLoadingException
Constructs a new OutputProjection object from the given BlockReader with the given lawnumber. universe is stored as the reference to the Physics object hosting this simulation. br Should contain a double "period", specifying the period of sampling, followed by "normal", the normal unit vector to the plane onto which we wish to project, doubles "xmin", "xmax", "ymin" and "ymax" specifying the range in the new coordinates to be represented; integers "width" and "height" specifying the width and the height in pixels of the image to use. "width" and "height" may be omitted, in which case the default is defaultWidth and defaultHeight. Next, optionally "gifName", a filename specifying the file write the animated gif to. If gifName is not provided, the animation is going to be displayed in a window. If gifName is given, the following options can be specified: "gifComments": comments written into gif "gifUniformDelay": time in centiseconds to wait between subsequent frames (default = 0) "gifLoopCount": number of times animation should be played (default = 1, 0 = indefinite) Finally, integers "xpos", "ypos" specify the position at which the window should appear (optional, take defaultXpos, defaultYpos if not given). (only if gifName is not provided)
Method Detail

act

public void act()
Does not exert a force on any objects, just outputs.
Overrides:
act in class Law
Following copied from class: noope.laws.Law
Parameters:
e - the list of entities that the force should act on
See Also:
Entity.addForce(Vector3D)

outputPosition

protected void outputPosition(Entity e,
                              double x,
                              double y)
Outputs the position of the Entity e at x, y in the coordinates of the plane we are projecting onto. Just gets the Entity's OutputProjectionPropertyRecord and calls its paint method with drawingGraphics and the coordinates.

constructNewPropertyRecord

public LawPropertyRecord constructNewPropertyRecord(BlockReader br,
                                                    Entity ent)
                                             throws BRLoadingException
Constructs a new OutputProjectionPropertyRecord object. If the parameter of br is null or an empty String, then an object of the class OutputProjectionPropertyRecord is constructed. If, however, a parameter is given, we try to get the subclass of OuputProjectionPropertyRecord with that name. First the name itself is tried and if no class by that name is found, we try to find it in the package noope.laws.
Overrides:
constructNewPropertyRecord in class Law
Following copied from class: noope.laws.Law
Parameters:
br - BlockReader used to read properties from
ent - is the instance of Entity, this LawPropertyRecord will be constructed for

dispose

public void dispose()
Closes the windows opened, then calls the inherited method.
Overrides:
dispose in class Law