public void redo() {
			super.redo();
			doNotFireUndoEvent = true;
			switch (undoID) {
			case UndoAction.TRANSLATE_MODEL:
				translateWholeModel(dx, dy);
				break;
			case UndoAction.ROTATE_MODEL:
				getModel().rotateWholeModel(angle);
				break;
			}
			doNotFireUndoEvent = false;
			getModel().notifyChange();
			if (MDView.this instanceof AtomisticView)
				((AtomisticView) MDView.this).refreshJmol();
			repaint();
		}

	}

	class UndoableLayeredComponentOperation extends AbstractUndoableEdit {

		private ModelComponent mc;
		private Layered lc;
		private int undoID;
		private String presentationName = "";
		private float x1, y1, x2, y2, x3, y3;

		UndoableLayeredComponentOperation(int undoID, Layered lc) {
			this.lc = lc;
			this.undoID = undoID;
			switch (undoID) {
			case UndoAction.INSERT_LAYERED_COMPONENT:
				if (lc instanceof ImageComponent)
					presentationName = "Inserting Image";
				else if (lc instanceof TextBoxComponent)
					presentationName = "Inserting Text Box";
				else if (lc instanceof LineComponent)
					presentationName = "Inserting Line";
				else if (lc instanceof RectangleComponent)
					presentationName = "Inserting Rectangle";
				else if (lc instanceof TriangleComponent)
					presentationName = "Inserting Triangle";
				else if (lc instanceof EllipseComponent)
					presentationName = "Inserting Ellipse";
				break;
			case UndoAction.REMOVE_LAYERED_COMPONENT:
				if (lc instanceof ImageComponent)
					presentationName = "Removing Image";
				else if (lc instanceof TextBoxComponent)
					presentationName = "Removing Text Box";
				else if (lc instanceof LineComponent)
					presentationName = "Removing Line";
				else if (lc instanceof RectangleComponent)
					presentationName = "Removing Rectangle";
				else if (lc instanceof TriangleComponent)
					presentationName = "Removing Triangle";
				else if (lc instanceof EllipseComponent)
					presentationName = "Removing Ellipse";
				break;
			case UndoAction.SEND_BACK_LAYERED_COMPONENT:
				if (lc instanceof ImageComponent)
					presentationName = "Sending Back Image";
				else if (lc instanceof TextBoxComponent)
					presentationName = "Sending Back Text Box";
				else if (lc instanceof LineComponent)
					presentationName = "Sending Back Line";
				else if (lc instanceof RectangleComponent)
					presentationName = "Sending Back Rectangle";
				else if (lc instanceof TriangleComponent)
					presentationName = "Sending Back Triangle";
				else if (lc instanceof EllipseComponent)
					presentationName = "Sending Back Ellipse";
				break;
			case UndoAction.BRING_FORWARD_LAYERED_COMPONENT:
				if (lc instanceof ImageComponent)
					presentationName = "Bringing Up Image";
				else if (lc instanceof TextBoxComponent)
					presentationName = "Bringing Up Text Box";
				else if (lc instanceof LineComponent)
					presentationName = "Bringing Up Line";
				else if (lc instanceof RectangleComponent)
					presentationName = "Bringing Up Rectangle";
				else if (lc instanceof TriangleComponent)
					presentationName = "Bringing Up Triangle";
				else if (lc instanceof EllipseComponent)
					presentationName = "Bringing Up Ellipse";
				break;
			case UndoAction.FRONT_LAYERED_COMPONENT:
				if (lc instanceof ImageComponent)
					presentationName = "Bringing Image in Front of Objects";
				else if (lc instanceof TextBoxComponent)
					presentationName = "Bringing Text Box in Front of Objects";
				else if (lc instanceof LineComponent)
					presentationName = "Bringing Line in Front of Objects";
				else if (lc instanceof RectangleComponent)
					presentationName = "Bringing Rectangle in Front of Objects";
				else if (lc instanceof TriangleComponent)
					presentationName = "Bringing Triangle in Front of Objects";
				else if (lc instanceof EllipseComponent)
					presentationName = "Bringing Ellipse in Front of Objects";
				break;
			case UndoAction.BACK_LAYERED_COMPONENT:
				if (lc instanceof ImageComponent)
					presentationName = "Sending Image Behind Objects";
				else if (lc instanceof TextBoxComponent)
					presentationName = "Sending Text Box Behind Objects";
				else if (lc instanceof LineComponent)
					presentationName = "Sending Line Behind Objects";
				else if (lc instanceof RectangleComponent)
					presentationName = "Sending Rectangle Behind Objects";
				else if (lc instanceof TriangleComponent)
					presentationName = "Sending Triangle Behind Objects";
				else if (lc instanceof EllipseComponent)
					presentationName = "Sending Ellipse Behind Objects";
				break;
			case UndoAction.ATTACH_LAYERED_COMPONENT:
				if (lc instanceof ImageComponent)
					presentationName = "Attaching Image";
				else if (lc instanceof TextBoxComponent)
					presentationName = "Attaching Text Box";
				else if (lc instanceof RectangleComponent)
					presentationName = "Attaching Rectangle";
				else if (lc instanceof TriangleComponent)
					presentationName = "Attaching Triangle";
				else if (lc instanceof EllipseComponent)
					presentationName = "Attaching Ellipse";
				mc = lc.getHost();
				break;
			case UndoAction.DETACH_LAYERED_COMPONENT:
				if (lc instanceof ImageComponent)
					presentationName = "Detaching Image";
				else if (lc instanceof TextBoxComponent)
					presentationName = "Detaching Text Box";
				else if (lc instanceof RectangleComponent)
					presentationName = "Detaching Rectangle";
				else if (lc instanceof TriangleComponent)
					presentationName = "Detaching Triangle";
				else if (lc instanceof EllipseComponent)
					presentationName = "Detaching Ellipse";
				mc = lc.getHost();
				break;
			case UndoAction.RESIZE_LINE:
				if (lc instanceof LineComponent) {
					presentationName = "Resizing Line";
					x1 = ((LineComponent) lc).getX1();
					x2 = ((LineComponent) lc).getX2();
					y1 = ((LineComponent) lc).getY1();
					y2 = ((LineComponent) lc).getY2();
				}
				break;
			case UndoAction.RESIZE_RECTANGLE:
				if (lc instanceof RectangleComponent) {
					presentationName = "Resizing Rectangle";
					x1 = ((RectangleComponent) lc).getX();
					y1 = ((RectangleComponent) lc).getY();
					x2 = ((RectangleComponent) lc).getWidth();
					y2 = ((RectangleComponent) lc).getHeight();
				}
				break;
			case UndoAction.RESIZE_TRIANGLE:
				if (lc instanceof TriangleComponent) {
					presentationName = "Resizing Triangle";
					TriangleComponent tc = (TriangleComponent) lc;
					x1 = tc.getVertex(0).x;
					y1 = tc.getVertex(0).y;
					x2 = tc.getVertex(1).x;
					y2 = tc.getVertex(1).y;
					x3 = tc.getVertex(2).x;
					y3 = tc.getVertex(2).y;
				}
				break;
			case UndoAction.RESIZE_ELLIPSE:
				if (lc instanceof EllipseComponent) {
					presentationName = "Resizing Ellipse";
					x1 = ((EllipseComponent) lc).getX();
					y1 = ((EllipseComponent) lc).getY();
					x2 = ((EllipseComponent) lc).getWidth();
					y2 = ((EllipseComponent) lc).getHeight();
				}
				break;
			}
		}

		public String getPresentationName() {
			return presentationName;
		}

		public void undo() {
			super.undo();
			doNotFireUndoEvent = true;
			switch (undoID) {
			case UndoAction.INSERT_LAYERED_COMPONENT:
				layerBasket.remove(lc);
				if (((ModelComponent) lc).isSelected())
					setSelectedComponent(null);
				break;
			case UndoAction.REMOVE_LAYERED_COMPONENT:
				layerBasket.add(lc);
				((ModelComponent) lc).setSelected(true);
				break;
			case UndoAction.SEND_BACK_LAYERED_COMPONENT:
				layerForward(lc);
				break;
			case UndoAction.BRING_FORWARD_LAYERED_COMPONENT:
				layerBack(lc);
				break;
			case UndoAction.FRONT_LAYERED_COMPONENT:
				lc.setLayer(Layered.BEHIND_PARTICLES);
				break;
			case UndoAction.BACK_LAYERED_COMPONENT:
				lc.setLayer(Layered.IN_FRONT_OF_PARTICLES);
				break;
			case UndoAction.DETACH_LAYERED_COMPONENT:
				lc.setHost(mc);
				break;
			case UndoAction.ATTACH_LAYERED_COMPONENT:
				lc.setHost(null);
				if (lc instanceof ModelComponent)
					((ModelComponent) lc).restoreState();
				break;
			case UndoAction.RESIZE_LINE:
				if (lc instanceof LineComponent)
					((LineComponent) lc).restoreState();
				break;
			case UndoAction.RESIZE_RECTANGLE:
				if (lc instanceof RectangleComponent)
					((RectangleComponent) lc).restoreState();
				break;
			case UndoAction.RESIZE_TRIANGLE:
				if (lc instanceof TriangleComponent)
					((TriangleComponent) lc).restoreState();
				break;
			case UndoAction.RESIZE_ELLIPSE:
				if (lc instanceof EllipseComponent)
					((EllipseComponent) lc).restoreState();
				break;
			}
			doNotFireUndoEvent = false;
			getModel().notifyChange();
			repaint();
		}

		public void redo() {
			super.redo();
			doNotFireUndoEvent = true;
			switch (undoID) {
			case UndoAction.INSERT_LAYERED_COMPONENT:
				layerBasket.add(lc);
				((ModelComponent) lc).setSelected(true);
				break;
			case UndoAction.REMOVE_LAYERED_COMPONENT:
				layerBasket.remove(lc);
				if (((ModelComponent) lc).isSelected())
					setSelectedComponent(null);
				break;
			case UndoAction.SEND_BACK_LAYERED_COMPONENT:
				layerBack(lc);
				break;
			case UndoAction.BRING_FORWARD_LAYERED_COMPONENT:
				layerForward(lc);
				break;
			case UndoAction.FRONT_LAYERED_COMPONENT:
				lc.setLayer(Layered.IN_FRONT_OF_PARTICLES);
				break;
			case UndoAction.BACK_LAYERED_COMPONENT:
				lc.setLayer(Layered.BEHIND_PARTICLES);
				break;
			case UndoAction.ATTACH_LAYERED_COMPONENT:
				lc.setHost(mc);
				break;
			case UndoAction.DETACH_LAYERED_COMPONENT:
				lc.setHost(null);
				break;
			case UndoAction.RESIZE_LINE:
				if (lc instanceof LineComponent)
					((LineComponent) lc).setLine(x1, y1, x2, y2);
				break;
			case UndoAction.RESIZE_RECTANGLE:
				if (lc instanceof RectangleComponent)
					((RectangleComponent) lc).setRect(x1, y1, x2, y2);
				break;
			case UndoAction.RESIZE_TRIANGLE:
				if (lc instanceof TriangleComponent) {
					TriangleComponent tc = (TriangleComponent) lc;
					tc.setVertex(0, x1, y1);
					tc.setVertex(1, x2, y2);
					tc.setVertex(2, x3, y3);
				}
				break;
			case UndoAction.RESIZE_ELLIPSE:
				if (lc instanceof EllipseComponent)
					((EllipseComponent) lc).setOval(x1, y1, x2, y2);
				break;
			}
			doNotFireUndoEvent = false;
			getModel().notifyChange();
			repaint();
		}