AlignViewport av;\r
AlignmentPanel ap;\r
int activeRow = -1;\r
- Vector activeRes;\r
BufferedImage image;\r
Graphics2D gg;\r
FontMetrics fm;\r
return height;\r
}\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param col DOCUMENT ME!\r
- */\r
- public void removeEditableColumn(int col)\r
- {\r
- if (activeRow == -1)\r
- {\r
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
- if(aa==null)\r
- return;\r
-\r
- for (int j = 0; j < aa.length; j++)\r
- {\r
- if (aa[j].editable)\r
- {\r
- activeRow = j;\r
-\r
- break;\r
- }\r
- }\r
- }\r
-\r
- if ((activeRes != null) && activeRes.contains(String.valueOf(col)))\r
- {\r
- activeRes.removeElement(String.valueOf(col));\r
- }\r
-\r
- repaint();\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param col DOCUMENT ME!\r
- */\r
- public void addEditableColumn(int col)\r
- {\r
- if (activeRow == -1)\r
- {\r
- AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
- if(aa==null)\r
- return;\r
-\r
- for (int j = 0; j < aa.length; j++)\r
- {\r
- if (aa[j].editable)\r
- {\r
- activeRow = j;\r
-\r
- break;\r
- }\r
- }\r
- }\r
-\r
- if (activeRes == null)\r
- {\r
- activeRes = new Vector();\r
- }\r
-\r
- if (!activeRes.contains(String.valueOf(col)))\r
- {\r
- activeRes.addElement(String.valueOf(col));\r
- }\r
\r
- repaint();\r
- }\r
\r
/**\r
* DOCUMENT ME!\r
\r
if (evt.getActionCommand().equals(REMOVE))\r
{\r
- for (int i = 0; i < activeRes.size(); i++)\r
+ for (int i = 0; i < av.getColumnSelection().size(); i++)\r
{\r
- anot[Integer.parseInt(activeRes.get(i).toString())] = null;\r
- anot[Integer.parseInt(activeRes.get(i).toString())] = null;\r
+ anot[av.getColumnSelection().columnAt(i)] = null;\r
}\r
}\r
else if (evt.getActionCommand().equals(LABEL))\r
aa[activeRow].hasText = true;\r
}\r
\r
- for (int i = 0; i < activeRes.size(); i++)\r
+ for (int i = 0; i < av.getColumnSelection().size(); i++)\r
{\r
- int index = Integer.parseInt(activeRes.get(i).toString());\r
+ int index = av.getColumnSelection().columnAt(i);\r
\r
if (anot[index] == null)\r
{\r
Color col = JColorChooser.showDialog(this,\r
"Choose foreground colour", Color.black);\r
\r
- for (int i = 0; i < activeRes.size(); i++)\r
+ for (int i = 0; i < av.getColumnSelection().size(); i++)\r
{\r
- int index = Integer.parseInt(activeRes.get(i).toString());\r
+ int index = av.getColumnSelection().columnAt(i);\r
\r
if (anot[index] == null)\r
{\r
aa[activeRow].hasText = true;\r
}\r
\r
- for (int i = 0; i < activeRes.size(); i++)\r
+ for (int i = 0; i < av.getColumnSelection().size(); i++)\r
{\r
- int index = Integer.parseInt(activeRes.get(i).toString());\r
+ int index = av.getColumnSelection().columnAt(i);\r
\r
if (anot[index] == null)\r
{\r
}\r
\r
adjustPanelHeight();\r
- activeRes = null;\r
repaint();\r
\r
return;\r
//Stretch Graph\r
graphStretch = i;\r
graphStretchY = evt.getY();\r
- activeRes = null;\r
- }\r
- else\r
- {\r
- activeRes = null;\r
}\r
\r
break;\r
\r
if (SwingUtilities.isRightMouseButton(evt))\r
{\r
- if (activeRes == null)\r
+ if (av.getColumnSelection() == null)\r
{\r
return;\r
}\r
\r
int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();\r
\r
- if (evt.isControlDown() || evt.isAltDown())\r
+ if (evt.isShiftDown())\r
{\r
- addEditableColumn(res);\r
- }\r
- else if (evt.isShiftDown())\r
- {\r
- if (activeRes == null)\r
- {\r
- activeRes = new Vector();\r
- }\r
- else\r
- {\r
- int start = Integer.parseInt(activeRes.get(activeRes.size() -\r
+ /*int start = Integer.parseInt(activeRes.get(activeRes.size() -\r
1).toString());\r
int end = res;\r
\r
\r
for (int n = start; n <= end; n++)\r
{\r
- addEditableColumn(n);\r
- }\r
- }\r
+ addEditableColumn(n);\r
+ } */\r
}\r
else\r
{\r
- activeRes = new Vector();\r
- activeRes.addElement(String.valueOf(res));\r
+ if (av.getColumnSelection().contains(res))\r
+ av.getColumnSelection().removeElement(res);\r
+ else\r
+ av.getColumnSelection().addElement(res);\r
+\r
+ ap.repaint();\r
+\r
}\r
}\r
\r
\r
int res = (evt.getX() / av.getCharWidth()) + av.getStartRes();\r
\r
+ if(av.hasHiddenColumns)\r
+ res = av.getColumnSelection().adjustForHiddenColumns(res);\r
+\r
if (row > -1 && res<aa[row].annotations.length)\r
{\r
if(aa[row].graphGroup>-1)\r
\r
AlignmentAnnotation[] aa = av.alignment.getAlignmentAnnotation();\r
\r
- int j;\r
int x = 0;\r
int y = 0;\r
char[] lastSS = new char[aa.length];\r
iconOffset = 0;\r
}\r
\r
- for (j = startRes; j < endRes; j++)\r
+ int column = startRes;\r
+ int yPos = startRes;\r
+ int aaMax = row.annotations.length-1;\r
+\r
+ while (yPos < endRes)\r
{\r
- if ((row.annotations.length <= j) ||\r
- (row.annotations[j] == null))\r
+ if (av.hasHiddenColumns)\r
+ {\r
+ column = av.getColumnSelection().adjustForHiddenColumns(yPos);\r
+ if (column > aaMax)\r
+ {\r
+ break;\r
+ }\r
+ }\r
+ else\r
+ column = yPos;\r
+\r
+ if ((row.annotations.length <= column) ||\r
+ (row.annotations[column] == null))\r
{\r
validRes = false;\r
}\r
validRes = true;\r
}\r
\r
- x = (j - startRes) * av.charWidth;\r
+ x = (yPos - startRes) * av.charWidth;\r
\r
if (activeRow == i)\r
{\r
g.setColor(Color.red);\r
\r
- if (activeRes != null)\r
+ if (av.getColumnSelection() != null)\r
{\r
- for (int n = 0; n < activeRes.size(); n++)\r
+ for (int n = 0; n < av.getColumnSelection().size(); n++)\r
{\r
- int v = Integer.parseInt(activeRes.get(n).toString());\r
+ int v = av.getColumnSelection().columnAt(n);\r
\r
- if (v == j)\r
+ if (v == column)\r
{\r
- g.fillRect((j - startRes) * av.charWidth, y,\r
+ g.fillRect((column - startRes) * av.charWidth, y,\r
av.charWidth, row.height);\r
}\r
}\r
}\r
\r
if (validRes &&\r
- (row.annotations[j].displayCharacter.length() > 0))\r
+ (row.annotations[column].displayCharacter.length() > 0))\r
{\r
\r
int charOffset = (av.charWidth -\r
- fm.charWidth(row.annotations[j].displayCharacter.charAt(\r
+ fm.charWidth(row.annotations[column].displayCharacter.charAt(\r
0))) / 2;\r
- g.setColor(row.annotations[j].colour);\r
+ g.setColor(row.annotations[column].colour);\r
\r
- if (j == 0 || row.graph>0)\r
+ if (column == 0 || row.graph>0)\r
{\r
- g.drawString(row.annotations[j].displayCharacter, x+charOffset,\r
+ g.drawString(row.annotations[column].displayCharacter, x+charOffset,\r
y + iconOffset + 3);\r
}\r
- else if (((row.annotations[j - 1] == null) ||\r
- (row.annotations[j].displayCharacter != row.annotations[j -\r
+ else if (((row.annotations[column - 1] == null) ||\r
+ (row.annotations[column].displayCharacter != row.annotations[column -\r
1].displayCharacter)))\r
{\r
- g.drawString(row.annotations[j].displayCharacter, x+charOffset,\r
+ g.drawString(row.annotations[column].displayCharacter, x+charOffset,\r
y + iconOffset + 3);\r
}\r
}\r
if (row.hasIcons)\r
{\r
if (!validRes ||\r
- (row.annotations[j].secondaryStructure != lastSS[i]))\r
+ (row.annotations[column].secondaryStructure != lastSS[i]))\r
{\r
switch (lastSS[i])\r
{\r
\r
if (validRes)\r
{\r
- lastSS[i] = row.annotations[j].secondaryStructure;\r
+ lastSS[i] = row.annotations[column].secondaryStructure;\r
}\r
else\r
{\r
lastSSX[i] = x;\r
}\r
}\r
+\r
+ yPos++;\r
}\r
\r
x += av.charWidth;\r
}\r
\r
eRes = Math.min(eRes, aa.annotations.length);\r
- for (int j = sRes; j < eRes; j++)\r
+\r
+ int column = sRes;\r
+ int yPos = sRes;\r
+ int aaMax = aa.annotations.length-1;\r
+\r
+ while( yPos < eRes )\r
{\r
- if(aa.annotations[j]==null || aa.annotations[j-1]==null)\r
+ if(av.hasHiddenColumns)\r
+ {\r
+ column = av.getColumnSelection().adjustForHiddenColumns(yPos);\r
+ if(column > aaMax)\r
+ {\r
+ break;\r
+ }\r
+ }\r
+ else\r
+ column = yPos;\r
+\r
+ yPos ++;\r
+\r
+ if(aa.annotations[column]==null || aa.annotations[column-1]==null)\r
{\r
x+=av.charWidth;\r
continue;\r
}\r
- g.setColor(aa.annotations[j].colour);\r
- y1 = y - (int) (((aa.annotations[j-1].value-min) / range) * graphHeight);\r
- y2 = y - (int) (((aa.annotations[j].value-min) / range) * graphHeight);\r
+\r
+ g.setColor(aa.annotations[column].colour);\r
+ y1 = y - (int) (((aa.annotations[column-1].value-min) / range) * graphHeight);\r
+ y2 = y - (int) (((aa.annotations[column].value-min) / range) * graphHeight);\r
g.drawLine(x-av.charWidth/2, y1, x+av.charWidth/2, y2);\r
x += av.charWidth;\r
}\r
\r
g.drawLine(x,y2,(eRes-sRes+1)*av.charWidth,y2);\r
\r
- eRes = Math.min(eRes, aa.annotations.length-1);\r
\r
+ int column = sRes;\r
+ int yPos = sRes;\r
+ int aaMax = aa.annotations.length-1;\r
\r
- for (int j = sRes; j < eRes; j++)\r
+ while( yPos < eRes )\r
{\r
+ if(av.hasHiddenColumns)\r
+ {\r
+ column = av.getColumnSelection().adjustForHiddenColumns(yPos);\r
+ if(column > aaMax)\r
+ {\r
+ break;\r
+ }\r
+ }\r
+ else\r
+ column = yPos;\r
+\r
+ yPos ++;\r
\r
- if (aa.annotations[j] == null)\r
+ if (aa.annotations[column] == null)\r
{\r
x += av.charWidth;\r
continue;\r
}\r
\r
- g.setColor(aa.annotations[j].colour);\r
- y1 = y - (int) (((aa.annotations[j].value-min) / (range)) * aa.graphHeight);\r
+\r
+ g.setColor(aa.annotations[column].colour);\r
+ y1 = y - (int) (((aa.annotations[column].value-min) / (range)) * aa.graphHeight);\r
\r
if(y1-y2>0)\r
g.fillRect(x, y2, av.charWidth, y1-y2 );\r