Changeset 238

Show
Ignore:
Timestamp:
09-03-12 12:50:29 (2 years ago)
Author:
tim.te.beek@…
Message:

Fix color of interactions not showing inside Cytoscape due to an alternate L&F tableHeaderRenderer

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/piqc-plugin/src/main/java/nl/nbic/brs/piqc/tableimport/views/PreviewPanel.java

    r229 r238  
    158158                verticalSeqGrp.addGroup(verticalParTopGrp); 
    159159                verticalSeqGrp.addPreferredGap(ComponentPlacement.RELATED); 
    160                 verticalSeqGrp.addComponent(scrollPane, 50, 250, Short.MAX_VALUE); 
     160                verticalSeqGrp.addComponent(scrollPane, 50, 150, Short.MAX_VALUE); 
    161161 
    162162                layout.setVerticalGroup(verticalSeqGrp); 
     
    195195        public Component getTableCellRendererComponent(final JTable table, final Object value, final boolean isSelected, final boolean hasFocus, final int row, final int column) { 
    196196                // Get component from default TableHeader renderer 
    197                 TableCellRenderer renderer = table.getTableHeader().getDefaultRenderer(); 
    198                 Component component = renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 
     197                Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 
    199198 
    200199                // Set color background for ID attributes: Source - Red, Edge - Green, Target - Blue 
     
    205204                if (sourceIDAttr != null && column == sourceIDAttr) 
    206205                        component.setBackground(new Color(255, 128, 128)); 
    207                 if (edgeIDAttr != null && column == edgeIDAttr) 
     206                else if (edgeIDAttr != null && column == edgeIDAttr) 
    208207                        component.setBackground(new Color(128, 255, 128)); 
    209                 if (targetIDAttr != null && column == targetIDAttr) 
     208                else if (targetIDAttr != null && column == targetIDAttr) 
    210209                        component.setBackground(new Color(128, 128, 255)); 
     210                else { 
     211                        // Use a normal background color from default renderer instead, to revert any previous color assingment 
     212                        TableCellRenderer renderer = table.getTableHeader().getDefaultRenderer(); 
     213                        Component defaultComponent = renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); 
     214                        component.setBackground(defaultComponent.getBackground()); 
     215                } 
    211216 
    212217                return component;