1 /*******************************************************************************
2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, 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/>.
17 *******************************************************************************/
18 package jalview.javascript;
20 import java.util.Vector;
22 import jalview.appletgui.AlignFrame;
23 import jalview.bin.JalviewLite;
24 import jalview.datamodel.SequenceI;
25 import jalview.structure.VamsasListener;
26 import jalview.structure.VamsasSource;
27 import netscape.javascript.JSObject;
29 public class MouseOverListener extends JSFunctionExec implements
30 VamsasListener, JsCallBack
36 SequenceI last = null;
40 public void mouseOver(SequenceI seq, int index, VamsasSource source)
42 if (seq != last || i != index)
44 // this should really be a trace message.
45 // Cache.log.debug("Mouse over " + v.getId() + " bound to "
46 // + seq + " at " + index);
49 AlignFrame src = null;
54 if (source instanceof jalview.appletgui.AlignViewport
55 && ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame.viewport == source)
57 // should be valid if it just generated an event!
58 src = ((jalview.appletgui.AlignViewport) source).applet.currentAlignFrame;
61 // TODO: ensure that if '_af' is specified along with a handler function, then only events from that alignFrame are sent to that function
63 executeJavascriptFunction(_listener, new Object[]
64 { src, seq.getDisplayId(false), "" + (1 + i), ""+seq.findPosition(i) });
65 } catch (Exception ex)
69 .println("JalviewLite javascript error: Couldn't send mouseOver with handler '"
71 if (ex instanceof netscape.javascript.JSException)
73 System.err.println("Javascript Exception: "
74 + ((netscape.javascript.JSException) ex).getMessage());
81 public MouseOverListener(JalviewLite applet, AlignFrame af,
90 public AlignFrame getAlignFrame()
96 public String getListenerFunction()