package vermilion;

import java.awt.event.KeyEvent;

/**
 * A tracker column which simply shows the row numbers at the left of a pattern.
 */
public class JTrackerColumnRowNum extends JTrackerColumn
{
    /**
     * Constructs the row number column which displays the pattern index
     * in column zero of any pattern.
     */
    public JTrackerColumnRowNum()
    {
        super("ROW", "ROW", null, 4, null, 0);
    }

    /**
     * Returns the row number as a string for the row number entry.
     */
    @Override
    public String getEntry(int rowNum)
    {
        return lineNum(rowNum);
    }

    /**
     * Row numbers are not modified, keypresses are ignored.
     */
    @Override
    public boolean setEntry(int rowNum, int cursorPos, KeyEvent keyChar)
    {
        return false;
    }

    // Returns an int between 0 and 9999 as a four character string.
    private String lineNum(int x)
    {
        String val = String.valueOf(x);
        int len = val.length();
        if (len == 1) val = "000" + x;
        else if (len == 2) val = "00" + x;
        else if (len == 3) val = "0" + x;
        return val;
    }

    /**
     * Returns a helper/info display message for the current column, cursor
     * position and cue if one exists.
     */
    @Override
    public String getCursorDescription(int rowNum, int cursorPos)
    {
        // TODO: Description of entry if any, cursor pos.
        return "Row " + rowNum;
    }
}
