wiki:NattableImplementationforGlycanArray

The following is the partial UML model of glycan array plugin's nattable related classes:

GRITS Nattable implementation is in edu.uga.ccrc.simiantools.display.control.table plugin. The main table class is the SimianTable. Glycan array plugin has two different tables, one for the raw data table, and one for the master (summary) table. The main difference between the raw data table and the master table is that the master table contains glycan images in one of the columns and requires special rendering mechanism. The following is the summary of my experience in extending SimianTable for Glycan Array plugin:

If you would like to display images in one of the columns, you have to override the following methods:

  • initCellAccumulator - the table needs its own CellLabelAccumulator
  • initConfigRegistry - need to initialize image config registry

The table object (GlycanArrayTableObject) needs to store the column ids for the cartoon column (where glycan cartoons will be shown) and the sequence column (where the glycan sequence string will be retrieved for image generation). For images to be displayed in the table, a unique label ("[feature_id].png") must be registered in the config registry for each cell of the cartoon column. AutoResizeImagePainter class (which is registered for these labels as the cell painter) then paints the images in the tables.

  • createMainTable should also be overriden to execute image specific code. Look into performImageConversion, updateImageRegistry and performAutoReizeAfterPaint methods to understand the image generation process.

Column headers for the tables

In order to specify different columns for the different tables (in Glycan array case, there are two types of tables: GlycanArrayTable and GlycanArrayMasterTable), you need to implement the following:

  • In your data model mapping class (enum class uk.ac.imperial.glycosciences.glycanarray.model.tablemodel.DMRawData and uk.ac.imperial.glycosciences.glycanarray.model.tablemodel.DMMeasurement respectively for the above two types of tables), add the new column name and label.

Example:

    public enum DMMeasurement {
	feature_id("Feature Id"),
	feature_name("Feature Name"),
	feature_sequence("Feature Sequences"),
	feature_cartoon("Cartoon"),
	feature_measurement("Value"),
	feature_stdev("Standard Deviation"),
	sample_concentration("Sample Concentration");
	
	private String sLabel;
    
    private DMMeasurement( String sLabel )
    {
        this.sLabel = sLabel;
    }

    public String getLabel() 
    {  
        return this.sLabel;  
    }

    public static DMMeasurement lookUp( String _sKey ) {
    	if ( feature_id.name().equals(_sKey ) )
    		return feature_id;
    	else if ( feature_name.name().equals(_sKey) ) 
    		return feature_name;
    	else if ( feature_sequence.name().equals(_sKey) ) 
    		return feature_sequence;
    	else if ( feature_measurement.name().equals(_sKey) ) 
    		return feature_measurement;
    	else if ( feature_stdev.name().equals(_sKey) ) 
    		return feature_stdev;
    	else if ( feature_cartoon.name().equals(_sKey) ) 
    		return feature_cartoon;
    	else if (sample_concentration.name().equals(_sKey))
    		return DMMeasurement.sample_concentration;
    	return null;
    }
}
  • update your preference class' getColumnHeader method to return the column header (uk.ac.imperial.glycosciences.glycanarray.preference.GlycanArrayRawDataPreference and uk.ac.imperial.glycosciences.glycanarray.preference.GlycanArrayPreference respectively). Example:
...

    @Override
    public SimianColumnHeader getColumnHeader(String _sKey) {	
	SimianColumnHeader header=null;
	if ( _sKey.equals(DMMeasurement.feature_id.name() ) ) {
		header = new SimianColumnHeader( DMMeasurement.feature_id.getLabel(), DMMeasurement.feature_id.name());
		header.setIsGrouped(false);
		return header;
	}
	if ( _sKey.equals(DMMeasurement.feature_name.name() ) ) {
		header = new SimianColumnHeader( DMMeasurement.feature_name.getLabel(), DMMeasurement.feature_name.name());
		header.setIsGrouped(false);
		return header;
	}
	if ( _sKey.equals(DMMeasurement.feature_sequence.name() ) ) {
		header = new SimianColumnHeader( DMMeasurement.feature_sequence.getLabel(), DMMeasurement.feature_sequence.name());
		header.setIsGrouped(false);
		return header;
	}
	if ( _sKey.equals(DMMeasurement.feature_measurement.name() ) ) {
		return new SimianColumnHeader( DMMeasurement.feature_measurement.getLabel(), DMMeasurement.feature_measurement.name());
	}
	if ( _sKey.equals(DMMeasurement.feature_stdev.name() ) ) {
		return new SimianColumnHeader(DMMeasurement.feature_stdev.getLabel(), DMMeasurement.feature_stdev.name());
	}
	if ( _sKey.equals(DMMeasurement.feature_cartoon.name() ) ) {
		header = new SimianColumnHeader(DMMeasurement.feature_cartoon.getLabel(), DMMeasurement.feature_cartoon.name());
		header.setIsGrouped(false);			
                return header;
	}
	if ( _sKey.equals(DMMeasurement.sample_concentration.name() ) ) {
		header = new SimianColumnHeader(DMMeasurement.sample_concentration.getLabel(), DMMeasurement.sample_concentration.name());
		header.setIsGrouped(false);
		return header;
	}
	return super.getColumnHeader(_sKey);
     }
  • In the table processor, implement (override) initializeColumnSettingd and setDefaultColumnSettings methods (GlycanArrayTableRawDataTableProcessor and GlycanArrayTableProcessor). Example:
...
    @Override
    protected TableViewerColumnSettings initializeColumnSettings() {
	TableViewerColumnSettings newSettings = getNewTableViewerSettings();
	int iNumCol = addColumns (newSettings);
	setLastVisibleCol(iNumCol);
	return newSettings;
    }

    private int addColumns(TableViewerColumnSettings settings) {
	SimianColumnHeader header = null;
	header = new SimianColumnHeader(DMMeasurement.feature_id.getLabel(), DMMeasurement.feature_id.name());
	header.setIsGrouped(false);		
        settings.addColumn(  header);
	header = new SimianColumnHeader(DMMeasurement.feature_cartoon.getLabel(), DMMeasurement.feature_cartoon.name() );
	header.setIsGrouped(false);
	settings.addColumn(  header);
	header = new SimianColumnHeader( DMMeasurement.feature_sequence.getLabel(), DMMeasurement.feature_sequence.name() );
	header.setIsGrouped(false);
	settings.addColumn(  header);
	header = new SimianColumnHeader( DMMeasurement.feature_name.getLabel(), DMMeasurement.feature_name.name()  );
	header.setIsGrouped(false);
	settings.addColumn(  header);
	header = new SimianColumnHeader( DMMeasurement.sample_concentration.getLabel(), DMMeasurement.sample_concentration.name()  );
	header.setIsGrouped(false);
	settings.addColumn(  header);
		
	settings.addColumn( DMMeasurement.feature_measurement.getLabel(), DMMeasurement.feature_measurement.name()  );
	settings.addColumn( DMMeasurement.feature_stdev.getLabel(), DMMeasurement.feature_stdev.name()  );
	return 2;   // return the number of grouped columns
    }
Last modified 6 years ago Last modified on 02/26/2016 05:35:05 PM

Attachments (1)

Download all attachments as: .zip