Android Open Source - CalWatch C L






From Project

Back to project page CalWatch.

License

The source code is released under:

GNU General Public License

If you think the Android project CalWatch listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

// $Id: CL.java,v 1.16 2011/05/23 04:47:17 gjbadros Exp $
///*  w  w  w . j a  va 2  s .c o  m*/
// Cassowary Incremental Constraint Solver
// Original Smalltalk Implementation by Alan Borning
// This Java Implementation by Greg J. Badros, <gjb@cs.washington.edu>
// http://www.cs.washington.edu/homes/gjb
// (C) 1998, 1999 Greg J. Badros and Alan Borning
// See ../LICENSE for legal details regarding this software
//
// CL.java
// The enumerations from ClLinearInequality,
// and `global' functions that we want easy to access

package EDU.Washington.grad.gjb.cassowary;

public class CL {
  protected final static boolean fDebugOn = false;
  public static boolean fTraceOn = false; //true;
  protected final static boolean fTraceAdded = false;
  protected final static boolean fGC = false;

  protected static void debugprint(String s)
  { System.err.println(s); }

  protected static void traceprint(String s)
  { System.err.println(s); }

  protected static void fnenterprint(String s)
  { System.err.println("* " + s); }

  protected static void fnexitprint(String s)
  { System.err.println("- " + s); }

  protected void CLassert(boolean f,String description) throws ExCLInternalError
  { 
    if (!f) { 
      throw new ExCLInternalError("Assertion failed:" + description); 
    }
  }

  protected void CLassert(boolean f) throws ExCLInternalError
  { 
    if (!f) { 
      throw new ExCLInternalError("Assertion failed");
    }
  }


  public static final byte GEQ = 1;
  public static final byte LEQ = 2;

  public static ClLinearExpression Plus(ClLinearExpression e1, ClLinearExpression e2)
    { return e1.plus(e2); }

  public static ClLinearExpression Plus(ClLinearExpression e1, double e2)
    { return e1.plus(new ClLinearExpression(e2)); }

  public static ClLinearExpression Plus(double e1, ClLinearExpression e2)
    { return (new ClLinearExpression(e1)).plus(e2); }

  public static ClLinearExpression Plus(ClVariable e1, ClLinearExpression e2)
    { return (new ClLinearExpression(e1)).plus(e2); }

  public static ClLinearExpression Plus(ClLinearExpression e1, ClVariable e2)
    { return e1.plus(new ClLinearExpression(e2)); }

  public static ClLinearExpression Plus(ClVariable e1, double e2)
    { return (new ClLinearExpression(e1)).plus(new ClLinearExpression(e2)); }

  public static ClLinearExpression Plus(double e1, ClVariable e2)
    { return (new ClLinearExpression(e1)).plus(new ClLinearExpression(e2)); }

  
  public static ClLinearExpression Minus(ClLinearExpression e1, ClLinearExpression e2)
    { return e1.minus(e2); }

  public static ClLinearExpression Minus(double e1, ClLinearExpression e2)
    { return (new ClLinearExpression(e1)).minus(e2); }

  public static ClLinearExpression Minus(ClLinearExpression e1, double e2)
    { return e1.minus(new ClLinearExpression(e2)); }

  public static ClLinearExpression Times(ClLinearExpression e1, ClLinearExpression e2) 
    throws ExCLNonlinearExpression
    { return e1.times(e2); }

  public static ClLinearExpression Times(ClLinearExpression e1, ClVariable e2) 
    throws ExCLNonlinearExpression
    { return e1.times(new ClLinearExpression(e2)); }

  public static ClLinearExpression Times(ClVariable e1, ClLinearExpression e2) 
    throws ExCLNonlinearExpression
    { return (new ClLinearExpression(e1)).times(e2); }

  public static ClLinearExpression Times(ClLinearExpression e1, double e2) 
    throws ExCLNonlinearExpression
    { return e1.times(new ClLinearExpression(e2)); }

  public static ClLinearExpression Times(double e1, ClLinearExpression e2) 
    throws ExCLNonlinearExpression
    { return (new ClLinearExpression(e1)).times(e2); }

  public static ClLinearExpression Times(double n, ClVariable clv) 
    throws ExCLNonlinearExpression
    { return (new ClLinearExpression(clv,n)); }

  public static ClLinearExpression Times( ClVariable clv, double n) 
    throws ExCLNonlinearExpression
    { return (new ClLinearExpression(clv,n)); }

  public static ClLinearExpression Divide(ClLinearExpression e1, ClLinearExpression e2)
    throws ExCLNonlinearExpression
    { return e1.divide(e2); }

