|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectlt05_pkg.PolkaDot
public class PolkaDot
This class encapsulates a polka dot shape, which has a diameter, a color, and a position. It is also understood that a polka dot shape belongs to a PolkaDotDataModel, and that the model should be notified anytime a polka dot's state changes.
Constructor Summary | |
---|---|
PolkaDot(int xPos,
int yPos,
java.awt.Color col,
int diameter,
PolkaDotDataModel dataModel)
Construct a polka dot with the specified attributes. |
|
PolkaDot(java.awt.Point point,
java.awt.Color col,
int diameter,
PolkaDotDataModel dataModel)
Construct a polka dot with the specified attributes. |
Method Summary | |
---|---|
int |
compareTo(PolkaDot otherDot)
|
boolean |
contains(java.awt.Point p)
This method determines whether the passed point is contained within this polka dot |
void |
decreaseSize()
Method that decreases the size of this dot by 10%, while maintaining position of centre. |
void |
drawComponent(java.awt.Graphics2D graphics2D)
This method causes this polka dot to be drawn on the passed Graphics2D objects. |
boolean |
equals(java.lang.Object object)
|
java.awt.Point |
getCentrePoint()
This method returns the location of this polka dot, as denoted by the point that represents the centre point of this shape. |
java.awt.Point |
getLocationOfTopLeftAnchor()
This method returns the location of this polka dot, as denoted by the point that represents the anchor point (which is the upper left corner of this shape). |
static PolkaDot |
getRandom(int xDim,
int yDim,
PolkaDotDataModel dataModel)
This method generates a random polka dot, with a color randomly chosen from within a palette of 6 basic colors (red, orange, yellow, green, blue, magenta). |
static java.awt.Color |
getRandomColor()
Returns a color randomly chosen from within a palette of 6 basic colors (red, orange, yellow, green, blue, magenta). |
java.awt.Color |
getTheColor()
Get the color of this polka dot |
int |
getTheDiameter()
Get the diameter of this polka dot |
int |
hashCode()
|
void |
increaseSize()
Method that increases the size of this dot by 10%, while maintaining position of centre. |
boolean |
isDuplicate(PolkaDot dot)
Method that determines whether the passed dot is a duplicate of this dot. |
boolean |
isFilled()
Method that indicates whether this polka dot is a shape that is meant to be filled or unfilled |
void |
setFilled(boolean isFilled)
Method to specify whether this polka dot should be a filled or unfilled shape. |
void |
setTheColor(java.awt.Color newColor)
Specify the color of this Polka Dot and notify that model has changed (only if new color is different than current color). |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public PolkaDot(int xPos, int yPos, java.awt.Color col, int diameter, PolkaDotDataModel dataModel)
xPos
- the x-coordinate of the upper left hand anchor point of the
polka dot to be created.yPos
- the y-coordinate of the upper left hand anchor point of the
polka dot to be created.col
- the colour of the polka dot to be created.diameter
- the diameter of the polka dot to be created.dataModel
- the PolkaDotDataModel object to which this new polka dot
object will belongpublic PolkaDot(java.awt.Point point, java.awt.Color col, int diameter, PolkaDotDataModel dataModel)
point
- the upper left hand anchor point of the polka dot to be
created.col
- the colour of the polka dot to be created.diameter
- the diameter of the polka dot to be created.dataModel
- the PolkaDotDataModel object to which this new polka dot
object will belongMethod Detail |
---|
public void setTheColor(java.awt.Color newColor)
newColor
- public void increaseSize()
public void decreaseSize()
public java.awt.Color getTheColor()
public int getTheDiameter()
public void drawComponent(java.awt.Graphics2D graphics2D)
graphics2D
- public static PolkaDot getRandom(int xDim, int yDim, PolkaDotDataModel dataModel)
xDim
- yDim
- dataModel
-
public static java.awt.Color getRandomColor()
public java.awt.Point getLocationOfTopLeftAnchor()
public java.awt.Point getCentrePoint()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean contains(java.awt.Point p)
p
-
public boolean isDuplicate(PolkaDot dot)
dot
-
public boolean isFilled()
public void setFilled(boolean isFilled)
isFilled
- as described above (true for filled version)public int compareTo(PolkaDot otherDot)
compareTo
in interface java.lang.Comparable<PolkaDot>
public boolean equals(java.lang.Object object)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |