jcpPanel.get2DHub().getRenderer().getRenderer2DModel().setZoomFactor(1);
}
} else if ("paste".equals(type)) {
handleSystemClipboard(sysClip);
Transferable transfer = sysClip.getContents( null );
ISimpleChemObjectReader reader = null;
String content=null;
if (supported(transfer, molFlavor) ) {
StringBuffer sb = new StringBuffer();
try {
//StringBufferInputStream sbis=null;
//sbis = (StringBufferInputStream) transfer.getTransferData(molFlavor);
StringReader sbis=null;
sbis = (StringReader) transfer.getTransferData(molFlavor);
int x;
while((x=sbis.read())!=-1){
sb.append((char)x);
}
reader = new MDLReader(new StringReader(sb.toString()));
} catch (UnsupportedFlavorException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
} catch (Exception e1) {
reader = new RGroupQueryReader(new StringReader(sb.toString()));
}
} else if (supported(transfer, DataFlavor.stringFlavor) ) {
try {
content = (String) transfer.getTransferData(DataFlavor.stringFlavor);
reader = new ReaderFactory().createReader(new StringReader(content));
//System.out.println(reader.getClass());
} catch (Exception e1) {
e1.printStackTrace();
}
}
// if looks like CML - InputStream required. Reader throws error.
if(content!=null && content.indexOf("cml")>-1) {
reader = new CMLReader(new ByteArrayInputStream(content.getBytes()));
}
IAtomContainer toPaste = null;
boolean rgrpQuery=false;
if (reader != null) {
IAtomContainer readMolecule =
chemModel.getBuilder().newInstance(IAtomContainer.class);
try {
if (reader.accepts(IAtomContainer.class)) {
toPaste = (IAtomContainer) reader.read(readMolecule);
} else if (reader.accepts(ChemFile.class)) {
toPaste = readMolecule;
IChemFile file = (IChemFile) reader.read(new ChemFile());
for (IAtomContainer ac :
ChemFileManipulator.getAllAtomContainers(file)) {
toPaste.add(ac);
}
} else if (reader.accepts(RGroupQuery.class)) {
rgrpQuery=true;
IRGroupQuery rgroupQuery = (RGroupQuery) reader.read(new RGroupQuery(DefaultChemObjectBuilder.getInstance()));
chemModel = new ChemModel();
RGroupHandler rgHandler = new RGroupHandler(rgroupQuery, this.jcpPanel);
this.jcpPanel.get2DHub().setRGroupHandler(rgHandler);
chemModel.setMoleculeSet(rgHandler.getMoleculeSet(chemModel));
rgHandler.layoutRgroup();