// delete Atoms from both modelList and viewer. public void deleteAtoms(int currentModelIndex, String key, int atomPosition) { modelList.get(currentModelIndex).removeAtom(key); // modelList.get(currentModelIndex).getAtomHash().remove(key); viewer.evalString( "delete atomno=" + atomPosition + " && modelindex=" + viewer.getDisplayModelIndex()); toolPanel.setModelText(modelList); }
// Method to load file from BioJava structure to Jmol Display public void loadFileToJmol(Structure struc) { createUserModel(struc); String pdb = DataManager.modelToPDB(modelList); viewer.openStringInline(pdb); toolPanel.setModelText(modelList); logger.log(Level.INFO, "After load File: "); }
// copy atoms into new Atoms object from selected atoms public void copyAtoms(int currentModelIndex, String key) { if (savedAtoms == null) { savedAtoms = new ArrayList<Atom>(); } try { Atom newAtom = (Atom) modelList.get(currentModelIndex).getAtomHash().get(key).clone(); savedAtoms.add(newAtom); } catch (CloneNotSupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } toolPanel.setModelText(modelList); }
// paste copied/cut atoms, not applicable when copied atoms are paste to same model. public void pasteSavedAtoms(int modelIndex) { if (savedAtoms == null) JOptionPane.showMessageDialog( jmolPanel, "You have not copied or cut any atoms to paste!", "Warning", JOptionPane.WARNING_MESSAGE); else { boolean error = false; for (int i = 0; i < savedAtoms.size(); i++) { for (Atom atm : modelList.get(modelIndex).getAtomHash().values()) { if (savedAtoms.get(i).getCoordinates()[0] == atm.getCoordinates()[0] && savedAtoms.get(i).getCoordinates()[1] == atm.getCoordinates()[1] && savedAtoms.get(i).getCoordinates()[2] == atm.getCoordinates()[2]) { error = true; break; } } if (error) { JOptionPane.showMessageDialog( jmolPanel, "You are trying to paste atoms in location occupied!", "Warning", JOptionPane.WARNING_MESSAGE); break; } else { addAtom(modelIndex, savedAtoms.get(i)); } } String pdb = DataManager.modelToPDB(modelList); System.out.println(pdb); viewer.openStringInline(pdb); viewer.setCurrentModelIndex(modelIndex); } toolPanel.setModelText(modelList); }