* @version $Revision$
*/
public class AnnotationPanel extends JPanel implements AwtRenderPanelI,
- MouseListener, MouseMotionListener, ActionListener,
- AdjustmentListener
+ MouseListener, MouseWheelListener, MouseMotionListener,
+ ActionListener, AdjustmentListener, Scrollable
{
final String HELIX = "Helix";
public final AnnotationRenderer renderer;
+ private MouseWheelListener[] _mwl;
+
/**
* Creates a new AnnotationPanel object.
*
addMouseMotionListener(this);
ap.annotationScroller.getVerticalScrollBar()
.addAdjustmentListener(this);
+ // save any wheel listeners on the scroller, so we can propagate scroll events to them.
+ _mwl = ap.annotationScroller.getMouseWheelListeners();
+ // and then set our own listener to consume all mousewheel events
+ ap.annotationScroller.addMouseWheelListener(this);
renderer = new AnnotationRenderer();
}
renderer = new AnnotationRenderer();
}
- /**
- * DOCUMENT ME!
- *
- * @param evt
- * DOCUMENT ME!
+ @Override
+ public void mouseWheelMoved(MouseWheelEvent e)
+ {
+ if (e.isShiftDown())
+ {
+ e.consume();
+ if (e.getWheelRotation() > 0)
+ {
+ ap.scrollRight(true);
+ }
+ else
+ {
+ ap.scrollRight(false);
+ }
+ }
+ else
+ {
+ // TODO: find the correct way to let the event bubble up to ap.annotationScroller
+ for (MouseWheelListener mwl : _mwl)
+ {
+ if (mwl != null)
+ {
+ mwl.mouseWheelMoved(e);
+ }
+ if (e.isConsumed())
+ {
+ break;
+ }
+ }
+ }
+ }
+
+ @Override
+ public Dimension getPreferredScrollableViewportSize()
+ {
+ return getPreferredSize();
+ }
+
+ @Override
+ public int getScrollableBlockIncrement(Rectangle visibleRect,
+ int orientation, int direction)
+ {
+ return 30;
+ }
+
+ @Override
+ public boolean getScrollableTracksViewportHeight()
+ {
+ return false;
+ }
+
+ @Override
+ public boolean getScrollableTracksViewportWidth()
+ {
+ return true;
+ }
+
+ @Override
+ public int getScrollableUnitIncrement(Rectangle visibleRect,
+ int orientation, int direction)
+ {
+ return 30;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see java.awt.event.AdjustmentListener#adjustmentValueChanged(java.awt.event.AdjustmentEvent)
*/
@Override
public void adjustmentValueChanged(AdjustmentEvent evt)
{
+ // update annotation label display
ap.alabels.setScrollOffset(-evt.getValue());
}