I've tried moving the Viewer instances to the top level content pane rather
than inside a JSplitPane and the same problem persists.

Dave


On 15 April 2013 14:26, N David Brown <hubd...@gmail.com> wrote:

> Thanks for this example, Bob.
>
> I've implemented as suggested and printouts show I receive many events
> such as SCRIPT, RESIZE, CLICK. However no HOVER events are generated.
>
> Is there an obvious reason why this might happen?
>
> I'm using two JmolPanel instances embedded into a JSplitPane. The
> JmolPanel definition is from the Jmol wiki iirc:
>
> public class JmolPanel extends JPanel {
>
>     private static final long serialVersionUID = 2422145881008561710L;
>
>     JmolViewer viewer;
>
>     private final Dimension currentSize = new Dimension();
>
>     public JmolPanel() {
>         viewer = JmolViewer.allocateViewer(this, new SmarterJmolAdapter(), 
> null, null, null, null, null);
>     }
>
>     @Override
>     public void paint(Graphics g) {
>         getSize(currentSize);
>         viewer.renderScreenImage(g, currentSize.width, currentSize.height);
>     }
>
>     public JmolViewer getViewer() {
>         return viewer;
>     }
> }
>
> The JmolCallbackListener I instantiate for both
> Viewer#setJmolCallbackListener calls is:
>
> public class CallbackListener implements JmolCallbackListener {
>
>     final private CustomAppConsole appConsole;
>     private int callbackId = 0;
>
>     public CallbackListener(final CustomAppConsole appConsole) {
>         this.appConsole = appConsole;
>     }
>
>     @Override
>     public void setCallbackFunction(String callbackType, String 
> callbackFunction) {
>         appConsole.setCallbackFunction(callbackType, callbackFunction);
>     }
>
>     @Override
>     public boolean notifyEnabled(EnumCallback type) {
>         System.out.println(String.format("Callback %d: 
> %s",callbackId++,type));
>
> switch (type) {
>         case HOVER:
>             return true
> ;
>         }
>         return appConsole.notifyEnabled(type);
>     }
>
>     @Override
>     public void notifyCallback(EnumCallback type, Object[] data) {
>         appConsole.notifyCallback(type, data);
>         String strInfo = (data == null || data[1] == null ? null : 
> data[1].toString());
>         switch (type) {
>         case HOVER:
>             if (strInfo != null) {
>                 System.out.println("HOVER: " + strInfo);
>             }
>             break;
>         }
>     }
> }
>
> The class CustomAppConsole is my subclass of AppConsole.
>
> Dave
>
>
> On 15 April 2013 14:04, Robert Hanson <hans...@stolaf.edu> wrote:
>
>> yes, this sounds like the way to go.
>>
>>
>>   // / JmolCallbackListener interface ///
>>   public boolean notifyEnabled(EnumCallback type) {
>>     switch (type) {
>>     case HOVER:
>>       return true;
>>     }
>>     return false;
>>   }
>>
>>   @SuppressWarnings("incomplete-switch")
>>   public void notifyCallback(EnumCallback type, Object[] data) {
>>     String strInfo = (data == null || data[1] == null ? null : data[1]
>>         .toString());
>>     switch (type) {
>>     case HOVER:
>> ....
>>    }
>> }
>>
>>
>>
>> On Mon, Apr 15, 2013 at 4:33 AM, N David Brown <hubd...@gmail.com> wrote:
>>
>>> That command still doesn't work, Angel.
>>>
>>> set hovercallback = "jmolscript: select _atomHovered; colour atoms red"
>>>
>>> In other news - I've created a custom JmolCallbackListener which is
>>> giving me ECHO and PICK events.
>>>
>>> Is there a HOVER event or similar I can enable?
>>>
>>> This will give me the Java notification I need.
>>>
>>> Many thanks,
>>>
>>> Dave
>>>
>>>
>>> On 15 April 2013 10:12, N David Brown <hubd...@gmail.com> wrote:
>>>
>>>> Ah, thanks Angel.
>>>>
>>>> I'll make a note of that for future reference.
>>>>
>>>> Since realising I'll need to have a callback in my own Java code I'm
>>>> now looking at JmolCallbackListener.
>>>>
>>>> Cheers,
>>>>
>>>> Dave
>>>>
>>>>
>>>> On 15 April 2013 10:09, Angel Herráez <angel.herr...@uah.es> wrote:
>>>>
>>>>> > Just to clarify, I'm working in Java not JavaScript.
>>>>>
>>>>> Yes, callbacks are by default thought to be attached to a JavaScript
>>>>> function, that's why you need yo use the "jmolscript" prefix. After
>>>>> that, either you include Jmol commands (and 'script' is one of them)
>>>>> or a JmolScript function as bob suggested.
>>>>>
>>>>>
>>>>> > set hovercallback = "jmolscript:Jmol select
>>>>> >  _atomHovered; colour atoms red"
>>>>> >
>>>>>
>>>>> Sorry I was not too explanative. This will be it:
>>>>>  set hovercallback = "jmolscript: select _atomHovered; colour atoms
>>>>> red"
>>>>>
>>>>>
>>>>>
>>>>> > Sadly this doesn't work.
>>>>> > Any suggestions? And could we have an example added to the
>>>>> > interactive script docs please?
>>>>> > Dave
>>>>> >
>>>>> >
>>>>> > On 15 April 2013 01:19, Robert Hanson <hans...@stolaf.edu> wrote:
>>>>> >     Just define a function and call it from your callback:
>>>>> >
>>>>> >
>>>>> >     function myfunc() {
>>>>> >     -- Jmol script here --
>>>>> >
>>>>> >
>>>>> >     }
>>>>> >
>>>>> >
>>>>> >     set hoverCallback "jmolscript:myfunc()"
>>>>> >
>>>>> >
>>>>> >     The global variable _atomhovered will contain the atom index of
>>>>> the
>>>>> >     hovered atom. So you can investigate it, perhaps:
>>>>> >
>>>>> >     function testme() {
>>>>> >
>>>>> >     Var theAtom = {atomindex=_atomHovered}
>>>>> >     if (theAtom.elemno==6) {hoverLabel="That's a carbon"} else
>>>>> >     {hoverLabel = "That's not a carbon"}
>>>>> >     }
>>>>> >
>>>>> >     set hovercallback "jmolscript:testme()"
>>>>> >
>>>>> >
>>>>> >
>>>>> >
>>>>> >     On Sun, Apr 14, 2013 at 5:21 PM, N David Brown <
>>>>> hubd...@gmail.com>
>>>>> >     wrote:
>>>>> >     I've seen this in the documentation:
>>>>> >
>>>>> >     set hoverCallback "jmolscript:script hover.spt"
>>>>> >
>>>>> >     I'd like my JAR to not have to deploy files like this hover.spt
>>>>> to
>>>>> >     the environment.
>>>>> >
>>>>> >     Is there an in-JAR filepath you can specify here?
>>>>> >
>>>>> >     Or an inline script variation?
>>>>> >
>>>>> >     Dave
>>>>> >
>>>>> >
>>>>> ----------------------------------------------------------------------
>>>>> >     --------
>>>>> >     Precog is a next-generation analytics platform capable of
>>>>> advanced
>>>>> >     analytics on semi-structured data. The platform includes APIs for
>>>>> >     building
>>>>> >     apps and a phenomenal toolset for data science. Developers can
>>>>> use
>>>>> >     our toolset for easy data analysis & visualization. Get a free
>>>>> >     account!
>>>>> >     http://www2.precog.com/precogplatform/slashdotnewsletter
>>>>> >     _______________________________________________
>>>>> >     Jmol-developers mailing list
>>>>> >     Jmol-developers@lists.sourceforge.net
>>>>> >     https://lists.sourceforge.net/lists/listinfo/jmol-developers
>>>>> >
>>>>> >
>>>>> >
>>>>> >     --
>>>>> >     Robert M. Hanson
>>>>> >     Larson-Anderson Professor of Chemistry
>>>>> >     Chair, Chemistry Department
>>>>> >     St. Olaf College
>>>>> >     Northfield, MN
>>>>> >     http://www.stolaf.edu/people/hansonr
>>>>> >
>>>>> >
>>>>> >     If nature does not answer first what we want,
>>>>> >     it is better to take what answer we get.
>>>>> >
>>>>> >     -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>>>>> >
>>>>> >
>>>>>
>>>>>
>>>>>
>>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>>
>>> Precog is a next-generation analytics platform capable of advanced
>>> analytics on semi-structured data. The platform includes APIs for
>>> building
>>> apps and a phenomenal toolset for data science. Developers can use
>>> our toolset for easy data analysis & visualization. Get a free account!
>>> http://www2.precog.com/precogplatform/slashdotnewsletter
>>> _______________________________________________
>>> Jmol-developers mailing list
>>> Jmol-developers@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/jmol-developers
>>>
>>>
>>
>>
>> --
>> Robert M. Hanson
>> Larson-Anderson Professor of Chemistry
>> Chair, Chemistry Department
>> St. Olaf College
>> Northfield, MN
>> http://www.stolaf.edu/people/hansonr
>>
>>
>> If nature does not answer first what we want,
>> it is better to take what answer we get.
>>
>> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>>
>>
>
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
Jmol-developers mailing list
Jmol-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-developers

Reply via email to