|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectballworld.model.BallModel
public class BallModel
The model that represents the balls and their associated control systems. The balls are held by a Dispatcher which is used for all communications to the balls. Uses a Timer object to update the model and the view at a regular time slice. This will give the effect of animation.�
Field Summary | |
---|---|
private Dispatcher |
_dispatcher
The dispatcher that updates all the balls. |
private IPaintStrategyFac |
_errorPaintStrategyFac
|
private IUpdateStrategyFac |
_errorUpdateStrategyFac
A factory for a beeping error strategy that beeps the speaker every 25 updates. |
private int |
_MaxRadius
The maximum radius for a new ball |
private int |
_MaxSpeed
The maximum speed for a new ball. |
private java.awt.Rectangle |
_MaxVel
The bounds for the velocity of a new ball |
private int |
_MinRadius
The minimum radius for a new ball |
private SwitcherStrategy |
_switcher
The one switcher strategy instance in the system. |
private javax.swing.Timer |
_timer
The timer that controls when the balls are periodically updated. |
private int |
_timeSlice
The time interval between timer ticks, in milliseconds |
private javax.swing.Timer |
_updateTimer
|
private int |
_updateTimeSlice
|
private IRandomizer |
rand
Randomizer utility object, used for random values for new balls |
private IViewControlAdapter |
viewCtrlAdpt
Adapter to the view for control tasks. |
private IViewUpdateAdapter |
viewUpdateAdpt
Adapter to the view for updating tasks |
Constructor Summary | |
---|---|
BallModel(IViewControlAdapter viewCtrlAdpt,
IViewUpdateAdapter viewUpdateAdpt)
Constructor for the model |
Method Summary | |
---|---|
void |
clearBalls()
Clear all the ball from the system. |
IUpdateStrategyFac |
combineStrategyFacs(IUpdateStrategyFac stratFac1,
IUpdateStrategyFac stratFac2)
Returns an IStrategyFac that can instantiate a MultiStrategy with the two strategies made by the two given IUpdateStrategyFac objects. |
private java.lang.String |
fixName(java.lang.String folder,
java.lang.Object classname,
java.lang.String append)
Fixes abbreviated, shortened names by adding the "ballworld.model.strategy." package part of the name and adding a "Strategy" suffix to the name. |
SwitcherStrategy |
getSwitcherStrategy()
Getter for the one switcher strategy instance |
void |
loadBall(IUpdateStrategy updateStrategy,
IPaintStrategy paintStrategy)
Load a ball into the system, where the ball uses the given update strategy instance. |
IPaintStrategy |
loadPaintStrategy(java.lang.String className)
Uses dynamic class loading to load and instantiate an IUpdateStrategy implementation, given its class name. |
IUpdateStrategy |
loadUpdateStrategy(java.lang.String className)
Uses dynamic class loading to load and instantiate an IUpdateStrategy implementation, given its class name. |
IPaintStrategyFac |
makePaintStrategyFac(java.lang.String classname)
Returns an IPaintStrategyFac that can instantiate the strategy specified by classname. |
IUpdateStrategyFac |
makeUpdateStrategyFac(java.lang.String classname)
Returns an IUpdateStrategyFac that can instantiate the strategy specified by classname. |
void |
start()
Start the model, in particular, start the timer. |
void |
switchSwitcherStrategy(IUpdateStrategy strat)
Change the switcher strategy's decoree to the supplied strategy |
void |
update(java.lang.Object g)
Update all the balls in the system, passing the given input parameter. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private SwitcherStrategy _switcher
private IRandomizer rand
private int _MaxRadius
private int _MinRadius
private int _MaxSpeed
private java.awt.Rectangle _MaxVel
private Dispatcher _dispatcher
private int _timeSlice
private javax.swing.Timer _timer
private IViewControlAdapter viewCtrlAdpt
private IViewUpdateAdapter viewUpdateAdpt
private int _updateTimeSlice
private javax.swing.Timer _updateTimer
private IUpdateStrategyFac _errorUpdateStrategyFac
private IPaintStrategyFac _errorPaintStrategyFac
Constructor Detail |
---|
public BallModel(IViewControlAdapter viewCtrlAdpt, IViewUpdateAdapter viewUpdateAdpt)
viewCtrlAdpt
- The view adapter for control tasksviewUpdateAdpt
- The view adapter for updating tasksMethod Detail |
---|
public void loadBall(IUpdateStrategy updateStrategy, IPaintStrategy paintStrategy)
updateStrategy
- An IUpdateStrategy for the new ball to use.paintStrategy
- An IPaintStrategy for the new ball to use.public void start()
public void clearBalls()
public void update(java.lang.Object g)
g
- An input parameter to give to each ball's update method.private java.lang.String fixName(java.lang.String folder, java.lang.Object classname, java.lang.String append)
folder
- TODOclassname
- The abbreviated, shortened nameappend
- TODO
public IUpdateStrategy loadUpdateStrategy(java.lang.String className)
className
- The fully qualified classname of a strategy
public IPaintStrategy loadPaintStrategy(java.lang.String className)
className
- The fully qualified classname of a strategy
public IUpdateStrategyFac makeUpdateStrategyFac(java.lang.String classname)
classname
- Shortened name of desired strategy
public IUpdateStrategyFac combineStrategyFacs(IUpdateStrategyFac stratFac1, IUpdateStrategyFac stratFac2)
stratFac1
- An IUpdateStrategyFac for a strategystratFac2
- An IUpdateStrategyFac for a strategy
public SwitcherStrategy getSwitcherStrategy()
public void switchSwitcherStrategy(IUpdateStrategy strat)
strat
- the new decoree for the switcherpublic IPaintStrategyFac makePaintStrategyFac(java.lang.String classname)
classname
- Shortened name of desired strategy
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |