Skip to content

Commit

Permalink
Fix to #44, update the number of rows in the association table when a…
Browse files Browse the repository at this point in the history
… new node is selected
  • Loading branch information
selewis committed Dec 8, 2016
1 parent e105fc4 commit f7bb395
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
2 changes: 1 addition & 1 deletion resources/org/paint/resources/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.28.2
v2.28.c
35 changes: 18 additions & 17 deletions src/org/paint/gui/association/AssociationsTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,24 +194,24 @@ private void setColumnWidths() {
term_col.setPreferredWidth(remainder);
term_col.setWidth(remainder);

initRowHeights();
// initRowHeights();
widths_initialized = true;
}
}

private void initRowHeights() {
int rows = assoc_model.getRowCount();
int row_height = getRowHeight() + 6;

for (int row = 0; row < rows; row++) {
WithCellModel with_model = (WithCellModel) assoc_model.getValueAt(row, AssociationsTableModel.WITH_COLUMN);
int with_count = with_model.getSize();
if (with_count == 0)
with_count = 1;
int with_height = Math.min(row_height * 4, row_height * with_count);
setRowHeight(row, with_height);
}
}
// private void initRowHeights() {
// int rows = assoc_model.getRowCount();
// int row_height = getRowHeight() + 8;
//
// for (int row = 0; row < rows; row++) {
// WithCellModel with_model = (WithCellModel) assoc_model.getValueAt(row, AssociationsTableModel.WITH_COLUMN);
// int with_count = with_model.getSize();
// if (with_count == 0)
// with_count = 1;
// int with_height = Math.min(row_height * 4, row_height * with_count);
// setRowHeight(row, with_height);
// }
// }

/* MouseListener methods */
public void mouseClicked(MouseEvent event) {
Expand Down Expand Up @@ -394,7 +394,7 @@ public void handleTermEvent(TermSelectEvent e) {
public void handleAnnotationChangeEvent(AnnotationChangeEvent event) {
if (node != null && event.getSource() != null) {
assoc_model.setNode(node);
initRowHeights();
// initRowHeights();
assoc_model.fireTableDataChanged();
}
}
Expand All @@ -409,8 +409,9 @@ public void handleGeneSelectEvent (GeneSelectEvent e) {
} else {
setAnnotations(null);
}
this.initRowHeights();
clearSelection();
// clearSelection();
assoc_model.fireTableDataChanged();
// initRowHeights();
}

public void handleChallengeEvent(ChallengeEvent event) {
Expand Down
4 changes: 4 additions & 0 deletions src/org/paint/gui/association/WithCellController.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.paint.gui.association;

import java.awt.Color;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
Expand Down Expand Up @@ -53,9 +54,12 @@ public Component getTableCellEditorComponent(JTable table, Object value,
if (value != null) {
model = (WithCellModel) value;
list.setModel(model);
list.setForeground(Color.blue);
list.setSelectionForeground(Color.blue);
list.setBackground(model.getBackground());
list.setSelectionBackground(model.getBackground());
list.setSelectedIndex(model.getSelectedIndex());
table.setRowHeight(row, model.getRowHeight());
}
return scrollpane;
}
Expand Down
7 changes: 7 additions & 0 deletions src/org/paint/gui/association/WithCellModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,13 @@ protected Color getBackground() {
return background_color;
}

protected int getRowHeight() {
int row_height = 22;
int with_count = with_list.size();
if (with_count == 0)
with_count = 1;
return Math.min(row_height * 4, row_height * with_count);
}
private void addWithsToList(List<String> with_strings, List<String> with_list, Color background_color) {
for (String with : with_strings) {
with_list.add(with);
Expand Down
4 changes: 4 additions & 0 deletions src/org/paint/gui/association/WithCellRenderer.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.paint.gui.association;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JList;
Expand All @@ -26,9 +27,12 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
if (value != null) {
WithCellModel model = (WithCellModel) value;
list.setModel(model);
list.setForeground(Color.blue);
list.setSelectionForeground(Color.blue);
list.setBackground(model.getBackground());
list.setSelectionBackground(model.getBackground());
list.setSelectedIndex(model.getSelectedIndex());
table.setRowHeight(row, model.getRowHeight());
}
return this;
}
Expand Down
4 changes: 2 additions & 2 deletions src/org/paint/util/HTMLUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ public class HTMLUtil {

// External link identifier and URL links
protected static final String [][] URL_primary = {
{"ENSEMBL", "http://www.ensembl.org/YYY/Gene/Summary?g=XXX" },
{"Ensembl", "http://www.ensembl.org/YYY/Gene/Summary?g=XXX" },
{"ENSEMBL", "http://www.ensembl.org/Multi/Gene/Summary?g=XXX" },
{"Ensembl", "http://www.ensembl.org/Multi/Gene/Summary?g=XXX" },
{"EnsemblGenome", "http://www.uniprot.org/uniprot/?query=XXX&sort=score" },
{"ENTREZ", "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&id=XXX" },
{"RefSeq", "http://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?db=protein&id=XXX" },
Expand Down

0 comments on commit f7bb395

Please sign in to comment.