void processMouseDragged(MouseEvent e) {

		if (ModelerUtilities.isRightClick(e))
			return;
		if (System.currentTimeMillis() - mousePressedTime < MINIMUM_MOUSE_DRAG_RESPONSE_INTERVAL)
			return;
		int x = e.getX();
		int y = e.getY();
		model.runMouseScript(MouseEvent.MOUSE_DRAGGED, x, y);
		if (model.getJob() != null && !model.getJob().isStopped()) {
			steerParticleUsingMouse(x - mouseHeldX, y - mouseHeldY);
			return;
		}

		super.processMouseDragged(e);

		if (callOutMouseDragged(x, y))
			return;
		if (handleMouseDragged(x, y))
			return;

		switch (actionID) {

		case SELE_ID:

			if (selectedComponent != null) {
				if (!isEditable() && !selectedComponent.isDraggable()) {
					showTip("<html><font color=red>The selected object is not draggable!</font></html>", x, y, 500);
				} else {
					if (selectedComponent instanceof RectangularObstacle) {
						if (obsRectSelected > RectangularObstacle.INSIDE) {
							RectangularObstacle r2d = (RectangularObstacle) selectedComponent;
							int xbox = (int) r2d.getWidth();
							int ybox = (int) r2d.getHeight();
							int xmin = (int) r2d.getX();
							int ymin = (int) r2d.getY();
							switch (obsRectSelected) {
							case RectangularObstacle.NW:
								xbox = xbox + xmin - x;
								ybox = ybox + ymin - y;
								xmin = x;
								ymin = y;
								break;
							case RectangularObstacle.NORTH:
								ybox = ybox + ymin - y;
								ymin = y;
								break;
							case RectangularObstacle.NE:
								xbox = x - xmin;
								ybox = ybox + ymin - y;
								ymin = y;
								break;
							case RectangularObstacle.EAST:
								xbox = x - xmin;
								break;
							case RectangularObstacle.SE:
								xbox = x - xmin;
								ybox = y - ymin;
								break;
							case RectangularObstacle.SOUTH:
								ybox = y - ymin;
								break;
							case RectangularObstacle.SW:
								xbox = xbox + xmin - x;
								ybox = y - ymin;
								xmin = x;
								break;
							case RectangularObstacle.WEST:
								xbox = xbox + xmin - x;
								xmin = x;
								break;
							}
							if (xbox < 0) {
								xmin = x;
								xbox = -xbox;
							}
							if (ybox < 0) {
								ymin = y;
								ybox = -ybox;
							}
							if (xbox == 0)
								xbox = 1;
							if (ybox == 0)
								ybox = 1;
							r2d.setRect(xmin, ymin, xbox, ybox);
							model.notifyChange();
							repaint();
							return;
						}
					}

					dragSelected = false;
					if (selectedComponent instanceof Molecule) {
						dragSelected = true;
						Molecule mol = (Molecule) selectedComponent;
						mol.translateTo(x - clickPoint.x, y - clickPoint.y);
						boundary.setRBC(mol);
						refreshForces();
					} else if (selectedComponent instanceof Atom) {
						dragSelected = true;
						Atom a = (Atom) selectedComponent;
						if (a.getRestraint() != null) {
							int amp = a.isBonded() ? 5 : (int) (400.0 / a.getRestraint().getK());
							Vector2D loc = moveSpring(x, y, (int) a.getRestraint().getX0(), (int) a.getRestraint().getY0(), 0, amp);
							if (loc == null)
								return;
							a.translateTo(loc.getX(), loc.getY());
						} else {
							a.translateTo(x - clickPoint.x, y - clickPoint.y);
						}
						boundary.setRBC(a);
						refreshForces();
					} else if (selectedComponent instanceof RectangularObstacle) {
						if (obsRectSelected <= RectangularObstacle.INSIDE) {
							((RectangularObstacle) selectedComponent).translateTo(x - clickPoint.x, y - clickPoint.y);
							dragSelected = true;
						}
					} else if (selectedComponent instanceof ImageComponent) {
						ImageComponent ic = (ImageComponent) selectedComponent;
						ic.translateTo(x - clickPoint.x, y - clickPoint.y);
						dragSelected = true;
						moveHostTo(ic.getHost(), ic.getRx() + ic.getWidth() * 0.5, ic.getRy() + ic.getHeight() * 0.5);
					} else if (selectedComponent instanceof TextBoxComponent) {
						TextBoxComponent tb = (TextBoxComponent) selectedComponent;
						dragSelected = true;
						tb.translateTo(x - clickPoint.x, y - clickPoint.y);
						if (tb.getAttachmentPosition() == TextBoxComponent.BOX_CENTER)
							moveHostTo(tb.getHost(), tb.getRx() + 0.5 * tb.getWidth(), tb.getRy() + 0.5 * tb.getHeight());
					} else if (selectedComponent instanceof LineComponent) {
						LineComponent lc = (LineComponent) selectedComponent;
						lc.translateTo(x - clickPoint.x, y - clickPoint.y);
						dragSelected = true;
						moveHostTo(lc.getHost(), lc.getRx(), lc.getRy());
					} else if (selectedComponent instanceof RectangleComponent) {
						RectangleComponent rc = (RectangleComponent) selectedComponent;
						rc.translateTo(x - clickPoint.x, y - clickPoint.y);
						dragSelected = true;
						moveHostTo(rc.getHost(), rc.getRx(), rc.getRy());
					} else if (selectedComponent instanceof TriangleComponent) {
						TriangleComponent tc = (TriangleComponent) selectedComponent;
						tc.translateTo(x - clickPoint.x, y - clickPoint.y);
						dragSelected = true;
						moveHostTo(tc.getHost(), tc.getRx(), tc.getRy());
					} else if (selectedComponent instanceof EllipseComponent) {
						EllipseComponent ec = (EllipseComponent) selectedComponent;
						ec.translateTo(x - clickPoint.x, y - clickPoint.y);
						dragSelected = true;
						moveHostTo(ec.getHost(), ec.getRx(), ec.getRy());
					}
					if (dragSelected) {
						repaint();
						setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
					}
				}
			}

			break;

		case ADDA_ID:
		case ADDB_ID:
		case ADDC_ID:
		case ADDD_ID:
			addAtomIndicator.x = addAtomIndicator.y = -1;
			repaint();
			break;

		case ADDI_ID:
		case WATE_ID:
		case BENZ_ID:
		case ADCH_ID:
			if (addObjectIndicator != null) {
				addObjectIndicator.setPainted(false);
				repaint();
			}
			break;

		case RCUR_ID:
		case SCUR_ID:
		case SFRE_ID:
			if (smartPoly != null) {
				updateSmartShape(x, y);
				repaint();
			}
			break;

		case RCIR_ID:
		case SCIR_ID:
		case RREC_ID:
		case SREC_ID:
			updateSmartShape(x, y);
			repaint();
			break;

		case DELE_ID:
		case ADOB_ID:
		case MARK_ID:
		case COUN_ID:
		case RECT_ID:
		case TRIA_ID:
		case ELLI_ID:
		case FILA_ID:
		case FILB_ID:
		case FILC_ID:
		case FILD_ID:
			dragRect(x, y);
			break;

		case ROTA_ID:
			if (selectedComponent instanceof Rotatable) {
				Rotatable r = (Rotatable) selectedComponent;
				if (r.isSelectedToRotate() && rotationHandle >= 0) {
					r.rotateTo(x, y, rotationHandle);
					if (r instanceof Molecule)
						refreshForces();
					repaint();
				} else {
					if (selectedComponent instanceof Molecule) {
						dragSelected = true;
						Molecule mol = (Molecule) selectedComponent;
						if (mol.contains(x, y)) {
							mol.setSelected(true);
							mol.translateTo(x - clickPoint.x, y - clickPoint.y);
							boundary.setRBC(mol);
							refreshForces();
							repaint();
						}
					}
				}
			}
			break;

		case VELO_ID:
			if (readyToAdjustVelocityVector) {
				if (selectedComponent instanceof Atom) {
					((Atom) selectedComponent).setVelocityHandleLocation(x, y);
					repaint();
				}
			}
			break;

		case HEAT_ID:
		case COOL_ID:
			pointHeater.setLocation(x, y);
			repaint();
			break;

		case MEAS_ID:
			if (readyToAdjustDistanceVector && indexOfSelectedMeasurement >= 0) {
				if (selectedComponent instanceof Atom) {
					Atom a = (Atom) selectedComponent;
					Atom a1 = whichAtomOtherThan(x, y, a);
					if (a1 != null) {
						a.setMeasurement(indexOfSelectedMeasurement, new Integer(a1.getIndex()));
					} else {
						a.setMeasurement(indexOfSelectedMeasurement, new Point(x, y));
					}
					repaint();
				}
			}
			break;

		case DUPL_ID:
			if (selectedComponent instanceof Atom) {
				((Atom) selectedComponent).translateTo(x, y);
				boundary.setRBC((Atom) selectedComponent);
			} else if (selectedComponent instanceof Molecule) {
				Molecule mol = (Molecule) selectedComponent;
				mol.translateTo(x, y);
				boundary.setRBC(mol);
			} else if (selectedComponent instanceof RectangularObstacle) {
				((RectangularObstacle) selectedComponent).translateTo(x - clickPoint.x, y - clickPoint.y);
			} else if (selectedComponent instanceof Layered) {
				((Layered) selectedComponent).setLocation(x - clickPoint.x, y - clickPoint.y);
			}
			repaint();
			break;

		case SBOU_ID:
			if (boundary.getType() != RectangularBoundary.DBC_ID) {
				double xmin = 0.0, ymin = 0.0, xbox = getSize().width, ybox = getSize().height;
				double x1, y1, x2, y2;
				int handle = boundary.getHandle();
				switch (handle) {
				case RectangularBoundary.UPPER_LEFT:
					if (model.isEmpty()) {
						xmin = x;
						xbox = boundary.width + boundary.x - x;
						ymin = y;
						ybox = boundary.height + boundary.y - y;
					} else {
						x1 = x;
						x2 = model.getIDMinX() >= 0 ? model.getMinX() - 0.5 * atom[model.getIDMinX()].getSigma() : model.getMinX();
						if (x1 > x2)
							x1 = x2;
						y1 = y;
						y2 = model.getIDMinY() >= 0 ? model.getMinY() - 0.5 * atom[model.getIDMinY()].getSigma() : model.getMinY();
						if (y1 > y2)
							y1 = y2;
						xmin = x1;
						xbox = boundary.width + boundary.x - x1;
						ymin = y1;
						ybox = boundary.height + boundary.y - y1;
					}
					break;
				case RectangularBoundary.UPPER_RIGHT:
					if (model.isEmpty()) {
						xmin = boundary.x;
						xbox = x - xmin;
						ymin = y;
						ybox = boundary.y + boundary.height - y;
					} else {
						x1 = x;
						x2 = model.getIDMaxX() >= 0 ? model.getMaxX() + 0.5 * atom[model.getIDMaxX()].getSigma() : model.getMaxX();
						if (x1 < x2)
							x1 = x2;
						y1 = y;
						y2 = model.getIDMinY() >= 0 ? model.getMinY() - 0.5 * atom[model.getIDMinY()].getSigma() : model.getMinY();
						if (y1 > y2)
							y1 = y2;
						xmin = boundary.x;
						xbox = x1 - xmin;
						ymin = y1;
						ybox = boundary.y + boundary.height - y1;
					}
					break;
				case RectangularBoundary.LOWER_LEFT:
					if (model.isEmpty()) {
						xmin = x;
						xbox = boundary.x + boundary.width - x;
						ymin = boundary.y;
						ybox = y - ymin;
					} else {
						x1 = x;
						x2 = model.getIDMinX() >= 0 ? model.getMinX() - 0.5 * atom[model.getIDMinX()].getSigma() : model.getMinX();
						if (x1 > x2)
							x1 = x2;
						y1 = y;
						y2 = model.getIDMaxY() >= 0 ? model.getMaxY() + 0.5 * atom[model.getIDMaxY()].getSigma() : model.getMaxY();
						if (y1 < y2)
							y1 = y2;
						xmin = x1;
						xbox = boundary.x + boundary.width - x1;
						ymin = boundary.y;
						ybox = y1 - ymin;
					}
					break;
				case RectangularBoundary.LOWER_RIGHT:
					if (model.isEmpty()) {
						xmin = boundary.x;
						xbox = x - xmin;
						ymin = boundary.y;
						ybox = y - ymin;
					} else {
						x1 = x;
						x2 = model.getIDMaxX() >= 0 ? model.getMaxX() + 0.5 * atom[model.getIDMaxX()].getSigma() : model.getMaxX();
						if (x1 < x2)
							x1 = x2;
						y1 = y;
						y2 = model.getIDMaxY() >= 0 ? model.getMaxY() + 0.5 * atom[model.getIDMaxY()].getSigma() : model.getMaxY();
						if (y1 < y2)
							y1 = y2;
						xmin = boundary.x;
						xbox = x1 - xmin;
						ymin = boundary.y;
						ybox = y1 - ymin;
					}
					break;
				}
				if (handle == RectangularBoundary.UPPER_LEFT || handle == RectangularBoundary.LOWER_LEFT || handle == RectangularBoundary.UPPER_RIGHT || handle == RectangularBoundary.LOWER_RIGHT) {
					boundary.setRect(xmin, ymin, xbox, ybox);
					repaint();
				}
			}
			break;

		case DGBD_ID:
			repaint();
			break;

		}

		if (useJmol)
			refreshJmol();
		e.consume();

	}