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

uk.ac.starlink.table.gui.MapGroupTableModel Maven / Gradle / Ivy

There is a newer version: 4.3
Show newest version
package uk.ac.starlink.table.gui;

import java.util.List;
import java.util.Map;
import javax.swing.table.AbstractTableModel;
import uk.ac.starlink.util.MapGroup;

/**
 * Provides a TableModel view of a MapGroup object.
 * For performance reasons this implementation takes a snapshot of 
 * the MapGroup at construction time rather than treating it as a
 * live object.
 *
 * @author   Mark Taylor (Starlink)
 */
public class MapGroupTableModel extends AbstractTableModel {

    private List> maps_;
    private List keys_;

    /**
     * Constructs a TableModel from a given MapGroup.
     *
     * @param   mapgroup  group to snapshot
     */
    public MapGroupTableModel( MapGroup mapgroup ) {
        maps_ = mapgroup.getMaps();
        keys_ = mapgroup.getKnownKeys();
    }

    public int getRowCount() {
        return maps_.size();
    }

    public int getColumnCount() {
        return keys_.size();
    }

    public V getValueAt( int irow, int icol ) {
        return maps_.get( irow ).get( keys_.get( icol ) );
    }

    public String getColumnName( int icol ) {
        return keys_.get( icol ).toString();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy