public Dimension resize(final Dimension newSize, final boolean isLoading) {
		if (ancestor == null)
			return newSize;
		float[] objectBounds = getModel().getBoundsOfObjects();
		if (objectBounds != null) {
			float xmin = objectBounds[0];
			float ymin = objectBounds[1];
			float xmax = objectBounds[2];
			float ymax = objectBounds[3];
			RectangularBoundary boundary = getModel().getBoundary();
			if (isLoading) {
				// leave 1 margin in checking if every object is contained within the boundary,
				// because particles may slightly penetrate into the walls
				if (!boundary.contains(new Rectangle((int) (xmin + 1), (int) (ymin + 1), (int) (xmax - xmin - 2), (int) (ymax - ymin - 2)))) {
					EventQueue.invokeLater(new Runnable() {
						public void run() {
							JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(MDView.this), "Some objects overlap with the boundary lines. This may have been caused by changing periodic boundary\nto reflecting boundary. Please move those particles off the border and re-save.", "Size Error", JOptionPane.ERROR_MESSAGE);
						}
					});
					return newSize;
				}
			} else {
				if (boundary.getType() == RectangularBoundary.DBC_ID) {
					if (xmax > newSize.width + 1 || ymax > newSize.height + 1) {
						Dimension d = getSize();
						resizeTo(d, false, false);
						EventQueue.invokeLater(new Runnable() {
							public void run() {
								JOptionPane.showMessageDialog(JOptionPane.getFrameForComponent(MDView.this), "The Model Container cannot be resized to the specified dimension.\nSome objects would be out of boundary.", "Resizing Error", JOptionPane.ERROR_MESSAGE);
							}
						});
						return d;
					}
				}
			}
		}
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				resizeTo(newSize, isLoading, !doNotFireUndoEvent);
			}
		});
		return newSize;
	}