public class Console extends Applet implements KeyListener
Usage: java org.lsmp.djepExamples.Console [expression]If an argument is passed, it is interpreted as an expression and evaluated. Otherwise, a prompt is printed, and the user can enter expressions to be evaluated.
This class has been designed to be sub classed to allow different consol applications. The methods
public void initialise() public void processEquation(Node node) throws Exception public boolean testSpecialCommands(String command) public void printPrompt() public void printIntroText() public void printHelp()can all be overwritten.
Furthermore main should be overwritten. For example
public static void main(String args[]) { Console c = new DJepConsole(); c.run(args); }
Component.BaselineResizeBehavior
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
Console()
Constructor
|
Modifier and Type | Method and Description |
---|---|
String |
getAppletInfo() |
String |
getPrompt()
Prints the prompt string.
|
boolean |
handleError(Exception e)
Handle an error in the parse and evaluate routines.
|
void |
init()
Applet initialization
|
void |
initialise()
sets up all the needed objects.
|
void |
inputLoop()
The main input loop for interactive operation.
|
void |
keyPressed(KeyEvent arg0) |
void |
keyReleased(KeyEvent event)
Handles keyRelease events
|
void |
keyTyped(KeyEvent arg0) |
static void |
main(String[] args)
Creates a new Console object and calls run()
|
void |
print(Object o)
Prints a line of text no newline.
|
void |
printFuns()
Prints a list of defined functions.
|
void |
printHelp()
Print help message.
|
void |
printIntroText()
Prints introductory text.
|
void |
println(Object o)
Prints a line of text no newline.
|
void |
printOps()
Prints a list of defined operators.
|
void |
printStdHelp()
Prints a standard help message.
|
void |
printVars()
Prints a list of constants.
|
boolean |
processCommand(String command)
Process a single command.
|
void |
processEquation(Node node)
Performs the required operation on a node.
|
void |
run(String[] args)
The main entry point with command line arguments
|
String[] |
split(String s)
Splits a string on spaces.
|
boolean |
testSpecialCommands(String command)
Checks for special commands used by subclasses.
|
destroy, getAccessibleContext, getAppletContext, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, isValidateRoot, newAudioClip, play, play, resize, resize, setStub, showStatus, start, stop
add, add, add, add, add, addContainerListener, 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, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, 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, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, revalidate, 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, transferFocusBackward, transferFocusUpCycle
public static void main(String[] args)
public void run(String[] args)
public void inputLoop()
public boolean processCommand(String command)
testSpecialCommands(String)
processEquation(Node)
handleError(Exception)
command
- The line to be processedpublic void initialise()
public void processEquation(Node node) throws ParseException
node
- Node representing expressionParseException
- if a Parse or evaluation errorpublic String getPrompt()
public final void printStdHelp()
public void printHelp()
public void printIntroText()
public void printFuns()
public void printOps()
public void printVars()
public boolean testSpecialCommands(String command)
verbose onThis method can be used detected this input, perform required actions and skip normal processing by returning true.
command
- split(String)
public boolean handleError(Exception e)
e
- public String[] split(String s)
s
- the input stringpublic void print(Object o)
public void println(Object o)
public void keyReleased(KeyEvent event)
keyReleased
in interface KeyListener
public void keyPressed(KeyEvent arg0)
keyPressed
in interface KeyListener
public void keyTyped(KeyEvent arg0)
keyTyped
in interface KeyListener
public String getAppletInfo()
getAppletInfo
in class Applet
Jas4pp 1.5 © Java Analysis Studio for Particle Physics