|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectppJava.serie04.oceanlife.OceanObject
public abstract class OceanObject
Objects in the Ocean
Field Summary | |
---|---|
private java.util.concurrent.CyclicBarrier |
barrier
|
private int[] |
borders
|
private javax.swing.ImageIcon |
imageIcon
|
private java.lang.String |
imagePath
|
private int |
imageSize
|
private int[] |
moveVector
|
private static int |
objectCount
|
private int[] |
offset
|
private int[] |
position
|
private static long |
serialVersionUID
|
Constructor Summary | |
---|---|
OceanObject()
Constructor for an Object, increases the object Count |
Method Summary | |
---|---|
int |
calcAbsDistance(int[] pos1,
int[] pos2)
Calculate the distance between two positions |
void |
changeDirections(OceanObject tempRefObject)
Change the direction in which to move of the object |
void |
checkBarrier()
|
void |
checkPosition(Ocean ocean)
Check if the position is in the Ocean |
protected javax.swing.ImageIcon |
createImageIcon(java.lang.String path,
java.lang.String description)
Returns an ImageIcon, or null if the path was invalid. |
int[] |
genRandomVector()
Generates a random vector for moving |
java.util.concurrent.CyclicBarrier |
getBarrier()
|
int[] |
getBorders()
Return the borders in which the object is allowed to move |
java.lang.String |
getClassName()
|
int[] |
getDiffVector(int[] position)
Calculate the difference of the X- and Y-Values of two positions |
int |
getDistance(int[] position)
Get the Distance to a position |
javax.swing.ImageIcon |
getImageIcon()
Return the Image to the object |
java.lang.String |
getImageResource()
Return the path of the Image to the Object |
int |
getImageSize()
Return the size of the Image to the Object |
int[] |
getMoveVector()
Return the move vector of the object |
static int |
getObjectCount()
Get the object count |
int[] |
getOffset()
Return the width and the height of the object |
int[] |
getPosition()
get the position of an object |
boolean |
hasSameDirection(OceanObject tempRefObject)
Have two objects the same X-direction? |
void |
incPosX(int i)
Increase the X-Value of the position by i |
void |
incPosY(int i)
Increase the Y-Value of the position by i |
boolean |
isVulnerableTo(OceanObject tempRefObject)
Can an object be eaten by another object? |
void |
moveStep()
Make one step in movement |
void |
normalizeImage()
Resizes the sprite of oceanObject |
void |
setBarrier(java.util.concurrent.CyclicBarrier barrier)
|
void |
setBorders(int[] borders)
Sets the borders in which the object is allowed to move |
void |
setImageIcon(javax.swing.ImageIcon image)
Sets the Image to the object |
void |
setImageResource(java.lang.String imageResource)
Set the path of the Image to the Object |
void |
setImageSize(int imageSize)
Sets the size of the Image |
void |
setMoveVector(int[] moveVector)
Sets the move vector of the object |
void |
setOffset(int[] offset)
Sets the width and the height of the object |
void |
setPosition(int[] position)
Sets the position of an object |
void |
switchMovementDirection(int[] signs)
Switch the direction in which to move |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.lang.Runnable |
---|
run |
Field Detail |
---|
private static final long serialVersionUID
private int[] position
private int[] moveVector
private int[] borders
private int[] offset
private static int objectCount
private transient java.util.concurrent.CyclicBarrier barrier
private java.lang.String imagePath
private javax.swing.ImageIcon imageIcon
private int imageSize
Constructor Detail |
---|
public OceanObject()
Method Detail |
---|
public java.lang.String getClassName()
public int[] genRandomVector()
public void checkBarrier()
public static int getObjectCount()
public int[] getPosition()
public void setPosition(int[] position)
position
- public void incPosX(int i)
i
- public void incPosY(int i)
i
- public void switchMovementDirection(int[] signs)
signs
- of the movement before switchingpublic int getDistance(int[] position)
position
-
public int calcAbsDistance(int[] pos1, int[] pos2)
pos1
- pos2
-
public int[] getDiffVector(int[] position)
position
-
public void checkPosition(Ocean ocean) throws OceanException
ocean
-
OceanException
- - if the position is not in the Oceanpublic void moveStep()
public void changeDirections(OceanObject tempRefObject)
tempRefObject
- public boolean hasSameDirection(OceanObject tempRefObject)
tempRefObject
-
public boolean isVulnerableTo(OceanObject tempRefObject)
tempRefObject
-
protected javax.swing.ImageIcon createImageIcon(java.lang.String path, java.lang.String description)
public java.lang.String toString()
toString
in class java.lang.Object
public void setImageResource(java.lang.String imageResource)
imageResource
- public java.lang.String getImageResource()
public void setMoveVector(int[] moveVector)
moveVector
- public int[] getMoveVector()
public void setBorders(int[] borders)
borders
- public int[] getBorders()
public void setOffset(int[] offset)
offset
- public int[] getOffset()
public void normalizeImage()
public void setImageIcon(javax.swing.ImageIcon image)
image
- public javax.swing.ImageIcon getImageIcon()
public int getImageSize()
public void setImageSize(int imageSize)
imageSize
- public void setBarrier(java.util.concurrent.CyclicBarrier barrier)
barrier
- the barrier to setpublic java.util.concurrent.CyclicBarrier getBarrier()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |