public static IChemModel readFromFileReader(final URL fileURL,
			final String url, final String type,
			final AbstractJChemPaintPanel panel) throws CDKException {

		IChemModel chemModel = null;
		WaitDialog.showDialog();

		// InChI workaround - guessing for InChI results into an INChIReader
		// (this does not work, we'd need an INChIPlainTextReader..)
		// Instead here we use STDInChIReader, to be consistent throughout JCP
		// using the nestedVm based classes.
		try {
			ISimpleChemObjectReader cor = null;
			if (url.endsWith("txt")) {
				// chemModel = StdInChIReader.readInChI(fileURL);
			} else {
				cor = FileHandler.createReader(fileURL, url, type);
				chemModel = JChemPaint.getChemModelFromReader(cor, panel);
			}
			boolean avoidOverlap = true;
			if (cor instanceof RGroupQueryReader) {
				avoidOverlap = false;
			}
			JChemPaint.cleanUpChemModel(chemModel, avoidOverlap, panel);

		} finally {
			WaitDialog.hideDialog();
		}
		return chemModel;
	}
	private static void checkCoordinates(final IChemModel chemModel)
			throws CDKException {
		for (final IAtomContainer next : ChemModelManipulator
				.getAllAtomContainers(chemModel)) {
			if (!GeometryTools.get2DCoordinateCoverage(next).equals(
					GeometryTools.CoordinateCoverage.FULL)) {
				final String error = GT._("Not all atoms have 2D coordinates."
						+ " JCP can only show full 2D specified structures."
						+ " Shall we lay out the structure?");
				final int answer = JOptionPane.showConfirmDialog(null, error,
						"No 2D coordinates", JOptionPane.YES_NO_OPTION);

				if (answer == JOptionPane.NO_OPTION) {
					throw new CDKException(
							GT._("Cannot display without 2D coordinates"));
				} else {
					// CreateCoordinatesForFileDialog frame =
					// new CreateCoordinatesForFileDialog(chemModel);
					// frame.pack();
					// frame.show();

					WaitDialog.showDialog();
					final List<IAtomContainer> acs = ChemModelManipulator
							.getAllAtomContainers(chemModel);
					generate2dCoordinates(acs);
					WaitDialog.hideDialog();
					return;
				}
			}
		}

		/*
		 * Add implicit hydrogens (in ControllerParameters,
		 * autoUpdateImplicitHydrogens is true by default, so we need to do that
		 * anyway)
		 */
		final CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(chemModel
				.getBuilder());
		for (final IAtomContainer molecule : ChemModelManipulator
				.getAllAtomContainers(chemModel)) {
			if (molecule != null) {
				try {
					hAdder.addImplicitHydrogens(molecule);
				} catch (final CDKException e) {
					// do nothing
				}
			}
		}
	}