Search in sources :

Example 1 with ColumnHeaderVerticalRenderer

use of org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColumnHeaderVerticalRenderer in project EnrichmentMapApp by BaderLab.

the class HeatMapMainPanel method createTableHeader.

private void createTableHeader(int expressionColumnWidth) {
    JTableHeader header = table.getTableHeader();
    header.setReorderingAllowed(false);
    HeatMapTableModel tableModel = (HeatMapTableModel) table.getModel();
    TableColumnModel columnModel = table.getColumnModel();
    TableCellRenderer vertRenderer = new ColumnHeaderVerticalRenderer();
    TableCellRenderer vertRendererPheno1 = new ColumnHeaderVerticalRenderer(EMStyleBuilder.Colors.LIGHTEST_PHENOTYPE_1);
    TableCellRenderer vertRendererPheno2 = new ColumnHeaderVerticalRenderer(EMStyleBuilder.Colors.LIGHTEST_PHENOTYPE_2);
    TableColumn rankColumn = columnModel.getColumn(HeatMapTableModel.RANK_COL);
    rankColumn.setHeaderRenderer(columnHeaderRankOptionRendererFactory.create(this, HeatMapTableModel.RANK_COL));
    rankColumn.setPreferredWidth(100);
    ((TableRowSorter<?>) table.getRowSorter()).setSortable(HeatMapTableModel.RANK_COL, false);
    int colCount = tableModel.getColumnCount();
    for (int col = HeatMapTableModel.DESC_COL_COUNT; col < colCount; col++) {
        EMDataSet dataset = tableModel.getDataSet(col);
        String pheno1 = dataset.getEnrichments().getPhenotype1();
        String pheno2 = dataset.getEnrichments().getPhenotype2();
        Optional<String> pheno = tableModel.getPhenotype(col);
        TableCellRenderer renderer;
        if (pheno.filter(p -> p.equals(pheno1)).isPresent())
            renderer = vertRendererPheno1;
        else if (pheno.filter(p -> p.equals(pheno2)).isPresent())
            renderer = vertRendererPheno2;
        else
            renderer = vertRenderer;
        TableColumn column = columnModel.getColumn(col);
        column.setHeaderRenderer(renderer);
        column.setPreferredWidth(expressionColumnWidth);
    }
}
Also used : Arrays(java.util.Arrays) Inject(com.google.inject.Inject) AfterInjection(org.baderlab.csplugins.enrichmentmap.AfterInjection) HeatMapTableModel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.HeatMapTableModel) Operator(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Operator) JTableHeader(javax.swing.table.JTableHeader) TableCellRenderer(javax.swing.table.TableCellRenderer) IconManager(org.cytoscape.util.swing.IconManager) Assisted(com.google.inject.assistedinject.Assisted) ComboItem(org.baderlab.csplugins.enrichmentmap.view.util.ComboItem) Map(java.util.Map) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) DEFAULT_SIZE(javax.swing.GroupLayout.DEFAULT_SIZE) Set(java.util.Set) ColorAndValueRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColorAndValueRenderer) Distance(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Distance) Component(java.awt.Component) Collectors(java.util.stream.Collectors) TableRowSorter(javax.swing.table.TableRowSorter) Sets(com.google.common.collect.Sets) PREFERRED_SIZE(javax.swing.GroupLayout.PREFERRED_SIZE) List(java.util.List) Alignment(javax.swing.GroupLayout.Alignment) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) LookAndFeelUtil(org.cytoscape.util.swing.LookAndFeelUtil) SwingUtil(org.baderlab.csplugins.enrichmentmap.view.util.SwingUtil) ColumnHeaderRankOptionRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColumnHeaderRankOptionRenderer) JCheckBox(javax.swing.JCheckBox) Optional(java.util.Optional) JTable(javax.swing.JTable) ColumnHeaderVerticalRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColumnHeaderVerticalRenderer) RankValue(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValue) JPanel(javax.swing.JPanel) ListSelectionModel(javax.swing.ListSelectionModel) ActionListener(java.awt.event.ActionListener) TableColumnModel(javax.swing.table.TableColumnModel) SortKey(javax.swing.RowSorter.SortKey) EnrichmentMap(org.baderlab.csplugins.enrichmentmap.model.EnrichmentMap) CompletableFuture(java.util.concurrent.CompletableFuture) GradientLegendPanel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.GradientLegendPanel) ArrayList(java.util.ArrayList) SwingUtilities(javax.swing.SwingUtilities) EMStyleBuilder(org.baderlab.csplugins.enrichmentmap.style.EMStyleBuilder) JButton(javax.swing.JButton) Transform(org.baderlab.csplugins.enrichmentmap.view.heatmap.HeatMapParams.Transform) TableColumn(javax.swing.table.TableColumn) JPopupMenu(javax.swing.JPopupMenu) ActionEvent(java.awt.event.ActionEvent) RankOptionErrorHeader(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankOptionErrorHeader) RankValueRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.RankValueRenderer) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) GroupLayout(javax.swing.GroupLayout) ColorRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColorRenderer) Comparator(java.util.Comparator) TableCellRenderer(javax.swing.table.TableCellRenderer) HeatMapTableModel(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.HeatMapTableModel) JTableHeader(javax.swing.table.JTableHeader) TableColumnModel(javax.swing.table.TableColumnModel) EMDataSet(org.baderlab.csplugins.enrichmentmap.model.EMDataSet) ColumnHeaderVerticalRenderer(org.baderlab.csplugins.enrichmentmap.view.heatmap.table.ColumnHeaderVerticalRenderer) TableColumn(javax.swing.table.TableColumn) TableRowSorter(javax.swing.table.TableRowSorter)

Aggregations

Sets (com.google.common.collect.Sets)1 Inject (com.google.inject.Inject)1 Assisted (com.google.inject.assistedinject.Assisted)1 BorderLayout (java.awt.BorderLayout)1 Component (java.awt.Component)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1 Set (java.util.Set)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Collectors (java.util.stream.Collectors)1 GroupLayout (javax.swing.GroupLayout)1 Alignment (javax.swing.GroupLayout.Alignment)1 DEFAULT_SIZE (javax.swing.GroupLayout.DEFAULT_SIZE)1 PREFERRED_SIZE (javax.swing.GroupLayout.PREFERRED_SIZE)1