2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.javascript;
20 import jalview.appletgui.AlignFrame;
21 import jalview.bin.JalviewLite;
22 import jalview.datamodel.SequenceI;
23 import jalview.structure.VamsasListener;
24 import jalview.structure.VamsasSource;
26 public class MouseOverListener extends JSFunctionExec implements
27 VamsasListener, JsCallBack
33 SequenceI last = null;
37 public void mouseOver(SequenceI seq, int index, VamsasSource source)
39 if (seq != last || i != index)
41 // this should really be a trace message.
42 // Cache.log.debug("Mouse over " + v.getId() + " bound to "
43 // + seq + " at " + index);
46 AlignFrame src = null;
51 if (source instanceof jalview.appletgui.AlignViewport
52 && ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame.viewport == source)
54 // should be valid if it just generated an event!
55 src = ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame;
58 // TODO: ensure that if '_af' is specified along with a handler
59 // function, then only events from that alignFrame are sent to that
62 executeJavascriptFunction(
65 { src, seq.getDisplayId(false), "" + (1 + i),
66 "" + seq.findPosition(i) });
67 } catch (Exception ex)
71 .println("JalviewLite javascript error: Couldn't send mouseOver with handler '"
73 if (ex instanceof netscape.javascript.JSException)
75 System.err.println("Javascript Exception: "
76 + ((netscape.javascript.JSException) ex).getMessage());
83 public MouseOverListener(JalviewLite applet, AlignFrame af,
92 public AlignFrame getAlignFrame()
98 public String getListenerFunction()