edu.cmu.relativelayout.matrix
Class RelativeMatrix

java.lang.Object
  extended by edu.cmu.relativelayout.matrix.RelativeMatrix

public class RelativeMatrix
extends Object

A matrix class that solves Equations for Variables.

Author:
Rachael Bennett (srbennett@gmail.com)

Constructor Summary
RelativeMatrix()
          Constructor for RelativeMatrix.
 
Method Summary
 void addEquation(Variable variable, Equation equation)
          Adds the given Equation to the matrix with the given Variable as its primary variable.
static boolean isDebugMode()
          Returns true if RelativeMatrix is currently in debugging mode.
 void removeEquation(Variable variable)
          Removes the Equation whose primary Variable is the given variable from the matrix.
static void setDebugMode(boolean isDebugging)
          Sets whether RelativeMatrix is in debugging mode.
 Map<Variable,Double> solve()
          Solves this matrix and returns a map containing keys for every variable that has been added to the matrix whose values are the solutions for those variables.
 String toString()
          Returns a string representation of the matrix.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RelativeMatrix

public RelativeMatrix()
Constructor for RelativeMatrix.

Method Detail

isDebugMode

public static boolean isDebugMode()
Returns true if RelativeMatrix is currently in debugging mode. See setDebugMode(boolean) for more information on debugging mode.


setDebugMode

public static void setDebugMode(boolean isDebugging)
Sets whether RelativeMatrix is in debugging mode. While in debugging mode, matrices will be solved whenever an equation is added or removed. This is very slow for complex interfaces (potentially over ten times slower than when debugging mode is turned off), but has the advantage that any InvalidBindingException, InconsistentConstraintException, or UnknownComponentException that is raised while solving the matrix will point back to the exact line of code where the offending Binding was added to the matrix, making debugging much easier.


addEquation

public void addEquation(Variable variable,
                        Equation equation)
Adds the given Equation to the matrix with the given Variable as its primary variable. See Binding#usesDimensionalVariable(boolean) for information on primary variables.


removeEquation

public void removeEquation(Variable variable)
Removes the Equation whose primary Variable is the given variable from the matrix.


solve

public Map<Variable,Double> solve()
Solves this matrix and returns a map containing keys for every variable that has been added to the matrix whose values are the solutions for those variables.


toString

public String toString()
Returns a string representation of the matrix.

Overrides:
toString in class Object