  public static boolean approx(double a, double b)
    {
      double epsilon = 1.0e-8;
      if (a == 0.0) {
  return (Math.abs(b) < epsilon);
      } else if (b == 0.0) {
  return (Math.abs(a) < epsilon);
      } else {
  return (Math.abs(a-b) < Math.abs(a) * epsilon);
      }
    }
  
  public static boolean approx(ClVariable clv, double b)
    {
      return approx(clv.value(),b);
    }
  
  static boolean approx(double a, ClVariable clv)
    {
      return approx(a,clv.value());
    }
}




Java Source Code List

EDU.Washington.grad.gjb.cassowary.CL.java
EDU.Washington.grad.gjb.cassowary.ClAbstractVariable.java
EDU.Washington.grad.gjb.cassowary.ClConstraint.java
EDU.Washington.grad.gjb.cassowary.ClDouble.java
EDU.Washington.grad.gjb.cassowary.ClDummyVariable.java
EDU.Washington.grad.gjb.cassowary.ClEditConstraint.java
EDU.Washington.grad.gjb.cassowary.ClEditInfo.java
EDU.Washington.grad.gjb.cassowary.ClEditOrStayConstraint.java
EDU.Washington.grad.gjb.cassowary.ClLinearConstraint.java
EDU.Washington.grad.gjb.cassowary.ClLinearEquation.java
EDU.Washington.grad.gjb.cassowary.ClLinearExpression.java
EDU.Washington.grad.gjb.cassowary.ClLinearInequality.java
EDU.Washington.grad.gjb.cassowary.ClObjectiveVariable.java
EDU.Washington.grad.gjb.cassowary.ClPoint.java
EDU.Washington.grad.gjb.cassowary.ClSimplexSolver.java
EDU.Washington.grad.gjb.cassowary.ClSlackVariable.java
EDU.Washington.grad.gjb.cassowary.ClStayConstraint.java
EDU.Washington.grad.gjb.cassowary.ClStrength.java
EDU.Washington.grad.gjb.cassowary.ClSymbolicWeight.java
EDU.Washington.grad.gjb.cassowary.ClTableau.java
EDU.Washington.grad.gjb.cassowary.ClTestColumns.java
EDU.Washington.grad.gjb.cassowary.ClTests.java
EDU.Washington.grad.gjb.cassowary.ClVariable.java
EDU.Washington.grad.gjb.cassowary.ExCLConstraintNotFound.java
EDU.Washington.grad.gjb.cassowary.ExCLError.java
EDU.Washington.grad.gjb.cassowary.ExCLInternalError.java
EDU.Washington.grad.gjb.cassowary.ExCLNonlinearExpression.java
EDU.Washington.grad.gjb.cassowary.ExCLNotEnoughStays.java
EDU.Washington.grad.gjb.cassowary.ExCLRequiredFailure.java
EDU.Washington.grad.gjb.cassowary.ExCLTooDifficult.java
EDU.Washington.grad.gjb.cassowary.Set.java
EDU.Washington.grad.gjb.cassowary.Timer.java
EDU.Washington.grad.gjb.cassowary.sym.java
EDU.Washington.grad.gjb.cassowary.testClLinearExpression.java
EDU.Washington.grad.gjb.cassowary.testClStrength.java
org.dwallach.calwatch.ApplicationTest.java
org.dwallach.calwatch.BatteryWrapper.java
org.dwallach.calwatch.CalWatchFaceService.java
org.dwallach.calwatch.CalendarFetcher.java
org.dwallach.calwatch.ClockFace.java
org.dwallach.calwatch.ClockState.java
org.dwallach.calwatch.Constants.java
org.dwallach.calwatch.EventLayoutTest.java
org.dwallach.calwatch.EventLayoutUniformTest.java
org.dwallach.calwatch.EventLayoutUniform.java
org.dwallach.calwatch.EventLayout.java
org.dwallach.calwatch.EventWrapper.java
org.dwallach.calwatch.MyViewAnim.java
org.dwallach.calwatch.PaintCan.java
org.dwallach.calwatch.PathCache.java
org.dwallach.calwatch.PhoneActivity.java
org.dwallach.calwatch.PreferencesHelper.java
org.dwallach.calwatch.TimeWrapper.java
org.dwallach.calwatch.VersionWrapper.java
org.dwallach.calwatch.WatchCalendarService.java
org.dwallach.calwatch.WearReceiverService.java
org.dwallach.calwatch.WearSender.java
org.dwallach.calwatch.WireEvent.java
org.dwallach.calwatch.WireUpdate.java
org.dwallach.calwatch.XWatchfaceReceiver.java