Class AbstractGUIMap

All Implemented Interfaces:
GUIElement, ImageObserver, MenuContainer, Serializable
Direct Known Subclasses:
GUIMap, GUIMiniMap

public abstract class AbstractGUIMap extends AbstractGUIElement
Abstract base class for GUIElements that display map views.
See Also:
  • Constructor Details

    • AbstractGUIMap

      protected AbstractGUIMap(boolean avoidCopyArea, @NotNull @NotNull TooltipManager tooltipManager, @NotNull @NotNull GUIElementListener elementListener, @NotNull @NotNull String name, @NotNull @NotNull MapUpdaterState mapUpdaterState, @NotNull @NotNull FacesProvider facesProvider, @Nullable @Nullable SmoothingRenderer smoothingRenderer, @NotNull @NotNull DarknessColors darknessColors, @NotNull @NotNull GuiFactory guiFactory)
      Creates a new instance.
      Parameters:
      avoidCopyArea - whether map scrolling is done by copying pixel areas; if unset, always repaint all map squares
      tooltipManager - the tooltip manager to update
      elementListener - the element listener to notify
      name - the name of this element
      mapUpdaterState - the map updater state instance to use
      facesProvider - the faces provider for looking up faces
      smoothingRenderer - the smoothing renderer to use or null to not draw smoothed faces
      darknessColors - the darkness colors instance for converting darkness values into colors
      guiFactory - the global GUI factory instance
  • Method Details

    • dispose

      public void dispose()
      Description copied from interface: GUIElement
      Releases all allocated resources.
      Specified by:
      dispose in interface GUIElement
      Overrides:
      dispose in class AbstractGUIElement
    • redrawSquare

      protected void redrawSquare(@NotNull @NotNull Graphics g, @NotNull @NotNull CfMapSquare mapSquare, @NotNull @NotNull CfMap map, int x, int y)
      Redraws one square.
      Parameters:
      g - the graphics to draw into
      mapSquare - the map square to draw
      map - the map
      x - the x-coordinate of the map tile to redraw
      y - the y-coordinate of the map tile to redraw
    • paintSquareBackground

      protected abstract void paintSquareBackground(@NotNull @NotNull Graphics g, int px, int py, boolean hasImage, @NotNull @NotNull CfMapSquare mapSquare)
      Paints the background of a map square.
      Parameters:
      g - the graphics to paint into
      px - the x-offset for painting
      py - the y-offset for painting
      hasImage - whether the square contains at least one image
      mapSquare - the map square
    • markPlayer

      protected abstract void markPlayer(@NotNull @NotNull Graphics g, int dx, int dy)
      Paints the player location.
      Parameters:
      g - the graphics to paint to
      dx - the x distance to map has just scrolled
      dy - the y distance to map has just scrolled
    • paintComponent

      public void paintComponent(@NotNull @NotNull Graphics g)
      Overrides:
      paintComponent in class JComponent
    • getPlayerX

      public int getPlayerX()
      Returns the x offset of the tile representing the player.
      Returns:
      the x offset
    • getPlayerY

      public int getPlayerY()
      Returns the y offset of the tile representing the player.
      Returns:
      the y offset
    • getOffsetX

      public int getOffsetX()
      Returns the x offset for drawing the square at coordinate 0 of the map.
      Returns:
      the x offset
    • getOffsetY

      public int getOffsetY()
      Returns the y offset for drawing the square at coordinate 0 of the map.
      Returns:
      the y offset
    • setBounds

      public void setBounds(int x, int y, int width, int height)
      Overrides:
      setBounds in class Component
    • paintColoredSquare

      protected void paintColoredSquare(@NotNull @NotNull Graphics g, @NotNull @NotNull Color color, int x, int y)
      Fills a square with one Color.
      Parameters:
      g - the graphics to paint into
      color - the color
      x - the x-coordinate
      y - the y-coordinate
    • getMapWidth

      protected int getMapWidth()
      Returns the map width in squares.
      Returns:
      the map width
    • getMapHeight

      protected int getMapHeight()
      Returns the map height in squares.
      Returns:
      the map height
    • getMinimumSize

      @Nullable public @Nullable Dimension getMinimumSize()
      Overrides:
      getMinimumSize in class JComponent