package com.srbenoit.modeling.grid;

import java.awt.Color;
import com.srbenoit.geom.Point2Int;

/**
 * A base class for objects that may be contained in a 2-dimensional grid. Each object has an X and
 * Y position, a radius, and a grid address.
 */
public interface GridMember2Int extends Point2Int {

    /**
     * Gets this grid this object is installed in.
     *
     * @return  the grid
     */
    Grid2D getGrid();

    /**
     * Gets the index of the object in the grid where it is installed.
     *
     * @return  the grid index
     */
    int getGridIndex();

    /**
     * Gets the radius to use when drawing the grid member.
     *
     * @return  the radius (0 to draw as a point)
     */
    double getRadius();

    /**
     * Gets the color in which to render the element.
     *
     * @return  the color
     */
    Color getColor();

    /**
     * Gets the fill color in which to render the element.
     *
     * @return  the color, or <code>null</code> for no fill
     */
    Color fillColor();

    /**
     * Installs the object in a grid. If the object is a member of a grid when this method is
     * called, the object is first removed from that grid, then added to <code>theGrid</code>.
     *
     * @param  theGrid  the grid in which the object is being installed
     */
    void installInGrid(Grid2D theGrid);

    /**
     * Removes the object from the grid in which it is installed, if any.
     */
    void removeFromGrid();

    /**
     * Clears the list of this object's neighbors.
     */
    void clearNeighbors();

    /**
     * Adds an object to the list of this object's neighbors.
     *
     * @param  neighbor  the neighbor to add
     */
    void addNeighbor(GridMember2Int neighbor);

    /**
     * Gets the number of neighbors the member has.
     *
     * @return  the number of neighbors
     */
    int getNumNeighbors();

    /**
     * Gets a neighbor grid member.
     *
     * @param   index  the index of the neighbor
     * @return  the neighbor
     */
    GridMember2Int getNeighbor(int index);
}
