X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FSeqCanvas.java;h=aa98e76cdef6b2c32069cea96d313b2c5a9992be;hb=d1a58585358deed317674daeeac5fb5be66637ab;hp=50d1f7b9cefb7886242ba52801479f009dc8225c;hpb=174230b4233d9ce80f94527768d2cd2f76da11ab;p=jalview.git diff --git a/src/jalview/gui/SeqCanvas.java b/src/jalview/gui/SeqCanvas.java index 50d1f7b..aa98e76 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, @@ -529,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); @@ -600,10 +625,11 @@ public class SeqCanvas extends JComponent if(av.getShowHiddenMarkers()) { g1.setColor(Color.blue); + g1.drawLine( (blockEnd - blockStart + 1) * av.charWidth - 1, - startSeq + offset, + 0 + offset, (blockEnd - blockStart + 1) * av.charWidth - 1, - startSeq + (endSeq - startSeq) * av.charHeight + offset); + (endSeq - startSeq) * av.charHeight + offset); } g1.translate( -screenY * av.charWidth, 0); @@ -698,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)) { @@ -705,6 +732,7 @@ public class SeqCanvas extends JComponent groupIndex = 0; } + if (group != null) { do @@ -722,7 +750,7 @@ 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; } @@ -769,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) @@ -781,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; @@ -807,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) @@ -819,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; @@ -841,6 +869,8 @@ public class SeqCanvas extends JComponent groupIndex++; + g.setStroke(new BasicStroke()); + if (groupIndex >= av.alignment.getGroups().size()) { break; @@ -848,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());