All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class pinball.player.Stub

java.lang.Object
   |
   +----java.lang.Thread
           |
           +----pinball.player.Stub

public class Stub
extends Thread
The way the strategy communicates with the pinball machine. It does this in an indirect way, so a strategy can play over the network. The stub also filters out the ball from the objects found.


Variable Index

 o badCount
Number of frames with only bad objects.
 o ballReturn
The ball return device.
 o betweenLaunch
Time between launches.
 o biggestObject
Biggest Object.
 o boarder
Area around flipper that is to be ignored.
 o bottom
Location from the bottom at the screen to be considered out of play.
 o buffer
The buffer that hold the information buffer.
 o buffinfo
The information buffer.
 o camera
The camera in the system.
 o canvas
Used for creating an image.
 o distanceFromFlippers
Ball's distance from either the left or right flipper, depending on which half of the screen it's on.
 o distanceFromLastSeen
Ball's distance from the last known location of the ball.
 o firstTime
Used in options to see if the they happened once.
 o flipperHeight
Anything moving below this be considered for flipping.
 o flipperOffset
Where is the flipper from the top of the screen.
 o flipperZone
Y location of begin flipper zone.
 o flipperZoneSize
Length of flipper zone.
 o fromBottom
Location from bottom of flippers to be considered out of play.
 o fromTop
Location from top of screen to be considered in play.
 o gameStats
Location to write game stats.
 o hitFlipper
Did the flipper hit the ball.
 o lastBallX
Last ball's x location.
 o lastBallY
Last ball's y location.
 o lastLaunched
Time last launched.
 o LEFT
Value of the left flipper.
 o left
The flippers in the game.
 o leftX
Left flipper x location.
 o leftY
Left flipper y location.
 o model
The greyscale values for the painting of the image.
 o outZone
Location from bottom of screen to be considered out of play.
 o outZoneEnd
End of outZone.
 o outZoneLength
Length of outZone.
 o pause
How long the flipper can be up in testing.
 o plunger
The plunger in the system.
 o queue
The queue of waiting buffers.
 o resetTime
How long can the flipper stay up in the game.
 o right
The flippers in the game.
 o RIGHT
Value of the right flipper.
 o rightX
Right flipper x location.
 o rightY
Right flipper y location.
 o sendFrame
Send frame.
 o smallestObject
Smallest Object.
 o startButton
Starts a new game on the pinball machine.
 o startDelay
Should the system way a few seconds at the begining for a ball to return.
 o startOfGame
Start of game.
 o startTime
Time when the flipper was flipped in testing.
 o stats
The statistics for the game.
 o strategy
The strategy to work on.
 o testingFlippers
Are the flippers being tested.
 o timeStamp
Should the system report time stamps.
 o top
Location from bottom of screen to be considered out of play.
 o triedLaunch
Number of tries to launch the ball.
 o visualDetection
Visual Ball Detection.
 o x
X location of the ball.
 o xsize
Image x size.
 o xTest
Used to test the x location of the ball.
 o y
Y location of the ball.
 o ysize
Image y size.
 o yTest
Used to test the y location of the ball.

Constructor Index

 o Stub()
Needed for when this class is extended.
 o Stub(Buffer, TextArea, Strategy, Camera)
The stub for the strategy.

Method Index

 o addBuffer(Buffer)
Adds a buffer to the queue.
 o ballIsInPlay()
Force ball in play
 o blipx()
Get the ball's x location.
 o blipx(int)
Set the ball's x location.
 o blipy()
Get the ball's y location.
 o blipy(int)
Set the ball's y location.
 o boarder(int)
Get the flipper boarder.
 o bottom()
The bottom of the playfield.
 o clearing()
Get the clearing flag.
 o clearing(boolean)
Set the clearing flag.
 o filter(boolean)
Filter out the ball from the other objects found.
 o findFlippers(int)
Search for the flipper the number of times given.
 o flipperFlipped()
