SequenceGroup selectionGroup;\r
int charHeight;\r
int charWidth;\r
- int chunkWidth;\r
- int chunkHeight;\r
+ int wrappedWidth;\r
Font font = new Font("SansSerif", Font.PLAIN, 10);\r
AlignmentI alignment;\r
ColumnSelection colSel = new ColumnSelection();\r
*\r
* @param w DOCUMENT ME!\r
*/\r
- public void setChunkWidth(int w)\r
+ public void setWrappedWidth(int w)\r
{\r
- this.chunkWidth = w;\r
+ this.wrappedWidth = w;\r
}\r
\r
/**\r
*\r
* @return DOCUMENT ME!\r
*/\r
- public int getChunkWidth()\r
+ public int getWrappedWidth()\r
{\r
- return chunkWidth;\r
+ return wrappedWidth;\r
}\r
\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @param h DOCUMENT ME!\r
- */\r
- public void setChunkHeight(int h)\r
- {\r
- this.chunkHeight = h;\r
- }\r
-\r
- /**\r
- * DOCUMENT ME!\r
- *\r
- * @return DOCUMENT ME!\r
- */\r
- public int getChunkHeight()\r
- {\r
- return chunkHeight;\r
- }\r
\r
/**\r
* DOCUMENT ME!\r
public class AlignmentPanel extends GAlignmentPanel\r
implements AdjustmentListener, Printable\r
{\r
- AlignViewport av;\r
+ public AlignViewport av;\r
OverviewPanel overviewPanel;\r
SeqPanel seqPanel;\r
IdPanel idPanel;\r
});\r
}\r
\r
+\r
/**\r
* DOCUMENT ME!\r
*/\r
\r
if (av.showAnnotation)\r
{\r
- pagesHigh += annotationPanel.getHeight();\r
+ pagesHigh += annotationPanel.adjustPanelHeight()+3;\r
}\r
\r
pagesHigh /= pheight;\r
\r
if (av.showAnnotation && (endSeq == av.alignment.getHeight()))\r
{\r
- pg.translate(-idWidth, (endSeq - startSeq) * av.charHeight);\r
+ pg.translate(-idWidth, (endSeq - startSeq) * av.charHeight +3);\r
alabels.drawComponent((Graphics2D) pg);\r
pg.translate(idWidth, 0);\r
annotationPanel.drawComponent((Graphics2D) pg, startRes, endRes +\r
public int printWrappedAlignment(Graphics pg, int pwidth, int pheight,\r
int pi) throws PrinterException\r
{\r
- int idWidth = calculateIdWidth().width + 4;\r
+\r
+ int annotationHeight = 0;\r
+ if (av.showAnnotation)\r
+ annotationHeight = annotationPanel.adjustPanelHeight();\r
+\r
+ int hgap = av.charHeight;\r
+ if (av.scaleAboveWrapped)\r
+ hgap += av.charHeight;\r
+\r
+ int cHeight = av.getAlignment().getHeight() * av.charHeight\r
+ + hgap\r
+ + annotationHeight;\r
+\r
+\r
+ int idWidth = calculateIdWidth().width + 4;\r
\r
int resWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(pwidth -\r
idWidth);\r
- int totalHeight = totalHeight = (av.alignment.getHeight() + 2) * ((av.alignment.getWidth() / resWidth) +\r
- 1) * av.charHeight;\r
+\r
+ int totalHeight = cHeight * (av.alignment.getWidth() / resWidth +1);\r
\r
pg.setColor(Color.white);\r
pg.fillRect(0, 0, pwidth, pheight);\r
pg.setFont(av.getFont());\r
\r
+\r
////////////////\r
// Draw the ids\r
pg.setColor(Color.black);\r
\r
pg.setClip(0, pi * pheight, pwidth, pheight);\r
\r
- int ypos = 2 * av.charHeight;\r
+ int ypos = hgap;\r
\r
do\r
{\r
(av.charHeight / 5));\r
}\r
\r
- ypos += ((av.alignment.getHeight() + 2) * av.charHeight);\r
+ ypos += cHeight;\r
}\r
while (ypos < totalHeight);\r
\r
if ((pi * pheight) < totalHeight)\r
{\r
return Printable.PAGE_EXISTS;\r
+\r
}\r
- else\r
+ else\r
{\r
return Printable.NO_SUCH_PAGE;\r
}\r
chooser.getSelectedFile().getParent());\r
}\r
\r
+\r
int height = ( (av.alignment.getHeight() + 1) * av.charHeight) + 30;\r
int width = idPanel.getWidth() + (av.alignment.getWidth() * av.charWidth);\r
\r
+\r
if (av.getWrapAlignment())\r
{\r
- height = ( (av.alignment.getWidth() / av.getChunkWidth()) + 1) *\r
- av.chunkHeight;\r
+ height = getWrappedHeight();\r
width = seqPanel.getWidth() + idPanel.getWidth();\r
-\r
}\r
-\r
-\r
- if (av.getShowAnnotation())\r
+ else if (av.getShowAnnotation())\r
{\r
- height += annotationPanel.getPreferredSize().height;\r
+ height += annotationPanel.adjustPanelHeight()+3;\r
}\r
\r
+\r
try\r
{\r
FileOutputStream out = new FileOutputStream(epsFile);\r
\r
}\r
\r
+ int getWrappedHeight()\r
+ {\r
+\r
+ int chunkWidth = seqPanel.seqCanvas.getWrappedCanvasWidth(\r
+ seqPanel.seqCanvas.getWidth());\r
+\r
+ int hgap = av.charHeight;\r
+ if (av.scaleAboveWrapped)\r
+ hgap += av.charHeight;\r
+\r
+ int annotationHeight = 0;\r
+ if (av.showAnnotation)\r
+ {\r
+ annotationHeight = annotationPanel.adjustPanelHeight();\r
+ }\r
+\r
+ int cHeight = av.getAlignment().getHeight() * av.charHeight\r
+ + hgap\r
+ + annotationHeight;\r
+\r
+\r
+ int height = ( (av.alignment.getWidth() / chunkWidth) + 1) * cHeight;\r
+\r
+ return height;\r
+ }\r
+\r
/**\r
* DOCUMENT ME!\r
*/\r
\r
if (av.getWrapAlignment())\r
{\r
- height = ( (av.alignment.getWidth() / av.getChunkWidth()) + 1) *\r
- av.chunkHeight;\r
+ height = getWrappedHeight();\r
width = seqPanel.getWidth() + idPanel.getWidth();\r
-\r
}\r
-\r
-\r
- if (av.getShowAnnotation())\r
+ else if (av.getShowAnnotation())\r
{\r
- height += annotationPanel.getPreferredSize().height;\r
+ height += annotationPanel.adjustPanelHeight()+3;\r
}\r
\r
try\r
ap.annotationScroller.getVerticalScrollBar().addAdjustmentListener(this);\r
}\r
\r
+ public AnnotationPanel(AlignViewport av)\r
+ {\r
+ this.av = av;\r
+ }\r
+\r
+\r
/**\r
* DOCUMENT ME!\r
*\r
/**\r
* DOCUMENT ME!\r
*/\r
- public void adjustPanelHeight()\r
+ public int adjustPanelHeight()\r
{\r
// setHeight of panels\r
image = null;\r
}\r
\r
this.setPreferredSize(new Dimension(1, height));\r
+\r
+ return height;\r
}\r
\r
/**\r
\r
if (av.getWrapAlignment())\r
{\r
+ int annotationHeight = 0;\r
+\r
+ if(av.showAnnotation)\r
+ {\r
+ AnnotationPanel ap = new AnnotationPanel(av);\r
+ annotationHeight = ap.adjustPanelHeight();\r
+ }\r
+\r
+ int hgap = av.charHeight;\r
+ if (av.scaleAboveWrapped)\r
+ hgap += av.charHeight;\r
+\r
+ int cHeight = av.getAlignment().getHeight() * av.charHeight\r
+ + hgap\r
+ + annotationHeight;\r
+\r
int rowSize = av.getEndRes() - av.getStartRes();\r
\r
// Draw the rest of the panels\r
- for (int ypos = 2 * av.charHeight, row = av.startRes;\r
+ for (int ypos = hgap, row = av.startRes;\r
(ypos <= getHeight()) && (row < av.alignment.getWidth());\r
- ypos += av.chunkHeight, row += rowSize)\r
+ ypos += cHeight, row += rowSize)\r
{\r
for (int i = starty; i < av.alignment.getHeight(); i++)\r
{\r
{\r
}\r
\r
+ int getWrappedY(int y)\r
+ {\r
+ int hgap = av.charHeight;\r
+ if (av.scaleAboveWrapped)\r
+ hgap += av.charHeight;\r
+\r
+ return y - hgap;\r
+ }\r
+\r
+\r
/**\r
* DOCUMENT ME!\r
*\r
\r
if (av.getWrapAlignment())\r
{\r
- y -= (2 * av.charHeight);\r
+ y = getWrappedY(y);\r
}\r
\r
int seq = av.getIndex(y);\r
\r
if (av.getWrapAlignment())\r
{\r
- y -= (2 * av.charHeight);\r
+ y = getWrappedY(y);\r
}\r
\r
//DEFAULT LINK IS FIRST IN THE LINK LIST\r
\r
if (av.getWrapAlignment())\r
{\r
- y -= (2 * av.charHeight);\r
+ y = getWrappedY(y);\r
}\r
\r
int seq = av.getIndex(y);\r
AlignViewport av;\r
boolean displaySearch = false;\r
int[] searchResults = null;\r
- int chunkHeight;\r
- int chunkWidth;\r
boolean fastPaint = false;\r
int LABEL_WEST;\r
int LABEL_EAST;\r
gg.setColor(Color.white);\r
gg.fillRect(0, 0, imgWidth, imgHeight);\r
\r
- chunkWidth = getWrappedCanvasWidth(getWidth());\r
- chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
-\r
- av.setChunkHeight(chunkHeight);\r
- av.setChunkWidth(chunkWidth);\r
\r
if (av.getWrapAlignment())\r
{\r
LABEL_WEST = fm.stringWidth(getMask());\r
}\r
\r
+ int hgap = av.charHeight;\r
+ if(av.scaleAboveWrapped)\r
+ hgap += av.charHeight;\r
+\r
int cWidth = (canvasWidth - LABEL_EAST - LABEL_WEST) / av.charWidth;\r
- int cHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
+ int cHeight = av.getAlignment().getHeight() * av.charHeight;\r
+\r
+ av.setWrappedWidth(cWidth);\r
\r
av.endRes = av.startRes + cWidth;\r
\r
+\r
int endx = (startRes + cWidth) - 1;\r
- int ypos = 2 * av.charHeight;\r
+ int ypos = hgap;\r
+\r
\r
while ((ypos <= canvasHeight) && (startRes < av.alignment.getWidth()))\r
{\r
\r
\r
drawPanel(g, startRes, endx, 0, al.getHeight(), startRes, 0, ypos);\r
+\r
+ if(av.showAnnotation)\r
+ {\r
+ g.translate(0, cHeight + ypos + 3);\r
+ if(annotations==null)\r
+ annotations = new AnnotationPanel(av);\r
+\r
+ annotations.drawComponent( (Graphics2D) g, startRes, endx + 1);\r
+ g.translate(0, -cHeight - ypos);\r
+ }\r
g.setClip(clip);\r
g.translate(-LABEL_WEST, 0);\r
\r
- ypos += cHeight;\r
+ ypos += cHeight+getAnnotationHeight()+hgap;\r
+ if(av.showAnnotation)\r
+ ypos -= 3;\r
+\r
startRes += cWidth;\r
endx = (startRes + cWidth) - 1;\r
\r
}\r
}\r
\r
+ AnnotationPanel annotations;\r
+ int getAnnotationHeight()\r
+ {\r
+ if(!av.showAnnotation)\r
+ return 0;\r
+\r
+ if(annotations==null)\r
+ annotations = new AnnotationPanel(av);\r
+\r
+ return annotations.adjustPanelHeight();\r
+ }\r
+\r
/**\r
* DOCUMENT ME!\r
*\r
\r
if (av.wrapAlignment)\r
{\r
+\r
+ int hgap = av.charHeight;\r
+ if (av.scaleAboveWrapped)\r
+ hgap += av.charHeight;\r
+\r
+ int cHeight = av.getAlignment().getHeight() * av.charHeight\r
+ + hgap + seqCanvas.getAnnotationHeight();\r
+\r
int y = evt.getY();\r
- y -= (2 * av.charHeight);\r
+ y -= hgap;\r
x -= seqCanvas.LABEL_WEST;\r
\r
- int chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
+\r
int cwidth = seqCanvas.getWrappedCanvasWidth(this.getWidth());\r
- wrappedBlock = y/chunkHeight;\r
- wrappedBlock += av.getStartRes()/cwidth;\r
\r
- res = wrappedBlock*cwidth + x / av.getCharWidth();\r
+ wrappedBlock = y / cHeight;\r
+ wrappedBlock += av.getStartRes() / cwidth;\r
+\r
+ res = wrappedBlock * cwidth + x / av.getCharWidth();\r
+\r
}\r
else\r
{\r
\r
int findSeq(MouseEvent evt)\r
{\r
+\r
int seq = 0;\r
int y = evt.getY();\r
\r
if (av.wrapAlignment)\r
{\r
- y -= (2 * av.charHeight);\r
- int chunkHeight = (av.getAlignment().getHeight() + 2) * av.charHeight;\r
- seq = ( (y % chunkHeight) / av.getCharHeight());\r
+ int hgap = av.charHeight;\r
+ if (av.scaleAboveWrapped)\r
+ hgap += av.charHeight;\r
+\r
+ int cHeight = av.getAlignment().getHeight() * av.charHeight\r
+ + hgap + seqCanvas.getAnnotationHeight();\r
+\r
+ y -= hgap;\r
+\r
+ seq = ( (y % cHeight) / av.getCharHeight());\r
}\r
else\r
{\r
\r
startWrapBlock=wrappedBlock;\r
\r
- if(seq<0 || res<0)\r
+ if(av.wrapAlignment && seq>av.alignment.getHeight())\r
+ {\r
+ JOptionPane.showInternalMessageDialog(Desktop.desktop,\r
+ "Cannot edit annotations in wrapped view.",\r
+ "Wrapped view - no edit",\r
+ JOptionPane.WARNING_MESSAGE);\r
return;\r
+ }\r
+\r
+ if(seq<0 || res<0)\r
+ return;\r
+\r
\r
SequenceI sequence = (Sequence) av.getAlignment().getSequenceAt(seq);\r
\r
"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n");\r
\r
for (int startRes = 0; startRes < al.getWidth();\r
- startRes += av.getChunkWidth())\r
+ startRes += av.getWrappedWidth())\r
{\r
- int endRes = startRes + av.getChunkWidth();\r
+ int endRes = startRes + av.getWrappedWidth();\r
\r
if (endRes > al.getWidth())\r
{\r