|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlt05_pkg.PolkaDotDataModel
public class PolkaDotDataModel
This class encapsulates a data model of a collection of polka dots. It initializes itself with 6 randomly selected polka dots. Duplicate polka dots are not permitted. Two polka dots are considered duplicate if they have the same centre points.
Constructor Summary | |
---|---|
PolkaDotDataModel()
Creates a collection and initialized it with three polka dots |
Method Summary | |
---|---|
boolean |
addDot(PolkaDot theDot)
Add the passed polka dot to this collection. |
void |
addListener(ModelListener listener)
Add a listener to this model. |
PolkaDot |
getClosestShape(java.awt.Point p)
This method returns the polka dot in this model that is closest to the passed point. |
java.util.Set<PolkaDot> |
getDots()
Return this collection as a List of PolkaDot objects. |
PolkaDot |
getMatchingDot(java.awt.Point p)
This method returns the polka dot in this model that the passed point hits. |
void |
notifyModelHasChanged()
|
void |
setTheColor(PolkaDot p,
java.awt.Color c)
|
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public PolkaDotDataModel()
Method Detail |
---|
public void addListener(ModelListener listener)
listener
- public void notifyModelHasChanged()
public java.util.Set<PolkaDot> getDots()
public boolean addDot(PolkaDot theDot)
theDot
- a non-null Polka Dot object
public PolkaDot getClosestShape(java.awt.Point p)
p
-
public PolkaDot getMatchingDot(java.awt.Point p)
p
-
public void setTheColor(PolkaDot p, java.awt.Color c)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |