private void popup(MouseEvent e) {
		if (!popupMenuEnabled)
			return;
		int x = e.getX();
		int y = e.getY();
		if (e.isShiftDown()) {
			Atom at = whichAtom(x, y);
			if (at != null) {
				if (selectedComponent != null && selectedComponent != at)
					selectedComponent.setSelected(false);
				at.setSelected(true);
				repaint();
				if (atomPopupMenu == null)
					atomPopupMenu = new AtomPopupMenu(this);
				atomPopupMenu.setTrajSelected(at.getShowRTraj());
				atomPopupMenu.setRMeanSelected(at.getShowRMean());
				atomPopupMenu.setFMeanSelected(at.getShowFMean());
				atomPopupMenu.setCoor(x, y);
				atomPopupMenu.show(this, x, y);
				return;
			}
			RectangularObstacle obs = whichObstacle(x, y);
			if (obs != null) {
				obs.setSelected(true);
				if (obstaclePopupMenu == null)
					obstaclePopupMenu = new ObstaclePopupMenu(this);
				obstaclePopupMenu.setCoor(x, y);
				obstaclePopupMenu.show(this, x, y);
				return;
			}
			selectedComponent = null;
			defaultPopupMenu.setCoor(x, y);
			defaultPopupMenu.show(this, x, y);
			return;
		}
		if (selectedComponent != null)
			selectedComponent.setSelected(false);
		if (openLayeredComponentPopupMenus(x, y, Layered.IN_FRONT_OF_PARTICLES))
			return;
		final Atom at = whichAtom(x, y);
		if (at != null) {
			Molecule mol = molecules.getMolecule(at);
			if (mol == null) {
				at.setSelected(true);
				if (atomPopupMenu == null)
					atomPopupMenu = new AtomPopupMenu(this);
				atomPopupMenu.setTrajSelected(at.getShowRTraj());
				atomPopupMenu.setRMeanSelected(at.getShowRMean());
				atomPopupMenu.setFMeanSelected(at.getShowFMean());
				atomPopupMenu.setCoor(x, y);
				atomPopupMenu.show(this, x, y);
				return;
			}
			if (!(mol instanceof MolecularObject)) {
				mol.setSelected(true);
				if (moleculePopupMenu == null)
					moleculePopupMenu = new MoleculePopupMenu(this);
				moleculePopupMenu.setCoor(x, y);
				moleculePopupMenu.show(this, x, y);
				return;
			}
		}
		MolecularObject ss = whichMolecularObject(x, y);
		if (ss != null) {
			ss.setSelected(true);
			if (molecularObjectPopupMenu == null)
				molecularObjectPopupMenu = new MolecularObjectPopupMenu(this);
			molecularObjectPopupMenu.setCoor(x, y);
			molecularObjectPopupMenu.pack();
			molecularObjectPopupMenu.show(this, x, y);
			return;
		}
		RectangularObstacle obs = whichObstacle(x, y);
		if (obs != null) {
			obs.setSelected(true);
			if (obstaclePopupMenu == null)
				obstaclePopupMenu = new ObstaclePopupMenu(this);
			obstaclePopupMenu.setCoor(x, y);
			obstaclePopupMenu.show(this, x, y);
			return;
		}
		RadialBond rBond = whichBond(x, y);
		if (rBond != null) {
			rBond.setSelected(true);
			if (radialBondPopupMenu == null)
				radialBondPopupMenu = new RadialBondPopupMenu(this);
			radialBondPopupMenu.setCoor(x, y);
			radialBondPopupMenu.show(this, x, y);
			return;
		}
		AngularBond aBond = whichAngle(x, y);
		if (aBond != null) {
			aBond.setSelected(true);
			if (angularBondPopupMenu == null)
				angularBondPopupMenu = new AngularBondPopupMenu(this);
			angularBondPopupMenu.setCoor(x, y);
			angularBondPopupMenu.show(this, x, y);
			return;
		}
		if (openLayeredComponentPopupMenus(x, y, Layered.BEHIND_PARTICLES))
			return;
		selectedComponent = null;
		defaultPopupMenu.setCoor(x, y);
		defaultPopupMenu.show(this, x, y);
	}