X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=49d4554069082906c231bb3f7b1fc674fe418074;hb=242fbce514e8895977fb7bbd20147cf0fe630407;hp=be8f5f6a89dbfa1d328cd41c538df118673c0ac4;hpb=3d0101179759ef157b088ea135423cd909512d9f;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index be8f5f6..49d4554 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -25,8 +25,10 @@ import jalview.datamodel.Annotation; import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenColumns; import jalview.datamodel.SequenceI; +import jalview.gui.JalviewColourChooser.ColourChooserListener; import jalview.renderer.AnnotationRenderer; import jalview.renderer.AwtRenderPanelI; +import jalview.schemes.FeatureColour; import jalview.schemes.ResidueProperties; import jalview.util.Comparison; import jalview.util.MessageManager; @@ -58,6 +60,7 @@ import java.util.Collections; import java.util.List; import javax.swing.JColorChooser; +import javax.swing.JDialog; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.JPopupMenu; @@ -175,11 +178,12 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (e.isShiftDown()) { e.consume(); - if (e.getWheelRotation() > 0) + double wheelRotation = e.getPreciseWheelRotation(); + if (wheelRotation > 0) { av.getRanges().scrollRight(true); } - else + else if (wheelRotation < 0) { av.getRanges().scrollRight(false); } @@ -338,24 +342,29 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, } else if (action.equals(COLOUR)) { - Color col = JColorChooser.showDialog(this, - MessageManager.getString("label.select_foreground_colour"), - Color.black); - - for (int index : av.getColumnSelection().getSelected()) + final Annotation[] fAnot = anot; + String title = MessageManager + .getString("label.select_foreground_colour"); + ColourChooserListener listener = new ColourChooserListener() { - if (!av.getAlignment().getHiddenColumns().isVisible(index)) + @Override + public void colourSelected(Color c) { - continue; - } - - if (anot[index] == null) - { - anot[index] = new Annotation("", "", ' ', 0); - } - - anot[index].colour = col; - } + HiddenColumns hiddenColumns = av.getAlignment().getHiddenColumns(); + for (int index : av.getColumnSelection().getSelected()) + { + if (hiddenColumns.isVisible(index)) + { + if (fAnot[index] == null) + { + fAnot[index] = new Annotation("", "", ' ', 0); + } + fAnot[index].colour = c; + } + }}; + }; + JalviewColourChooser.showColourChooser(this, + title, Color.black, listener); } else // HELIX, SHEET or STEM @@ -670,7 +679,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, } graphStretchY = evt.getY(); adjustPanelHeight(); - ap.paintAlignment(true); + ap.paintAlignment(false, false); } else { @@ -724,7 +733,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, if (av.hasHiddenColumns()) { column = av.getAlignment().getHiddenColumns() - .adjustForHiddenColumns(column); + .visibleToAbsoluteColumn(column); } AlignmentAnnotation ann = aa[row]; @@ -782,6 +791,10 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, { this.setToolTipText(JvSwingUtils.wrapTooltip(true, description)); } + else + { + this.setToolTipText(null); // no tooltip if null or empty description + } } else { @@ -904,6 +917,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, @Override public void paintComponent(Graphics g) { + super.paintComponent(g); + g.setColor(Color.white); g.fillRect(0, 0, getWidth(), getHeight()); @@ -959,7 +974,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, gg.fillRect(0, 0, imgWidth, image.getHeight()); imageFresh = true; } - + drawComponent(gg, av.getRanges().getStartRes(), av.getRanges().getEndRes() + 1); imageFresh = false; @@ -992,10 +1007,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, int er = av.getRanges().getEndRes() + 1; int transX = 0; - long stime = System.currentTimeMillis(); gg.copyArea(0, 0, imgWidth, getHeight(), -horizontal * av.getCharWidth(), 0); - long mtime = System.currentTimeMillis(); if (horizontal > 0) // scrollbar pulled right, image to the left { @@ -1012,17 +1025,13 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, drawComponent(gg, sr, er); gg.translate(-transX, 0); - long dtime = System.currentTimeMillis(); + fastPaint = true; - repaint(); - long rtime = System.currentTimeMillis(); - if (debugRedraw) - { - System.err.println("Scroll:\t" + horizontal + "\tCopyArea:\t" - + (mtime - stime) + "\tDraw component:\t" + (dtime - mtime) - + "\tRepaint call:\t" + (rtime - dtime)); - } + // Call repaint on alignment panel so that repaints from other alignment + // panel components can be aggregated. Otherwise performance of the overview + // window and others may be adversely affected. + av.getAlignPanel().repaint(); } private volatile boolean lastImageGood = false; @@ -1185,5 +1194,14 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, { fastPaint((int) evt.getNewValue() - (int) evt.getOldValue()); } + else if (evt.getPropertyName().equals(ViewportRanges.STARTRESANDSEQ)) + { + fastPaint(((int[]) evt.getNewValue())[0] + - ((int[]) evt.getOldValue())[0]); + } + else if (evt.getPropertyName().equals(ViewportRanges.MOVE_VIEWPORT)) + { + repaint(); + } } }