Get the flippers flipped condition.
 o flipperFlipped(boolean)
 o flipperOffset()
Get the flipper offset.
 o flipperOffset(int)
Set the flipper offset.
 o flipperStart()
Get the start of the flipper's area.
 o flipperZone()
Get the flipper's zone.
 o getBlipsFrame()
Get the frame of found objects.
 o getBuffNumber()
 o getCenterChange()
For the flippers, to find the center of the change of the image.
 o getImage()
Get a frame from the camera.
 o getLock()
Get the lock on the information buffer.
 o getNextBuffer()
Get the next buffer from the queue.
 o getObjects()
Get the objects table.
 o getRawFrame()
Get the raw frame from the camera.
 o getRecentBuffer()
Get the recent buffer from the queue.
 o headerInfo(String)
Write to the header of the log.
 o height()
Get the height.
 o id()
Get buffer's id.
 o imageOffset()
Get the image offset.
 o imageOffset(int)
Set the image offset.
 o isLeftDown()
Is the left flipper down.
 o isLeftUp()
Is the left flipper down.
 o isQueueEmpty()
Checks if the queue is empty.
 o isRightDown()
Is the right flipper down.
 o isRightUp()
Is the right flipper down.
 o lastBallLocation()
Get the last ball's location.
 o launchBall()
Have the system launch the ball.
 o leftFlipperReset(long)
Should the left flipper be reset.
 o leftFlipperState(boolean)
Set the state of the left flipper.
 o leftX()
X location of left flipper.
 o leftY()
Y location of left flipper.
 o locateFlippers()
Locate the flippers in the game.
 o logit(int, String, int, Object)
Write to the log.
 o nextBuffer()
Go to the next information buffer.
 o number()
Get frame grabbed number.
 o offsets(int, int)
Set the location of the offsets.
 o outZone()
Get the flipper's outzone.
 o outZone(int)
Override the outZone value.
 o outZoneEnd()
Get the end flipper's outzone.
 o process()
Process the blips found.
 o readFlippersFile()
Read in the flipper's file to see where the flippers were previously located.
 o releaseAllBuffers()
Release all the buffers from the queue.
 o releaseLock()
Release the lock on the information buffer.
 o releaseLock(Buffer)
Release the lock on the information buffer.
 o releaseLock(int)
Release the lock on the information buffer.
 o requestFrame()
Get a frame from the camera.
 o resize()
Get the resize flag.
 o resize(int, int, int, int)
Set the resize flag and include resize information.
 o resize(int, int, int, int, int)
Set the resize flag and include resize information.
 o resized()
Set the condition that it was resized.
 o resizeX()
Get the resize x size.
 o resizeXOffset()
Get the resize x offset.
 o resizeY()
Get the resize y size.
 o resizeYOffset()
Get the resize y offset.
 o rightFlipperReset(long)
Should the right flipper be reset.
 o rightFlipperState(boolean)
Set the state of the right flipper.
 o rightX()
X location of right flipper.
 o rightY()
Y location of right flipper.
 o run()
Get the loctions of the objects found and determine which is the ball and flip the flippers based on these finding.
 o sendFrame()
Should the system send a frame from the camera over the network.
 o sendFrame(boolean)
Set if the system should send a frame from the camera over the network.
 o setBuffer(Buffer)
Set the buffer used by the stub.
 o setObjects(Vector)
Set the blips in the buffer.
 o setupImage()
Setup the color model for the frame from the camera.
 o skip()
Skip past some of the buffers, if there is more recent data in the system.
 o skipBuffer()
Skip the buffer.
 o skipFrame()
The frame was skipped.
 o statistics()
Check the list of statistic events and see what to log.
 o statsBallInPlay()
Check if ball is in play.
 o storeBall()
Save the ball's location to the log file.
 o storeBlips()
Write the blips to the log file.
 o strategyDraw(Graphics, int, int)
Allows the strategy to draw to the screen any lines or other graphics for the user to see how the strategy operates.
 o time()
