// Path: library/src/main/java/no/agens/cassowarylayout/util/DimensionParser.java
// public class DimensionParser {
// 
//     private static Pattern pattern = Pattern.compile("^(wrapContent|matchParent)|(\\d+)(px|dp|sp|pt|in|mm)");
// 
//     public static Double getDimension(String widthHeightString, Context context) {
// 
//         Double widthHeight = null;
// 
//         Matcher matcher = pattern.matcher(widthHeightString);
// 
//         matcher.find();
// 
//         if (matcher.matches()) {
//             if  (matcher.group(2) == null) {
//                 widthHeight = (double)RelativeLayout.LayoutParams.MATCH_PARENT;
//                 if ("wrapContent".equals(matcher.group(1))) {
//                     widthHeight = (double)RelativeLayout.LayoutParams.WRAP_CONTENT;
//                 }
//             } else {
//                 String value = matcher.group(2);
//                 String unit = matcher.group(3);
//                 try {
//                     widthHeight = (double)TypedValue.applyDimension(getUnitFromString(unit), Integer.parseInt(value), context.getResources().getDisplayMetrics());
//                     //widthHeight = Integer.parseInt(widthHeightString.substring(0, widthHeightString.));
//                 } catch (NumberFormatException e) {
//                     // ignore
//                 }
//             }
//         }
// 
//         return widthHeight;
// 
//     }
// 
//     private static int getUnitFromString(String unitString) {
// 
//         int unit = TypedValue.COMPLEX_UNIT_DIP;
//         if ("px".equals(unitString)) {
//             unit = TypedValue.COMPLEX_UNIT_PX;
//         } else if ("dp".equals(unitString)) {
//             unit = TypedValue.COMPLEX_UNIT_DIP;
//         } else if ("sp".equals(unitString)) {
//             unit = TypedValue.COMPLEX_UNIT_SP;
//         } else if ("pt".equals(unitString)) {
//             unit = TypedValue.COMPLEX_UNIT_PT;
//         } else if ("in".equals(unitString)) {
//             unit = TypedValue.COMPLEX_UNIT_IN;
//         } else if ("mm".equals(unitString)) {
//             unit = TypedValue.COMPLEX_UNIT_MM;
//         }
//         return unit;
//     }
// }
// 
// Path: library/src/main/java/no/agens/cassowarylayout/util/TimerUtil.java
// public class TimerUtil {
//     public static long since(long since) {
//         return (System.nanoTime() - since) / 1000000;
//     }
// }


import android.content.Context;
import android.util.Log;
import org.pybee.cassowary.Constraint;
import org.pybee.cassowary.ConstraintNotFound;
import org.pybee.cassowary.Expression;
import org.pybee.cassowary.SimplexSolver;
import org.pybee.cassowary.Variable;
import java.util.HashMap;
import no.agens.cassowarylayout.util.DimensionParser;
import no.agens.cassowarylayout.util.TimerUtil;
        } catch (ConstraintNotFound constraintNotFound) {
            constraintNotFound.printStackTrace();
        }
    }

    public void addConstraints(CharSequence[] constraints) {
        for (CharSequence constraint : constraints) {
            try {
                addConstraint(constraint.toString());
            } catch (RuntimeException e) {
                Log.e(LOG_TAG, "could not add constraint " + constraint.toString(), e);
            }

        }
    }

    public void addConstraints(int id) {
        String[] constraints = context.getResources().getStringArray(id);
        addConstraints(constraints);
    }

    public Node getContainerNode() {
        return containerNode;
    }

    public void solve() {
        long timeBeforeSolve = System.nanoTime();

        solver.solve();

// Path: library/src/main/java/no/agens/cassowarylayout/util/DimensionParser.java
// public class DimensionParser {
// 
//     private static Pattern pattern = Pattern.compile("^(wrapContent|matchParent)|(\\d+)(px|dp|sp|pt|in|mm)");
// 
//     public static Double getDimension(String widthHeightString, Context context) {
// 
//         Double widthHeight = null;
// 
//         Matcher matcher = pattern.matcher(widthHeightString);
// 
//         matcher.find();
// 
//         if (matcher.matches()) {
//             if  (matcher.group(2) == null) {
//                 widthHeight = (double)RelativeLayout.LayoutParams.MATCH_PARENT;
//                 if ("wrapContent".equals(matcher.group(1))) {
//                     widthHeight = (double)RelativeLayout.LayoutParams.WRAP_CONTENT;
//                 }
//             } else {
//                 String value = matcher.group(2);
//                 String unit = matcher.group(3);
//                 try {
//                     widthHeight = (double)TypedValue.applyDimension(getUnitFromString(unit), Integer.parseInt(value), context.getResources().getDisplayMetrics());
//                     //widthHeight = Integer.parseInt(widthHeightString.substring(0, widthHeightString.));
//                 } catch (NumberFormatException e) {
//                     // ignore
//                 }
//             }
//         }
// 
//         return widthHeight;
// 
//     }
// 
//     private static int getUnitFromString(String unitString) {
// 
//         int unit = TypedValue.COMPLEX_UNIT_DIP;
//         if ("px".equals(unitString)) {
//             unit = TypedValue.COMPLEX_UNIT_PX;
//         } else if ("dp".equals(unitString)) {
//             unit = TypedValue.COMPLEX_UNIT_DIP;
//         } else if ("sp".equals(unitString)) {
//             unit = TypedValue.COMPLEX_UNIT_SP;
//         } else if ("pt".equals(unitString)) {
//             unit = TypedValue.COMPLEX_UNIT_PT;
//         } else if ("in".equals(unitString)) {
//             unit = TypedValue.COMPLEX_UNIT_IN;
//         } else if ("mm".equals(unitString)) {
//             unit = TypedValue.COMPLEX_UNIT_MM;
//         }
//         return unit;
//     }
// }
// 
// Path: library/src/main/java/no/agens/cassowarylayout/util/TimerUtil.java
// public class TimerUtil {
//     public static long since(long since) {
//         return (System.nanoTime() - since) / 1000000;
//     }
// }


// Path: library/src/main/java/no/agens/cassowarylayout/CassowaryModel.java
import android.content.Context;
import android.util.Log;
import org.pybee.cassowary.Constraint;
import org.pybee.cassowary.ConstraintNotFound;
import org.pybee.cassowary.Expression;
import org.pybee.cassowary.SimplexSolver;
import org.pybee.cassowary.Variable;
import java.util.HashMap;
import no.agens.cassowarylayout.util.DimensionParser;
import no.agens.cassowarylayout.util.TimerUtil;

        } catch (ConstraintNotFound constraintNotFound) {
            constraintNotFound.printStackTrace();
        }
    }

    public void addConstraints(CharSequence[] constraints) {
        for (CharSequence constraint : constraints) {
            try {
                addConstraint(constraint.toString());
            } catch (RuntimeException e) {
                Log.e(LOG_TAG, "could not add constraint " + constraint.toString(), e);
            }

        }
    }

    public void addConstraints(int id) {
        String[] constraints = context.getResources().getStringArray(id);
        addConstraints(constraints);
    }

    public Node getContainerNode() {
        return containerNode;
    }

    public void solve() {
        long timeBeforeSolve = System.nanoTime();

        solver.solve();

        Log.d(LOG_TAG, "solve took " + TimerUtil.since(timeBeforeSolve));