예제 #1
0
 public static void main(String[] args) {
   Example4 ef = new Example4();
   try {
     final String molS = "C1C2=CC=CC=C2C3=C4CC5=CC=CC=C5C4=C6CC7=CC=CC=C7C6=C13";
     Molecule mol = MolImporter.importMol(molS);
     PolarizabilityPlugin plugin = new PolarizabilityPlugin();
     plugin.setMolecule(mol);
     plugin.run();
     ArrayList values = new ArrayList();
     java.text.NumberFormat nf = java.text.NumberFormat.getInstance();
     nf.setMaximumFractionDigits(3);
     for (int i = 0; i < mol.getAtomCount(); i++) {
       values.add(Float.valueOf(nf.format(((Double) plugin.getResult(i)).floatValue())));
     }
     mol.hydrogenize(true);
     for (int i = 0; i < mol.getExplicitHcount(); i++) {
       values.add(new Double(0));
     }
     ef.setPlugin(plugin);
     JFrame frame = ef.createSpaceFrame(mol, values);
     frame.setTitle("Polarizability");
     java.net.URL u = ef.getClass().getResource("/chemaxon/marvin/space/gui/mspace16.gif");
     frame.setIconImage(
         Toolkit.getDefaultToolkit().createImage((java.awt.image.ImageProducer) u.getContent()));
     frame.setVisible(true);
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
  // initialize data hash table servers
  // read server addresses from file and initialize the servers
  private void initServers() {

    try {
      java.net.URL path = ClassLoader.getSystemResource(clientSettingFile);
      FileReader fr = new FileReader(path.getFile());
      BufferedReader br = new BufferedReader(fr);
      try {
        String[] portMap = br.readLine().split(",");
        mServerCount = portMap.length;
        mPortMap = new int[mServerCount];
        for (int i = 0; i < mServerCount; i++) {
          mPortMap[i] = Integer.parseInt(portMap[i]);
        }
      } catch (IOException e) {
        e.printStackTrace();
        System.exit(-1);
      }
    } catch (FileNotFoundException e2) {
      e2.printStackTrace();
      System.exit(-1);
    }

    mDhtServerArray = new IDistributedHashTable[mServerCount];
    for (int i = 0; i < mServerCount; i++) {
      try {
        mDhtServerArray[i] =
            (IDistributedHashTable)
                Naming.lookup("rmi://localhost:" + mPortMap[i] + "/DistributedHashTable");
        appendOutput("server: " + (i + 1) + " is connected");
      } catch (Exception e) {
        appendOutput("initServers: " + (i + 1) + " " + e.getMessage());
      }
    }
  }
 /** Shows JSort help in the jEdit help viewer */
 private void showHelp() {
   java.net.URL helpUrl = TextToolsSortDialog.class.getResource("TextTools.html");
   if (helpUrl == null) {
     Log.log(Log.NOTICE, this, "Help URL is null, cannot display help");
   } else {
     new org.gjt.sp.jedit.help.HelpViewer(helpUrl.toString());
   }
 } // }}}
  // ===================================================
  // ObjHtmlPanel.Listener
  public void linkSelected(java.net.URL href, String target) {
    String url = href.toExternalForm();
    int slash = url.lastIndexOf('/');
    if (slash > 0) url = url.substring(slash + 1);

    Job t = actionMap.get(url);
    fapp.guiRun().run(this, new Job(t.getPermissions(), t.getCBRunnable()));
  }
  // ===================================================
  // ObjHtmlPanel.Listener
  public void linkSelected(java.net.URL href, String target) {
    String url = href.toExternalForm();
    int slash = url.lastIndexOf('/');
    if (slash > 0) url = url.substring(slash + 1);

    Job job = actionMap.get(url);
    if (job != null) app.guiRun().run(this, job);
  }