The time stamp used in the threads.
 o top()
The top of the playfield.
 o topBottom(int, int)
Set the top & bottom for the in play area.
 o toString()
Name of the object.
 o width()
Get the width of the frame.
 o writeFlippersFile()
Write the flippers file, to store the locations of the flippers.
 o XOffset()
Get the x offset.
 o YOffset()
Get the y offset.

Variables

 o buffer
 protected Buffer buffer
The buffer that hold the information buffer.

 o buffinfo
 protected BufferInfo buffinfo
The information buffer.

 o left
 protected Flipper left
The flippers in the game.

 o right
 protected Flipper right
The flippers in the game.

 o stats
 protected Stats stats
The statistics for the game.

 o gameStats
 protected TextArea gameStats
Location to write game stats.

 o x
 protected int x
X location of the ball.

 o y
 protected int y
Y location of the ball.

 o xsize
 protected int xsize
Image x size.

 o ysize
 protected int ysize
Image y size.

 o leftX
 protected int leftX
Left flipper x location.

 o leftY
 protected int leftY
Left flipper y location.

 o rightX
 protected int rightX
Right flipper x location.

 o rightY
 protected int rightY
Right flipper y location.

 o boarder
 protected int boarder
Area around flipper that is to be ignored.

 o LEFT
 protected final int LEFT
Value of the left flipper.

 o RIGHT
 protected final int RIGHT
Value of the right flipper.

 o flipperOffset
 protected int flipperOffset
Where is the flipper from the top of the screen.

 o startTime
 protected long startTime
Time when the flipper was flipped in testing.

 o pause
 protected long pause
How long the flipper can be up in testing.

 o resetTime
 protected int resetTime
How long can the flipper stay up in the game.

 o lastBallX
 protected int lastBallX
Last ball's x location.

 o lastBallY
 protected int lastBallY
Last ball's y location.

 o badCount
 protected int badCount
Number of frames with only bad objects.

 o flipperZone
 protected int flipperZone
Y location of begin flipper zone.

 o flipperZoneSize
 protected int flipperZoneSize
Length of flipper zone.

 o hitFlipper
 protected boolean hitFlipper
Did the flipper hit the ball.

 o firstTime
 protected boolean firstTime
Used in options to see if the they happened once.

 o fromTop
 protected int fromTop
Location from top of screen to be considered in play.

 o fromBottom
 protected int fromBottom
Location from bottom of flippers to be considered out of play.

 o flipperHeight
 protected int flipperHeight
Anything moving below this be considered for flipping.

 o top
 protected int top
Location from bottom of screen to be considered out of play. Gets value from fromTop.

 o outZone
 protected int outZone
Location from bottom of screen to be considered out of play. Gets value from fromBottom.

 o outZoneLength
 protected int outZoneLength
Length of outZone.

 o outZoneEnd
 protected int outZoneEnd
End of outZone.

 o bottom
 protected int bottom
Location from the bottom at the screen to be considered out of play.

 o xTest
 protected int xTest
Used to test the x location of the ball. x location + xoffset

 o yTest
 protected int yTest
Used to test the y location of the ball. y location + yoffset

 o distanceFromLastSeen
 protected int distanceFromLastSeen
Ball's distance from the last known location of the ball.

 o biggestObject
 protected int biggestObject
Biggest Object.

 o smallestObject
 protected int smallestObject
Smallest Object.

 o lastLaunched
 protected long lastLaunched
Time last launched.

 o betweenLaunch
 protected long betweenLaunch
Time between launches.

 o distanceFromFlippers
 protected int distanceFromFlippers
Ball's distance from either the left or right flipper, depending on which half of the screen it's on.

 o strategy
 protected Strategy strategy
The strategy to work on.

 o testingFlippers
 protected boolean testingFlippers
Are the flippers being tested.

 o queue
 protected StrategyQueue queue
The queue of waiting buffers.

 o plunger
 protected Plunger plunger
