1 /* $RCSfile$ 2 * $Author$ 3 * $Date$ 4 * $Revision$ 5 * 6 * Copyright (C) 2011 The Jmol Development Team 7 * 8 * Contact: jmol-developers@lists.sf.net 9 * 10 * This library is free software; you can redistribute it and/or 11 * modify it under the terms of the GNU Lesser General Public 12 * License as published by the Free Software Foundation; either 13 * version 2.1 of the License, or (at your option) any later version. 14 * 15 * This library is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 18 * Lesser General Public License for more details. 19 * 20 * You should have received a copy of the GNU Lesser General Public 21 * License along with this library; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 23 * 02110-1301, USA. 24 */ 25 26 package org.jmol.io; 27 28 import java.util.Map; 29 30 import org.jmol.viewer.FileManager; 31 import org.jmol.viewer.Viewer; 32 33 public class DOMReader { 34 private FileManager fm; 35 private Viewer vwr; 36 private Object[] aDOMNode = new Object[1]; 37 private Object atomSetCollection; 38 private Map<String, Object> htParams; 39 DOMReader()40 public DOMReader() {} 41 set(FileManager fileManager, Viewer vwr, Object DOMNode, Map<String, Object> htParams)42 void set(FileManager fileManager, Viewer vwr, Object DOMNode, Map<String, Object> htParams) { 43 fm = fileManager; 44 this.vwr = vwr; 45 aDOMNode[0] = DOMNode; 46 this.htParams = htParams; 47 } 48 run()49 void run() { 50 Object info = null; 51 52 /** 53 * ignored 54 * 55 * @j2sNative 56 * 57 * 58 */ 59 { 60 info= vwr.apiPlatform.getJsObjectInfo(aDOMNode, null, null); 61 } 62 // note that this will not work in JSmol because we don't implement the nameSpaceInfo stuff there 63 // and we cannot pass [HTMLUnknownObject] 64 if (info != null) 65 htParams.put("nameSpaceInfo", info); 66 // no append option here 67 vwr.zap(false, true, false); 68 atomSetCollection = vwr.getModelAdapter().getAtomSetCollectionFromDOM( 69 aDOMNode, htParams); 70 if (atomSetCollection instanceof String) 71 return; 72 fm.setFileInfo(new String[] { "JSNode" }); 73 } 74 }