com.swfm.mica.core
Class MiDebug

java.lang.Object
  extended bycom.swfm.mica.core.MiDebug

public class MiDebug
extends java.lang.Object

This class provides debug support. The most common usages is to call MiDebug#println, which will send a message to both STDOUT and the (optional) log file, and MiDebug.printStackTrace() which sends the stack trace to both STDOUT and the (optional) log file.

To see the size of the bounds and drawBounds of a MiPart, drawn as green and yellow rectangles, respectively, you can do the following:

part.setAfterRenderer(new MiBoundsRenderer());

To trace when an action is generated by a part (for example to see whenever a icon is moved or resized:

MiDebug.traceActions(myIcon, MiiActionTypes.Mi_GEOMETRY_CHANGE_ACTION, MiDebug.Mi_LOG_PRINT_CHANGE_EVENT | MiDebug.Mi_LOG_PRINT_STACK | MiDebug.Mi_LOG_PRINT_BOUNDS);

or for this particular example:

MiDebug.traceGeometricActions(myIcon);

Version:
%I% %G%
Author:
Michael L. Davis

Field Summary
static boolean checkForLingeringInvalidLayoutsBelow
           
static boolean debug
           
static boolean localDebug
           
static int Mi_LOG_DUMP_SUBJECT
           
static int Mi_LOG_DUMP_TARGET
           
static int Mi_LOG_PRINT_BOUNDS
           
static int Mi_LOG_PRINT_CHANGE_EVENT
           
static int Mi_LOG_PRINT_STACK
           
static boolean printValidationErrors
           
static int TRACE_AREA_INVALIDATION
           
static int TRACE_BASIC_ALLOCATIONS
           
static int TRACE_CANVAS_DRAW_TIMES
           
static int TRACE_CUSTOM_DEBUG_INFO
           
static int TRACE_DOUBLE_BUFFER_RENDERING
           
static int TRACE_DRAG_AND_DROP
           
static int TRACE_DRAWING_OF_ATTACHMENTS
           
static int TRACE_DRAWING_OF_PARTS
           
static int TRACE_EVENT_DISPATCHING
           
static int TRACE_EVENT_HANDLER_GRABS
           
static int TRACE_EVENT_INPUT
           
static int TRACE_EVENT_TO_COMMAND_TRANSLATION
           
static int TRACE_INTERACTIVE_SELECT
           
static int TRACE_KEYBOARD_FOCUS_DISPATCHING
           
static int TRACE_MODEL_CHANGE_EVENTS
           
static int TRACE_SHORT_CUT_DISPATCHING
           
static int TRACE_WINDOW_AND_CANVAS_RESIZING
           
static java.lang.String[] traceClasses
           
static int traceIterations
           
static int traceMode
           
 
Constructor Summary
MiDebug()
           
 
Method Summary
static void addLoggingFilename(java.lang.String name)
           
static void addLoggingPrintStream(java.io.PrintStream stream)
           
static void assertt(boolean flag)
           
static void checkForLingeringInvalidLayoutsBelow(MiPart obj)
           
static void clearNumberOfErrors()
           
static void delay(long count)
           
static void dump(MiPart obj)
           
static void dumpPart(MiPart obj)
           
static void dumpStructureOnly(MiPart obj)
           
static void enter(java.lang.String traceMsg)
           
static void enterAndClearNumberOfErrors(java.lang.String traceMsg)
           
static void exit()
           
static int exitAndReturnNumberOfErrors()
           
static java.lang.String getFullPathName(MiPart obj)
          public static boolean isShowing(MiPart subject, boolean thisPart) { if (!subject.isVisible()) { println(subject + ": not visible"); return(false); } if (subject.isHidden()) { println(subject + ": hidden"); return(false); } // FIX: needs to check all containing editors.
static java.io.PrintStream getLoggingPrintStream(int index)
           
static void getMemoryStatistics(long[] freeMemory, long[] totalMemory)
           
static void getMemoryStatistics(long[] freeMemory, long[] totalMemory, boolean doGarbageCollection)
           
static java.lang.String getMicaClassName(java.lang.Object obj)
           
static boolean getMicaPrefixEnabled()
           
static int getNumberOfErrors()
           
static int getNumberOfLoggingPrintStreams()
           
static MiPart getPartWithInvalidArea(MiPart container)
           
static java.lang.String getStackTrace(java.lang.Throwable e)
           
static java.lang.String[] getTraceClasses()
           
static int getTraceIterations()
           
static int getTraceMode()
           
static void halt()
           
static void halt(java.lang.String msg)
           
static boolean isTracing(MiPart part, int tracingMode)
           
static void print(java.lang.String str)
           
static void printAllThreads()
           
static void printHex(int val)
           
static void println(java.lang.Object obj)
           
static void println(java.lang.String str)
           
static void printlnError(java.lang.String errorMsg)
           
static void printMemoryReport()
           
static void printStackTrace()
           
static void printStackTrace(java.lang.String msg)
           
static void printStackTrace(java.lang.Throwable e)
           
static void printValidationError(MiValueValidationError error)
           
static void printVerbose(java.lang.String str)
           
static void priority(java.lang.String traceMsg)
           
static void removeBoundingBox(MiPart target)
           
static void setLoggingFilename(java.lang.String name)
           
static void setLoggingPrintStream(java.io.PrintStream stream)
           
static void setMicaPrefixEnabled(boolean flag)
           
static void setOutputMessagePrefix(java.lang.String str)
           
static void setTraceClasses(java.lang.String[] classNames)
           
static void setTraceIterations(int numberOfIterations)
           
static void setTraceMode(int mask)
           
static void showBoundingBox(MiPart target)
           
static void sleep(long microSeconds)
           
static void startFullTrace()
           
static void stopFullTrace()
           
static void stopTracingActions(MiPart obj)
           
static void trace(java.lang.String traceMsg)
           
static void traceActions(MiPart obj, int eventTypes, int options)
           
static void traceGeometricActions(MiPart obj)
           
static void where()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

TRACE_SHORT_CUT_DISPATCHING

public static final int TRACE_SHORT_CUT_DISPATCHING
See Also:
Constant Field Values

TRACE_DRAWING_OF_PARTS

public static final int TRACE_DRAWING_OF_PARTS
See Also:
Constant Field Values

TRACE_DRAWING_OF_ATTACHMENTS

public static final int TRACE_DRAWING_OF_ATTACHMENTS
See Also:
Constant Field Values

TRACE_KEYBOARD_FOCUS_DISPATCHING

public static final int TRACE_KEYBOARD_FOCUS_DISPATCHING
See Also:
Constant Field Values

TRACE_DRAG_AND_DROP

public static final int TRACE_DRAG_AND_DROP
See Also:
Constant Field Values

TRACE_WINDOW_AND_CANVAS_RESIZING

public static final int TRACE_WINDOW_AND_CANVAS_RESIZING
See Also:
Constant Field Values

TRACE_CANVAS_DRAW_TIMES

public static final int TRACE_CANVAS_DRAW_TIMES
See Also:
Constant Field Values

TRACE_DOUBLE_BUFFER_RENDERING

public static final int TRACE_DOUBLE_BUFFER_RENDERING
See Also:
Constant Field Values

TRACE_EVENT_DISPATCHING

public static final int TRACE_EVENT_DISPATCHING
See Also:
Constant Field Values

TRACE_EVENT_HANDLER_GRABS

public static final int TRACE_EVENT_HANDLER_GRABS
See Also:
Constant Field Values

TRACE_EVENT_INPUT

public static final int TRACE_EVENT_INPUT
See Also:
Constant Field Values

TRACE_AREA_INVALIDATION

public static final int TRACE_AREA_INVALIDATION
See Also:
Constant Field Values

TRACE_EVENT_TO_COMMAND_TRANSLATION

public static final int TRACE_EVENT_TO_COMMAND_TRANSLATION
See Also:
Constant Field Values

TRACE_INTERACTIVE_SELECT

public static final int TRACE_INTERACTIVE_SELECT
See Also:
Constant Field Values

TRACE_CUSTOM_DEBUG_INFO

public static final int TRACE_CUSTOM_DEBUG_INFO
See Also:
Constant Field Values

TRACE_BASIC_ALLOCATIONS

public static final int TRACE_BASIC_ALLOCATIONS
See Also:
Constant Field Values

TRACE_MODEL_CHANGE_EVENTS

public static final int TRACE_MODEL_CHANGE_EVENTS
See Also:
Constant Field Values

debug

public static boolean debug

localDebug

public static boolean localDebug

checkForLingeringInvalidLayoutsBelow

public static boolean checkForLingeringInvalidLayoutsBelow

traceMode

public static int traceMode

traceIterations

public static int traceIterations

traceClasses

public static java.lang.String[] traceClasses

printValidationErrors

public static boolean printValidationErrors

Mi_LOG_PRINT_CHANGE_EVENT

public static final int Mi_LOG_PRINT_CHANGE_EVENT
See Also:
Constant Field Values

Mi_LOG_PRINT_STACK

public static final int Mi_LOG_PRINT_STACK
See Also:
Constant Field Values

Mi_LOG_PRINT_BOUNDS

public static final int Mi_LOG_PRINT_BOUNDS
See Also:
Constant Field Values

Mi_LOG_DUMP_SUBJECT

public static final int Mi_LOG_DUMP_SUBJECT
See Also:
Constant Field Values

Mi_LOG_DUMP_TARGET

public static final int Mi_LOG_DUMP_TARGET
See Also:
Constant Field Values
Constructor Detail

MiDebug

public MiDebug()
Method Detail

setOutputMessagePrefix

public static void setOutputMessagePrefix(java.lang.String str)

setLoggingFilename

public static void setLoggingFilename(java.lang.String name)
                               throws java.lang.Exception
Throws:
java.lang.Exception

addLoggingFilename

public static void addLoggingFilename(java.lang.String name)
                               throws java.lang.Exception
Throws:
java.lang.Exception

getNumberOfLoggingPrintStreams

public static int getNumberOfLoggingPrintStreams()

getLoggingPrintStream

public static java.io.PrintStream getLoggingPrintStream(int index)

setLoggingPrintStream

public static void setLoggingPrintStream(java.io.PrintStream stream)

addLoggingPrintStream

public static void addLoggingPrintStream(java.io.PrintStream stream)

getMemoryStatistics

public static void getMemoryStatistics(long[] freeMemory,
                                       long[] totalMemory,
                                       boolean doGarbageCollection)

getMemoryStatistics

public static void getMemoryStatistics(long[] freeMemory,
                                       long[] totalMemory)

printMemoryReport

public static void printMemoryReport()

setTraceMode

public static void setTraceMode(int mask)

getTraceMode

public static int getTraceMode()

setTraceClasses

public static void setTraceClasses(java.lang.String[] classNames)

getTraceClasses

public static java.lang.String[] getTraceClasses()

setTraceIterations

public static void setTraceIterations(int numberOfIterations)

getTraceIterations

public static int getTraceIterations()

isTracing

public static boolean isTracing(MiPart part,
                                int tracingMode)

assertt

public static void assertt(boolean flag)

showBoundingBox

public static void showBoundingBox(MiPart target)

removeBoundingBox

public static void removeBoundingBox(MiPart target)

getMicaClassName

public static java.lang.String getMicaClassName(java.lang.Object obj)

dumpStructureOnly

public static void dumpStructureOnly(MiPart obj)

dump

public static void dump(MiPart obj)

dumpPart

public static void dumpPart(MiPart obj)

sleep

public static void sleep(long microSeconds)

halt

public static void halt()

halt

public static void halt(java.lang.String msg)

where

public static void where()

printAllThreads

public static void printAllThreads()

getStackTrace

public static java.lang.String getStackTrace(java.lang.Throwable e)

printStackTrace

public static void printStackTrace(java.lang.Throwable e)

printStackTrace

public static void printStackTrace()

printStackTrace

public static void printStackTrace(java.lang.String msg)

enter

public static void enter(java.lang.String traceMsg)

trace

public static void trace(java.lang.String traceMsg)

priority

public static void priority(java.lang.String traceMsg)

printlnError

public static void printlnError(java.lang.String errorMsg)

exit

public static void exit()

startFullTrace

public static void startFullTrace()

stopFullTrace

public static void stopFullTrace()

clearNumberOfErrors

public static void clearNumberOfErrors()

getNumberOfErrors

public static int getNumberOfErrors()

enterAndClearNumberOfErrors

public static void enterAndClearNumberOfErrors(java.lang.String traceMsg)

exitAndReturnNumberOfErrors

public static int exitAndReturnNumberOfErrors()

printHex

public static void printHex(int val)

setMicaPrefixEnabled

public static void setMicaPrefixEnabled(boolean flag)

getMicaPrefixEnabled

public static boolean getMicaPrefixEnabled()

println

public static void println(java.lang.String str)

println

public static void println(java.lang.Object obj)

print

public static void print(java.lang.String str)

delay

public static void delay(long count)

getPartWithInvalidArea

public static MiPart getPartWithInvalidArea(MiPart container)

traceGeometricActions

public static void traceGeometricActions(MiPart obj)

traceActions

public static void traceActions(MiPart obj,
                                int eventTypes,
                                int options)

stopTracingActions

public static void stopTracingActions(MiPart obj)

checkForLingeringInvalidLayoutsBelow

public static void checkForLingeringInvalidLayoutsBelow(MiPart obj)

getFullPathName

public static java.lang.String getFullPathName(MiPart obj)
public static boolean isShowing(MiPart subject, boolean thisPart) { if (!subject.isVisible()) { println(subject + ": not visible"); return(false); } if (subject.isHidden()) { println(subject + ": hidden"); return(false); } // FIX: needs to check all containing editors. for (int i = 0; i < subject.getNumberOfContainers(); ++i) { MiEditor editor = subject.getContainer(i).getContainingEditor(); if (editor == null) { println(subject + ": container has no editor " + subject.getContainer(i)); return(false); } if (editor.isShowing(thisPart)) { println(subject + ": editor not shwoing" + editor); return(true); } // FIX: need to xform drawBounds if references are between here and editor... if (thisPart && editor.getWorldBounds().intersects(subject.getDrawBounds(new MiBounds()))) return(true); } if ((subject instanceof MiWindow) && (((MiWindow )subject).isRootWindow())) return(true); println(subject + ": has no showing containers and is not a root window"); return(false); }


printVerbose

public static void printVerbose(java.lang.String str)

printValidationError

public static void printValidationError(MiValueValidationError error)