Ejemplo n.º 1
0
 public void scaleMirror(float value) {
   DebugPrinter.println("Mirror::scaleMirror(" + value + ")");
   value = scaleFactor - (value / 2);
   DebugPrinter.println("...value'=" + value);
   float arra[] = new float[3];
   arra[0] = value;
   arra[1] = 1;
   arra[2] = 1;
   ScaleMirror.setValue(arra);
 }
Ejemplo n.º 2
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);
  }
Ejemplo n.º 3
0
  // ***** ScalarWidget.Listener Interface *****//
  // valueChanged() is called as soon as a Widget is activated (I think) [PC]
  public void valueChanged(ScalarWidget src, float value) {
    /* I'm not sure if there need to be two cases for each widget:
     * (1) the dragger is being manipulated
     * (2) the dragger's value was set directly via a Coupled NumberBox
     * In the case of (1), the [WIDTH/DISTANCE]_TRAVERSAL case of the original callback
     *  switch should probably be used.
     * In the case of (2), the [WIDTH/DISTANCE] case may should be used.
     * I believe these two situations must be considered, so to check this, I've included
     *  a selection structure that relies on Widget.isActive() to tell whether the Widget
     *  is being dragged or not.  [PC]
     */

    if (!updating) {

      // ** Debug: Finding value sent by a widget **//
      String widget =
          (src == distanceWidget)
              ? "distanceWidget"
              : ((src == widthWidget) ? "widthWidget" : "Unknown Widget");
      DebugPrinter.println(
          "NSlitDragger ScalarWidget.Listener: " + widget + "'s value changed to " + value);

      updating = true;
      if (src == widthWidget) {
        /* Updates needed:
         * (1) update distance constraints
         */

        // GRANT - ADDED THIS
        if (widthSetInternally) {
          widthSetInternally = false;
          updating = false;
          return;
        }

        width = value;
        // System.out.println("WidthChanged to: " + value);
        // updateDistanceDraggerConstraints(); //why distance?
        // Changed this call...seems that you should update the width instead of the distance if
        // the width widget is generating the event...seems to be working now [JD]
        updateWidthDraggerConstraints();

      } else if (src == distanceWidget) {
        /* Updates needed:
         * (1) update width constraints
         * (2) move width Widgets
         */

        if (distanceSetInternally) {
          distanceSetInternally = false;
          updating = false;
          return;
        }

        distance = 2 * value / (N.getValue() - 1);

        if (N.getValue() == 1) distance = 0;

        distanceWidgetPosition = value;
        System.out.println("Distance changed to: " + distance);
        System.out.println("Distance Widget Position changed to: " + distanceWidgetPosition);
        // updateWidthDraggerConstraints(); //why width?
        // changed the call to update the distance...seems that you should update the distance if
        // the distance widget generated the event..seems to be working now [JD]
        updateDistanceDraggerConstraints();
      } else {
        System.out.println("NSlitDragger.valueChanged(): ERROR: Invalid widget source: " + src);
      }

      // Once done updating, allow further updates to take place.
      updating = false;
    } // End actions to perform if updating
  }