package com.jscape.inet.terminal.events;

import com.jscape.inet.terminal.TerminalListener;

/**
 * Represents <code>Terminal</code> cell event. This event is generated
 * when new character comes. Holds information about cell coordinates.
 */
public class CellEvent
        implements TerminalEvent {

    private final int row;
    private final int column;

    //----------------------------------------------------------------------------

    /**
     * Creates <code>CellEvent</code> object giving screen cell coordinates.
     *
     * @param row    row number.
     * @param column column number.
     */
    public CellEvent(int row, int column) {
        this.row = row;
        this.column = column;
    }

    //----------------------------------------------------------------------------

    /**
     * Returns screen cell row number.
     *
     * @return screen cell row number.
     */
    public int getRow() {
        return this.row;
    }

    //----------------------------------------------------------------------------

    /**
     * Returns screen cell column number.
     *
     * @return screen cell column number.
     */
    public int getColumn() {
        return this.column;
    }

    //----------------------------------------------------------------------------

    /**
     * Calls correct callback method of <code>TerminalListener</code> object.
     *
     * @param listener <code>TerminalListener</code> object.
     */
    public void accept(TerminalListener listener) {
        listener.onCellEvent(this);
    }

}