예제 #1
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);
        }
      }
    }
  }
예제 #2
0
  public Capacitor2() {

    super();

    title = "Capacitor2";
    setID("Capacitor2");

    //      Building the world.

    setDamping(0.02);
    setGravity(new Vector3d(0., 0., 0.));
    // theEngine.setShowTime(true);
    setDeltaTime(0.25);
    setBoundingArea(new BoundingSphere(new Point3d(), 16));

    mDLIC = new FieldConvolution();
    mDLIC.setSize(new Dimension(512, 512));
    mDLIC.setComputePlane(new RectangularPlane(new BoundingSphere(new Point3d(), 18)));

    // Creating components.

    // -> Positive-end Conductor
    RectangularBox conductor1 = new RectangularBox();
    conductor1.setPosition(plate1_position);
    conductor1.setOrientation(new Vector3d(1., 0., 0.));
    conductor1.setNormal(new Vector3d(0., 1., 0.));
    conductor1.setLength(plate_length);
    conductor1.setWidth(plate_width);
    conductor1.setHeight(plate_height);
    Collection<Wall> walls1 = conductor1.getWalls();
    Iterator<Wall> it = walls1.iterator();
    while (it.hasNext()) {
      Wall wall = (Wall) it.next();
      wall.getCollisionController().setTolerance(0.1);
    }

    addElements(walls1);

    // -> Negative-end Conductor
    RectangularBox conductor2 = new RectangularBox();
    conductor2.setPosition(plate2_position);
    conductor2.setOrientation(new Vector3d(1., 0., 0.));
    conductor2.setNormal(new Vector3d(0., 1., 0.));
    conductor2.setLength(plate_length);
    conductor2.setWidth(plate_width);
    conductor2.setHeight(plate_height);
    Collection<Wall> walls2 = conductor2.getWalls();
    it = walls2.iterator();
    while (it.hasNext()) {
      Wall wall = (Wall) it.next();
      wall.getCollisionController().setTolerance(0.1);
    }

    addElements(walls2);

    // -> Point Charges
    addChargesToList1(N);
    addChargesToList2(N);

    // -> Text fields and labels.
    plate1Number_label = new JLabel("Plate 1 - Number of charges: ");
    plate1Number_label.setPreferredSize(
        new Dimension(labelWidth, plate1Number_label.getPreferredSize().height));
    plate1Number_label.setHorizontalAlignment(SwingConstants.LEFT);
    // guiElements.add(plate1Number_label);

    plate1Number = new JTextField();
    plate1Number.setColumns(4);
    plate1Number.setHorizontalAlignment(SwingConstants.RIGHT);
    plate1Number.setText(String.valueOf(N));
    plate1Number.addActionListener(this);
    // guiElements.add(plate1Number_label);

    UIPanel Plate1Panel = new UIPanel();
    Plate1Panel.add(plate1Number_label);
    Plate1Panel.add(plate1Number);
    // guiElements.add(plate1Panel);

    plate1Charge_label = new JLabel("Individual particle charge: ");
    plate1Charge_label.setPreferredSize(
        new Dimension(labelWidth, plate1Charge_label.getPreferredSize().height));
    plate1Charge_label.setHorizontalAlignment(SwingConstants.LEFT);

    plate1Charge = new JTextField();
    plate1Charge.setColumns(4);
    plate1Charge.setHorizontalAlignment(SwingConstants.RIGHT);
    plate1Charge.setText(String.valueOf(pc_charge));
    plate1Charge.addActionListener(this);

    UIPanel plate1ChargePanel = new UIPanel();
    plate1ChargePanel.add(plate1Charge_label);
    plate1ChargePanel.add(plate1Charge);
    // guiElements.add(plate1ChargePanel);

    plate2Number_label = new JLabel("Plate 2 - Number of charges: ");
    plate2Number_label.setPreferredSize(
        new Dimension(labelWidth, plate2Number_label.getPreferredSize().height));
    plate2Number_label.setHorizontalAlignment(SwingConstants.LEFT);

    plate2Number = new JTextField();
    plate2Number.setColumns(4);
    plate2Number.setHorizontalAlignment(SwingConstants.RIGHT);
    plate2Number.setText(String.valueOf(N));
    plate2Number.addActionListener(this);

    UIPanel Plate2Panel = new UIPanel();
    Plate2Panel.add(plate2Number_label);
    Plate2Panel.add(plate2Number);
    // guiElements.add(plate2Panel);

    plate2Charge_label = new JLabel("Individual particle charge: ");
    plate2Charge_label.setPreferredSize(
        new Dimension(labelWidth, plate2Charge_label.getPreferredSize().height));
    plate2Charge_label.setHorizontalAlignment(SwingConstants.LEFT);

    plate2Charge = new JTextField();
    plate2Charge.setColumns(4);
    plate2Charge.setHorizontalAlignment(SwingConstants.RIGHT);
    plate2Charge.setText(String.valueOf(-pc_charge));
    plate2Charge.addActionListener(this);

    UIPanel plate2ChargePanel = new UIPanel();
    plate2ChargePanel.add(plate2Charge_label);
    plate2ChargePanel.add(plate2Charge);
    // guiElements.add(plate2ChargePanel);

    ControlGroup controls = new ControlGroup();
    controls.setText("Parameters");
    controls.add(Plate1Panel);
    controls.add(plate1ChargePanel);
    controls.add(Plate2Panel);
    controls.add(plate2ChargePanel);
    addElement(controls);
    VisualizationControl vizPanel = new VisualizationControl();
    vizPanel.setConvolutionModes(DLIC.DLIC_FLAG_E | DLIC.DLIC_FLAG_EP);
    vizPanel.setFieldConvolution(mDLIC);
    addElement(vizPanel);

    addActions();

    theScene.setFogEnabled(true);
    resetCamera();
    theScene.setFogTransformFrontScale(0.0);
    // mViewer.setFogTransformBackScale(0.02);
    // initFogTransform() needs to be called in the constructor after resetCamera() if a non-default
    // camera
    // position is being used.
    // initFogTransform();

    mSEC.start();
  }
