testing.physicsEngine.guiTest
Class AbstractTestEnvironment

java.lang.Object
  extended by testing.physicsEngine.guiTest.AbstractTestEnvironment
Direct Known Subclasses:
CornerTest, CrossfireTest, DominoTest, PegTest, SeesawTest, SimpleCollisionTest

public abstract class AbstractTestEnvironment
extends java.lang.Object

Abstract class that is used to create basic simulations using the physics engine (for testing and demo purposes). This renders simple shapes without using the game engine framework.

Author:
Alex Sloan

Field Summary
protected static int DISPLAY_HEIGHT
           
protected static int DISPLAY_WIDTH
           
protected  int loopCount
           
protected  java.util.List<PhysicalParameters> myNewBodies
           
protected  boolean needsReset
           
protected  java.lang.String recentUserActivity
           
 
Constructor Summary
AbstractTestEnvironment(java.lang.String title)
          Create an AbstractTestEnvironment of given title.
 
Method Summary
protected  java.util.List<PhysicalParameters> createWalls(int wallThickness)
           
protected  void drawGUItext(java.awt.Graphics2D g)
          Demo customisable GUI render
(package private) abstract  java.util.List<PhysicalParameters> initBodies()
          This method must be implemented by extending classes, it returns the list of PhysicalParameters representing each of the bodies in the world, set to their initial positions.
(package private) abstract  PhysicsEngine initEngine()
          This method must be implemented by extending classes, and returns the PhysicsEngine properly initialized.
protected  void keyHit(char c)
          Notification that a key was pressed
protected  void mouseClick(java.awt.Point p)
          Notification that the mouse was clicked
 void run()
          Initializes and runs the simulation.
protected  void stop()
          Stops the simulation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DISPLAY_WIDTH

protected static final int DISPLAY_WIDTH
See Also:
Constant Field Values

DISPLAY_HEIGHT

protected static final int DISPLAY_HEIGHT
See Also:
Constant Field Values

needsReset

protected boolean needsReset

recentUserActivity

protected java.lang.String recentUserActivity

myNewBodies

protected java.util.List<PhysicalParameters> myNewBodies

loopCount

protected int loopCount
Constructor Detail

AbstractTestEnvironment

public AbstractTestEnvironment(java.lang.String title)
Create an AbstractTestEnvironment of given title.

Parameters:
title -
Method Detail

stop

protected void stop()
Stops the simulation


initEngine

abstract PhysicsEngine initEngine()
This method must be implemented by extending classes, and returns the PhysicsEngine properly initialized.


initBodies

abstract java.util.List<PhysicalParameters> initBodies()
This method must be implemented by extending classes, it returns the list of PhysicalParameters representing each of the bodies in the world, set to their initial positions.


drawGUItext

protected void drawGUItext(java.awt.Graphics2D g)
Demo customisable GUI render

Parameters:
g - The graphics context to use for rendering here

run

public void run()
Initializes and runs the simulation. This method contains the "game loop" that updates and redraws the shapes in the simulation for each time step. Adapted from phys2d.svn.trunk.phys2d.test.net.phys2d.raw.test.AbstractDemo.drawBody, see http://code.google.com/p/phys2d/source/browse/trunk/phys2d/test/net/ phys2d/raw/test/AbstractDemo.java for original code.


mouseClick

protected void mouseClick(java.awt.Point p)
Notification that the mouse was clicked

Parameters:
p - The point at which the mouse was clicked

keyHit

protected void keyHit(char c)
Notification that a key was pressed

Parameters:
c - The character of key hit

createWalls

protected java.util.List<PhysicalParameters> createWalls(int wallThickness)
Parameters:
wallThickness - the thickness of the walls
Returns:
a list of PhysicalParameters which are positioned on the edges of the display, acting as walls