All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.googlecode.lanterna.gui2.table.TableCellRenderer Maven / Gradle / Ivy

There is a newer version: 3.2.0-alpha1
Show newest version
/*
 * This file is part of lanterna (http://code.google.com/p/lanterna/).
 *
 * lanterna is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see .
 *
 * Copyright (C) 2010-2016 Martin
 */
package com.googlecode.lanterna.gui2.table;

import com.googlecode.lanterna.TerminalSize;
import com.googlecode.lanterna.gui2.TextGUIGraphics;

/**
 * The main interface to implement when you need to customize the way table cells are drawn
 *
 * @param  Type of data in the table cells
 * @author Martin
 */
public interface TableCellRenderer {
    /**
     * Called by the table when it wants to know how big a particular table cell should be
     * @param table Table containing the cell
     * @param cell Data stored in the cell
     * @param columnIndex Column index of the cell
     * @param rowIndex Row index of the cell
     * @return Size this renderer would like the cell to have
     */
    TerminalSize getPreferredSize(Table table, V cell, int columnIndex, int rowIndex);

    /**
     * Called by the table when it's time to draw a cell, you can see how much size is available by checking the size of
     * the {@code textGUIGraphics}. The top-left position of the graphics object is the top-left position of this cell.
     * @param table Table containing the cell
     * @param cell Data stored in the cell
     * @param columnIndex Column index of the cell
     * @param rowIndex Row index of the cell
     * @param textGUIGraphics Graphics object to draw with
     */
    void drawCell(Table table, V cell, int columnIndex, int rowIndex, TextGUIGraphics textGUIGraphics);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy