X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=93af6ec83f40402919d343286f881ef79a979c5e;hb=d043ce47fc710d3eb2629ba926a8a7417bd67d8c;hp=e9ef19c03eee53a7f83cdfd88541c743b1c7627c;hpb=04c8f7bff663aa469127e9eed4164e02933782f1;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index e9ef19c..93af6ec 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -150,6 +150,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, */ public AnnotationPanel(AlignmentPanel ap) { + setName("AnnotationPanel"); ToolTipManager.sharedInstance().registerComponent(this); ToolTipManager.sharedInstance().setInitialDelay(0); ToolTipManager.sharedInstance().setDismissDelay(10000); @@ -726,13 +727,13 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, } if (dragMode == DragMode.Undefined) - { + { /* * drag is diagonal - defer deciding whether to * treat as up/down or left/right */ - return; - } + return; + } try { @@ -749,6 +750,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, int newHeight = Math.max(0, graphAnnotation.graphHeight + deltaY); graphAnnotation.graphHeight = newHeight; adjustPanelHeight(); + setNoFastPaint(); ap.paintAlignment(false, false); } } @@ -890,6 +892,10 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, && ann.annotations[column] != null) { tooltip = ann.annotations[column].description; + if ("".equals(tooltip)) + { + tooltip = null; + } } return tooltip; @@ -1001,7 +1007,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, } private volatile boolean imageFresh = false; - private Rectangle visibleRect = new Rectangle(), clipBounds = new Rectangle(); @@ -1014,7 +1019,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, @Override public void paintComponent(Graphics g) { - // BH: note that this method is generally recommended to // call super.paintComponent(g). Otherwise, the children of this // component will not be rendered. That is not needed here @@ -1022,11 +1026,12 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, // just a JPanel contained in a JViewPort. computeVisibleRect(visibleRect); - g.setColor(Color.white); g.fillRect(0, 0, visibleRect.width, visibleRect.height); - if (image != null) + ViewportRanges ranges = av.getRanges(); + + if (allowFastPaint && image != null) { // BH 2018 optimizing generation of new Rectangle(). if (fastPaint @@ -1035,15 +1040,17 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, || (visibleRect.height != clipBounds.height)) { - g.drawImage(image, 0, 0, this); + + g.drawImage(image, 0, 0, this); fastPaint = false; return; } } - imgWidth = (av.getRanges().getEndRes() - av.getRanges().getStartRes() - + 1) * av.getCharWidth(); + imgWidth = (ranges.getEndRes() - ranges.getStartRes() + 1) + * av.getCharWidth(); if (imgWidth < 1) { + fastPaint = false; return; } Graphics2D gg; @@ -1088,7 +1095,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, gg = (Graphics2D) image.getGraphics(); } - + drawComponent(gg, av.getRanges().getStartRes(), av.getRanges().getEndRes() + 1); gg.dispose(); @@ -1097,11 +1104,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, } /** - * set true to enable redraw timing debug output on stderr - */ - private final boolean debugRedraw = false; - - /** * non-Thread safe repaint * * @param horizontal @@ -1122,6 +1124,11 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, int er = av.getRanges().getEndRes() + 1; int transX = 0; + if (er == sr + 1) + { + fastPaint = false; + return; + } Graphics2D gg = (Graphics2D) image.getGraphics(); if (imgWidth>Math.abs(horizontal*av.getCharWidth())) { @@ -1139,6 +1146,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, er = sr - horizontal; } } + gg.translate(transX, 0); drawComponent(gg, sr, er); @@ -1146,7 +1154,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, gg.translate(-transX, 0); gg.dispose(); - fastPaint = true; // Call repaint on alignment panel so that repaints from other alignment @@ -1264,6 +1271,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, private int[] bounds = new int[2]; + private boolean allowFastPaint; @Override public int[] getVisibleVRange() { @@ -1370,4 +1378,13 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, } return annotationHeight; } + + /** + * Clears the flag that allows a 'fast paint' on the next repaint, so + * requiring a full repaint + */ + public void setNoFastPaint() + { + allowFastPaint = false; + } }