X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=0213565b98f22ce005d8521630e0a8ada21f9621;hb=9807ea8cc4e867378c52d51b832168d4bc611d29;hp=3a4a19751a765381e3260ebf50cbf3dea81b6d5c;hpb=3a45e0d68dde73c005832b7b3924194b214e00ff;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 3a4a197..0213565 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -50,7 +50,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, AlignViewport av; AlignmentPanel ap; int activeRow = -1; - Vector activeRes; BufferedImage image; Graphics2D gg; FontMetrics fm; @@ -149,74 +148,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, return height; } - /** - * DOCUMENT ME! - * - * @param col DOCUMENT ME! - */ - public void removeEditableColumn(int col) - { - if (activeRow == -1) - { - AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - if(aa==null) - return; - for (int j = 0; j < aa.length; j++) - { - if (aa[j].editable) - { - activeRow = j; - - break; - } - } - } - - if ((activeRes != null) && activeRes.contains(String.valueOf(col))) - { - activeRes.removeElement(String.valueOf(col)); - } - - repaint(); - } - - /** - * DOCUMENT ME! - * - * @param col DOCUMENT ME! - */ - public void addEditableColumn(int col) - { - if (activeRow == -1) - { - AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - if(aa==null) - return; - - for (int j = 0; j < aa.length; j++) - { - if (aa[j].editable) - { - activeRow = j; - - break; - } - } - } - - if (activeRes == null) - { - activeRes = new Vector(); - } - - if (!activeRes.contains(String.valueOf(col))) - { - activeRes.addElement(String.valueOf(col)); - } - - repaint(); - } /** * DOCUMENT ME! @@ -230,10 +162,9 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (evt.getActionCommand().equals(REMOVE)) { - for (int i = 0; i < activeRes.size(); i++) + for (int i = 0; i < av.getColumnSelection().size(); i++) { - anot[Integer.parseInt(activeRes.get(i).toString())] = null; - anot[Integer.parseInt(activeRes.get(i).toString())] = null; + anot[av.getColumnSelection().columnAt(i)] = null; } } else if (evt.getActionCommand().equals(LABEL)) @@ -251,9 +182,9 @@ public class AnnotationPanel extends JPanel implements MouseListener, aa[activeRow].hasText = true; } - for (int i = 0; i < activeRes.size(); i++) + for (int i = 0; i < av.getColumnSelection().size(); i++) { - int index = Integer.parseInt(activeRes.get(i).toString()); + int index = av.getColumnSelection().columnAt(i); if (anot[index] == null) { @@ -268,9 +199,9 @@ public class AnnotationPanel extends JPanel implements MouseListener, Color col = JColorChooser.showDialog(this, "Choose foreground colour", Color.black); - for (int i = 0; i < activeRes.size(); i++) + for (int i = 0; i < av.getColumnSelection().size(); i++) { - int index = Integer.parseInt(activeRes.get(i).toString()); + int index = av.getColumnSelection().columnAt(i); if (anot[index] == null) { @@ -313,9 +244,9 @@ public class AnnotationPanel extends JPanel implements MouseListener, aa[activeRow].hasText = true; } - for (int i = 0; i < activeRes.size(); i++) + for (int i = 0; i < av.getColumnSelection().size(); i++) { - int index = Integer.parseInt(activeRes.get(i).toString()); + int index = av.getColumnSelection().columnAt(i); if (anot[index] == null) { @@ -328,7 +259,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, } adjustPanelHeight(); - activeRes = null; repaint(); return; @@ -363,24 +293,9 @@ public class AnnotationPanel extends JPanel implements MouseListener, } else if(aa[i].graph>0) { - if(SwingUtilities.isRightMouseButton(evt) - && aa[i].graphLines!=null - && aa[i].graphLines.size()>0) - { - SliderPanel sp = new SliderPanel(aa[i], ap); - return; - } - else - { //Stretch Graph graphStretch = i; graphStretchY = evt.getY(); - activeRes = null; - } - } - else - { - activeRes = null; } break; @@ -389,7 +304,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (SwingUtilities.isRightMouseButton(evt)) { - if (activeRes == null) + if (av.getColumnSelection() == null) { return; } @@ -422,19 +337,9 @@ public class AnnotationPanel extends JPanel implements MouseListener, int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - if (evt.isControlDown() || evt.isAltDown()) + if (evt.isShiftDown()) { - addEditableColumn(res); - } - else if (evt.isShiftDown()) - { - if (activeRes == null) - { - activeRes = new Vector(); - } - else - { - int start = Integer.parseInt(activeRes.get(activeRes.size() - + /*int start = Integer.parseInt(activeRes.get(activeRes.size() - 1).toString()); int end = res; @@ -447,14 +352,18 @@ public class AnnotationPanel extends JPanel implements MouseListener, for (int n = start; n <= end; n++) { - addEditableColumn(n); - } - } + addEditableColumn(n); + } */ } else { - activeRes = new Vector(); - activeRes.addElement(String.valueOf(res)); + if (av.getColumnSelection().contains(res)) + av.getColumnSelection().removeElement(res); + else + av.getColumnSelection().addElement(res); + + ap.repaint(); + } } @@ -539,11 +448,11 @@ public class AnnotationPanel extends JPanel implements MouseListener, int res = (evt.getX() / av.getCharWidth()) + av.getStartRes(); - if ((row > -1) && (res < aa[row].annotations.length) && - (aa[row].annotations[res] != null)) - { - + if(av.hasHiddenColumns) + res = av.getColumnSelection().adjustForHiddenColumns(res); + if (row > -1 && res-1) { StringBuffer tip = new StringBuffer(""); @@ -552,15 +461,23 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (aa[gg].graphGroup == aa[row].graphGroup && aa[gg].annotations[res]!=null) tip.append(aa[gg].label+" "+aa[gg].annotations[res].description+"
" ); } - tip.setLength(tip.length()-4); - this.setToolTipText(tip.toString()+""); + if(tip.length()!=6) + { + tip.setLength(tip.length() - 4); + this.setToolTipText(tip.toString() + ""); + } } - else + else if(aa[row].annotations[res] != null) this.setToolTipText(aa[row].annotations[res].description); - StringBuffer text = new StringBuffer("Sequence position " + - (res + 1) + " " + aa[row].annotations[res].description); - ap.alignFrame.statusBar.setText(text.toString()); + if(aa[row].annotations[res]!=null) + { + StringBuffer text = new StringBuffer("Sequence position " + + (res + 1) + " " + + aa[row].annotations[res].description); + + ap.alignFrame.statusBar.setText(text.toString()); + } } } @@ -622,7 +539,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, */ public void fastPaint(int horizontal) { - if ((horizontal == 0) || + if ((horizontal == 0) || gg==null || (av.alignment.getAlignmentAnnotation() == null) || (av.alignment.getAlignmentAnnotation().length < 1)) { @@ -689,7 +606,6 @@ public class AnnotationPanel extends JPanel implements MouseListener, AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation(); - int j; int x = 0; int y = 0; char[] lastSS = new char[aa.length]; @@ -711,6 +627,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, } + if (row.graph>0) { if(row.graphGroup>-1 && graphGroupDrawn[ row.graphGroup ] ) @@ -734,10 +651,25 @@ public class AnnotationPanel extends JPanel implements MouseListener, iconOffset = 0; } - for (j = startRes; j < endRes; j++) + int column = startRes; + int yPos = startRes; + int aaMax = row.annotations.length-1; + + while (yPos < endRes) { - if ((row.annotations.length <= j) || - (row.annotations[j] == null)) + if (av.hasHiddenColumns) + { + column = av.getColumnSelection().adjustForHiddenColumns(yPos); + if (column > aaMax) + { + break; + } + } + else + column = yPos; + + if ((row.annotations.length <= column) || + (row.annotations[column] == null)) { validRes = false; } @@ -746,21 +678,21 @@ public class AnnotationPanel extends JPanel implements MouseListener, validRes = true; } - x = (j - startRes) * av.charWidth; + x = (yPos - startRes) * av.charWidth; if (activeRow == i) { g.setColor(Color.red); - if (activeRes != null) + if (av.getColumnSelection() != null) { - for (int n = 0; n < activeRes.size(); n++) + for (int n = 0; n < av.getColumnSelection().size(); n++) { - int v = Integer.parseInt(activeRes.get(n).toString()); + int v = av.getColumnSelection().columnAt(n); - if (v == j) + if (v == column) { - g.fillRect((j - startRes) * av.charWidth, y, + g.fillRect((column - startRes) * av.charWidth, y, av.charWidth, row.height); } } @@ -768,24 +700,24 @@ public class AnnotationPanel extends JPanel implements MouseListener, } if (validRes && - (row.annotations[j].displayCharacter.length() > 0)) + (row.annotations[column].displayCharacter.length() > 0)) { int charOffset = (av.charWidth - - fm.charWidth(row.annotations[j].displayCharacter.charAt( + fm.charWidth(row.annotations[column].displayCharacter.charAt( 0))) / 2; - g.setColor(row.annotations[j].colour); + g.setColor(row.annotations[column].colour); - if (j == 0 || row.graph>0) + if (column == 0 || row.graph>0) { - g.drawString(row.annotations[j].displayCharacter, x+charOffset, + g.drawString(row.annotations[column].displayCharacter, x+charOffset, y + iconOffset + 3); } - else if (((row.annotations[j - 1] == null) || - (row.annotations[j].displayCharacter != row.annotations[j - + else if (((row.annotations[column - 1] == null) || + (row.annotations[column].displayCharacter != row.annotations[column - 1].displayCharacter))) { - g.drawString(row.annotations[j].displayCharacter, x+charOffset, + g.drawString(row.annotations[column].displayCharacter, x+charOffset, y + iconOffset + 3); } } @@ -793,7 +725,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (row.hasIcons) { if (!validRes || - (row.annotations[j].secondaryStructure != lastSS[i])) + (row.annotations[column].secondaryStructure != lastSS[i])) { switch (lastSS[i]) { @@ -828,7 +760,7 @@ public class AnnotationPanel extends JPanel implements MouseListener, if (validRes) { - lastSS[i] = row.annotations[j].secondaryStructure; + lastSS[i] = row.annotations[column].secondaryStructure; } else { @@ -838,6 +770,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, lastSSX[i] = x; } } + + yPos++; } x += av.charWidth; @@ -856,7 +790,8 @@ public class AnnotationPanel extends JPanel implements MouseListener, case 'E': g.setColor(SHEET_COLOUR); - if (row.annotations[endRes].secondaryStructure != 'E') + if (row.annotations[endRes] !=null + && row.annotations[endRes].secondaryStructure != 'E') { g.fillRect(lastSSX[i], y + 4 + iconOffset, x - lastSSX[i] - 4, 7); @@ -971,34 +906,50 @@ public class AnnotationPanel extends JPanel implements MouseListener, g.drawLine(x-av.charWidth,y2,(eRes-sRes+1)*av.charWidth,y2); - if(aa.graphLines!=null) + if(aa.threshold!=null) { - for(int l=0; l aaMax) + { + break; + } + } + else + column = yPos; + + yPos ++; + + if(aa.annotations[column]==null || aa.annotations[column-1]==null) { x+=av.charWidth; continue; } - g.setColor(aa.annotations[j].colour); - y1 = y - (int) (((aa.annotations[j-1].value-min) / range) * graphHeight); - y2 = y - (int) (((aa.annotations[j].value-min) / range) * graphHeight); + + g.setColor(aa.annotations[column].colour); + y1 = y - (int) (((aa.annotations[column-1].value-min) / range) * graphHeight); + y2 = y - (int) (((aa.annotations[column].value-min) / range) * graphHeight); g.drawLine(x-av.charWidth/2, y1, x+av.charWidth/2, y2); x += av.charWidth; } @@ -1016,21 +967,18 @@ public class AnnotationPanel extends JPanel implements MouseListener, float range = max - min; - if(aa.graphLines!=null) + if(aa.threshold!=null) { - for(int l=0; l aaMax) + { + break; + } + } + else + column = yPos; + + yPos ++; + + if (aa.annotations[column] == null) { x += av.charWidth; continue; } - g.setColor(aa.annotations[j].colour); - y1 = y - (int) (((aa.annotations[j].value-min) / (range)) * aa.graphHeight); + + g.setColor(aa.annotations[column].colour); + y1 = y - (int) (((aa.annotations[column].value-min) / (range)) * aa.graphHeight); if(y1-y2>0) g.fillRect(x, y2, av.charWidth, y1-y2 );