Click here to Skip to main content
15,896,557 members
Articles / Web Development / HTML

Discrete Wavelet Transforms, a Java Implementation

Rate me:
Please Sign up or sign in to vote.
4.95/5 (16 votes)
13 Nov 2014CPOL10 min read 60.7K   5.6K   19  
This article presents a Java example application that performs discrete wavelet transforms.
/*
 * $Id: Debug.java 490 2006-10-01 16:08:04Z metlov $
 *
 * Galaxy PBW server 2.0 abstract core package.
 *
 * Implementation of the Galaxy game server for playing over WWW. For more
 * information about Galaxy PBW development visit :
 *    http://kinetic.ac.donetsk.ua/galaxywww/
 *
 * (c) 1996 -- 2007 by Konstantin Metlov(metlov@kinetic.ac.donetsk.ua);
 *
 * Galaxy PBW server package is Distributed under GNU General Public License
 *
 *    This code comes with ABSOLUTELY NO WARRANTY.
 *  For license details see COPYING file in this directory.
 *
 */

package gnu.jel.debug;

/** 
 * This class used for incorporating internal checks and
 * assertions into the code.  
 * <BR>None of these functions does anything if Debug.enabled is false.
 * <BR>If you really want to throw ALL debug messages from the final,
 * compiler generated, code -- wrap calls to Debug methods into the
 * <TT>if</TT> statement, checking <TT>Debug.enabled</TT> constant.
 * As shown in the example : 
 * <PRE>
 * import cz.fzu.metlov.jel.*;
 * ..... BLA BLA BLA ...
 * if (Debug.enabled) {
 *  Debug.println("I want this message to disappear in the optimized version");
 *  Debug.check(foo==superTimeConsumingFunction(bar), 
 * "I do not want to evaluate superTimeConsumingFunction(), when optimized."); 
 * }; 
 *</PRE> 
 */
public final class Debug {

  /**
   * Determines if debugging is enabled in current compilation.
   */
  public final static boolean enabled=@DEBUG@; // <-- AUTO GENERATED
  

  /**
   * Prints a line of the debug output.
   * The resulting line goes to System.err and is prefixed by "[DEBUG] ".
   * @param message message to print.
   */
  public final static void println(String message) {
    if (enabled) {
      System.err.print("[DEBUG] ");
      System.err.println(message);
    };
  };

  /**
   * Checks for the condition.
   * If condition is false this function prints a given message
   * to the System.err along with the stack trace.
   * @param condition is the condition to check.
   * @param message is the message to print if condition is false.
   */
  public final static void check(boolean condition, String message) {
    if (enabled && (!condition)) {
      System.err.print("Assertion failed :");
      System.err.println(message);
      Throwable tracer=new Throwable(message);
      tracer.printStackTrace();
    }; 
  };

  /**
   * Checks for the condition.
   * If condition is false this function prints a "Assertion failed."
   * to the System.err along with the stack trace.
   * @param condition is the condition to check.
   */
  public final static void check(boolean condition) {
    if (enabled && (!condition)) {
      Throwable tracer=new Throwable("Assertion failed.");
      tracer.printStackTrace();
    }; 
  };

  /**
   * Reports an exception, which should not occur(i.e. handled improperly).
   * @param t is what was thrown.
   * @param message is algorithm specific message.
   */
  public final static void reportThrowable(Throwable t,String message) {
    if (enabled) {
      System.err.println("Unexpected exception has occured :");
      System.err.println(message);
      t.printStackTrace();
    };
  };

  /**
   * Reports an exception, which should not occur(i.e. handled improperly).
   * @param t is what was thrown.
   */
  public final static void reportThrowable(Throwable t) {
    if (enabled) {
      System.err.println("Unexpected exception has occured :");
      t.printStackTrace();
    };
  };
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Founder PEI Watershed Alliance, Inc.
United States United States
I am an analytical chemist and an educator. I program primarily to perform matrix computations for regression analysis, process signals, acquire data from sensors, and to control devices.

I participate in many open source development communities and Linux user forums. I do contract work for an environmental analytical laboratory, where I am primarily focused on LIMS programming and network administration.

I am a member of several community-interest groups such as the Prince Edward Island Watershed Alliance, the Lot 11 and Area Watershed Management Group, and the Petersham Historic Commission.

Comments and Discussions