From 18dbe82eae761c1e96d2eb5b842747a515db116f Mon Sep 17 00:00:00 2001 From: amwaterhouse Date: Wed, 15 Jun 2005 14:56:59 +0000 Subject: [PATCH] add / remove editable columns --- src/jalview/gui/AnnotationPanel.java | 69 +++++++++++++++++++--------------- 1 file changed, 38 insertions(+), 31 deletions(-) diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 50c9fef..a6c2055 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -43,7 +43,7 @@ public class AnnotationPanel AlignViewport av; AlignmentPanel ap; int activeRow = -1; - ArrayList activeRes; + Vector activeRes; BufferedImage image; Graphics2D gg; FontMetrics fm; @@ -116,7 +116,8 @@ public class AnnotationPanel this.setPreferredSize(new Dimension(1, height)); } - public void addEditableColumn(int i) + + public void removeEditableColumn(int col) { if (activeRow == -1) { @@ -127,21 +128,42 @@ public class AnnotationPanel if (aa[j].editable) { activeRow = j; - break; } } } - if (activeRes == null) + if (activeRes != null && activeRes.contains(String.valueOf(col))) { - activeRes = new ArrayList(); - activeRes.add(String.valueOf(i)); + activeRes.removeElement(String.valueOf(col)); + } + repaint(); + } - return; + + public void addEditableColumn(int col) + { + if (activeRow == -1) + { + AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); + + for (int j = 0; j < aa.length; j++) + { + if (aa[j].editable) + { + activeRow = j; + break; + } + } } - activeRes.add(String.valueOf(i)); + if (activeRes == null) + activeRes = new Vector(); + + if (!activeRes.contains(String.valueOf(col))) + activeRes.addElement(String.valueOf(col)); + + repaint(); } public void actionPerformed(ActionEvent evt) @@ -164,9 +186,7 @@ public class AnnotationPanel JOptionPane.QUESTION_MESSAGE); if (label == null) - { - label = ""; - } + return; if ( (label.length() > 0) && !aa[activeRow].hasText) { @@ -181,7 +201,6 @@ public class AnnotationPanel { anot[index] = new Annotation(label, "", ' ', 0); } - anot[index].displayCharacter = label; } } @@ -228,9 +247,7 @@ public class AnnotationPanel symbol); if (label == null) - { - label = ""; - } + return; if ( (label.length() > 0) && !aa[activeRow].hasText) { @@ -326,7 +343,7 @@ public class AnnotationPanel { if (activeRes == null) { - activeRes = new ArrayList(); + activeRes = new Vector(); } else { @@ -349,8 +366,8 @@ public class AnnotationPanel } else { - activeRes = new ArrayList(); - activeRes.add(String.valueOf(res)); + activeRes = new Vector(); + activeRes.addElement(String.valueOf(res)); } repaint(); @@ -582,28 +599,18 @@ public class AnnotationPanel if (j == 0) { - if ( (row.annotations[0].secondaryStructure == 'H') || - (row.annotations[0].secondaryStructure == 'E')) - { g.drawString(row.annotations[j].displayCharacter, x, y + iconOffset + 2); - } } - else if ( ( (row.annotations[j].secondaryStructure == 'H') || - (row.annotations[j].secondaryStructure == 'E')) && + else if ( ( (row.annotations[j - 1] == null) || - (row.annotations[j].secondaryStructure != row.annotations[j - - 1].secondaryStructure))) + (row.annotations[j].displayCharacter != row.annotations[j - + 1].displayCharacter))) { g.drawString(row.annotations[j].displayCharacter, x, y + iconOffset + 2); } - if (!row.hasIcons) - { - g.drawString(row.annotations[j].displayCharacter, - x + charOffset, y + iconOffset + 2); - } } if (row.hasIcons) -- 1.7.10.2