From: Nicolas <ni...@us...> - 2005-10-24 20:44:35
|
Update of /cvsroot/jmol/Jmol/src/org/jmol/adapter/smarter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7936/src/org/jmol/adapter/smarter Modified Files: SmarterJmolAdapter.java AtomSetCollection.java Log Message: Initial work on loading multiple files Index: SmarterJmolAdapter.java =================================================================== RCS file: /cvsroot/jmol/Jmol/src/org/jmol/adapter/smarter/SmarterJmolAdapter.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- SmarterJmolAdapter.java 22 Oct 2005 21:13:03 -0000 1.19 +++ SmarterJmolAdapter.java 24 Oct 2005 20:44:27 -0000 1.20 @@ -71,6 +71,36 @@ } } + public Object openBufferedReaders(String[] name, + BufferedReader[] bufferedReader) { + int size = Math.min(name.length, bufferedReader.length); + AtomSetCollection[] atomSetCollections = new AtomSetCollection[size]; + for (int i = 0; i < size; i++) { + try { + Object atomSetCollectionOrErrorMessage = + Resolver.resolve(name[i], bufferedReader[i], logger); + if (atomSetCollectionOrErrorMessage instanceof String) + return atomSetCollectionOrErrorMessage; + if (atomSetCollectionOrErrorMessage instanceof AtomSetCollection) { + atomSetCollections[i] = + (AtomSetCollection)atomSetCollectionOrErrorMessage; + if (atomSetCollections[i].errorMessage != null) + return atomSetCollections[i].errorMessage; + } else { + return "unknown reader error"; + } + } catch (Exception e) { + e.printStackTrace(); + return "" + e; + } + } + AtomSetCollection result = new AtomSetCollection(atomSetCollections); + if (result.errorMessage != null) { + return result.errorMessage; + } + return result; + } + public Object openDOMReader(Object DOMNode) { try { Object atomSetCollectionOrErrorMessage = Index: AtomSetCollection.java =================================================================== RCS file: /cvsroot/jmol/Jmol/src/org/jmol/adapter/smarter/AtomSetCollection.java,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- AtomSetCollection.java 16 Jul 2005 00:39:33 -0000 1.29 +++ AtomSetCollection.java 24 Oct 2005 20:44:27 -0000 1.30 @@ -74,6 +74,36 @@ SmarterJmolAdapter.PATH_SEPARATOR); } + /** + * Creates an AtomSetCollection based on an array of AtomSetCollection + * + * @param array Array of AtomSetCollection + */ + AtomSetCollection(AtomSetCollection[] array) { + this("Array"); + for (int i = 0; i < array.length; i++) { + appendAtomSetCollection(array[i]); + } + } + + /** + * Appends an AtomSetCollection + * + * @param collection AtomSetCollection to append + */ + protected void appendAtomSetCollection(AtomSetCollection collection) { + // Clone each AtomSet + int clonedAtoms = 0; + for (int atomSetNum = 0; atomSetNum < collection.atomSetCount; atomSetNum++) { + newAtomSet(); + setAtomSetName(collection.atomSetNames[atomSetNum]); + for (int atomNum = 0; atomNum < collection.atomSetAtomCounts[atomSetNum]; atomNum++) { + newCloneAtom(collection.atoms[clonedAtoms]); + clonedAtoms++; + } + } + } + protected void finalize() { // System.out.println("Model.finalize() called"); try{super.finalize();}catch(Throwable t){} |