|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.haphazard.gui.engine.GraphicalObject
Superclass for anything that can exist on a map
Field Summary | |
long |
id
A unique id for the object |
protected Sprite |
mDefaultSprite
The default look |
protected java.lang.String |
mDescription
the description of the object |
protected java.awt.Color |
mDescriptionColor
The color of the description text |
protected long |
mDescriptionDisplayTime
The duration for displaying the description |
protected long |
mDescriptionStartTime
The time the description started displaying |
protected Dimension3D |
mDimension
The volume of the object in cm x cm x cm |
java.lang.String |
mLink
Where the object was loaded from originally |
protected java.lang.String |
mName
The name of the object |
protected Sprite |
mSpriteDisplayed
|
protected java.util.Hashtable |
mSprites
|
protected int |
mWeight
The weight of the object in grams |
Constructor Summary | |
GraphicalObject()
Creates a new graphical object |
|
GraphicalObject(Sprite defaultSprite)
The constructor updates the map |
Method Summary | |
void |
addSprite(Sprite sprite)
Adds a sprite to this object |
boolean |
combineSprites(java.lang.String baseSprite,
java.lang.String frontSprite,
java.lang.String newSpriteName)
Combines two Sprites to one new. |
void |
displayDescription(long displayTime,
java.awt.Color color)
Sets the time to display the description |
void |
displaySprite(java.lang.String spriteKey)
Sets the sprite to be displayed according to the spriteKey and flippedVertically. |
java.util.Enumeration |
getAvailableSprites()
Gets the available sprites |
java.awt.Rectangle |
getBoundingBox(java.awt.Point middleTileCoordinate)
Return the bounding box on the screen of this Frame of the Sprite that is displayed. |
java.lang.String |
getDescription()
returns the description for this graphical object |
Dimension3D |
getDimension()
Gets this objects dimension |
java.lang.String |
getName()
Gets the name of the graphical object |
Sprite |
getNotResettedSprite(java.lang.String spriteKey)
Gets a specific sprite that is reseted. |
Sprite |
getResettedSprite(java.lang.String spriteKey)
Gets a specific sprite that is resetted. |
int |
getWeight()
Gets the weight of the item |
boolean |
isDefaultSpriteDisplayed()
checks if the defaultSprite is displayed. |
void |
load(java.io.InputStream stream)
Loads an object from a file |
static GraphicalObject |
loadInstance(java.io.InputStream input)
Loads an instance of GraphicalObject |
void |
optimize()
Optimizes the clipping rectangle of all sprites |
boolean |
paintComponent(java.awt.Graphics2D g,
Map map,
java.awt.Point middleTileScreenCoord)
Paints the component |
void |
resetDisplayedSprite()
Resets this DynamicGraphicalObject to displayed its defaultSprite |
void |
save(java.io.OutputStream stream)
Saves the object in an XML-file |
void |
setDefaultSprite(Sprite sprite)
Sets the default sprite. |
void |
setDefaultSprite(java.lang.String spriteKey)
Sets what sprite should be displayed as default. |
void |
setDescription(java.lang.String description)
sets the description for this graphical object FIXME: format the string to a nice format . |
void |
setDimension(Dimension3D dimension)
Sets this objects dimension |
void |
setName(java.lang.String name)
Sets the name of the graphical object |
void |
setWeight(int weight)
Sets the weight of the item |
java.lang.String |
toString()
Returns this GraphicalObject as a string. |
java.lang.String |
toXML(int indent)
Transforms this object into XML-notation |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected java.lang.String mName
protected java.lang.String mDescription
protected Dimension3D mDimension
protected int mWeight
public java.lang.String mLink
public long id
protected long mDescriptionDisplayTime
protected long mDescriptionStartTime
protected java.awt.Color mDescriptionColor
protected Sprite mDefaultSprite
protected Sprite mSpriteDisplayed
protected java.util.Hashtable mSprites
Constructor Detail |
public GraphicalObject()
public GraphicalObject(Sprite defaultSprite)
defaultSprite
- which sprite should be defaultMethod Detail |
public void setName(java.lang.String name)
name
- The name to setpublic java.lang.String getName()
public void setDescription(java.lang.String description)
description
- the description for the objectpublic java.lang.String getDescription()
public int getWeight()
public void setWeight(int weight)
weight
- The weight in gramspublic void setDimension(Dimension3D dimension)
dimension
- The dimension to be setpublic Dimension3D getDimension()
public java.awt.Rectangle getBoundingBox(java.awt.Point middleTileCoordinate)
middleTileCoordinate
- The middle coordinate of the tile the object is residing on
public void addSprite(Sprite sprite)
sprite
- The sprite to addpublic void setDefaultSprite(Sprite sprite)
sprite
- The sprite to set as the default spritepublic void setDefaultSprite(java.lang.String spriteKey)
spriteKey
- the "name" of the sprite to be set as defaultpublic java.util.Enumeration getAvailableSprites()
public void displayDescription(long displayTime, java.awt.Color color)
displayTime
- the time to display the description in milliseconds
if displayTime == -1 then it is always displayedcolor
- the color for the descriptionpublic void displaySprite(java.lang.String spriteKey)
spriteKey
- the "name" of the spritepublic Sprite getResettedSprite(java.lang.String spriteKey)
spriteKey
- the name of the sprite to be returned
public Sprite getNotResettedSprite(java.lang.String spriteKey)
spriteKey
- the name of the sprite to be returned
public void resetDisplayedSprite()
public boolean isDefaultSpriteDisplayed()
public boolean paintComponent(java.awt.Graphics2D g, Map map, java.awt.Point middleTileScreenCoord)
middleTileScreenCoord
- The middle coordinate of the tile the object is residing ong
- The graphics control to use to paint this objectmap
- this is user by the DynamicGraphicalObject for calculating moves on a tile
public void optimize()
public boolean combineSprites(java.lang.String baseSprite, java.lang.String frontSprite, java.lang.String newSpriteName)
baseSprite
- the name of the sprite that serves as a basefrontSprite
- the name of the sprite that should be in frontnewSpriteName
- the name of the new sprite
public void save(java.io.OutputStream stream)
stream
- The stream to save topublic static GraphicalObject loadInstance(java.io.InputStream input)
input
- The input for the stream
public void load(java.io.InputStream stream)
stream
- The stream to loadpublic java.lang.String toXML(int indent)
indent
- The level of indentation to use
public java.lang.String toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |