public class DebugTools
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
DebugTools.DebugFocus
A KeyboardFocusManager that records the events it passes.
|
class |
DebugTools.DebugStream
Specialized class for writing debug text.
|
static class |
DebugTools.DefaultLineWriter |
static interface |
DebugTools.LineWriter
Superclass of objects that receive and process lines produced
by DebugStream instances.
|
class |
DebugTools.LoggingJFrame
A subclass of JFrame that logs events going through processEvent.
|
class |
DebugTools.MouseLoggingAdapter
An adapter that handles mouse events
and logs them before passing them on.
|
Modifier and Type | Field and Description |
---|---|
java.awt.KeyEventDispatcher |
keyEventDispatcher
tool for printing all keyboard events
usage:
KeyboardFocusManager.getCurrentKeyboardFocusManager()
.addKeyEventDispatcher(keyEventDispatcher);
remove with method removeKeyEventDispatcher
|
DebugTools.LineWriter |
outDebug
A LineWriter that sends the lines to System.out.
|
DebugTools.LineWriter |
silentDebug
A LineWriter that simply ignores its input.
|
Constructor and Description |
---|
DebugTools()
create a new debugging context.
|
Modifier and Type | Method and Description |
---|---|
java.lang.String |
callers(boolean doself,
int n)
Returns a string identifying the call path to the client.
|
java.lang.String |
callers(int n)
Returns a string identifying the call path to the client.
|
static void |
compareTwoFiles(java.lang.String fileA,
java.lang.String fileB)
Compare two files with diff and send result to stdout.
|
static void |
compareTwoFiles(java.lang.String fileA,
java.lang.String fileB,
File dest)
Compare two files with diff and send result to a File.
|
static void |
compareTwoFiles(java.lang.String fileA,
java.lang.String fileB,
java.lang.ProcessBuilder.Redirect dest)
Compare two files with diff and send result to a ProcessBuilder.Redirect.
|
PrintStream |
createStddbg() |
PrintStream |
createStddbg(DebugTools.LineWriter wrtr) |
PrintStream |
createStddbg(java.lang.String charset,
DebugTools.LineWriter wrtr) |
static java.lang.String |
deMax(int v) |
static java.lang.String |
errorcntstr(int errs)
Format a number-of-errors value.
|
static DebugTools |
getDefault() |
PrintStream |
getStddbg() |
java.lang.String |
getStddbgPrefix() |
DebugTools.LineWriter |
getStddbgWriter() |
boolean |
isFocusLogging() |
boolean |
isKeyLogging() |
static java.lang.String |
naturalSize(java.awt.Dimension dim) |
void |
printOnEDT(java.lang.String s)
Utility to ensure that printing is done on the Event Dispatch Thread.
|
void |
setFocusLogging(boolean turnOn)
Turn on focus logging by replacing the current KeyboardFocusManager.
|
void |
setKeyLogging(boolean turnOn)
Turn on key logging by adding a local key event dispatcher to
the KeybordFocusManager
|
void |
setStddbgPrefix(java.lang.String pre) |
void |
setStddbgWriter(DebugTools.LineWriter newWriter) |
static java.lang.String |
sizeList(java.awt.Component vic)
Produce a formatted description of the size information of a component.
|
void |
traceContainerSize(java.awt.Component vic)
Print size parameters for all ancestors of a component.
|
void |
traceSize(java.awt.Component vic,
java.lang.String indent)
Print size parameters for a tree of components.
|
public DebugTools.LineWriter silentDebug
public DebugTools.LineWriter outDebug
public java.awt.KeyEventDispatcher keyEventDispatcher
public DebugTools()
public static DebugTools getDefault()
public void printOnEDT(java.lang.String s)
s
- The string to printpublic PrintStream getStddbg()
public PrintStream createStddbg()
public PrintStream createStddbg(DebugTools.LineWriter wrtr)
wrtr
- A LineWriter for processing each output line.
If there is an existing stddbg with an empty charset name,
its LineWriter will be replaced.public PrintStream createStddbg(java.lang.String charset, DebugTools.LineWriter wrtr) throws UnsupportedEncodingException
charset
- Name of the charset to use. Suggested value: "UTF-8".
May be an empty string to invoke the default charset.wrtr
- A LineWriter for processing each output line.
May be null to specify the default.UnsupportedEncodingException
- If charset does not name a valid encoding.public java.lang.String getStddbgPrefix()
public void setStddbgPrefix(java.lang.String pre)
pre
- new value for debug print line prefix.
If the current stddbg is not using DefauiltLineWriter,
this method has no effect.public void setStddbgWriter(DebugTools.LineWriter newWriter)
public DebugTools.LineWriter getStddbgWriter()
public boolean isFocusLogging()
public boolean isKeyLogging()
public void setFocusLogging(boolean turnOn)
turnOn
- If true the focus manager below will be installled.public void setKeyLogging(boolean turnOn)
turnOn
- desired state of key loggingpublic java.lang.String callers(int n)
n
- the number of parents of the client to reportpublic java.lang.String callers(boolean doself, int n)
doself
- If true, the client is included in the trace back list.
Usually this is not necessary; so false is preferable.n
- the number of parents of the client to reportpublic static java.lang.String deMax(int v)
public static java.lang.String naturalSize(java.awt.Dimension dim)
public static java.lang.String sizeList(java.awt.Component vic)
(min-w,pref-w,max-w)x(min-h,pref-h,max-h) nat ...
where nat ...
is the natural size for each limit that
has been artificially set. The natural size is given in the form (w, h)
.vic
- the Component to be probed.public void traceSize(java.awt.Component vic, java.lang.String indent)
vic
- The topmost of the componentsindent
- A line prefix. On recursive calls,
this value is augmented with four additional spaces.public void traceContainerSize(java.awt.Component vic)
vic
- The bottommost of the componentspublic static void compareTwoFiles(java.lang.String fileA, java.lang.String fileB)
fileA
- First filefileB
- Second filepublic static void compareTwoFiles(java.lang.String fileA, java.lang.String fileB, File dest)
fileA
- First filefileB
- Second filedest
- where to send the outputpublic static void compareTwoFiles(java.lang.String fileA, java.lang.String fileB, java.lang.ProcessBuilder.Redirect dest)
fileA
- First filefileB
- Second filedest
- where to send the outputpublic static java.lang.String errorcntstr(int errs)
errs
- The number to format.