Android Open Source - CalWatch Cl Linear Inequality






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: ClLinearInequality.java,v 1.15 1999/04/20 00:26:33 gjb Exp $
///* ww  w . j a  v  a  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
//
// ClLinearInequality
//

package EDU.Washington.grad.gjb.cassowary;

public class ClLinearInequality extends ClLinearConstraint
{
  
  public ClLinearInequality(ClLinearExpression cle,
          ClStrength strength,
          double weight)
  {
    super(cle,strength,weight);
  }

  public ClLinearInequality(ClLinearExpression cle,
          ClStrength strength)
  {
    super(cle,strength);
  }

  public ClLinearInequality(ClLinearExpression cle)
  {
    super(cle);
  }

  public ClLinearInequality(ClVariable clv1,
          byte op_enum,
          ClVariable clv2,
          ClStrength strength,
          double weight)
       throws ExCLInternalError
  {
    super(new ClLinearExpression(clv2),strength,weight);
    if (op_enum == CL.GEQ) {
      _expression.multiplyMe(-1.0);
      _expression.addVariable(clv1);
    } else if (op_enum == CL.LEQ) {
      _expression.addVariable(clv1,-1.0);
    } else // the operator was invalid
      throw new ExCLInternalError("Invalid operator in ClLinearInequality constructor");
  }

  public ClLinearInequality(ClVariable clv1,
          byte op_enum,
          ClVariable clv2,
          ClStrength strength)
       throws ExCLInternalError
  {
    this(clv1,op_enum,clv2,strength,1.0);
  }

  public ClLinearInequality(ClVariable clv1,
          byte op_enum,
          ClVariable clv2)
       throws ExCLInternalError
  {
    this(clv1,op_enum,clv2,ClStrength.required,1.0);
  }


  public ClLinearInequality(ClVariable clv,
          byte op_enum,
          double val,
          ClStrength strength,
          double weight)
       throws ExCLInternalError
  {
    super(new ClLinearExpression(val),strength,weight);
    if (op_enum == CL.GEQ) {
      _expression.multiplyMe(-1.0);
      _expression.addVariable(clv);
    } else if (op_enum == CL.LEQ) {
      _expression.addVariable(clv,-1.0);
    } else // the operator was invalid
      throw new ExCLInternalError("Invalid operator in ClLinearInequality constructor");
  }

  public ClLinearInequality(ClVariable clv,
          byte op_enum,
          double val,
          ClStrength strength)
       throws ExCLInternalError
  {
    this(clv,op_enum,val,strength,1.0);
  }

  public ClLinearInequality(ClVariable clv,
          byte op_enum,
          double val)
       throws ExCLInternalError
  {
    this(clv,op_enum,val,ClStrength.required,1.0);
  }

  public ClLinearInequality(ClLinearExpression cle1,
          byte op_enum,
          ClLinearExpression cle2,
          ClStrength strength,
          double weight)
       throws ExCLInternalError
  {
    super(((ClLinearExpression) cle2.clone()),strength,weight);
    if (op_enum == CL.GEQ) {
      _expression.multiplyMe(-1.0);
      _expression.addExpression(cle1);
    } else if (op_enum == CL.LEQ) {
      _expression.addExpression(cle1,-1.0);
    } else // the operator was invalid
      throw new ExCLInternalError("Invalid operator in ClLinearInequality constructor");
  }

  public ClLinearInequality(ClLinearExpression cle1,
          byte op_enum,
          ClLinearExpression cle2,
          ClStrength strength)
       throws ExCLInternalError
  {
    this(cle1,op_enum,cle2,strength,1.0);
  }

  public ClLinearInequality(ClLinearExpression cle1,
          byte op_enum,
          ClLinearExpression cle2)
       throws ExCLInternalError
  {
    this(cle1,op_enum,cle2,ClStrength.required,1.0);
  }


  public ClLinearInequality(ClAbstractVariable clv,
          byte op_enum,
          ClLinearExpression cle,
          ClStrength strength,
          double weight)
       throws ExCLInternalError
  {
    super(((ClLinearExpression) cle.clone()),strength,weight);
    if (op_enum == CL.GEQ) {
      _expression.multiplyMe(-1.0);
      _expression.addVariable(clv);
    } else if (op_enum == CL.LEQ) {
      _expression.addVariable(clv,-1.0);
    } else // the operator was invalid
      throw new ExCLInternalError("Invalid operator in ClLinearInequality constructor");
  }

  public ClLinearInequality(ClAbstractVariable clv,
          byte op_enum,
          ClLinearExpression cle,
          ClStrength strength)
       throws ExCLInternalError
  {
    this(clv,op_enum,cle,strength,1.0);
  }

  public ClLinearInequality(ClAbstractVariable clv,
          byte op_enum,
          ClLinearExpression cle)
       throws ExCLInternalError
  {
    this(clv,op_enum,cle,ClStrength.required,1.0);
  }


  public ClLinearInequality(ClLinearExpression cle,
          byte op_enum,
          ClAbstractVariable clv,
          ClStrength strength,
          double weight)
       throws ExCLInternalError
  {
    super(((ClLinearExpression) cle.clone()),strength,weight);
    if (op_enum == CL.LEQ) {
      _expression.multiplyMe(-1.0);
      _expression.addVariable(clv);
    } else if (op_enum == CL.GEQ) {
      _expression.addVariable(clv,-1.0);
    } else // the operator was invalid
      throw new ExCLInternalError("Invalid operator in ClLinearInequality constructor");
  }


  public ClLinearInequality(ClLinearExpression cle,
          byte op_enum,
          ClAbstractVariable clv,
          ClStrength strength)
       throws ExCLInternalError
  {
    this(cle,op_enum,clv,strength,1.0);
  }

  public ClLinearInequality(ClLinearExpression cle,
          byte op_enum,
          ClAbstractVariable clv)
       throws ExCLInternalError
  {
    this(cle,op_enum,clv,ClStrength.required,1.0);
  }


  public final boolean isInequality()
  { return true; }

  public final String toString()
  { return super.toString() + " >= 0 )"; }
}




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