debug.java

来自「ALGAE是一个快速创建算法演示的框架。目前支持的算法实现语言包括java和c」· Java 代码 · 共 140 行

JAVA
140 行
字号
package edu.odu.cs.zeil.AlgAE;import java.awt.Dimension;import java.awt.Frame;import java.awt.Insets;import java.awt.Point;import java.io.PrintWriter;import edu.odu.cs.zeil.AlgAE.TextDialog;class GCAnnouncer {    GCAnnouncer() {}        protected void finalize() throws Throwable    {	Debug.debug ("GC finalization detected");	GCAnnouncer gca = new GCAnnouncer();    }}    public class Debug{  public static boolean debug = true;  public static boolean events = false;  public static boolean edgeScore = false;  public static boolean garbageCollector = false;  public static boolean positionScore = false;  public static boolean edgePositionScore = false;  public static boolean reposition = false;  public static boolean directionTo = false;  public static boolean timer = false;  public static boolean entryPoint = false;  public static boolean edgeDraw = false;  public static boolean graphDraw = false;  public static boolean recenter = false;  public static boolean messageSynch = false;  public static boolean tokenizer = false;  public static boolean splitters = false;  public static boolean sockets = false;  public static boolean clientread = false;  public static boolean sourceCode = false;  public static boolean threads = false;  public static boolean termination = false;  public static boolean image = false;  public static PrintWriter out = null; // new PrintWriter(System.out);  public static Frame theFrame = null;  public static void debug (String message)  {    if (out != null)      {	out.println (message);	out.flush();      }  }    public static void error (String message)  {    debug (message);    if (theFrame != null)       {	 TextDialog td = new TextDialog (theFrame, message);       }  }    public static void show (boolean flag, String message)  {    if (flag && (out != null))      debug (message);  }  public static void show (boolean flag, String message, int value)  {    if (flag && (out != null))      debug (message + value);  }  public static void show (boolean flag, String message, boolean value)  {    if (flag && (out != null))      debug (message + value);  }  public static void show (boolean flag, String message, double value)  {    if (flag && (out != null))      debug (message + value);  }  public static void show (boolean flag, String message, Point value)  {    if (flag && (out != null))      debug (message + "(" + value.x + ", " + value.y + ")");  }  public static void show (boolean flag, String message, Dimension value)  {    if (flag && (out != null))      debug (message + "[" + value.width + ", " + value.height + "]");  }  public static void show (boolean flag, String message, Insets value)  {    if (flag && (out != null))      debug (message + value);  }  public static void show (boolean flag, String message, String value)  {    if (flag && (out != null))      debug (message + "\"" + value + "\"");  }  public static void assert (boolean flag, boolean test, String message)  {    if (!test)      show (flag, "Assertion violated: " + message);  }  public static void watchForGC()  {      if (garbageCollector) {	  GCAnnouncer gca = new GCAnnouncer();      }  }    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?