Class AbstractMapArchObject<A extends MapArchObject<A>>

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static @NotNull java.lang.String MAP_NAME_UNNAMED
      The name of an unnamed map.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addMapArchObjectListener​(@NotNull MapArchObjectListener listener)
      Registers an event listener.
      void addText​(@NotNull java.lang.String text)
      Appends 'text' to the map text.
      void beginTransaction()
      Starts a new transaction.
      @NotNull java.lang.String calculateTilePath​(@NotNull Direction direction, @Nullable MapFile mapFile)
      Calculate a single tile path in a particular direction.
      void calculateTilePaths​(@Nullable MapFile mapFile, @NotNull 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​(@Nullable java.lang.Object obj)  
      int getDarkness()
      Returns the light / darkness of this map.
      int getDifficulty()
      Returns the map's difficulty.
      @NotNull java.awt.Point getEnter()
      Returns the enter coordinates.
      int getEnterX()
      Returns the enter x coordinate.
      int getEnterY()
      Returns the enter y coordinate.
      @NotNull java.lang.String getMapName()
      Returns the map name.
      @NotNull Size2D getMapSize()
      Returns the map size.
      int getResetTimeout()
      Returns the reset timeout (in seconds).
      int getSwapTime()
      Returns the swap time (in ticks).
      @NotNull java.lang.String getText()
      Returns the message text.
      @NotNull java.lang.String getTilePath​(@NotNull 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​(@Nullable java.awt.Point pos)
      Checks whether the given coordinate is within map bounds.
      boolean isTilePathAuto​(@NotNull Direction direction, @Nullable MapFile mapFile)
      Determines whether a tiled map in the specified direction is automatic tiled path or not.
      void removeMapArchObjectListener​(@NotNull 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​(@NotNull java.lang.String name)
      Sets the map name.
      void setMapSize​(@NotNull 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​(@NotNull Direction direction, @NotNull java.lang.String tilePath)
      Sets a tile path.
      void updateModifiedAttribute​(@NotNull java.lang.String userName)
      Updates the "Modified:" attribute in the message text.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MAP_NAME_UNNAMED

        @NotNull
        public static final @NotNull java.lang.String MAP_NAME_UNNAMED
        The name of an unnamed map.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractMapArchObject

        protected AbstractMapArchObject()
        Creates a new instance.
      • AbstractMapArchObject

        protected AbstractMapArchObject​(@NotNull
                                        @NotNull AbstractMapArchObject<A> mapArchObject)
        Creates a new instance as a copy of another map arch object.
        Parameters:
        mapArchObject - the other map arch object
    • Method Detail

      • setMapName

        public void setMapName​(@NotNull
                               @NotNull java.lang.String name)
        Description copied from interface: MapArchObject
        Sets the map name.
        Specified by:
        setMapName in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        name - the new map name
      • setEnterX

        public void setEnterX​(int enterX)
        Description copied from interface: MapArchObject
        Sets the enter x coordinate.
        Specified by:
        setEnterX in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        enterX - the new enter x coordinate
      • setEnterY

        public void setEnterY​(int enterY)
        Description copied from interface: MapArchObject
        Sets the enter y coordinate.
        Specified by:
        setEnterY in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        enterY - the new enter y coordinate
      • getEnter

        @NotNull
        public @NotNull java.awt.Point getEnter()
        Description copied from interface: MapArchObject
        Returns the enter coordinates.
        Specified by:
        getEnter in interface MapArchObject<A extends MapArchObject<A>>
        Returns:
        the enter coordinates
      • isOutdoor

        public boolean isOutdoor()
        Description copied from interface: MapArchObject
        Returns whether the map is an "outdoor" map.
        Specified by:
        isOutdoor in interface MapArchObject<A extends MapArchObject<A>>
        Returns:
        whether the map is an "outdoor" map
      • setOutdoor

        public void setOutdoor​(boolean outdoor)
        Description copied from interface: MapArchObject
        Sets whether the map is an "outdoor" map.
        Specified by:
        setOutdoor in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        outdoor - whether the map is an "outdoor" map
      • setResetTimeout

        public void setResetTimeout​(int resetTimeout)
        Description copied from interface: MapArchObject
        Sets the reset timeout (in seconds).
        Specified by:
        setResetTimeout in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        resetTimeout - the new reset timeout (in seconds)
      • setSwapTime

        public void setSwapTime​(int swapTime)
        Description copied from interface: MapArchObject
        Sets the swap time (in ticks).
        Specified by:
        setSwapTime in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        swapTime - the swap time (in ticks)
      • setDifficulty

        public void setDifficulty​(int difficulty)
        Description copied from interface: MapArchObject
        Sets the map's difficulty.
        Specified by:
        setDifficulty in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        difficulty - the new difficulty for this map
      • isFixedReset

        public boolean isFixedReset()
        Description copied from interface: MapArchObject
        Returns whether this map uses a fixed reset.
        Specified by:
        isFixedReset in interface MapArchObject<A extends MapArchObject<A>>
        Returns:
        whether this map uses a fixed reset
      • setFixedReset

        public void setFixedReset​(boolean fixedReset)
        Description copied from interface: MapArchObject
        Sets whether this map uses a fixed reset.
        Specified by:
        setFixedReset in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        fixedReset - whether this map should use a fixed reset
      • getDarkness

        public int getDarkness()
        Description copied from interface: MapArchObject
        Returns the light / darkness of this map. (0 means fully bright)
        Specified by:
        getDarkness in interface MapArchObject<A extends MapArchObject<A>>
        Returns:
        the light / darkness of this map
      • setDarkness

        public void setDarkness​(int darkness)
        Description copied from interface: MapArchObject
        Sets the light / darkness of this map.
        Specified by:
        setDarkness in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        darkness - the new light / darkness of this map
      • getTilePath

        @NotNull
        public @NotNull java.lang.String getTilePath​(@NotNull
                                                     @NotNull Direction direction)
        Description copied from interface: MapArchObject
        Returns a tile path.
        Specified by:
        getTilePath in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        direction - the tile path direction
        Returns:
        the tile path
      • setTilePath

        public void setTilePath​(@NotNull
                                @NotNull Direction direction,
                                @NotNull
                                @NotNull java.lang.String tilePath)
        Description copied from interface: MapArchObject
        Sets a tile path.
        Specified by:
        setTilePath in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        direction - the tile path direction
        tilePath - the new tile path
      • calculateTilePath

        @NotNull
        public @NotNull java.lang.String calculateTilePath​(@NotNull
                                                           @NotNull Direction direction,
                                                           @Nullable
                                                           @Nullable MapFile mapFile)
        Description copied from interface: MapArchObject
        Calculate a single tile path in a particular direction.
        Specified by:
        calculateTilePath in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        direction - the direction
        mapFile - map file
        Returns:
        Calculated tile path, empty string on failure.
      • calculateTilePaths

        public void calculateTilePaths​(@Nullable
                                       @Nullable MapFile mapFile,
                                       @NotNull
                                       @NotNull java.io.File mapsDirectory)
        Description copied from interface: MapArchObject
        Calculates tiled paths for the map automatically.
        Specified by:
        calculateTilePaths in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        mapFile - map file
        mapsDirectory - maps directory
      • isTilePathAuto

        public boolean isTilePathAuto​(@NotNull
                                      @NotNull Direction direction,
                                      @Nullable
                                      @Nullable MapFile mapFile)
        Description copied from interface: MapArchObject
        Determines whether a tiled map in the specified direction is automatic tiled path or not.
        Specified by:
        isTilePathAuto in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        direction - direction of the tiled map
        mapFile - map file
        Returns:
        Whether the tile is automatic.
      • setState

        public void setState​(@NotNull
                             A mapArchObject)
        Description copied from interface: MapArchObject
        Resets the state of this object to the state of the given map arch object.
        Specified by:
        setState in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        mapArchObject - the map arch object to copy the state from
      • equals

        public boolean equals​(@Nullable
                              @Nullable java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • setModified

        protected void setModified()
        Marks this map arch object as changed. The map arch object then notifies the registered listeners of the change at the end of the transaction.
      • endTransaction

        public void endTransaction​(boolean fireEvent)
        Description copied from interface: MapArchObject
        Ends a transaction. Invoking this method will reduce the transaction depth by only 1.

        Ending a nested operation is a cheap operation. Ending a transaction without changes also is a cheap operation.

        If the last transaction is ended, the changes are committed.

        An example where setting 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.

        Specified by:
        endTransaction in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        fireEvent - true if an event should be fired even in case this doesn't end the outermost transaction.
        See Also:
        MapArchObject.beginTransaction(), MapArchObject.endTransaction()
      • addText

        public void addText​(@NotNull
                            @NotNull java.lang.String text)
        Description copied from interface: MapArchObject
        Appends 'text' to the map text.
        Specified by:
        addText in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        text - the string to add
      • setText

        public void setText​(java.lang.String text)
        Description copied from interface: MapArchObject
        Sets the map text.
        Specified by:
        setText in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        text - the new map text
      • getText

        @NotNull
        public @NotNull java.lang.String getText()
        Description copied from interface: MapArchObject
        Returns the message text.
        Specified by:
        getText in interface MapArchObject<A extends MapArchObject<A>>
        Returns:
        the message text
      • updateModifiedAttribute

        public void updateModifiedAttribute​(@NotNull
                                            @NotNull java.lang.String userName)
        Description copied from interface: MapArchObject
        Updates the "Modified:" attribute in the message text.
        Specified by:
        updateModifiedAttribute in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        userName - the user name to include
      • isPointValid

        public boolean isPointValid​(@Nullable
                                    @Nullable java.awt.Point pos)
        Description copied from interface: MapArchObject
        Checks whether the given coordinate is within map bounds.
        Specified by:
        isPointValid in interface MapArchObject<A extends MapArchObject<A>>
        Parameters:
        pos - the coordinates to check
        Returns:
        true if the given coordinates are on the map, otherwise false (also returns false if pos == null)