X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FAnnotationPanel.java;h=5b5a884dbab045138996bee684cd374dde88638c;hb=9d30955a72847c8906b55fd458380762d84ea8ee;hp=74505554f45fe802fc4677c2aee01cacd3d7105b;hpb=c73c8c28e34bdcac21e89aa89b69e85dad9e0189;p=jalview.git diff --git a/src/jalview/gui/AnnotationPanel.java b/src/jalview/gui/AnnotationPanel.java index 7450555..5b5a884 100755 --- a/src/jalview/gui/AnnotationPanel.java +++ b/src/jalview/gui/AnnotationPanel.java @@ -21,14 +21,19 @@ package jalview.gui; import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; import jalview.datamodel.ColumnSelection; +import jalview.datamodel.HiddenColumns; import jalview.datamodel.SequenceI; import jalview.renderer.AnnotationRenderer; import jalview.renderer.AwtRenderPanelI; import jalview.schemes.ResidueProperties; import jalview.util.Comparison; import jalview.util.MessageManager; +import jalview.util.Platform; +import jalview.viewmodel.ViewportListenerI; +import jalview.viewmodel.ViewportRanges; import java.awt.AlphaComposite; import java.awt.Color; @@ -49,13 +54,13 @@ import java.awt.event.MouseMotionListener; import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelListener; import java.awt.image.BufferedImage; +import java.beans.PropertyChangeEvent; import java.util.ArrayList; import java.util.Collections; import java.util.List; import javax.swing.JColorChooser; import javax.swing.JMenuItem; -import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; import javax.swing.Scrollable; @@ -70,8 +75,13 @@ import javax.swing.ToolTipManager; */ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, MouseListener, MouseWheelListener, MouseMotionListener, - ActionListener, AdjustmentListener, Scrollable + ActionListener, AdjustmentListener, Scrollable, ViewportListenerI { + enum DragMode + { + Select, Resize, Undefined + }; + String HELIX = MessageManager.getString("label.helix"); String SHEET = MessageManager.getString("label.sheet"); @@ -115,16 +125,14 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, // Used For mouse Dragging and resizing graphs int graphStretch = -1; - int graphStretchY = -1; + int mouseDragLastX = -1; - int min; // used by mouseDragged to see if user + int mouseDragLastY = -1; - int max; // used by mouseDragged to see if user + DragMode dragMode = DragMode.Undefined; boolean mouseDragging = false; - boolean MAC = false; - // for editing cursor int cursorX = 0; @@ -142,9 +150,6 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, */ public AnnotationPanel(AlignmentPanel ap) { - - MAC = jalview.util.Platform.isAMac(); - ToolTipManager.sharedInstance().registerComponent(this); ToolTipManager.sharedInstance().setInitialDelay(0); ToolTipManager.sharedInstance().setDismissDelay(10000); @@ -161,6 +166,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, // and then set our own listener to consume all mousewheel events ap.annotationScroller.addMouseWheelListener(this); renderer = new AnnotationRenderer(); + + av.getRanges().addPropertyChangeListener(this); } public AnnotationPanel(AlignViewport av) @@ -169,20 +176,27 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI, renderer = new AnnotationRenderer(); } + /** + * Responds to a mouse wheel movement by scrolling the annotations up or down. + * Annotation labels are scrolled via method adjustmentValueChanged when the + * vertical scrollbar is adjusted. + *
+ * If shift is pressed, then scrolling is left or right instead, and is + * delegated to AlignmentPanel, so that both sequences and annotations are + * scrolled together. + *
+ * This object is a MouseWheelListener to AnnotationLabels, so mouse wheel + * events over the labels are delegated to this method. + *
+ * Note that this method may also be fired by scrolling with a gesture on a
+ * trackpad.
+ */
@Override
public void mouseWheelMoved(MouseWheelEvent e)
{
if (e.isShiftDown())
{
- e.consume();
- if (e.getWheelRotation() > 0)
- {
- ap.scrollRight(true);
- }
- else
- {
- ap.scrollRight(false);
- }
+ ap.getSeqPanel().mouseWheelMoved(e);
}
else
{
@@ -205,7 +219,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
@Override
public Dimension getPreferredScrollableViewportSize()
{
- return getPreferredSize();
+ Dimension ps = getPreferredSize();
+ return new Dimension(ps.width, adjustForAlignFrame(false, ps.height));
}
@Override
@@ -285,7 +300,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
if (anot.length < av.getColumnSelection().getMax())
{
- Annotation[] temp = new Annotation[av.getColumnSelection().getMax() + 2];
+ Annotation[] temp = new Annotation[av.getColumnSelection().getMax()
+ + 2];
System.arraycopy(anot, 0, temp, 0, anot.length);
anot = temp;
aa[activeRow].annotations = anot;
@@ -296,7 +312,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
{
for (int index : av.getColumnSelection().getSelected())
{
- if (av.getColumnSelection().isVisible(index))
+ if (av.getAlignment().getHiddenColumns().isVisible(index))
{
anot[index] = null;
}
@@ -305,7 +321,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
else if (action.equals(LABEL))
{
String exMesg = collectAnnotVals(anot, LABEL);
- String label = JOptionPane.showInputDialog(this,
+ String label = JvOptionPane.showInputDialog(this,
MessageManager.getString("label.enter_label"), exMesg);
if (label == null)
@@ -320,7 +336,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
for (int index : av.getColumnSelection().getSelected())
{
- if (!av.getColumnSelection().isVisible(index))
+ if (!av.getAlignment().getHiddenColumns().isVisible(index))
{
continue;
}
@@ -343,7 +359,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
for (int index : av.getColumnSelection().getSelected())
{
- if (!av.getColumnSelection().isVisible(index))
+ if (!av.getAlignment().getHiddenColumns().isVisible(index))
{
continue;
}
@@ -385,7 +401,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
aa[activeRow].hasIcons = true;
}
- String label = JOptionPane.showInputDialog(MessageManager
+ String label = JvOptionPane.showInputDialog(MessageManager
.getString("label.enter_label_for_the_structure"), symbol);
if (label == null)
@@ -403,7 +419,7 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
}
for (int index : av.getColumnSelection().getSelected())
{
- if (!av.getColumnSelection().isVisible(index))
+ if (!av.getAlignment().getHiddenColumns().isVisible(index))
{
continue;
}
@@ -413,8 +429,8 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
anot[index] = new Annotation(label, "", type, 0);
}
- anot[index].secondaryStructure = type != 'S' ? type : label
- .length() == 0 ? ' ' : label.charAt(0);
+ anot[index].secondaryStructure = type != 'S' ? type
+ : label.length() == 0 ? ' ' : label.charAt(0);
anot[index].displayCharacter = label;
}
@@ -446,25 +462,26 @@ public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
StringBuilder collatedInput = new StringBuilder(64);
String last = "";
ColumnSelection viscols = av.getColumnSelection();
+ HiddenColumns hidden = av.getAlignment().getHiddenColumns();
/*
* the selection list (read-only view) is in selection order, not
* column order; make a copy so we can sort it
*/
- List