コード例 #1
0
 private void process(final boolean parallel) {
   if (sim != null) {
     sim.stopAndWait();
   }
   try {
     sim = null;
     final Future<Result<T>> fenv = EnvironmentBuilder.build(new FileInputStream(xml));
     final IEnvironment<T> env = fenv.get().getEnvironment();
     rand = fenv.get().getRandomEngine();
     sim = new Simulation<>(env, new DoubleTime(Double.POSITIVE_INFINITY), parallel);
     bar.setSimulation(sim);
     scp.setSimulation(sim);
     final Thread simThread = new Thread(sim);
     createMonitor();
     simThread.start();
     final TimeStepMonitor<T> tm = bar.getTimeMonitor();
     sim.addOutputMonitor(tm);
     bar.setRandom(rand.getSeed());
     bar.setFileOK(true);
     bar.setProcessOK(true);
     effectsTab.setEnabled(true);
     status.setOK();
     status.setText(r(Res.FILE_PROCESSED) + ": " + xml.getAbsolutePath());
   } catch (Exception e) {
     processError(e);
   }
 }
コード例 #2
0
 private void setRandom() {
   if (rand != null) {
     try {
       rand.setSeed(bar.getRandomText());
       status.setOK();
       status.setText(r(Res.RANDOM_REINIT_SUCCESS) + ": " + rand.getSeed());
     } catch (final NumberFormatException e) {
       status.setNo();
       status.setText(r(Res.RANDOM_REINIT_FAIL) + ": " + r(Res.IS_NOT_AN_INTEGER));
     }
   } else {
     status.setNo();
     status.setText(r(Res.RANDOM_REINIT_FAIL) + ": RandomEngine " + r(Res.IS_NOT_INITIALIZED_YET));
   }
 }
コード例 #3
0
 private void openXML() {
   final JFileChooser fc = new JFileChooser();
   fc.setMultiSelectionEnabled(false);
   fc.setFileFilter(XML_FILTER);
   fc.setCurrentDirectory(currentDirectory);
   final int returnVal = fc.showOpenDialog(null);
   if (returnVal == JFileChooser.APPROVE_OPTION) {
     xml = fc.getSelectedFile();
     currentDirectory = fc.getSelectedFile().getParentFile();
     if (xml.exists() && xml.getName().endsWith("xml")) {
       status.setText(r(Res.READY_TO_PROCESS) + " " + xml.getAbsolutePath());
       status.setOK();
       if (sim != null) {
         sim.stop();
       }
       bar.setFileOK(true);
     } else {
       status.setText(r(Res.FILE_NOT_VALID) + " " + xml.getAbsolutePath());
       status.setNo();
       bar.setFileOK(false);
     }
   }
 }