The plunger in the system.

 o startButton
 protected StartButton startButton
Starts a new game on the pinball machine.

 o ballReturn
 protected BallReturn ballReturn
The ball return device.

 o camera
 protected Camera camera
The camera in the system.

 o triedLaunch
 protected int triedLaunch
Number of tries to launch the ball.

 o model
 protected ColorModel model
The greyscale values for the painting of the image.

 o sendFrame
 protected boolean sendFrame
Send frame.

 o canvas
 protected Canvas canvas
Used for creating an image.

 o startOfGame
 protected long startOfGame
Start of game.

 o visualDetection
 protected boolean visualDetection
Visual Ball Detection.

 o timeStamp
 protected boolean timeStamp
Should the system report time stamps.

 o startDelay
 protected boolean startDelay
Should the system way a few seconds at the begining for a ball to return.

Constructors

 o Stub
 public Stub(Buffer buffer,
             TextArea gameStats,
             Strategy strategy,
             Camera camera)
The stub for the strategy.

Parameters:
buffer - The first buffer for the information buffers.
gameStats - the area on the screen to write stats info.
strategy - the strategy thread.
camera - the camera for the system.
 o Stub
 public Stub()
Needed for when this class is extended.

Methods

 o setupImage
 public void setupImage()
Setup the color model for the frame from the camera. Used for a strategy that wants to see the image from the camera.

 o toString
 public String toString()
Name of the object.

Overrides:
toString in class Thread
 o run
 public void run()
Get the loctions of the objects found and determine which is the ball and flip the flippers based on these finding.

Overrides:
run in class Thread
 o skipBuffer
 protected void skipBuffer()
Skip the buffer.

 o locateFlippers
 public void locateFlippers()
Locate the flippers in the game.

 o process
 public void process()
Process the blips found. Find the ball and decide on wheither to flip or not.

 o setBuffer
 public void setBuffer(Buffer buffer)
Set the buffer used by the stub.

Parameters:
buffer - the buffer to be used.
 o getRecentBuffer
 public Buffer getRecentBuffer()
Get the recent buffer from the queue.

Returns:
the recent buffer.
 o getNextBuffer
 public Buffer getNextBuffer()
Get the next buffer from the queue.

Returns:
the next buffer in the queue.
 o addBuffer
 public void addBuffer(Buffer b)
Adds a buffer to the queue.

Parameters:
b - the buffer to add.
 o isQueueEmpty
 public boolean isQueueEmpty()
Checks if the queue is empty.

Returns:
empty status.
 o getBlipsFrame
 public int[][] getBlipsFrame()
Get the frame of found objects.

Returns:
the blips frame.
 o getObjects
 public Vector getObjects()
Get the objects table.

 o setObjects
 public void setObjects(Vector b)
Set the blips in the buffer.

Parameters:
b - the blips found.
 o getRawFrame
 public byte[] getRawFrame()
Get the raw frame from the camera.

 o number
 public int number()
Get frame grabbed number.

Returns:
the number of this frame.
 o id
 public int id()
Get buffer's id.

Returns:
the id of this buffer.
 o blipx
 public int blipx()
Get the ball's x location.

Returns:
ball's x location
 o blipy
 public int blipy()
Get the ball's y location.

Returns:
ball's y location
 o blipx
 public void blipx(int x)
Set the ball's x location.

Parameters:
x - ball's x location
 o blipy
 public void blipy(int y)
Set the ball's y location.

Parameters:
y - ball's y location
 o time
 public TimeStamp time()
The time stamp used in the threads.

Returns:
the time stamp.
 o width
 public int width()
Get the width of the frame.

Returns:
width.
 o height
 public int height()
Get the height.

Returns:
height.
 o boarder
 public void boarder(int b)
Get the flipper boarder.

Parameters:
return - The size of the flipper boarder.
 o offsets
 public void offsets(int x,
                     int y)
Set the location of the offsets.

