private ModelComponent getSelectedComponent(int modifiers, int x, int y) {
		ModelComponent lc = null;
		if ((modifiers & MouseEvent.SHIFT_DOWN_MASK) != MouseEvent.SHIFT_DOWN_MASK) {
			lc = whichLayeredComponent(x, y);
			if (lc != null && ((Layered) lc).getLayer() == Layered.IN_FRONT_OF_PARTICLES) {
				lc.setSelected(true);
				clickPoint.setLocation(x - lc.getRx(), y - lc.getRy());
				return selectedComponent;
			}
		}
		Atom at = whichAtom(x, y);
		if (at != null) {
			if ((modifiers & MouseEvent.SHIFT_DOWN_MASK) == MouseEvent.SHIFT_DOWN_MASK) {
				at.setSelected(true);
				clickPoint.setLocation(x - at.getRx(), y - at.getRy());
			} else {
				Molecule mol = molecules.getMolecule(at);
				if (mol == null) {
					at.setSelected(true);
					clickPoint.setLocation(x - at.getRx(), y - at.getRy());
				} else {
					at.setSelected(false);
					if (!mol.isSelected())
						mol.setSelected(true);
					clickPoint.setLocation(x - mol.getRx(), y - mol.getRy());
				}
			}
			return selectedComponent;
		}
		// if the user clicks on the interior of a molecular object
		MolecularObject mo = whichMolecularObject(x, y);
		if (mo != null) {
			if (!mo.isSelected())
				mo.setSelected(true);
			clickPoint.setLocation(x - mo.getRx(), y - mo.getRy());
			return selectedComponent;
		}
		RectangularObstacle obs = whichObstacle(x, y);
		if (obs != null && obs.contains(x, y)) {
			clickPoint.setLocation(x - obs.getMinX(), y - obs.getMinY());
			obs.setSelected(true);
			return selectedComponent;
		}
		RadialBond rBond = whichBond(x, y);
		if (rBond != null) {
			rBond.setSelected(true);
			return selectedComponent;
		}
		AngularBond aBond = whichAngle(x, y);
		if (aBond != null) {
			aBond.setSelected(true);
			return selectedComponent;
		}
		if (lc != null && ((Layered) lc).getLayer() == Layered.BEHIND_PARTICLES) {
			lc.setSelected(true);
			clickPoint.setLocation(x - lc.getRx(), y - lc.getRy());
			return selectedComponent;
		}
		return null;
	}