X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqCanvas.java;h=45bcf66d4c7bbb62c62229db86ad53007fe25719;hb=d3760e28db022dd704f19d0e2df05af8675cf3c3;hp=b4ef770883b7d6947dd810d688dd4d1666219b12;hpb=c20e9d4ae9c98b093e74a10bf965e6d20d80fadf;p=jalview.git diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index b4ef770..45bcf66 100755 --- a/src/jalview/gui/SeqCanvas.java +++ b/src/jalview/gui/SeqCanvas.java @@ -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); } @@ -328,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, @@ -393,7 +418,16 @@ public class SeqCanvas extends JComponent String getMask() { String mask = "00"; - for (int i = av.alignment.getWidth(); i > 0; i /= 10) + int maxWidth = 0; + int tmp; + for(int i=0; imaxWidth) + maxWidth = tmp; + } + + for (int i = maxWidth; i > 0; i /= 10) { mask += "0"; } @@ -441,7 +475,7 @@ public class SeqCanvas extends JComponent int endx; int ypos = hgap; - int maxwidth = av.alignment.getWidth(); + int maxwidth = av.alignment.getWidth()-1; if(av.hasHiddenColumns) maxwidth = av.getColumnSelection().findColumnPosition(maxwidth)-1; @@ -529,14 +563,12 @@ 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); ypos += cHeight+getAnnotationHeight()+hgap; - if(av.showAnnotation) - ypos -= 3; startRes += cWidth; } @@ -602,7 +634,7 @@ public class SeqCanvas extends JComponent g1.setColor(Color.blue); g1.drawLine( (blockEnd - blockStart + 1) * av.charWidth - 1, - 0+offset, + 0 + offset, (blockEnd - blockStart + 1) * av.charWidth - 1, (endSeq - startSeq) * av.charHeight + offset); } @@ -731,11 +763,11 @@ public class SeqCanvas extends JComponent } if ( (sx <= (endRes-startRes)*av.charWidth) && - group.getSequences(false). + group.getSequences(null). contains(av.alignment.getSequenceAt(i))) { if ((bottom == -1) && - !group.getSequences(false).contains( + !group.getSequences(null).contains( av.alignment.getSequenceAt(i + 1))) { bottom = sy + av.charHeight; @@ -744,7 +776,7 @@ public class SeqCanvas extends JComponent if (!inGroup) { if (((top == -1) && (i == 0)) || - !group.getSequences(false).contains( + !group.getSequences(null).contains( av.alignment.getSequenceAt(i - 1))) { top = sy;