Пример #1
0
 /* (non-Javadoc)
  * @see teal.sim.engine.HasSimEngine#setModel(teal.sim.engine.TSimEngine)
  */
 public void setFramework(TFramework eMgr) {
   if ((fWork != null) && (fWork != eMgr) && (fWork instanceof TFramework)) {
     TFramework tfWork = (TFramework) fWork;
     // remove any existing Elements
     if (fconvolution != null) {
       tfWork.removeTElement(fconvolution);
     }
     if (fieldVis != null) {
       tfWork.removeTElement(fieldVis);
     }
     if (manager != null) {
       tfWork.removeTElement(manager);
     }
   }
   //        if(eMgr instanceof TFramework) {
   fWork = eMgr;
   if (fWork != null) {
     TFramework tfWork = (TFramework) fWork;
     if (fconvolution != null) {
       tfWork.addTElement(fconvolution, false);
     }
     if (fieldVis != null) {
       tfWork.addTElement(fieldVis, false);
     }
     if (manager != null) {
       tfWork.addTElement(manager, false);
     }
   }
   //        }
 }
Пример #2
0
 // 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);
   }
 }
Пример #3
0
 public void setFieldConvolution(FieldConvolution fc) {
   fconvolution = fc;
   buildConvoActions();
   if (fconvolution != null) {
     mElements.add(fc);
     if ((fWork != null) && (fWork instanceof TFramework)) {
       ((TFramework) fWork).addTElement(fconvolution, false);
     }
   }
 }
Пример #4
0
 public void setFieldVisGrid(FieldDirectionGrid mgr) {
   if (mgr != null) {
     fieldVis = mgr;
     fvSlider.addRoute("value", fieldVis, "resolution");
     fieldVis.setResolution(((Integer) fvSlider.getValue()).intValue());
     setFVControlsVisible(true);
     setShowFV(mgr.isDrawn());
     mElements.add(mgr);
     if ((fWork != null) && (fWork instanceof TFramework)) {
       ((TFramework) fWork).addTElement(fieldVis, false);
     }
   } else {
     setFVControlsVisible(false);
   }
 }
Пример #5
0
 public void setFieldLineManager(FieldLineManager mgr) {
   if (mgr != null) {
     manager = mgr;
     flSlider.addRoute(manager, "symmetryCount");
     manager.setSymmetryCount(((Integer) flSlider.getValue()).intValue());
     manager.setColorMode(perVertexColor ? FieldLine.COLOR_VERTEX : FieldLine.COLOR_VERTEX_FLAT);
     setFLControlsVisible(true);
     mElements.add(manager);
     if ((fWork != null) && (fWork instanceof TFramework)) {
       ((TFramework) fWork).addTElement(manager, false);
     }
   } else {
     setFLControlsVisible(false);
   }
 }
Пример #6
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);
   }
 }
Пример #7
0
  public void actionPerformed(ActionEvent evt) {
    if (evt.getSource() == showLinesCB) {
      setLinesEnabled(showLinesCB.isSelected());

    } else if (evt.getSource() == showFVisCB) {
      setFVEnabled(showFVisCB.isSelected());

    } else if (evt.getSource() == colorModeCB) {
      perVertexColor = colorModeCB.isSelected();
      manager.setColorMode(
          colorModeCB.isSelected() ? FieldLine.COLOR_VERTEX : FieldLine.COLOR_VERTEX_FLAT);

    } else {
      int cmd = Integer.parseInt(evt.getActionCommand());
      if (fconvolution != null) {
        Cursor cr = null;
        if (fWork instanceof TFramework) {
          cr = ((TFramework) fWork).getAppCursor();
          ((TFramework) fWork).setAppCursor(new Cursor(Cursor.WAIT_CURSOR));
        }
        Thread.yield();
        TSimEngine model = fconvolution.getSimEngine();
        if (model != null) {
          TEngineControl smc = model.getEngineControl();
          if (smc.getSimState() == TEngineControl.RUNNING) {
            smc.stop();
            model.refresh();
            Thread.yield();
          }

          switch (cmd) {
            case DLIC.DLIC_FLAG_E:
              //                            fconvolution.setField(((EMEngine)model).getEField());
              fconvolution.setField(model.getElementByType(EField.class));
              fconvolution.generateFieldImage();
              break;
            case DLIC.DLIC_FLAG_B:
              //                            fconvolution.setField(((EMEngine)model).getBField());
              fconvolution.setField(model.getElementByType(BField.class));
              fconvolution.generateFieldImage();
              break;
            case DLIC.DLIC_FLAG_G:
              //                            fconvolution.setField(((EMEngine)model).getGField());
              fconvolution.setField(model.getElementByType(GField.class));
              fconvolution.generateFieldImage();
              break;
            case DLIC.DLIC_FLAG_P:
              //                            fconvolution.setField(((EMEngine)model).getPField());
              fconvolution.setField(model.getElementByType(PField.class));
              fconvolution.generateFieldImage();
              break;
            case DLIC.DLIC_FLAG_EP:
              //                            fconvolution.setField(new
              // Potential(((EMEngine)model).getEField()));
              fconvolution.setField(new Potential(model.getElementByType(EField.class)));
              fconvolution.generateFieldImage();
              break;
            case DLIC.DLIC_FLAG_BP:
              //                            fconvolution.setField(new
              // Potential(((EMEngine)model).getBField()));
              fconvolution.setField(new Potential(model.getElementByType(BField.class)));
              fconvolution.generateFieldImage();
              break;
            case DLIC.DLIC_FLAG_EF:
              //                            fconvolution.setField(((EMEngine)model).getEField());
              fconvolution.setField(model.getElementByType(EField.class));
              fconvolution.generateColorMappedFluxImage();
              break;
            case DLIC.DLIC_FLAG_BF:
              //                            fconvolution.setField(((EMEngine)model).getBField());
              fconvolution.setField(model.getElementByType(BField.class));
              fconvolution.generateColorMappedFluxImage();
              break;
            default:
              break;
          }
          fconvolution.getImage();
        } else {
          TDebug.println(0, "DLIC model is null");
        }
        if (fWork instanceof TFramework) {
          ((TFramework) fWork).setAppCursor(cr);
        }
      }
    }
  }