X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqCanvas.java;h=aa98e76cdef6b2c32069cea96d313b2c5a9992be;hb=488e3a038c2ba1a3926f2af5eaea97ba76e028d0;hp=15c15c3d25c0768cd90a6300ae7a09a9a2839703;hpb=92fbe9788fe62f1e3fcf22e5e64a289d426b1869;p=jalview.git diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 15c15c3..aa98e76 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -1,6 +1,6 @@ /* * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * Copyright (C) 2006 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -62,7 +62,7 @@ public class SeqCanvas extends JComponent fr = new FeatureRenderer(av); sr = new SequenceRenderer(av); setLayout(new BorderLayout()); - PaintRefresher.Register(this, av.alignment); + PaintRefresher.Register(this, av.getSequenceSetId()); setBackground(Color.white); } @@ -133,9 +133,16 @@ public class SeqCanvas extends JComponent ypos += av.charHeight; if(av.hasHiddenColumns) - startx = av.getColumnSelection().adjustForHiddenColumns(startx); + { + startx = av.getColumnSelection().adjustForHiddenColumns(startx); + endx = av.getColumnSelection().adjustForHiddenColumns(endx); + } - // EAST SCALE + int maxwidth = av.alignment.getWidth(); + if (av.hasHiddenColumns) + maxwidth = av.getColumnSelection().findColumnPosition(maxwidth) - 1; + + // WEST SCALE for (int i = 0; i < av.alignment.getHeight(); i++) { SequenceI seq = av.alignment.getSequenceAt(i); @@ -321,9 +328,34 @@ public class SeqCanvas extends JComponent return; } - img = new BufferedImage(imgWidth, imgHeight, BufferedImage.TYPE_INT_RGB); - gg = (Graphics2D) img.getGraphics(); - gg.setFont(av.getFont()); + if (img == null || imgWidth != img.getWidth() || imgHeight != img.getHeight()) + { + try{ + img = new BufferedImage(imgWidth, imgHeight, + BufferedImage.TYPE_INT_RGB); + gg = (Graphics2D) img.getGraphics(); + gg.setFont(av.getFont()); + }catch(OutOfMemoryError er) + { + System.gc(); + System.out.println(er +" making image, SeqCanvas"); + javax.swing.SwingUtilities.invokeLater(new Runnable() + { + public void run() + { + javax.swing.JOptionPane.showInternalMessageDialog(Desktop. + desktop, + "Out of memory creating alignment image!!" + + + "\nSee help files for increasing Java Virtual Machine memory." + , "Out of memory", + javax.swing.JOptionPane.WARNING_MESSAGE); + } + }); + + return; + } + } if (av.antiAlias) gg.setRenderingHint(RenderingHints.KEY_ANTIALIASING, @@ -404,7 +436,6 @@ public class SeqCanvas extends JComponent public void drawWrappedPanel(Graphics g, int canvasWidth, int canvasHeight, int startRes) { - AlignmentI al = av.getAlignment(); FontMetrics fm = getFontMetrics(av.getFont()); @@ -435,14 +466,18 @@ public class SeqCanvas extends JComponent int endx; int ypos = hgap; + int maxwidth = av.alignment.getWidth(); + + if(av.hasHiddenColumns) + maxwidth = av.getColumnSelection().findColumnPosition(maxwidth)-1; - while ((ypos <= canvasHeight) && (startRes < av.alignment.getWidth())) + while ((ypos <= canvasHeight) && (startRes < maxwidth)) { endx = startRes + cWidth -1; - if (endx > al.getWidth()) + if (endx > maxwidth) { - endx = al.getWidth(); + endx = maxwidth; } g.setFont(av.getFont()); @@ -467,6 +502,35 @@ public class SeqCanvas extends JComponent drawNorthScale(g, startRes, endx, ypos); } + if (av.hasHiddenColumns && av.showHiddenMarkers) + { + g.setColor(Color.blue); + int res; + for (int i = 0; i < av.getColumnSelection().getHiddenColumns().size(); + i++) + { + res = av.getColumnSelection().findHiddenRegionPosition(i) - + startRes; + + if (res < 0 || res > endx - startRes) + continue; + + gg.fillPolygon(new int[] + {res * av.charWidth - av.charHeight / 4, + res * av.charWidth + av.charHeight / 4, + res * av.charWidth}, + new int[] + { + ypos - (av.charHeight / 2), + ypos - (av.charHeight / 2), + ypos - (av.charHeight / 2) + 8 + }, 3); + + } + } + + + // When printing we have an extra clipped region, // the Printable page which we need to account for here Shape clip = g.getClip(); @@ -490,7 +554,7 @@ public class SeqCanvas extends JComponent annotations = new AnnotationPanel(av); annotations.drawComponent( (Graphics2D) g, startRes, endx+1); - g.translate(0, -cHeight - ypos); + g.translate(0, -cHeight - ypos -3); } g.setClip(clip); g.translate(-LABEL_WEST, 0); @@ -558,15 +622,15 @@ public class SeqCanvas extends JComponent draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); - g1.setColor(Color.blue); - g1.drawLine( (blockEnd - blockStart + 1) * av.charWidth - 1, - startSeq + offset, - (blockEnd - blockStart + 1) * av.charWidth - 1, - startSeq + (endSeq - startSeq) * av.charHeight + offset); - g1.drawLine( (blockEnd - blockStart + 1) * av.charWidth, - startSeq + offset, - (blockEnd - blockStart + 1) * av.charWidth, - startSeq + (endSeq - startSeq) * av.charHeight + offset); + if(av.getShowHiddenMarkers()) + { + g1.setColor(Color.blue); + + g1.drawLine( (blockEnd - blockStart + 1) * av.charWidth - 1, + 0 + offset, + (blockEnd - blockStart + 1) * av.charWidth - 1, + (endSeq - startSeq) * av.charHeight + offset); + } g1.translate( -screenY * av.charWidth, 0); screenY += blockEnd - blockStart + 1; @@ -578,6 +642,7 @@ public class SeqCanvas extends JComponent blockEnd = blockStart + (endRes - startRes) - screenY; g1.translate(screenY * av.charWidth, 0); draw(g1, blockStart, blockEnd, startSeq, endSeq, offset); + g1.translate( -screenY * av.charWidth, 0); } } @@ -659,6 +724,7 @@ public class SeqCanvas extends JComponent int sy = -1; int ex = -1; int groupIndex = -1; + int visWidth = (endRes - startRes +1) * av.charWidth; if ((group == null) && (av.alignment.getGroups().size() > 0)) { @@ -666,6 +732,7 @@ public class SeqCanvas extends JComponent groupIndex = 0; } + if (group != null) { do @@ -683,17 +750,17 @@ public class SeqCanvas extends JComponent ex = (((group.getEndRes() + 1) - group.getStartRes()) * av.charWidth) - 1; - if(sx+ex<0 || sx>imgWidth) + if(sx+ex<0 || sx>visWidth) { continue; } if ( (sx <= (endRes-startRes)*av.charWidth) && - group.sequences.contains(av.alignment.getSequenceAt( - i))) + group.getSequences(false). + contains(av.alignment.getSequenceAt(i))) { if ((bottom == -1) && - !group.sequences.contains( + !group.getSequences(false).contains( av.alignment.getSequenceAt(i + 1))) { bottom = sy + av.charHeight; @@ -702,7 +769,7 @@ public class SeqCanvas extends JComponent if (!inGroup) { if (((top == -1) && (i == 0)) || - !group.sequences.contains( + !group.getSequences(false).contains( av.alignment.getSequenceAt(i - 1))) { top = sy; @@ -730,10 +797,10 @@ public class SeqCanvas extends JComponent { if (inGroup) { - if (sx >= 0 && sx < imgWidth) + if (sx >= 0 && sx < visWidth) g.drawLine(sx, oldY, sx, sy); - if (sx + ex < imgWidth) + if (sx + ex < visWidth) g.drawLine(sx + ex, oldY, sx + ex, sy); if (sx < 0) @@ -742,8 +809,8 @@ public class SeqCanvas extends JComponent sx = 0; } - if (sx + ex > imgWidth) - ex = imgWidth; + if (sx + ex > visWidth) + ex = visWidth; else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) ex = (endRes - startRes + 1) * av.charWidth; @@ -768,10 +835,10 @@ public class SeqCanvas extends JComponent if (inGroup) { sy = offset + ( (i - startSeq) * av.charHeight); - if (sx >= 0 && sx < imgWidth) + if (sx >= 0 && sx < visWidth) g.drawLine(sx, oldY, sx, sy); - if (sx + ex < imgWidth) + if (sx + ex < visWidth) g.drawLine(sx + ex, oldY, sx + ex, sy); if (sx < 0) @@ -780,8 +847,8 @@ public class SeqCanvas extends JComponent sx = 0; } - if (sx + ex > imgWidth) - ex = imgWidth; + if (sx + ex > visWidth) + ex = visWidth; else if (sx + ex >= (endRes - startRes + 1) * av.charWidth) ex = (endRes - startRes + 1) * av.charWidth; @@ -802,6 +869,8 @@ public class SeqCanvas extends JComponent groupIndex++; + g.setStroke(new BasicStroke()); + if (groupIndex >= av.alignment.getGroups().size()) { break; @@ -809,7 +878,7 @@ public class SeqCanvas extends JComponent group = (SequenceGroup) av.alignment.getGroups().elementAt(groupIndex); - g.setStroke(new BasicStroke()); + } while (groupIndex < av.alignment.getGroups().size());