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.
-
badCount
- Number of frames with only bad objects.
-
ballReturn
- The ball return device.
-
betweenLaunch
- Time between launches.
-
biggestObject
- Biggest Object.
-
boarder
- Area around flipper that is to be ignored.
-
bottom
- Location from the bottom at the screen to be considered out of play.
-
buffer
- The buffer that hold the information buffer.
-
buffinfo
- The information buffer.
-
camera
- The camera in the system.
-
canvas
- Used for creating an image.
-
distanceFromFlippers
-
Ball's distance from either the left or right flipper, depending on which
half of the screen it's on.
-
distanceFromLastSeen
- Ball's distance from the last known location of the ball.
-
firstTime
- Used in options to see if the they happened once.
-
flipperHeight
- Anything moving below this be considered for flipping.
-
flipperOffset
- Where is the flipper from the top of the screen.
-
flipperZone
- Y location of begin flipper zone.
-
flipperZoneSize
- Length of flipper zone.
-
fromBottom
- Location from bottom of flippers to be considered out of play.
-
fromTop
- Location from top of screen to be considered in play.
-
gameStats
- Location to write game stats.
-
hitFlipper
- Did the flipper hit the ball.
-
lastBallX
- Last ball's x location.
-
lastBallY
- Last ball's y location.
-
lastLaunched
- Time last launched.
-
LEFT
- Value of the left flipper.
-
left
- The flippers in the game.
-
leftX
- Left flipper x location.
-
leftY
- Left flipper y location.
-
model
- The greyscale values for the painting of the image.
-
outZone
-
Location from bottom of screen to be considered out of play.
-
outZoneEnd
- End of outZone.
-
outZoneLength
- Length of outZone.
-
pause
- How long the flipper can be up in testing.
-
plunger
- The plunger in the system.
-
queue
- The queue of waiting buffers.
-
resetTime
- How long can the flipper stay up in the game.
-
right
- The flippers in the game.
-
RIGHT
- Value of the right flipper.
-
rightX
- Right flipper x location.
-
rightY
- Right flipper y location.
-
sendFrame
- Send frame.
-
smallestObject
- Smallest Object.
-
startButton
- Starts a new game on the pinball machine.
-
startDelay
- Should the system way a few seconds at the begining for a ball to return.
-
startOfGame
- Start of game.
-
startTime
- Time when the flipper was flipped in testing.
-
stats
- The statistics for the game.
-
strategy
- The strategy to work on.
-
testingFlippers
- Are the flippers being tested.
-
timeStamp
- Should the system report time stamps.
-
top
-
Location from bottom of screen to be considered out of play.
-
triedLaunch
- Number of tries to launch the ball.
-
visualDetection
- Visual Ball Detection.
-
x
- X location of the ball.
-
xsize
- Image x size.
-
xTest
- Used to test the x location of the ball.
-
y
- Y location of the ball.
-
ysize
- Image y size.
-
yTest
- Used to test the y location of the ball.
-
Stub()
- Needed for when this class is extended.
-
Stub(Buffer, TextArea, Strategy, Camera)
- The stub for the strategy.
-
addBuffer(Buffer)
- Adds a buffer to the queue.
-
ballIsInPlay()
-
Force ball in play
-
blipx()
- Get the ball's x location.
-
blipx(int)
- Set the ball's x location.
-
blipy()
- Get the ball's y location.
-
blipy(int)
- Set the ball's y location.
-
boarder(int)
- Get the flipper boarder.
-
bottom()
- The bottom of the playfield.
-
clearing()
-
Get the clearing flag.
-
clearing(boolean)
-
Set the clearing flag.
-
filter(boolean)
- Filter out the ball from the other objects found.
-
findFlippers(int)
- Search for the flipper the number of times given.
-
flipperFlipped()
- Get the flippers flipped condition.
-
flipperFlipped(boolean)
-
-
flipperOffset()
- Get the flipper offset.
-
flipperOffset(int)
- Set the flipper offset.
-
flipperStart()
- Get the start of the flipper's area.
-
flipperZone()
- Get the flipper's zone.
-
getBlipsFrame()
- Get the frame of found objects.
-
getBuffNumber()
-
-
getCenterChange()
- For the flippers, to find the center of the change of the image.
-
getImage()
- Get a frame from the camera.
-
getLock()
- Get the lock on the information buffer.
-
getNextBuffer()
- Get the next buffer from the queue.
-
getObjects()
- Get the objects table.
-
getRawFrame()
- Get the raw frame from the camera.
-
getRecentBuffer()
- Get the recent buffer from the queue.
-
headerInfo(String)
- Write to the header of the log.
-
height()
- Get the height.
-
id()
- Get buffer's id.
-
imageOffset()
-
Get the image offset.
-
imageOffset(int)
- Set the image offset.
-
isLeftDown()
- Is the left flipper down.
-
isLeftUp()
- Is the left flipper down.
-
isQueueEmpty()
- Checks if the queue is empty.
-
isRightDown()
- Is the right flipper down.
-
isRightUp()
- Is the right flipper down.
-
lastBallLocation()
- Get the last ball's location.
-
launchBall()
- Have the system launch the ball.
-
leftFlipperReset(long)
- Should the left flipper be reset.
-
leftFlipperState(boolean)
- Set the state of the left flipper.
-
leftX()
-
X location of left flipper.
-
leftY()
-
Y location of left flipper.
-
locateFlippers()
-
Locate the flippers in the game.
-
logit(int, String, int, Object)
- Write to the log.
-
nextBuffer()
- Go to the next information buffer.
-
number()
- Get frame grabbed number.
-
offsets(int, int)
- Set the location of the offsets.
-
outZone()
- Get the flipper's outzone.
-
outZone(int)
- Override the outZone value.
-
outZoneEnd()
- Get the end flipper's outzone.
-
process()
- Process the blips found.
-
readFlippersFile()
- Read in the flipper's file to see where the flippers were previously located.
-
releaseAllBuffers()
-
Release all the buffers from the queue.
-
releaseLock()
- Release the lock on the information buffer.
-
releaseLock(Buffer)
- Release the lock on the information buffer.
-
releaseLock(int)
- Release the lock on the information buffer.
-
requestFrame()
- Get a frame from the camera.
-
resize()
- Get the resize flag.
-
resize(int, int, int, int)
-
Set the resize flag and include resize information.
-
resize(int, int, int, int, int)
-
Set the resize flag and include resize information.
-
resized()
- Set the condition that it was resized.
-
resizeX()
- Get the resize x size.
-
resizeXOffset()
- Get the resize x offset.
-
resizeY()
- Get the resize y size.
-
resizeYOffset()
- Get the resize y offset.
-
rightFlipperReset(long)
- Should the right flipper be reset.
-
rightFlipperState(boolean)
- Set the state of the right flipper.
-
rightX()
-
X location of right flipper.
-
rightY()
-
Y location of right flipper.
-
run()
-
Get the loctions of the objects found and determine which is the ball and flip
the flippers based on these finding.
-
sendFrame()
- Should the system send a frame from the camera over the network.
-
sendFrame(boolean)
- Set if the system should send a frame from the camera over the network.
-
setBuffer(Buffer)
- Set the buffer used by the stub.
-
setObjects(Vector)
- Set the blips in the buffer.
-
setupImage()
- Setup the color model for the frame from the camera.
-
skip()
- Skip past some of the buffers, if there is more recent data in the system.
-
skipBuffer()
-
Skip the buffer.
-
skipFrame()
- The frame was skipped.
-
statistics()
- Check the list of statistic events and see what to log.
-
statsBallInPlay()
-
Check if ball is in play.
-
storeBall()
- Save the ball's location to the log file.
-
storeBlips()
- Write the blips to the log file.
-
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.
-
time()
-
The time stamp used in the threads.
-
top()
- The top of the playfield.
-
topBottom(int, int)
- Set the top & bottom for the in play area.
-
toString()
- Name of the object.
-
width()
- Get the width of the frame.
-
writeFlippersFile()
- Write the flippers file, to store the locations of the flippers.
-
XOffset()
- Get the x offset.
-
YOffset()
- Get the y offset.
buffer
protected Buffer buffer
- The buffer that hold the information buffer.
buffinfo
protected BufferInfo buffinfo
- The information buffer.
left
protected Flipper left
- The flippers in the game.
right
protected Flipper right
- The flippers in the game.
stats
protected Stats stats
- The statistics for the game.
gameStats
protected TextArea gameStats
- Location to write game stats.
x
protected int x
- X location of the ball.
y
protected int y
- Y location of the ball.
xsize
protected int xsize
- Image x size.
ysize
protected int ysize
- Image y size.
leftX
protected int leftX
- Left flipper x location.
leftY
protected int leftY
- Left flipper y location.
rightX
protected int rightX
- Right flipper x location.
rightY
protected int rightY
- Right flipper y location.
boarder
protected int boarder
- Area around flipper that is to be ignored.
LEFT
protected final int LEFT
- Value of the left flipper.
RIGHT
protected final int RIGHT
- Value of the right flipper.
flipperOffset
protected int flipperOffset
- Where is the flipper from the top of the screen.
startTime
protected long startTime
- Time when the flipper was flipped in testing.
pause
protected long pause
- How long the flipper can be up in testing.
resetTime
protected int resetTime
- How long can the flipper stay up in the game.
lastBallX
protected int lastBallX
- Last ball's x location.
lastBallY
protected int lastBallY
- Last ball's y location.
badCount
protected int badCount
- Number of frames with only bad objects.
flipperZone
protected int flipperZone
- Y location of begin flipper zone.
flipperZoneSize
protected int flipperZoneSize
- Length of flipper zone.
hitFlipper
protected boolean hitFlipper
- Did the flipper hit the ball.
firstTime
protected boolean firstTime
- Used in options to see if the they happened once.
fromTop
protected int fromTop
- Location from top of screen to be considered in play.
fromBottom
protected int fromBottom
- Location from bottom of flippers to be considered out of play.
flipperHeight
protected int flipperHeight
- Anything moving below this be considered for flipping.
top
protected int top
- Location from bottom of screen to be considered out of play.
Gets value from fromTop.
outZone
protected int outZone
- Location from bottom of screen to be considered out of play.
Gets value from fromBottom.
outZoneLength
protected int outZoneLength
- Length of outZone.
outZoneEnd
protected int outZoneEnd
- End of outZone.
bottom
protected int bottom
- Location from the bottom at the screen to be considered out of play.
xTest
protected int xTest
- Used to test the x location of the ball. x location + xoffset
yTest
protected int yTest
- Used to test the y location of the ball. y location + yoffset
distanceFromLastSeen
protected int distanceFromLastSeen
- Ball's distance from the last known location of the ball.
biggestObject
protected int biggestObject
- Biggest Object.
smallestObject
protected int smallestObject
- Smallest Object.
lastLaunched
protected long lastLaunched
- Time last launched.
betweenLaunch
protected long betweenLaunch
- Time between launches.
distanceFromFlippers
protected int distanceFromFlippers
- Ball's distance from either the left or right flipper, depending on which
half of the screen it's on.
strategy
protected Strategy strategy
- The strategy to work on.
testingFlippers
protected boolean testingFlippers
- Are the flippers being tested.
queue
protected StrategyQueue queue
- The queue of waiting buffers.
plunger
protected Plunger plunger
- The plunger in the system.
startButton
protected StartButton startButton
- Starts a new game on the pinball machine.
ballReturn
protected BallReturn ballReturn
- The ball return device.
camera
protected Camera camera
- The camera in the system.
triedLaunch
protected int triedLaunch
- Number of tries to launch the ball.
model
protected ColorModel model
- The greyscale values for the painting of the image.
sendFrame
protected boolean sendFrame
- Send frame.
canvas
protected Canvas canvas
- Used for creating an image.
startOfGame
protected long startOfGame
- Start of game.
visualDetection
protected boolean visualDetection
- Visual Ball Detection.
timeStamp
protected boolean timeStamp
- Should the system report time stamps.
startDelay
protected boolean startDelay
- Should the system way a few seconds at the begining for a ball to return.
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.
Stub
public Stub()
- Needed for when this class is extended.
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.
toString
public String toString()
- Name of the object.
- Overrides:
- toString in class Thread
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
skipBuffer
protected void skipBuffer()
- Skip the buffer.
locateFlippers
public void locateFlippers()
- Locate the flippers in the game.
process
public void process()
- Process the blips found. Find the ball and decide on wheither to flip or not.
setBuffer
public void setBuffer(Buffer buffer)
- Set the buffer used by the stub.
- Parameters:
- buffer - the buffer to be used.
getRecentBuffer
public Buffer getRecentBuffer()
- Get the recent buffer from the queue.
- Returns:
- the recent buffer.
getNextBuffer
public Buffer getNextBuffer()
- Get the next buffer from the queue.
- Returns:
- the next buffer in the queue.
addBuffer
public void addBuffer(Buffer b)
- Adds a buffer to the queue.
- Parameters:
- b - the buffer to add.
isQueueEmpty
public boolean isQueueEmpty()
- Checks if the queue is empty.
- Returns:
- empty status.
getBlipsFrame
public int[][] getBlipsFrame()
- Get the frame of found objects.
- Returns:
- the blips frame.
getObjects
public Vector getObjects()
- Get the objects table.
setObjects
public void setObjects(Vector b)
- Set the blips in the buffer.
- Parameters:
- b - the blips found.
getRawFrame
public byte[] getRawFrame()
- Get the raw frame from the camera.
number
public int number()
- Get frame grabbed number.
- Returns:
- the number of this frame.
id
public int id()
- Get buffer's id.
- Returns:
- the id of this buffer.
blipx
public int blipx()
- Get the ball's x location.
- Returns:
- ball's x location
blipy
public int blipy()
- Get the ball's y location.
- Returns:
- ball's y location
blipx
public void blipx(int x)
- Set the ball's x location.
- Parameters:
- x - ball's x location
blipy
public void blipy(int y)
- Set the ball's y location.
- Parameters:
- y - ball's y location
time
public TimeStamp time()
- The time stamp used in the threads.
- Returns:
- the time stamp.
width
public int width()
- Get the width of the frame.
- Returns:
- width.
height
public int height()
- Get the height.
- Returns:
- height.
boarder
public void boarder(int b)
- Get the flipper boarder.
- Parameters:
- return - The size of the flipper boarder.
offsets
public void offsets(int x,
int y)
- Set the location of the offsets.
- Parameters:
- x - xoffset.
- y - yoffset.
resizeX
public int resizeX()
- Get the resize x size.
- Returns:
- x resize.
resizeY
public int resizeY()
- Get the resize y size.
- Returns:
- y resize.
resizeXOffset
public int resizeXOffset()
- Get the resize x offset.
- Returns:
- x resize offset.
resizeYOffset
public int resizeYOffset()
- Get the resize y offset.
- Returns:
- y resize offset.
XOffset
public int XOffset()
- Get the x offset.
- Returns:
- x offset.
YOffset
public int YOffset()
- Get the y offset.
- Returns:
- y offset.
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.
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.
resize
public boolean resize()
- Get the resize flag.
- Returns:
- resize flag.
resized
public void resized()
- Set the condition that it was resized.
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.
clearing
public boolean clearing()
- Get the clearing flag.
- Parameters:
- clearing - status.
flipperOffset
public int flipperOffset()
- Get the flipper offset.
Return flipper offset.
flipperOffset
public void flipperOffset(int i)
- Set the flipper offset.
- Parameters:
- i - flipper offset.
imageOffset
public void imageOffset(int i)
- Set the image offset.
- Parameters:
- i - the image offset.
imageOffset
public int imageOffset()
- Get the image offset.
- Returns:
- the image offset.
flipperFlipped
public boolean flipperFlipped()
- Get the flippers flipped condition.
- Returns:
- the status of the flippers flipped status.
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.
outZone
public void outZone(int out)
- Override the outZone value.
- Parameters:
- out - the new outZone value.
top
public int top()
- The top of the playfield.
- Returns:
- top of playfield.
bottom
public int bottom()
- The bottom of the playfield.
- Returns:
- bottom of playfield.
nextBuffer
public void nextBuffer()
- Go to the next information buffer.
getLock
public void getLock()
- Get the lock on the information buffer.
releaseLock
public void releaseLock()
- Release the lock on the information buffer.
releaseLock
public void releaseLock(Buffer b)
- Release the lock on the information buffer.
- Parameters:
- Buffer - b The buffer to unlock.
releaseLock
public void releaseLock(int buff)
- Release the lock on the information buffer.
- Parameters:
- int - b The buffer to unlock.
getBuffNumber
public int getBuffNumber()
leftFlipperState
public void leftFlipperState(boolean s)
- Set the state of the left flipper.
- Parameters:
- s - Flip state. True for up, false for down.
rightFlipperState
public void rightFlipperState(boolean s)
- Set the state of the right flipper.
- Parameters:
- s - Flip state. True for up, false for down.
flipperFlipped
public void flipperFlipped(boolean s)
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.
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.
isLeftUp
public boolean isLeftUp()
- Is the left flipper down.
- Returns:
- flipper's down status.
isRightUp
public boolean isRightUp()
- Is the right flipper down.
- Returns:
- flipper's down status.
isLeftDown
public boolean isLeftDown()
- Is the left flipper down.
- Returns:
- flipper's down status.
isRightDown
public boolean isRightDown()
- Is the right flipper down.
- Returns:
- flipper's down status.
storeBlips
public void storeBlips()
- Write the blips to the log file.
skipFrame
public void skipFrame()
- The frame was skipped.
skip
public boolean skip()
- Skip past some of the buffers, if there is more recent data in the system.
storeBall
public void storeBall()
- Save the ball's location to the log file.
filter
public void filter(boolean findFlippers)
- Filter out the ball from the other objects found.
- Parameters:
- findFlippers - Is the system finding the flippers.
statistics
public void statistics()
- Check the list of statistic events and see what to log.
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.
statsBallInPlay
public boolean statsBallInPlay()
- Check if ball is in play.
- Returns:
- ball's in play status.
ballIsInPlay
public void ballIsInPlay()
- Force ball in play
leftX
public int leftX()
- X location of left flipper.
- Returns:
- left flipper's x location.
leftY
public int leftY()
- Y location of left flipper.
- Returns:
- left flipper's y location.
rightX
public int rightX()
- X location of right flipper.
- Returns:
- right flipper's x location.
rightY
public int rightY()
- Y location of right flipper.
- Returns:
- right flipper's y location.
flipperZone
public int flipperZone()
- Get the flipper's zone.
- Returns:
- flipper zone.
outZone
public int outZone()
- Get the flipper's outzone.
- Returns:
- flipper outzone.
outZoneEnd
public int outZoneEnd()
- Get the end flipper's outzone.
- Returns:
- the end flipper outzone.
flipperStart
public int flipperStart()
- Get the start of the flipper's area.
- Returns:
- flipper's area
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.
headerInfo
public void headerInfo(String s)
- Write to the header of the log.
- Parameters:
- s - String to write.
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.
readFlippersFile
public void readFlippersFile()
- Read in the flipper's file to see where the flippers were previously located.
writeFlippersFile
public void writeFlippersFile()
- Write the flippers file, to store the locations of the flippers.
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.
launchBall
public void launchBall()
- Have the system launch the ball.
getImage
public Image getImage()
- Get a frame from the camera.
requestFrame
public void requestFrame()
- Get a frame from the camera.
sendFrame
public void sendFrame(boolean b)
- Set if the system should send a frame from the camera over the network.
sendFrame
public boolean sendFrame()
- Should the system send a frame from the camera over the network.
releaseAllBuffers
public void releaseAllBuffers()
- Release all the buffers from the queue.
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