Example #1
0
  public NSlitDragger(XDragWidget widthDragger, XDragWidget distDragger, WTInt n) {
    // Get references to the Widgets
    widthWidget = widthDragger;
    distanceWidget = distDragger;

    // Add this as a Listener to the Widgets
    widthWidget.addListener(this);
    distanceWidget.addListener(this);

    // Get a reference to N
    N = n;
  }
Example #2
0
  public void updateDistanceDraggerConstraints() {
    float min = width * (N.getValue() - 1), max = APERTURE_WIDTH / 2.0f - width;

    // ** Manage book keeping variables for other classes **//
    min_distance = min;
    max_distance = max;

    distanceWidget.setMin(min);
    distanceWidget.setMax(max);

    distanceSetInternally = true;
  }
Example #3
0
 // If was single slit, evaluate differently
 public float evaluateSingle() {
   distanceSetInternally = true;
   distance = 2 * width;
   distanceWidgetPosition = distance * (N.getValue() - 1) / 2.0f;
   distanceWidget.setValue(distanceWidgetPosition);
   return distance / 500.0f;
 }
Example #4
0
  public void updateWidthDraggerConstraints() {
    float max,
        max1 = APERTURE_WIDTH / 2.0f - distanceWidgetPosition, // The slit touches the wall
        max2 = distance / 2.0f; // The two slits touch

    DebugPrinter.println(
        "distWidgetPosition-> " + distanceWidgetPosition + " distance->" + distance);

    if (N.getValue() == 1) {
      max = APERTURE_WIDTH / 2.0f;
    } else {
      max = (max1 < max2) ? max1 : max2;
    }
    min_width = 0;
    max_width = max;

    widthWidget.setMin(0);
    widthWidget.setMax(max);
  }
Example #5
0
 public void evaluateDistance() {
   distanceSetInternally = true;
   distanceWidgetPosition = distance * (N.getValue() - 1) / 2.0f;
   distanceWidget.setValue(distanceWidgetPosition);
 }