|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectinfpp.oceanlife.Ocean
public class Ocean
Implements the constructor of oceans, the ocean objects and the addition and removal of ocean objects.
Field Summary | |
---|---|
private int |
animationSpeed
The sleep time for ocean object threads. |
private java.lang.String |
BubbleIconLocation
The location of the icon to use for bubbles. |
private java.awt.Point |
ClickPosition
The position of the last mouse click |
private int |
depth
The width of the ocean. |
private java.lang.String |
FishIconLeftwardLocation
The location of the icon to use if the fish swims leftward and is not highlighted. |
private java.lang.String |
FishIconRightwardLocation
The location of the icon to use if the fish swims rightward and is not highlighted. |
private java.lang.String |
HighlightedBubbleIconLocation
The location of the icon to use for highlighted bubbles. |
private java.lang.String |
HighlightedFishIconLeftwardLocation
The location of the icon to use if the fish swims leftward and is highlighted. |
private java.lang.String |
HighlightedFishIconRightwardLocation
The location of the icon to use if the fish swims rightward and is highlighted. |
private java.lang.String |
HighlightedPlantIconLocation
The location of the icon to use for highlighted plants. |
private java.lang.String |
HighlightedStoneIconLocation
The location of the icon to use for highlighted stones. |
private int |
numberOfHighlightedObjects
Gives the number of currently highlighted objects. |
private java.awt.Color |
oceanBackgroundColor
The ocean background colour |
private boolean |
oceanGUIRunning
Indicates whether the GUI thread is currently running. |
private java.util.LinkedList<OceanObject> |
oceanObjects
The linked list that holds the information about ocean objects. |
private java.lang.String[] |
OceanObjectStrings
The types of ocean object available |
private java.lang.String |
OilBlobLocation
The location of the icon to use for oil blobs. |
private boolean |
oilCatastrophe
Indicates whether an oil catastrophe is happening. |
private java.lang.String |
PlantIconLocation
The location of the icon to use for plants. |
private java.lang.String |
StoneIconLocation
The location of the icon to use for stones. |
private int |
width
The width of the ocean. |
Constructor Summary | |
---|---|
Ocean(int width,
int depth,
java.util.LinkedList<OceanObject> oceanObjects)
|
Method Summary | |
---|---|
void |
addOceanObject(OceanObject obj)
|
boolean |
collisionDetected(OceanObject toAdd)
|
int |
getAnimationSpeed()
|
java.lang.String |
getBubbleIconLocation()
|
int |
getClassIndex(OceanObject obj)
|
java.awt.Point |
getClickPosition()
|
int |
getDepth()
|
java.lang.String |
getFishIconLeftwardLocation()
|
java.lang.String |
getFishIconRightwardLocation()
|
java.lang.String |
getHighlightedBubbleIconLocation()
|
java.lang.String |
getHighlightedFishIconLeftwardLocation()
|
java.lang.String |
getHighlightedFishIconRightwardLocation()
|
java.lang.String |
getHighlightedPlantIconLocation()
|
java.lang.String |
getHighlightedStoneIconLocation()
|
int |
getNumberOfHighlightedObjects()
|
int |
getObjectIndexFromClickPosition(java.awt.Point p)
|
java.awt.Color |
getOceanBackgroundColor()
|
java.util.LinkedList<OceanObject> |
getOceanObjects()
|
java.lang.String[] |
getOceanObjectStrings()
|
java.lang.String |
getOilBlobLocation()
|
java.lang.String |
getPlantIconLocation()
|
java.lang.String |
getStoneIconLocation()
|
int |
getWidth()
|
void |
highlight(OceanObject obj)
|
void |
initialiseOceanObjects(java.util.LinkedList<OceanObject> oceanObjects)
|
boolean |
isOceanGUIRunning()
|
boolean |
isOilCatastrophe()
|
boolean |
isPositionValid(OceanObject obj)
|
void |
removeOceanObject(int x)
|
void |
setAnimationSpeed(int animationSpeed)
|
void |
setClickPosition(java.awt.Point clickPosition)
|
void |
setDepth(int depth)
|
void |
setFishIconLeftwardLocation(java.lang.String fishIconLeftwardLocation)
|
void |
setFishIconRightwardLocation(java.lang.String fishIconRightwardLocation)
|
void |
setHighlightedFishIconLeftwardLocation(java.lang.String highlightedFishIconLeftwardLocation)
|
void |
setHighlightedFishIconRightwardLocation(java.lang.String highlightedFishIconRightwardLocation)
|
void |
setNumberOfHighlightedObjects(int numberOfHighlightedObjects)
|
void |
setOceanBackgroundColor(java.awt.Color oceanBackgroundColor)
|
void |
setOceanGUIRunning(boolean oceanRunning)
|
void |
setOceanObjectStrings(java.lang.String[] oceanObjectStrings)
|
void |
setOilBlobLocation(java.lang.String oilBlobLocation)
|
void |
setOilCatastrophe(boolean oilCatastrophe)
|
void |
setWidth(int width)
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private int width
private int depth
private int animationSpeed
private final java.util.LinkedList<OceanObject> oceanObjects
private java.awt.Color oceanBackgroundColor
private boolean oilCatastrophe
private java.awt.Point ClickPosition
private int numberOfHighlightedObjects
private boolean oceanGUIRunning
private java.lang.String[] OceanObjectStrings
private java.lang.String FishIconLeftwardLocation
private java.lang.String FishIconRightwardLocation
private java.lang.String HighlightedFishIconLeftwardLocation
private java.lang.String HighlightedFishIconRightwardLocation
private java.lang.String OilBlobLocation
private java.lang.String StoneIconLocation
private java.lang.String HighlightedStoneIconLocation
private java.lang.String BubbleIconLocation
private java.lang.String HighlightedBubbleIconLocation
private java.lang.String PlantIconLocation
private java.lang.String HighlightedPlantIconLocation
Constructor Detail |
---|
public Ocean(int width, int depth, java.util.LinkedList<OceanObject> oceanObjects) throws java.lang.Exception
width
- width of the oceandepth
- depth of the oceanoceanObjects
- objects in the ocean
java.lang.Exception
Method Detail |
---|
public java.lang.String getFishIconLeftwardLocation()
public java.lang.String getFishIconRightwardLocation()
public java.lang.String getHighlightedFishIconLeftwardLocation()
public java.lang.String getHighlightedFishIconRightwardLocation()
public void setFishIconLeftwardLocation(java.lang.String fishIconLeftwardLocation)
fishIconLeftwardLocation
- The location of the icon to use if the fish swims leftward and
is not highlighted.public void setFishIconRightwardLocation(java.lang.String fishIconRightwardLocation)
fishIconRightwardLocation
- The location of the icon to use if the fish swims rightward
and is not highlighted.public void setHighlightedFishIconLeftwardLocation(java.lang.String highlightedFishIconLeftwardLocation)
highlightedFishIconLeftwardLocation
- The location of the icon to use if the fish swims leftward and
is highlighted.public void setHighlightedFishIconRightwardLocation(java.lang.String highlightedFishIconRightwardLocation)
highlightedFishIconRightwardLocation
- The location of the icon to use if the fish swims rightward
and is highlighted.public java.lang.String getOilBlobLocation()
public void setOilBlobLocation(java.lang.String oilBlobLocation)
oilBlobLocation
- The location of the icon to use for oil blobs.public java.lang.String toString()
toString
in interface OceanInterface
toString
in class java.lang.Object
Object.toString()
public int getDepth()
getDepth
in interface OceanInterface
OceanInterface.getDepth()
public boolean isOceanGUIRunning()
public void setOceanGUIRunning(boolean oceanRunning)
oceanRunning
- a boolean indicating whether or not the GUI should run.public int getAnimationSpeed()
public void setAnimationSpeed(int animationSpeed)
animationSpeed
- the animationSpeed to setpublic int getWidth()
getWidth
in interface OceanInterface
public void setDepth(int depth) throws java.lang.Exception
setDepth
in interface OceanInterface
depth
- the depth of the ocean to set
exception
- for negative value
java.lang.Exception
- if the depth is negativepublic void setWidth(int width)
setWidth
in interface OceanInterface
width
- set the width of the ocean
exception
- for negative valuepublic java.lang.String[] getOceanObjectStrings()
public void setOceanObjectStrings(java.lang.String[] oceanObjectStrings)
oceanObjectStrings
- the oceanObjectStrings to setpublic java.awt.Color getOceanBackgroundColor()
public void setOceanBackgroundColor(java.awt.Color oceanBackgroundColor)
oceanBackgroundColor
- the oceanBackgroundColor to setpublic boolean isOilCatastrophe()
public void setOilCatastrophe(boolean oilCatastrophe)
oilCatastrophe
- a boolean signalling an impending oil catastrophepublic java.lang.String getStoneIconLocation()
public java.lang.String getHighlightedStoneIconLocation()
public java.lang.String getBubbleIconLocation()
public java.lang.String getHighlightedBubbleIconLocation()
public java.lang.String getPlantIconLocation()
public java.lang.String getHighlightedPlantIconLocation()
public java.util.LinkedList<OceanObject> getOceanObjects()
getOceanObjects
in interface OceanInterface
public java.awt.Point getClickPosition()
public void setClickPosition(java.awt.Point clickPosition)
clickPosition
- the
position of the last mouse click as reported by the GUI.public boolean isPositionValid(OceanObject obj)
public boolean collisionDetected(OceanObject toAdd)
toAdd
- an oceanObject that should be added to the ocean.
public void initialiseOceanObjects(java.util.LinkedList<OceanObject> oceanObjects) throws java.lang.Exception
initialiseOceanObjects
in interface OceanInterface
oceanObjects
- Sets ocean objects.
java.lang.IllegalArgumentException
- Throws exceptions for invalid ocean object positions.
java.lang.Exception
- if something went wrong during the initialisation, such as
objects being outside of the ocean.public int getObjectIndexFromClickPosition(java.awt.Point p)
public int getClassIndex(OceanObject obj)
obj
- the ocean object whose type we wish to know
public void highlight(OceanObject obj)
obj
- the object to highlight or unhighlight.public int getNumberOfHighlightedObjects()
public void setNumberOfHighlightedObjects(int numberOfHighlightedObjects)
numberOfHighlightedObjects
- the number of highlighted objects to set, should this be
necessary in the future.public void addOceanObject(OceanObject obj) throws java.lang.Exception
addOceanObject
in interface OceanInterface
obj
- the object to add
java.lang.Exception
- if the object cannot be added, eg due to a collision with an
existing object or it being added outside of the ocean.public void removeOceanObject(int x) throws java.lang.Exception
removeOceanObject
in interface OceanInterface
x
- the list index of the object in question.
java.lang.Exception
- if no object exists at the given index.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |