|
|||||||||
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
cox.jmatt.java.MathTools.util.BasicMathPrinter
public class BasicMathPrinter
This class provides a MathPrinter implementation with all required methods and several extension points. The basic log and print functions are covered and extra machinery is provided to extract the stack trace from a Throwable and return it as a String. In addition, BMP provides a simple GUI with a TextArea to receive messages, Checkboxes to selectively enable/disable the three log levels, a Checkbox to enable/disable stack trace printing, and a Button to clear the console (txaConsole). The standard GUI arranges the buttons and checkboxes to the right of the console. This is accomplished via the standardGUI() method which returns a reference to the MathPrinter itself; the constructor DOES NOT establish the GUI!
The extension machinery comes via the required processMathObject() method and the processGoButton() method. MathTools-using applications can use the first method as required per the purpose of the application. The latter method is used if BMP is subclassed as the application's GUI. The processGoButton() method is called whenever the [Go!] button is clicked. Default behavior is to test the log and print methods but it is primarily provided to allow for easy subclassing: applications with minimal GUI requirements can simply subclass BMP and provide what they need there. (The default version also checks for version information in the resource 'version.txt' in the top level of the JAR file.)
For subclasses with more complex GUI requirements, standardGUI() is NOT mandatory! Each necessary component, txaConsole and the control Panel, has a finalized public to build it. For a complex GUI, subclass BMP, set the layout as required and add txaConsole and getControlPanel() wherever they are convenient. The getTitle() method is used in the standardGUI() to put a title in the NORTH position. If the GUI requirement is more complex still, implement the MathPrinter interface manually.
All MathPrinter methods except processMathObject() are finalized. This is done to prevent infinite loops: BMP is designed to RECEIVE from CapCom, not to
SEND to it. If overriding the processMathObject() method DO NOT call CapCom.processMathObject(), otherwise bad things will happen! Default behavior for the
processMathObject() method is to dump the toString()
'ed contents of the argument to the clipboard if this is enabled and the argument is not
null.
Nested Class Summary |
---|
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 | |
---|---|
java.awt.TextArea |
txaConsole
This is the TextArea used for displaying information. |
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 | |
---|---|
BasicMathPrinter()
|
Method Summary | |
---|---|
void |
actionPerformed(java.awt.event.ActionEvent aev)
This method checks to see if the [Clr] or [Go!] buttos have been pressed. |
void |
clearScreen()
Clear the TextArea. |
java.awt.Panel |
getControlPanel(boolean pVertical)
The control Panel holds the [Go!] and [Clr] buttons as well as the log enable\disable checkboxes. |
java.lang.String |
getTitle()
Override this method to change BMP's title to something other than 'Basic MathPrinter'. |
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 pErr)
Logged messages and stack traces appear in the TextArea if their levels are enabled. |
void |
mathPrintln(java.lang.String pMesg)
These messages go straight to the TextArea. |
void |
printStackTrace(java.lang.Throwable pThr)
Extract and print the Stack Trace from a throwable. |
void |
processGoButton()
This method provides an extension point for simple subclasses. |
java.lang.Object |
processMathObject(java.lang.Object pObj)
This method provides access to the system Clipboard if the '[]Clip' Checkbox is enabled. |
MathPrinter |
standardGUI()
This method sets up the standard GUI: BorderLayout with getTitle() in the NORTH position, txaConsole in the CENTER, and the control panel at EAST. |
Methods inherited from class java.awt.Panel |
---|
addNotify, getAccessibleContext |
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, getLocale, 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, resize, resize, 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 |
Field Detail |
---|
public final java.awt.TextArea txaConsole
Constructor Detail |
---|
public BasicMathPrinter()
Method Detail |
---|
public final MathPrinter standardGUI()
public final java.awt.Panel getControlPanel(boolean pVertical)
pVertical
- true for a vertical bar, false for horizontal.public final void mathLog(byte pLevel, java.lang.String pMesg, java.lang.Throwable pErr)
mathLog
in interface MathPrinter
pLevel
- One of the LOG_ levels defined above.pMesg
- A String message describing the event.pErr
- A Throwable generated by the event. May be null.public void printStackTrace(java.lang.Throwable pThr)
public final void mathPrintln(java.lang.String pMesg)
mathPrintln
in interface MathPrinter
pMesg
- The String message to be printed.public java.lang.Object processMathObject(java.lang.Object pObj)
toString()
content is wrapped in the appropriate Transferable
and sent to the clipboard. Any errors are reported at
Debug level. The Object sent in is returned unaltered.
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 void processGoButton()
public java.lang.String getTitle()
public void clearScreen()
public void actionPerformed(java.awt.event.ActionEvent aev)
actionPerformed
in interface java.awt.event.ActionListener
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |