edu.umd.cs.jazz.util
Class ZDebug

java.lang.Object
  |
  +--edu.umd.cs.jazz.util.ZDebug
All Implemented Interfaces:
java.io.Serializable

public class ZDebug
extends java.lang.Object
implements java.io.Serializable

ZDebug provides static methods for maintaining/setting/retrieving global debugging state. It is not inteneded to be instantiated.

Warning: Serialized and ZSerialized objects of this class will not be compatible with future Jazz releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Jazz. A future release of Jazz will provide support for long term persistence.

Author:
Ben Bederson
, Britt McAlister
See Also:
ZNode, Serialized Form

Field Summary
static boolean debug
          Flag denoting whether debugging in general should be enabled.
static boolean debugPick
          Flag denoting whether to print debugging info related to picking
static boolean debugPrintFrameRate
          Flag denoting whether to print debugging info related to the frame rate.
static boolean debugPrintUsedMemory
          Flag denoting whether to print debugging info related to the memory usage.
static boolean debugRegionMgmt
          Flag denoting whether there is a display to help debug region management
static boolean debugRender
          Flag denoting whether to print debugging info related to render operations
static boolean debugRepaint
          Flag denoting whether to print debugging info related to repaint operations
static boolean debugSpatialIndexing
          Flag denoting whether to print debugging info related to spatial indexing.
static boolean debugTiming
          Flag denoting whether to print debugging info related to timing
static int printResultsFrameRate
          Specifies the rate that totals should be calculated and printed to the console when debugPrintFrameRate or debugPrintUsedMemory are true.
static boolean showBounds
          Flag denoting whether the bounds of each object are being rendered Don't set this directly - rather call setShowBounds(boolean, edu.umd.cs.jazz.ZCamera).
 
Constructor Summary
ZDebug()
           
 
Method Summary
static void clearPaintCount()
          Clears the paint count.
static void dump(ZNode node)
          Debugging function to dump the scenegraph rooted at the specified node to stdout.
protected static void dump(ZSceneGraphObject sgo, int level, boolean includeChildren)
          Internal method for dump(ZNode node).
protected static void dumpElement(java.lang.String space, java.lang.String origHeader, java.lang.String element)
          Print the element for the scenegraph dump.
static java.lang.String dumpString(ZSceneGraphObject obj, boolean includeChildren)
          Debugging function to dump the scenegraph rooted at the specified node to a String.
static void endProcessingInput()
           
static void endProcessingOutput()
           
static long getApproximateUsedMemory()
           
 long getFramesProcessed()
          Return the number of frames that have been processed since the last time resetFPSTiming was called.
static double getInputFPS()
          Return the frames per second used to process input events and activities.
static double getOutputFPS()
          Return the frames per seconds used to paint graphics to the screen.
static int getPaintCount()
          Returns the number of nodes that painted themselves during the last render.
static double getTotalFPS()
          Return how many frames are processed and painted per second.
static void incPaintCount()
          Call this method whenever a node paints itself.
static boolean isEventThread()
          In general, both Swing and Jazz are not thread safe.
static void resetFPSTiming()
          Reset the variables used to track FPS.
static void setShowBounds(boolean showBounds, ZCamera camera)
          Controls whether the bounds of each object should be drawn as a debugging aid.
static void startProcessingInput()
           
static void startProcessingOutput()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debug

public static final boolean debug
Flag denoting whether debugging in general should be enabled. Settig thisto false will cause all debugging code will be optimized out of Jazz during compilation.

See Also:
Constant Field Values

showBounds

public static boolean showBounds
Flag denoting whether the bounds of each object are being rendered Don't set this directly - rather call setShowBounds(boolean, edu.umd.cs.jazz.ZCamera).


debugRegionMgmt

public static boolean debugRegionMgmt
Flag denoting whether there is a display to help debug region management


debugRender

public static boolean debugRender
Flag denoting whether to print debugging info related to render operations


debugRepaint

public static boolean debugRepaint
Flag denoting whether to print debugging info related to repaint operations


debugTiming

public static boolean debugTiming
Flag denoting whether to print debugging info related to timing


debugPick

public static boolean debugPick
Flag denoting whether to print debugging info related to picking


debugSpatialIndexing

public static boolean debugSpatialIndexing
Flag denoting whether to print debugging info related to spatial indexing.


debugPrintFrameRate

public static boolean debugPrintFrameRate
Flag denoting whether to print debugging info related to the frame rate.


debugPrintUsedMemory

public static boolean debugPrintUsedMemory
Flag denoting whether to print debugging info related to the memory usage.


printResultsFrameRate

public static int printResultsFrameRate
Specifies the rate that totals should be calculated and printed to the console when debugPrintFrameRate or debugPrintUsedMemory are true.

Constructor Detail

ZDebug

public ZDebug()
Method Detail

setShowBounds

public static void setShowBounds(boolean showBounds,
                                 ZCamera camera)
Controls whether the bounds of each object should be drawn as a debugging aid. Caller must also specify the camera that should be used in computing how to display bounds.

Parameters:
showBounds - true to show bounds, or false to hide bounds
camera - The camera the bounds should be scaled for.

clearPaintCount

public static void clearPaintCount()
Clears the paint count. The paint count is the number of nodes that painted themselves during the last render. This method should be called at the begining of each render.

See Also:
incPaintCount(), getPaintCount()

incPaintCount

public static void incPaintCount()
Call this method whenever a node paints itself.

See Also:
clearPaintCount(), getPaintCount()

isEventThread

public static boolean isEventThread()
In general, both Swing and Jazz are not thread safe. Generally, modifications to both the Swing component hierarchy and the Jazz scenegraph should not occur outside of the Java event dispatch thread. Practically speaking, this means that if any thread other than the event dispatch thread needs to modify anything in a Swing component hierarchy or a Jazz scenegraph, they must do so in the event thread. Swing provides two utilites to make calls on the event thread, called invokeLater and invokeAndWait (see javax.swing.SwingUtilities). Some common Jazz programming violations of this policy are modifying Jazz objects in an animation thread or modifying Jazz objects from the main thread (ie. public static void main(String[] main)). Modifications to the Jazz scenegraph CAN be made in a thread BEFORE the Window containing a ZCanvas is shown. Not coincidently, this is when events start being generated for a Jazz ZCanvas. For code that will modify a Jazz scenegraph, the following function reports whether the code has been called from the event thread. This function is provided as a convenience to verify that Jazz scenegraph modifications are occuring on the appropriate thread.

Returns:
Was this function called from the event dispatch thread?
See Also:
SwingUtilities.invokeLater(java.lang.Runnable), SwingUtilities.invokeAndWait(java.lang.Runnable), SwingUtilities.isEventDispatchThread()

getPaintCount

public static int getPaintCount()
Returns the number of nodes that painted themselves during the last render.

See Also:
clearPaintCount(), incPaintCount()

startProcessingOutput

public static void startProcessingOutput()

endProcessingOutput

public static void endProcessingOutput()

startProcessingInput

public static void startProcessingInput()

endProcessingInput

public static void endProcessingInput()

getTotalFPS

public static double getTotalFPS()
Return how many frames are processed and painted per second. Note that since piccolo doesn�t paint continuously this rate will be slow unless you are interacting with the system or have activities scheduled.


getInputFPS

public static double getInputFPS()
Return the frames per second used to process input events and activities.


getOutputFPS

public static double getOutputFPS()
Return the frames per seconds used to paint graphics to the screen.


getFramesProcessed

public long getFramesProcessed()
Return the number of frames that have been processed since the last time resetFPSTiming was called.


resetFPSTiming

public static void resetFPSTiming()
Reset the variables used to track FPS. If you reset seldom they you will get good average FPS values, if you reset more often only the frames recorded after the last reset will be taken into consideration.


getApproximateUsedMemory

public static long getApproximateUsedMemory()

dump

public static void dump(ZNode node)
Debugging function to dump the scenegraph rooted at the specified node to stdout. It uses ZSceneGraphObject.dump() to display each object, and descends the hierarchy.

Parameters:
node - The root of the subtree to display.

dumpString

public static java.lang.String dumpString(ZSceneGraphObject obj,
                                          boolean includeChildren)
Debugging function to dump the scenegraph rooted at the specified node to a String. It uses ZSceneGraphObject.dump() to display each object, and descends the hierarchy.

Parameters:
obj - The scenegraph object being dumped.
includeChildren - true if children nodes should be dumped.

dump

protected static void dump(ZSceneGraphObject sgo,
                           int level,
                           boolean includeChildren)
Internal method for dump(ZNode node). This method handles pretty indenting of each level as it recurses down the tree.

Parameters:
sgo - the scenegraph object being dumped.
level - a count of recursion level for indenting.
includeChildren - true if children nodes should be dumped.

dumpElement

protected static void dumpElement(java.lang.String space,
                                  java.lang.String origHeader,
                                  java.lang.String element)
Print the element for the scenegraph dump. Parse the element, and if there are any newlines, space out each line with the 'space' parameter. Also, print the header for the first line, and a matching number of spaces for ensuing lines.

Parameters:
space - space to indent the header.
origHeader - text header for the first line.


Copyright � 2003 by University of Maryland, College Park, MD 20742, USA All rights reserved.