Parameters:
x - xoffset.
y - yoffset.
 o resizeX
 public int resizeX()
Get the resize x size.

Returns:
x resize.
 o resizeY
 public int resizeY()
Get the resize y size.

Returns:
y resize.
 o resizeXOffset
 public int resizeXOffset()
Get the resize x offset.

Returns:
x resize offset.
 o resizeYOffset
 public int resizeYOffset()
Get the resize y offset.

Returns:
y resize offset.
 o XOffset
 public int XOffset()
Get the x offset.

Returns:
x offset.
 o YOffset
 public int YOffset()
Get the y offset.

Returns:
y offset.
 o resize
 public void resize(int x,
                    int y,
                    int OX,
                    int OY)
Set the resize flag and include resize information.

Parameters:
x - x size.
y - y size.
OX - x offset.
OY - y offset.
 o resize
 public void resize(int x,
                    int y,
                    int OX,
                    int OY,
                    int t)
Set the resize flag and include resize information.

Parameters:
x - x size.
y - y size.
OX - x offset.
OY - y offset.
t - the transfer size.
 o resize
 public boolean resize()
Get the resize flag.

Returns:
resize flag.
 o resized
 public void resized()
Set the condition that it was resized.

 o clearing
 public void clearing(boolean c)
Set the clearing flag. Will clear the frame on the display. Used to clear when the ball's location is draw near the edge of the display. Clears the cross hair that's left at the edge.

Parameters:
c - clearing status.
 o clearing
 public boolean clearing()
Get the clearing flag.

Parameters:
clearing - status.
 o flipperOffset
 public int flipperOffset()
Get the flipper offset. Return flipper offset.

 o flipperOffset
 public void flipperOffset(int i)
Set the flipper offset.

Parameters:
i - flipper offset.
 o imageOffset
 public void imageOffset(int i)
Set the image offset.

Parameters:
i - the image offset.
 o imageOffset
 public int imageOffset()
Get the image offset.

Returns:
the image offset.
 o flipperFlipped
 public boolean flipperFlipped()
Get the flippers flipped condition.

Returns:
the status of the flippers flipped status.
 o topBottom
 public void topBottom(int t,
                       int b)
Set the top & bottom for the in play area. Top is the top of the screen to define anything over that is to be in play. Bottom is the end of the playing area. Anything under that is out of play.

Parameters:
t - top of playfield.
b - bottom of playfield.
 o outZone
 public void outZone(int out)
Override the outZone value.

Parameters:
out - the new outZone value.
 o top
 public int top()
The top of the playfield.

Returns:
top of playfield.
 o bottom
 public int bottom()
The bottom of the playfield.

Returns:
bottom of playfield.
 o nextBuffer
 public void nextBuffer()
Go to the next information buffer.

 o getLock
 public void getLock()
Get the lock on the information buffer.

 o releaseLock
 public void releaseLock()
Release the lock on the information buffer.

 o releaseLock
 public void releaseLock(Buffer b)
Release the lock on the information buffer.

Parameters:
Buffer - b The buffer to unlock.
 o releaseLock
 public void releaseLock(int buff)
Release the lock on the information buffer.

Parameters:
int - b The buffer to unlock.
 o getBuffNumber
 public int getBuffNumber()
 o leftFlipperState
 public void leftFlipperState(boolean s)
Set the state of the left flipper.

Parameters:
s - Flip state. True for up, false for down.
 o rightFlipperState
 public void rightFlipperState(boolean s)
Set the state of the right flipper.

Parameters:
s - Flip state. True for up, false for down.
 o flipperFlipped
 public void flipperFlipped(boolean s)
 o leftFlipperReset
 public boolean leftFlipperReset(long reset)
Should the left flipper be reset. Has it been up long enough.

Parameters:
done - Has the flipper been up at least this long?
Returns:
should the flipper be reset or not.
 o rightFlipperReset
 public boolean rightFlipperReset(long reset)
Should the right flipper be reset. Has it been up long enough.

