예제 #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
 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;
 }
예제 #3
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;
 }