public abstract class AbstractMapArchObject<A extends MapArchObject<A>> extends java.lang.Object implements MapArchObject<A>
MapArchObject
that covers similarities between
Crossfire maps and Daimonin maps.hashCode()
and equals(Object)
work on non-final fields and thus will break any operation
inside Collections!Modifier and Type | Field and Description |
---|---|
static java.lang.String |
MAP_NAME_UNNAMED
The name of an unnamed map.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractMapArchObject()
Creates a new instance.
|
protected |
AbstractMapArchObject(AbstractMapArchObject<A> mapArchObject)
Creates a new instance as a copy of another map arch object.
|
Modifier and Type | Method and Description |
---|---|
void |
addMapArchObjectListener(MapArchObjectListener listener)
Registers an event listener.
|
void |
addText(java.lang.String text)
Appends 'text' to the map text.
|
void |
beginTransaction()
Starts a new transaction.
|
java.lang.String |
calculateTilePath(Direction direction,
MapFile mapFile)
Calculate a single tile path in a particular direction.
|
void |
calculateTilePaths(MapFile mapFile,
java.io.File mapsDirectory)
Calculates tiled paths for the map automatically.
|
void |
endTransaction()
Ends a transaction.
|
void |
endTransaction(boolean fireEvent)
Ends a transaction.
|
boolean |
equals(java.lang.Object obj) |
int |
getDarkness()
Returns the light / darkness of this map.
|
int |
getDifficulty()
Returns the map's difficulty.
|
java.awt.Point |
getEnter()
Returns the enter coordinates.
|
int |
getEnterX()
Returns the enter x coordinate.
|
int |
getEnterY()
Returns the enter y coordinate.
|
java.lang.String |
getMapName()
Returns the map name.
|
Size2D |
getMapSize()
Returns the map size.
|
int |
getResetTimeout()
Returns the reset timeout (in seconds).
|
int |
getSwapTime()
Returns the swap time (in ticks).
|
java.lang.String |
getText()
Returns the message text.
|
protected abstract A |
getThis()
Returns this map arch object cast to its real type.
|
java.lang.String |
getTilePath(Direction direction)
Returns a tile path.
|
int |
getTilePaths()
Returns the number of tile paths.
|
int |
hashCode() |
boolean |
isFixedReset()
Returns whether this map uses a fixed reset.
|
boolean |
isOutdoor()
Returns whether the map is an "outdoor" map.
|
boolean |
isPointValid(java.awt.Point pos)
Checks whether the given coordinate is within map bounds.
|
boolean |
isTilePathAuto(Direction direction,
MapFile mapFile)
Determines whether a tiled map in the specified direction is automatic
tiled path or not.
|
void |
removeMapArchObjectListener(MapArchObjectListener listener)
Unregisters an event listener.
|
void |
setDarkness(int darkness)
Sets the light / darkness of this map.
|
void |
setDifficulty(int difficulty)
Sets the map's difficulty.
|
void |
setEnterX(int enterX)
Sets the enter x coordinate.
|
void |
setEnterY(int enterY)
Sets the enter y coordinate.
|
void |
setFixedReset(boolean fixedReset)
Sets whether this map uses a fixed reset.
|
void |
setMapName(java.lang.String name)
Sets the map name.
|
void |
setMapSize(Size2D mapSize)
Sets the map size.
|
protected void |
setModified()
Marks this map arch object as changed.
|
void |
setOutdoor(boolean outdoor)
Sets whether the map is an "outdoor" map.
|
void |
setResetTimeout(int resetTimeout)
Sets the reset timeout (in seconds).
|
void |
setState(A mapArchObject)
Resets the state of this object to the state of the given map arch
object.
|
void |
setSwapTime(int swapTime)
Sets the swap time (in ticks).
|
void |
setText(java.lang.String text)
Sets the map text.
|
void |
setTilePath(Direction direction,
java.lang.String tilePath)
Sets a tile path.
|
void |
updateModifiedAttribute(java.lang.String userName)
Updates the "Modified:" attribute in the message text.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
createClone
@NotNull public static final java.lang.String MAP_NAME_UNNAMED
protected AbstractMapArchObject()
protected AbstractMapArchObject(@NotNull AbstractMapArchObject<A> mapArchObject)
mapArchObject
- the other map arch object@NotNull public Size2D getMapSize()
getMapSize
in interface MapArchObject<A extends MapArchObject<A>>
public void setMapSize(@NotNull Size2D mapSize)
setMapSize
in interface MapArchObject<A extends MapArchObject<A>>
mapSize
- the new map size@NotNull public java.lang.String getMapName()
getMapName
in interface MapArchObject<A extends MapArchObject<A>>
public void setMapName(@NotNull java.lang.String name)
setMapName
in interface MapArchObject<A extends MapArchObject<A>>
name
- the new map namepublic int getEnterX()
getEnterX
in interface MapArchObject<A extends MapArchObject<A>>
public void setEnterX(int enterX)
setEnterX
in interface MapArchObject<A extends MapArchObject<A>>
enterX
- the new enter x coordinatepublic int getEnterY()
getEnterY
in interface MapArchObject<A extends MapArchObject<A>>
public void setEnterY(int enterY)
setEnterY
in interface MapArchObject<A extends MapArchObject<A>>
enterY
- the new enter y coordinate@NotNull public java.awt.Point getEnter()
getEnter
in interface MapArchObject<A extends MapArchObject<A>>
public boolean isOutdoor()
isOutdoor
in interface MapArchObject<A extends MapArchObject<A>>
public void setOutdoor(boolean outdoor)
setOutdoor
in interface MapArchObject<A extends MapArchObject<A>>
outdoor
- whether the map is an "outdoor" mappublic int getResetTimeout()
getResetTimeout
in interface MapArchObject<A extends MapArchObject<A>>
public void setResetTimeout(int resetTimeout)
setResetTimeout
in interface MapArchObject<A extends MapArchObject<A>>
resetTimeout
- the new reset timeout (in seconds)public int getSwapTime()
getSwapTime
in interface MapArchObject<A extends MapArchObject<A>>
public void setSwapTime(int swapTime)
setSwapTime
in interface MapArchObject<A extends MapArchObject<A>>
swapTime
- the swap time (in ticks)public int getDifficulty()
getDifficulty
in interface MapArchObject<A extends MapArchObject<A>>
public void setDifficulty(int difficulty)
setDifficulty
in interface MapArchObject<A extends MapArchObject<A>>
difficulty
- the new difficulty for this mappublic boolean isFixedReset()
isFixedReset
in interface MapArchObject<A extends MapArchObject<A>>
public void setFixedReset(boolean fixedReset)
setFixedReset
in interface MapArchObject<A extends MapArchObject<A>>
fixedReset
- whether this map should use a fixed resetpublic int getDarkness()
getDarkness
in interface MapArchObject<A extends MapArchObject<A>>
public void setDarkness(int darkness)
setDarkness
in interface MapArchObject<A extends MapArchObject<A>>
darkness
- the new light / darkness of this mappublic int getTilePaths()
getTilePaths
in interface MapArchObject<A extends MapArchObject<A>>
@NotNull public java.lang.String getTilePath(@NotNull Direction direction)
getTilePath
in interface MapArchObject<A extends MapArchObject<A>>
direction
- the tile path directionpublic void setTilePath(@NotNull Direction direction, @NotNull java.lang.String tilePath)
setTilePath
in interface MapArchObject<A extends MapArchObject<A>>
direction
- the tile path directiontilePath
- the new tile path@NotNull public java.lang.String calculateTilePath(@NotNull Direction direction, @Nullable MapFile mapFile)
calculateTilePath
in interface MapArchObject<A extends MapArchObject<A>>
direction
- the directionmapFile
- map filepublic void calculateTilePaths(@Nullable MapFile mapFile, @NotNull java.io.File mapsDirectory)
calculateTilePaths
in interface MapArchObject<A extends MapArchObject<A>>
mapFile
- map filemapsDirectory
- maps directorypublic boolean isTilePathAuto(@NotNull Direction direction, @Nullable MapFile mapFile)
isTilePathAuto
in interface MapArchObject<A extends MapArchObject<A>>
direction
- direction of the tiled mapmapFile
- map filepublic void setState(@NotNull A mapArchObject)
setState
in interface MapArchObject<A extends MapArchObject<A>>
mapArchObject
- the map arch object to copy the state frompublic boolean equals(@Nullable java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public void addMapArchObjectListener(@NotNull MapArchObjectListener listener)
addMapArchObjectListener
in interface MapArchObject<A extends MapArchObject<A>>
listener
- the listener to registerpublic void removeMapArchObjectListener(@NotNull MapArchObjectListener listener)
removeMapArchObjectListener
in interface MapArchObject<A extends MapArchObject<A>>
listener
- the listener to unregisterprotected void setModified()
public void beginTransaction()
MapArchObject.endTransaction()
.
Beginning a nested transaction is a cheap operation.beginTransaction
in interface MapArchObject<A extends MapArchObject<A>>
MapArchObject.endTransaction()
,
MapArchObject.endTransaction(boolean)
public void endTransaction()
endTransaction(false)
.endTransaction
in interface MapArchObject<A extends MapArchObject<A>>
MapArchObject.beginTransaction()
,
MapArchObject.endTransaction(boolean)
public void endTransaction(boolean fireEvent)
fireEvent
to true
is useful even though the
outermost transaction is not ended is when during painting the UI should
be updated though painting is not finished.endTransaction
in interface MapArchObject<A extends MapArchObject<A>>
fireEvent
- true
if an event should be fired even in case
this doesn't end the outermost transaction.MapArchObject.beginTransaction()
,
MapArchObject.endTransaction()
public void addText(@NotNull java.lang.String text)
addText
in interface MapArchObject<A extends MapArchObject<A>>
text
- the string to addpublic void setText(java.lang.String text)
setText
in interface MapArchObject<A extends MapArchObject<A>>
text
- the new map text@NotNull public java.lang.String getText()
getText
in interface MapArchObject<A extends MapArchObject<A>>
public void updateModifiedAttribute(@NotNull java.lang.String userName)
updateModifiedAttribute
in interface MapArchObject<A extends MapArchObject<A>>
userName
- the user name to includepublic boolean isPointValid(@Nullable java.awt.Point pos)
isPointValid
in interface MapArchObject<A extends MapArchObject<A>>
pos
- the coordinates to checktrue
if the given coordinates are on the map, otherwise
false
(also returns false
if pos == null
)@NotNull protected abstract A getThis()