Parameters:
done - Has the flipper been up at least this long?
Returns:
should the flipper be reset or not.
 o isLeftUp
 public boolean isLeftUp()
Is the left flipper down.

Returns:
flipper's down status.
 o isRightUp
 public boolean isRightUp()
Is the right flipper down.

Returns:
flipper's down status.
 o isLeftDown
 public boolean isLeftDown()
Is the left flipper down.

Returns:
flipper's down status.
 o isRightDown
 public boolean isRightDown()
Is the right flipper down.

Returns:
flipper's down status.
 o storeBlips
 public void storeBlips()
Write the blips to the log file.

 o skipFrame
 public void skipFrame()
The frame was skipped.

 o skip
 public boolean skip()
Skip past some of the buffers, if there is more recent data in the system.

 o storeBall
 public void storeBall()
Save the ball's location to the log file.

 o filter
 public void filter(boolean findFlippers)
Filter out the ball from the other objects found.

Parameters:
findFlippers - Is the system finding the flippers.
 o statistics
 public void statistics()
Check the list of statistic events and see what to log.

 o findFlippers
 public void findFlippers(int quantity)
Search for the flipper the number of times given.

Parameters:
quantity - number of times to look for the flippers.
 o statsBallInPlay
 public boolean statsBallInPlay()
Check if ball is in play.

Returns:
ball's in play status.
 o ballIsInPlay
 public void ballIsInPlay()
Force ball in play

 o leftX
 public int leftX()
X location of left flipper.

Returns:
left flipper's x location.
 o leftY
 public int leftY()
Y location of left flipper.

Returns:
left flipper's y location.
 o rightX
 public int rightX()
X location of right flipper.

Returns:
right flipper's x location.
 o rightY
 public int rightY()
Y location of right flipper.

Returns:
right flipper's y location.
 o flipperZone
 public int flipperZone()
Get the flipper's zone.

Returns:
flipper zone.
 o outZone
 public int outZone()
Get the flipper's outzone.

Returns:
flipper outzone.
 o outZoneEnd
 public int outZoneEnd()
Get the end flipper's outzone.

Returns:
the end flipper outzone.
 o flipperStart
 public int flipperStart()
Get the start of the flipper's area.

Returns:
flipper's area
 o logit
 public void logit(int frame,
                   String info,
                   int priority,
                   Object object)
Write to the log.

Parameters:
frame - frame number.
info - String to write.
priority - priority level.
object - caller of logit.
 o headerInfo
 public void headerInfo(String s)
Write to the header of the log.

Parameters:
s - String to write.
 o getCenterChange
 public Location getCenterChange()
For the flippers, to find the center of the change of the image.

Returns:
The location of the center of the image.
 o readFlippersFile
 public void readFlippersFile()
Read in the flipper's file to see where the flippers were previously located.

 o writeFlippersFile
 public void writeFlippersFile()
Write the flippers file, to store the locations of the flippers.

 o strategyDraw
 public void strategyDraw(Graphics g,
                          int wSize,
                          int hSize)
Allows the strategy to draw to the screen any lines or other graphics for the user to see how the strategy operates. This also draws the flipper's locations.

Parameters:
g - the graphics area to draw to.
canvasWidth - the width of the canvas.
canvasHeight - the height of the canvas.
 o launchBall
 public void launchBall()
Have the system launch the ball.

 o getImage
 public Image getImage()
Get a frame from the camera.

 o requestFrame
 public void requestFrame()
Get a frame from the camera.

 o sendFrame
 public void sendFrame(boolean b)
Set if the system should send a frame from the camera over the network.

 o sendFrame
 public boolean sendFrame()
Should the system send a frame from the camera over the network.

 o releaseAllBuffers
 public void releaseAllBuffers()
Release all the buffers from the queue.

 o lastBallLocation
 public Point lastBallLocation()
Get the last ball's location. return the point of the ball.


All Packages  Class Hierarchy  This Package  Previous  Next  Index