public static void showInstance(final File inFile, final String type,
			final AbstractJChemPaintPanel jcpPanel, final boolean debug) {
		try {
			final IChemModel chemModel = JChemPaint.readFromFile(inFile, type,
					jcpPanel);

			final String name = inFile.getName();
			final JChemPaintPanel p = JChemPaint.showInstance(chemModel, name,
					debug);
			p.setCurrentWorkDirectory(inFile.getParentFile());
			p.setLastOpenedFile(inFile);
			p.setIsAlreadyAFile(inFile);
		} catch (final CDKException ex) {
			JOptionPane.showMessageDialog(jcpPanel, ex.getMessage());
			return;
		} catch (final FileNotFoundException e) {
			JOptionPane.showMessageDialog(jcpPanel, GT._("File does not exist")
					+ ": " + inFile.getPath());
			return;
		}
	}
	public static JChemPaintPanel showInstance(final IChemModel chemModel,
			final String title, final boolean debug) {
		final JFrame f = new JFrame(title + " - JChemPaint");
		chemModel.setID(title);
		f.addWindowListener(new JChemPaintPanel.AppCloser());
		f.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
		final JChemPaintPanel p = new JChemPaintPanel(chemModel,
				GUI_APPLICATION, debug, null, new ArrayList<String>());
		p.updateStatusBar();
		f.setPreferredSize(new Dimension(800, 494)); // 1.618
		f.add(p);
		f.pack();
		final Point point = GraphicsEnvironment.getLocalGraphicsEnvironment()
				.getCenterPoint();
		final int w2 = f.getWidth() / 2;
		final int h2 = f.getHeight() / 2;
		f.setLocation(point.x - w2, point.y - h2);
		f.setVisible(true);
		frameList.add(f);
		return p;
	}
	/**
	 * Returns an IChemModel, using the reader provided (picked).
	 * 
	 * @param cor
	 * @param panel
	 * @return
	 * @throws CDKException
	 */
	public static IChemModel getChemModelFromReader(
			final ISimpleChemObjectReader cor,
			final AbstractJChemPaintPanel panel) throws CDKException {
		panel.get2DHub().setRGroupHandler(null);
		String error = null;
		ChemModel chemModel = null;
		IChemFile chemFile = null;
		if (cor.accepts(IChemFile.class) && chemModel == null) {
			// try to read a ChemFile
			try {
				chemFile = (IChemFile) cor.read((IChemObject) new ChemFile());
				if (chemFile == null) {
					error = "The object chemFile was empty unexpectedly!";
				}
			} catch (final Exception exception) {
				error = "Error while reading file: " + exception.getMessage();
				exception.printStackTrace();
			}
		}
		if (error != null) {
			throw new CDKException(error);
		}
		if (chemModel == null && chemFile != null) {
			chemModel = (ChemModel) chemFile.getChemSequence(0).getChemModel(0);
		}
		if (cor.accepts(ChemModel.class) && chemModel == null) {
			// try to read a ChemModel
			try {

				chemModel = (ChemModel) cor.read((IChemObject) new ChemModel());
				if (chemModel == null) {
					error = "The object chemModel was empty unexpectedly!";
				}
			} catch (final Exception exception) {
				error = "Error while reading file: " + exception.getMessage();
				exception.printStackTrace();
			}
		}

		// Smiles reading
		if (cor.accepts(AtomContainerSet.class) && chemModel == null) {
			// try to read a AtomContainer set
			try {
				final IAtomContainerSet som = cor.read(new AtomContainerSet());
				chemModel = new ChemModel();
				chemModel.setMoleculeSet(som);
				if (chemModel == null) {
					error = "The object chemModel was empty unexpectedly!";
				}
			} catch (final Exception exception) {
				error = "Error while reading file: " + exception.getMessage();
				exception.printStackTrace();
			}
		}

		// MDLV3000 reading
		if (cor.accepts(AtomContainer.class) && chemModel == null) {
			// try to read a AtomContainer
			final IAtomContainer mol = cor.read(new AtomContainer());
			if (mol != null) {
				try {
					final IAtomContainerSet newSet = new AtomContainerSet();
					newSet.addAtomContainer(mol);
					chemModel = new ChemModel();
					chemModel.setMoleculeSet(newSet);
					if (chemModel == null) {
						error = "The object chemModel was empty unexpectedly!";
					}
				} catch (final Exception exception) {
					error = "Error while reading file: "
							+ exception.getMessage();
					exception.printStackTrace();
				}
			}
		}

		// RGroupQuery reading
		if (cor.accepts(RGroupQuery.class) && chemModel == null) {
			final IRGroupQuery rgroupQuery = cor.read(new RGroupQuery());
			if (rgroupQuery != null) {
				try {
					chemModel = new ChemModel();
					final RGroupHandler rgHandler = new RGroupHandler(
							rgroupQuery);
					panel.get2DHub().setRGroupHandler(rgHandler);
					chemModel.setMoleculeSet(rgHandler
							.getMoleculeSet(chemModel));
					rgHandler.layoutRgroup();

				} catch (final Exception exception) {
					error = "Error while reading file: "
							+ exception.getMessage();
					exception.printStackTrace();
				}
			}
		}

		if (error != null) {
			throw new CDKException(error);
		}

		if (chemModel == null && chemFile != null) {
			chemModel = (ChemModel) chemFile.getChemSequence(0).getChemModel(0);
		}

		// SmilesParser sets valencies, switch off by default.
		if (cor instanceof SMILESReader) {
			final IAtomContainer allinone = JChemPaintPanel
					.getAllAtomContainersInOne(chemModel);
			for (int k = 0; k < allinone.getAtomCount(); k++) {
				allinone.getAtom(k).setValency(null);
			}
		}
		return chemModel;
	}