|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
java.awt.Panel
java.applet.Applet
cox.jmatt.java.MathTools.util.MTApplet
public class MTApplet
This Applet is designed to allow MathTools scripting via a web browser and to act as CapCom's MathPrinter on an (X)HTML page. The GUI consists of a TextArea
used for displaying log and print messages along with Checkboxes to enable/disable log levels, a Checkbox to enable the Clipboard, a [Calc] button to show a
QuickRPNCalculator
, a [Clr] button to clear the screen. When using MTApplet make sure to leave room for these components!
All MathPrinter method are finalized method because they are not designed to be subclassed. To script MathTools using a browser, embed a MTApplet somewhere in the page. Obtain a reference to it from the scripting language, call setAsPrinter() if desired, and program away!
NOTE: All create__() methods in this Applet return static versions of their class. To obtain the SCROB aliases call the (instance) getSCROB() method on the Object returned.
Applets generally do not have filesystem access so MTApplet
will not create and cannot access the MathFileIO
class. It can, however,
provide Applet-appropriate access via Class.getResourceAsStream()
. This functionality is available through the getResourceStream()
and getResourceReader()
methods. They both operate from MTApplet
's Classloader (not the Math ClassLoader) and must work within
the security and access restrictions imposed on any Applet. Use as needed but USE WITH CARE!
Security permitting, the processMathObject()
method provides access to the system clipboard. If the Object passed in is not null, the '[]CB'
Checkbox is enabled, and the security manager allows it the String content of the Object passed in is dumped to the clipboard.
HTML documents using MTApplet on a local machine may need access to Capcom's MAuthenticator or Accessory creation methods it is possible to set the appropriate
flags using <param> tags. The two parameters are control.MAuthenticator
for setting MAuthenticator access and control.Accessory
to
allow accessory creation. Setting either of these to 'true' enables the correspoinding field in CapCom.
MTApplet
includes a QuickRPNCalculator
usable from a dialog. Since calculators are not always a good idea, it can be enabled or
disabled via the setCalculatorEnabled()
. The showCalc()
method can bring up the calculator from within a script, if it is enabled.
By default the calculator is disabled. To enable by default use a <param> tag: set control.Calculator
to true.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.applet.Applet |
---|
java.applet.Applet.AccessibleApplet |
Nested classes/interfaces inherited from class java.awt.Panel |
---|
java.awt.Panel.AccessibleAWTPanel |
Nested classes/interfaces inherited from class java.awt.Container |
---|
java.awt.Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
Field Summary |
---|
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface cox.jmatt.java.MathTools.util.MathPrinter |
---|
LOG_DEBUG, LOG_ERROR, LOG_INFO |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
MTApplet()
|
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent aev)
ActionListener method. |
boolean |
authenticateInstructor(java.lang.String pCode)
Check an authentication code at Instructor level. |
boolean |
authenticateProctor(java.lang.String pCode)
Check an authentication code at Proctor level. |
boolean |
authenticateStudent(java.lang.String pCode)
Check an authentication code at Student level. |
void |
clearScreen()
Clear the TextArea used for messages. |
void |
closeAll()
MTApplet maintains an internal list of resource InputStreams and Readers. |
Arithmetic |
createArithmetic()
Create and return an Arithmetic instance. |
COFormatterFactory |
createCOFormatter()
Create a COFormatterFactory |
MathConsole |
createConsole()
Create and return a MathConsole. |
GraphEngineFactory |
createGraphEngineFactory()
Return a new GraphEngineFactory. |
MathDBC |
createMathDBC()
Create a MathDBC instance. |
MathGenHTML |
createMathHTM()
Return a MathGenHTML object. |
MathSet |
createMathSet()
Create a real-number MathSet . |
MathXML |
createMathXML()
Create and return a MathXML object. |
MComplex |
createMComplex()
Create a MComplex instance. |
MathDrawSVG |
createMDraw()
Return a MathDrawSVG object. |
MathEngine |
createMEngine()
Create and return an instance of MathEngine. |
MEquation |
createMEquation()
Create and return a MEquation. |
MFraction |
createMFraction(java.lang.String pFormat)
Create an MFraction from a formatting String. |
MathGenLatex |
createMLatex()
Create a MathGenLatex . |
MMatrixBuilder |
createMMBuilder()
Create and return a new MMatrixBuilder. |
MRadical |
createMRadical()
Create and return a MRadical. |
MathStat |
createMStat()
Create and return a MathStat. |
MTest |
createMTest()
Create an empty MTest. |
MathTestFormatter |
createMTFormatter()
Create a new MathTestFormatter. |
MTXProcessor |
createMTXPro()
Create and return a MTXMLProcessor. |
GraphPanelFactory |
createNotebook()
Create a GraphPanelFactory . |
Percent |
createPercent()
Create and return a Percent instance. |
Polynomial |
createPolynomial()
Create a default (zero) Polynomial. |
Polynomial |
createPolynomial(java.lang.String pPoly)
Create a Polynomial from a format String. |
Question |
createQuestion()
Create and return a blank Question. |
Question |
createQuestion(java.lang.String pID,
java.lang.String pProb,
java.lang.String pAns)
Create and return a Question with all data provided. |
SimpleTagImpl |
createSimpleTag()
Return a SimpleTagImpl. |
void |
destroy()
Overridden to call MathDBC.closeAll() and this.closeAll() . |
java.io.BufferedReader |
getResourceReader(java.lang.String pName)
This method works per getResourceStream() (and does use that method) but wraps the resulting stream in a BufferedReader . |
java.io.InputStream |
getResourceStream(java.lang.String pName)
This method allows access to Class.getResourceAsStream() , which provides MTApplet with the closest thing to filesystem access it
can get. |
void |
init()
Calls setUpGUI() . |
void |
lostOwnership(java.awt.datatransfer.Clipboard pClip,
java.awt.datatransfer.Transferable pData)
Required for the ClipboardOwner interface. |
void |
mathLog(byte pLevel,
java.lang.String pMesg,
java.lang.Throwable pThr)
This method may be called directly or via a MathConsole from createConsole()! |
void |
mathPrintln(java.lang.String pMesg)
Send a String to the TextArea 'screen.' Can be called directly or through a MathConsole. |
void |
printClassInfo(java.lang.Object pObj)
This method prints the Class name of the Object passed in, or 'null' if it is null. |
java.lang.Object |
processMathObject(java.lang.Object pObj)
Overridden for clipboard access, security restrictions permitting. |
void |
setAsPrinter()
Call this method to set THIS instance of MTApplet as the Global Printer. |
MTApplet |
setCalculatorEnabled(boolean isEnabled)
Enable/disable the calculator. |
void |
setGlobalPizza(java.lang.String pPizza)
Convenience method for setGlobalPizza(pPizza, null, null). |
void |
setGlobalPizza(java.lang.String pPizza,
java.lang.String pLineSep,
java.lang.String pKeySep)
No scripting tool allows Global Pizza access past getting parameters from it. |
void |
setUpGUI()
Set up the GUI. |
void |
showCalc()
Display a QuickRPNCalculator if it is enabled. |
Methods inherited from class java.applet.Applet |
---|
getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop |
Methods inherited from class java.awt.Panel |
---|
addNotify |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public MTApplet()
Method Detail |
---|
public void init()
setUpGUI()
. If subclassing this must be done manually!
init
in class java.applet.Applet
public final void setUpGUI()
public void destroy()
MathDBC.closeAll()
and this.closeAll()
. If overriding this method they must be called manually.
destroy
in class java.applet.Applet
public void actionPerformed(java.awt.event.ActionEvent aev)
actionPerformed
in interface java.awt.event.ActionListener
public void clearScreen()
public final void showCalc()
QuickRPNCalculator
if it is enabled. If not, nothing happens.
public final MTApplet setCalculatorEnabled(boolean isEnabled)
isEnabled
- true to enable the calculator, false to disable and possibly hide it.public final void mathLog(byte pLevel, java.lang.String pMesg, java.lang.Throwable pThr)
mathLog
in interface MathPrinter
pLevel
- One of the LOG_ levels defined above.pMesg
- A String message describing the event.pThr
- A Throwable generated by the event. May be null.public final void mathPrintln(java.lang.String pMesg)
mathPrintln
in interface MathPrinter
pMesg
- The String message to be printed.public final java.lang.Object processMathObject(java.lang.Object pObj)
Transferable
and sent to the clipboard.
processMathObject
in interface MathPrinter
pObj
- The data to be processed.
public void lostOwnership(java.awt.datatransfer.Clipboard pClip, java.awt.datatransfer.Transferable pData)
ClipboardOwner
interface. Default behavior prints a Debug-level message when ownership is lost.
lostOwnership
in interface java.awt.datatransfer.ClipboardOwner
public final void setAsPrinter()
public void printClassInfo(java.lang.Object pObj)
public void setGlobalPizza(java.lang.String pPizza, java.lang.String pLineSep, java.lang.String pKeySep)
No scripting tool allows Global Pizza access past getting parameters from it. Applications can set the Global Pizza before script execution, so methods
like MathEngine's blines()
can function. This method provides MTApplet with the capability to set the Global Pizza, presumably before execution
of a script requiring such access.
This method splits the supplied String first on pLineSep and then each 'line' on pKeySep. The result is then added to a Properties object which, when the lines run out, is set as the Global Pizza. The default values for pLineSep and pKeySep are a newline and an equals sign, respectively. The second split has an upper limit of two, so the key separator can be used afterward and will not lose data.
pPizza
- The String containing the Properties-formatted data for the Global Pizza.pLineSep
- The separator to split the data into 'lines.' Defaults to a single newline.pKeySep
- The String used to separate the key from the value.public void setGlobalPizza(java.lang.String pPizza)
public final java.io.InputStream getResourceStream(java.lang.String pName)
Class.getResourceAsStream()
, which provides MTApplet
with the closest thing to filesystem access it
can get. The access is only allowed within the bounds of the Applet
security constraints so all of its restrictions are in effect. The Math
ClassLoader is not accessed so only the resources available to a normal Applet can be fetched. Use with care! Any errors are reported at Error level
and the return value for such is null.
pName
- The name of the resource to be fetched.public final java.io.BufferedReader getResourceReader(java.lang.String pName)
getResourceStream()
(and does use that method) but wraps the resulting stream in a BufferedReader
. Restrictions
are per getResourceStream()
and if a stream cannot be created the return value is null. Any errors are reported at Error level.
pName
- The name of the resource to be read.public final void closeAll()
MTApplet
maintains an internal list of resource InputStreams and Readers. This method closes them and reports any errors from attempting to do
so. The destroy()
method calls this one automatically but subclasses overriding it might not. If there is any doubt, call it from the script!
Multiple calls will have no ill effects.
public final boolean authenticateStudent(java.lang.String pCode)
code
at Student level.
public final boolean authenticateProctor(java.lang.String pCode)
code
at Proctor level.
public final boolean authenticateInstructor(java.lang.String pCode)
code
at Instructor level.
public Question createQuestion()
public Question createQuestion(java.lang.String pID, java.lang.String pProb, java.lang.String pAns)
public MathEngine createMEngine()
public MathConsole createConsole()
public Arithmetic createArithmetic()
public MathXML createMathXML()
public Polynomial createPolynomial()
public Polynomial createPolynomial(java.lang.String pPoly)
pPoly
- A String conforming to the Polynomial.createPolynomial() method. Which this one calls!public MFraction createMFraction(java.lang.String pFormat)
public MMatrixBuilder createMMBuilder()
public Percent createPercent()
public MEquation createMEquation()
public MRadical createMRadical()
public MathStat createMStat()
public MTXProcessor createMTXPro()
public GraphEngineFactory createGraphEngineFactory()
public MathDrawSVG createMDraw()
public MathGenHTML createMathHTM()
public SimpleTagImpl createSimpleTag()
public MathDBC createMathDBC()
public MTest createMTest()
public MathTestFormatter createMTFormatter()
public COFormatterFactory createCOFormatter()
public GraphPanelFactory createNotebook()
GraphPanelFactory
.
public MathGenLatex createMLatex()
MathGenLatex
.
public MComplex createMComplex()
MComplex
instance.
public MathSet createMathSet()
MathSet
.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |