public void propertyChange(PropertyChangeEvent pce) {
   Object source = pce.getSource();
   if (source == posSlider_x) {
     double posX = ((Double) pce.getNewValue()).doubleValue();
     posDisk.x = posX;
     Disk.setNode3D(ShapeNodeDisk);
     Disk.setPosition(posDisk);
     PlaceBNVectors();
   } else if (source == posSlider_y) {
     double posY = ((Double) pce.getNewValue()).doubleValue();
     posDisk.y = posY;
     Disk.setNode3D(ShapeNodeDisk);
     Disk.setPosition(posDisk);
     PlaceBNVectors();
   } else if (source == angDisk) {
     angleDisk = ((Double) pce.getNewValue()).doubleValue();
     double angDisk_rad = angleDisk * Math.PI / 180.;
     double compx = Math.cos(angDisk_rad);
     double compy = Math.sin(angDisk_rad);
     Disk.setNode3D(ShapeNodeDisk);
     Disk.setDirection(new Vector3d(compx, compy, 0.));
     flux_plot.setNormalDisk(new Vector3d(compx, compy, 0.));
     PlaceBNVectors();
   } else if (source == radDisk) {
     radiusDisk = ((Double) pce.getNewValue()).doubleValue();
     ShapeNodeDisk.setGeometry(Cylinder.makeGeometry(32, radiusDisk, heightDisk));
     Disk.setNode3D(ShapeNodeDisk);
     arrowScale = arrowScaleInitial * radiusDisk / radiusDiskInitial;
     flux_plot.setRadiusDisk(radiusDisk);
     PlaceBNVectors();
   } else {
     super.propertyChange(pce);
   }
 }
  // This method is called whenever the "reset" button of the simulation is pressed.  This should
  // reset all the
  // simulation objects and parameters to their initial state.
  public void reset() {
    super.reset();

    mag.setPosition(new Vector3d());
    mag.setDirection(new Vector3d(0, 1, 0));

    flux_graph.clear(0);
    flux_graph.setXRange(0., 2.);
    flux_graph.setYRange(-3., 3.);
    flux_plot.reset();

    theEngine.requestRefresh();
  }
 // This method is an event handler called whenever an actionEvent is received (assuming an event
 // listener has been
 // added, which is done a TealAction is created).  This method should contain the code you want to
 // run when each
 // ActionEvent is received.
 public void actionPerformed(ActionEvent e) {
   // If the ActionEvent received is the one corresponding to our Help menu item added above,
   // launch the help file.
   if (e.getActionCommand().compareToIgnoreCase("Gauss's Law for a Dipole and Disk") == 0) {
     if (mFramework instanceof TFramework) {
       ((TFramework) mFramework).openBrowser("help/gausslawmagdipoledisk.html");
     }
   } else if (e.getActionCommand().compareToIgnoreCase("Execution & View") == 0) {
     if (mFramework instanceof TFramework) {
       ((TFramework) mFramework).openBrowser("help/executionView.html");
     }
   } else {
     super.actionPerformed(e);
   }
 }
Example #4
0
 public void propertyChange(PropertyChangeEvent pce) {
   super.propertyChange(pce);
 }
Example #5
0
 public void actionPerformed(ActionEvent e) {
   String command = e.getActionCommand();
   System.out.println("Action: " + command);
   if (e.getActionCommand().compareToIgnoreCase("Capacitor2") == 0) {
     if ((mFramework != null) && (mFramework instanceof TFramework)) {
       ((TFramework) mFramework).openBrowser("help/capacitor.html");
     } else {
       TDebug.println("mFramework is null!");
     }
   } else if (e.getSource() == plate1Number) {
     int value = 0;
     try {
       value = Integer.parseInt(plate1Number.getText());
     } catch (NumberFormatException exception) {
       return;
     }
     if (value < 0) {
       value = 0;
       plate1Number.setText("0");
     }
     int change = value - pcList1.size();
     if (change > 0) {
       addChargesToList1(change);
     } else {
       removeChargesFromList1(-change);
     }
   } else if (e.getSource() == plate2Number) {
     int value = 0;
     try {
       value = Integer.parseInt(plate2Number.getText());
     } catch (NumberFormatException exception) {
       return;
     }
     if (value < 0) {
       value = 0;
       plate2Number.setText("0");
     }
     int change = value - pcList2.size();
     if (change > 0) {
       addChargesToList2(change);
     } else {
       removeChargesFromList2(-change);
     }
   } else if (e.getSource() == plate1Charge) {
     double value = 0.;
     try {
       value = Double.parseDouble(plate1Charge.getText());
     } catch (NumberFormatException exception) {
       return;
     }
     for (int i = 0; i < pcList1.size(); i++) {
       PointCharge pc = (PointCharge) pcList1.get(i);
       pc.setCharge(value);
     }
   } else if (e.getSource() == plate2Charge) {
     double value = 0.;
     try {
       value = Double.parseDouble(plate2Charge.getText());
     } catch (NumberFormatException exception) {
       return;
     }
     for (int i = 0; i < pcList2.size(); i++) {
       PointCharge pc = (PointCharge) pcList2.get(i);
       pc.setCharge(value);
     }
   } else {
     super.actionPerformed(e);
   }
 }