package vermilion;

import java.awt.event.KeyEvent;

/**
 * A base class for the different column types we can display in the tracker.
  */
public abstract class JTrackerColumn
{
    /**
     * The name of the parameter this column represents. In the case of machine
     * track (for pattern cues) the 'parameterName' is the machine ID that the
     * pattern cues are for.
     */
    public String parameterName;

    /**
     * The name of this column in the pattern, usually the parameterName plus
     * an optional track number.
     */
    public String columnName;

    /**
     * The pattern node that this column is displaying a part of.
     */
    public PatternNode pattern;

    /**
     * An offset for the column, now deprecated. TODO: Use this to allow the
     * user to move columns around.
     */
    public int columnOffset;

    /**
     * The number of digits that this column has, used for placing the cursor
     * and setting table column pixel widths.
     */
    public int columnWidth;

    /**
     * The commands being displayed by this column.
     */
    public PatternTrackNode commandList;


    /**
     * Constructs a new column displaying the given pattern node.
     */
    public JTrackerColumn(String colName, String paramName, PatternNode node, int offset, int width, PatternTrackNode commands)
    {
        columnName = colName;
        parameterName = paramName;
        pattern = node;
        columnOffset = offset;
        columnWidth = width;
        commandList = commands;
    }

    /**
     * Returns the digits to display at a given row for this column.
     */
    public abstract String getEntry(int rowNum);

    /**
     * Passes a keypress to a column for interpretation. We pass the character
     * as well as the digit position in the column.
     */
    public abstract boolean setEntry(int rowNum, int cursorPos, KeyEvent key);

    /**
     * Returns the column's name, as toString is used to get the column header.
     */
    @Override
    public String toString()
    {
        return columnName;
    }
}