예제 #3
0
  private void buildConvoActions() {
    if (convoButtons != null) {
      if (!convoButtons.isEmpty()) {
        Iterator it = convoButtons.iterator();
        while (it.hasNext()) {
          JButton b = (JButton) it.next();
          remove(b);
        }
      }
      convoButtons = null;
    }

    if ((convoFlags > 0) && (fconvolution != null)) {
      JButton but = null;
      convoButtons = new ArrayList<JButton>();

      if ((convoFlags & DLIC.DLIC_FLAG_E) == DLIC.DLIC_FLAG_E) {
        TealAction efAction =
            new TealAction("Electric Field:  Grass Seeds", String.valueOf(DLIC.DLIC_FLAG_E), this);
        sharedActions.add(efAction);
        but = new JButton(efAction);
        but.setFont(but.getFont().deriveFont(Font.BOLD));
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_B) == DLIC.DLIC_FLAG_B) {
        TealAction mfAction =
            new TealAction("Magnetic Field:  Iron Filings", String.valueOf(DLIC.DLIC_FLAG_B), this);
        sharedActions.add(mfAction);
        but = new JButton(mfAction);
        but.setFont(but.getFont().deriveFont(Font.BOLD));
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_G) == DLIC.DLIC_FLAG_G) {
        TealAction gAction = new TealAction("Gravity", String.valueOf(DLIC.DLIC_FLAG_G), this);
        sharedActions.add(gAction);
        but = new JButton(gAction);
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_P) == DLIC.DLIC_FLAG_P) {
        TealAction pAction = new TealAction("Pauli Forces", String.valueOf(DLIC.DLIC_FLAG_P), this);
        sharedActions.add(pAction);
        but = new JButton(pAction);
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_EP) == DLIC.DLIC_FLAG_EP) {
        TealAction epAction =
            new TealAction("Electric Potential", String.valueOf(DLIC.DLIC_FLAG_EP), this);
        sharedActions.add(epAction);
        but = new JButton(epAction);
        but.setFont(but.getFont().deriveFont(Font.BOLD));
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_BP) == DLIC.DLIC_FLAG_BP) {
        TealAction mpAction =
            new TealAction("Magnetic Potential", String.valueOf(DLIC.DLIC_FLAG_BP), this);
        sharedActions.add(mpAction);
        but = new JButton(mpAction);
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_EF) == DLIC.DLIC_FLAG_EF) {
        TealAction efAction =
            new TealAction("Electic Flux", String.valueOf(DLIC.DLIC_FLAG_EF), this);
        sharedActions.add(efAction);
        but = new JButton(efAction);
        convoButtons.add(but);
        add(but);
      }

      if ((convoFlags & DLIC.DLIC_FLAG_BF) == DLIC.DLIC_FLAG_BF) {
        TealAction mfAction =
            new TealAction("Magnetic Flux", String.valueOf(DLIC.DLIC_FLAG_BF), this);
        sharedActions.add(mfAction);
        but = new JButton(mfAction);
        convoButtons.add(but);
        add(but);
      }

      if (convoProgress == null) {
        convoProgress = new ProgressBar();
        fconvolution.addProgressEventListener(convoProgress);
        add(convoProgress);
      }
    }
  }