|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.wolfram.jlink.MathListener
public abstract class MathListener
This abstract class is the parent class of all the MathXXXListener classes, which let you trigger a call into Mathematica on the occurrence of a particular event. Developers are encouraged to subclass it for their own "listener" classes that need to call into Mathematica. It handles virtually all of the complexity in creating a listener-type class, including the interaction with Mathematica. Examine the source code for any of the MathXXXListener classes to see how you can subclass this class for your own needs.
| Constructor Summary | |
|---|---|
MathListener()
The constructor that is typically called from Mathematica. |
|
MathListener(KernelLink ml)
Call this version only when you know for sure what link should be used for UI-triggered computations. |
|
MathListener(java.lang.String[][] handlers)
This form of the constructor lets you skip having to make a series of setHandler() calls. |
|
| Method Summary | |
|---|---|
protected Expr |
callMathHandler(java.lang.String meth,
java.lang.Object[] args)
Derived classes call this method from their event handler methods. |
protected void |
callVoidMathHandler(java.lang.String meth,
java.lang.Object[] args)
Just like callMathHandler(), except it discards the result of the computation. |
protected java.lang.String |
getHandler(java.lang.String methName)
Allows subclasses to get the name of the Mathematica function assigned to handle the given method. |
protected KernelLink |
getLink()
Gives the link that will be used by this MathListener for computations. |
boolean |
setHandler(java.lang.String meth,
java.lang.String func)
Associates the specified Mathematica function with the specified method from the any of the "listener" interfaces implemented by the class. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public MathListener()
public MathListener(KernelLink ml)
ml - The link to which computations will be sent when events notifications arrive.public MathListener(java.lang.String[][] handlers)
handlers - An array of {meth, func} pairs associating methods in the derived class
with Mathematica functions.| Method Detail |
|---|
public boolean setHandler(java.lang.String meth,
java.lang.String func)
meth - The method in the "listener" interface (for example, "actionPerformed").func - The Mathematica function to execute.
protected Expr callMathHandler(java.lang.String meth,
java.lang.Object[] args)
- the kernel is running DoModal[] - kernel sharing (via ShareKernel[] or ShareFrontEnd[]) is turned on, and the kernel is not busy with some other computation - the kernel executes ServiceJava[] - somewhere on the stack is a call from Mathematica into Java - the program is standalone, not being scripted from a Mathematica session
meth - the name of the event handler method that is being invoked (e.g., "actionPerformed", "windowClosing", "mousePressed", etc.)args - the arguments to be passed to the Mathematica handler function. The arguments will be sent individually,
not as a list. To pass primitive types like integers, wrap them in their corresponding wrapper classes
(e.g., new Integer(i)).
protected void callVoidMathHandler(java.lang.String meth,
java.lang.Object[] args)
meth - the name of the event handler method that is being invoked (e.g., "actionPerformed", "windowClosing", "mousePressed", etc.)args - the arguments to be passed to the Mathematica handler function. The arguments will be sent individually,
not as a list. To pass primitive types like integers, wrap them in their corresponding wrapper classes
(e.g., new Integer(i)).callMathHandler(String, Object[])protected KernelLink getLink()
protected java.lang.String getHandler(java.lang.String methName)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||