示例#1
0
 // Change border constraints to keep SelPoint inside window
 public void setBorderConstraints(int r, int b) {
   // Sanity check first
   /*
    * System.out.println("SP.setBordConstr: Passed (" + r + ", " + b + ")" + " this = " + this);
    */
   if ((r < 10.0) || (b < 10.0)) return;
   // Remove old border constraints if applicable
   try {
     if (rightBorderConstraint != null) solver.removeConstraint(rightBorderConstraint);
     if (bottomBorderConstraint != null) solver.removeConstraint(bottomBorderConstraint);
   } catch (CLInternalError e) {
     System.out.println("SelPoint.setBC: CLInternalError!");
   } catch (ConstraintNotFoundException e) {
     System.out.println("SelPoint.setBC: CLConstraintNotFound!");
   }
   try {
     rightBorderConstraint = new ClLinearInequality(clX, CL.LEQ, r);
     bottomBorderConstraint = new ClLinearInequality(clY, CL.LEQ, b);
     solver.addConstraint(rightBorderConstraint);
     solver.addConstraint(bottomBorderConstraint);
   } catch (CLInternalError e) {
     System.out.println("SelPoint.setBC: CLInternalError!");
   } catch (RequiredConstraintFailureException e) {
     System.out.println("SelPoint.setBC: CLRequiredFailure!");
   }
 }
示例#2
0
  // Convert an (x, y) pair plus flags into a SelPoint
  public SelPoint(
      ClSimplexSolver solver,
      int x,
      int y,
      boolean isSelected,
      boolean isHighlighted,
      int r,
      int b) {
    this.solver = solver;
    this.x = x;
    this.y = y;
    this.isSelected = isSelected;
    this.isHighlighted = isHighlighted;
    editX = null;
    editY = null;
    clX = new ClVariable(this.x);
    clY = new ClVariable(this.y);
    rightBorderConstraint = null;
    bottomBorderConstraint = null;
    /*
     * System.out.println("SP.SP: clX = " + clX + ", clY = " + clY);
     */

    id = nextID++;

    // Initialize ownership, interested lists
    interCC = new ArrayList<ConstrComponent>(4);
    interConstr = new ArrayList<Constraint>(4);
    owner = null;

    // Set stay constraints on point
    try {
      stayX = new ClStayConstraint(clX, ClStrength.weak, 1.0);
      stayY = new ClStayConstraint(clY, ClStrength.weak, 1.0);
      solver.addConstraint(stayX);
      solver.addConstraint(stayY);
      // Set within-window constraints on point
      leftBorderConstraint = new ClLinearInequality(clX, CL.GEQ, 3.0);
      topBorderConstraint = new ClLinearInequality(clY, CL.GEQ, 3.0);
      solver.addConstraint(leftBorderConstraint);
      solver.addConstraint(topBorderConstraint);
      setBorderConstraints(r, b);
    } catch (CLInternalError e) {
      System.out.println("SelPoint constructor: ExCLInternalError!");
    } catch (RequiredConstraintFailureException e) {
      System.out.println("SelPoint constructor: ExCLInternalError!");
    }
  }
示例#3
0
 public void removeEditConstraints() {
   try {
     if (editX != null) solver.removeConstraint(editX);
     if (editY != null) solver.removeConstraint(editY);
   } catch (CLInternalError e) {
     System.out.println("SelPoint.removeEC: CLInternalError!");
   } catch (ConstraintNotFoundException e) {
     System.out.println("SelPoint.removeEC: CLConstraintNotFound!");
   }
   editX = null;
   editY = null;
 }
示例#4
0
 // Set/remove the edit constraints associated with the SelPoint
 public void setEditConstraints() {
   editX = new ClEditConstraint(clX, ClStrength.strong);
   editY = new ClEditConstraint(clY, ClStrength.strong);
   try {
     solver.addConstraint(editX);
     solver.addConstraint(editY);
   } catch (CLInternalError e) {
     System.out.println("SelPoint.setEC: CLInternalError!");
   } catch (RequiredConstraintFailureException e) {
     System.out.println("SelPoint.setEC: CLRequiredFailure!");
   }
 }
示例#5
0
 // Remove all constraints associated with the point that it manages itself
 public void removeAllConstraints() {
   // Get rid of edit constraints first, if any
   removeEditConstraints();
   // Remove other constraints
   try {
     if (stayX != null) solver.removeConstraint(stayX);
     if (stayY != null) solver.removeConstraint(stayY);
     if (leftBorderConstraint != null) solver.removeConstraint(leftBorderConstraint);
     if (topBorderConstraint != null) solver.removeConstraint(topBorderConstraint);
     if (rightBorderConstraint != null) solver.removeConstraint(rightBorderConstraint);
     if (bottomBorderConstraint != null) solver.removeConstraint(bottomBorderConstraint);
   } catch (CLInternalError e) {
     System.out.println("SelPoint.removeAllC: CLInternalError!");
   } catch (ConstraintNotFoundException e) {
     System.out.println("SelPoint.removeAllC: CLConstraintNotFound!");
   }
   stayX = null;
   stayY = null;
   leftBorderConstraint = null;
   topBorderConstraint = null;
   rightBorderConstraint = null;
   bottomBorderConstraint = null;
 }