protected Icon isIcon(Point p) {
		Icon image = null;
		int pos = viewToModel(p);
		if (pos >= 0) {
			image = getIcon(pos);
			if (pos == 0)
				return image;
			if (image == null) {
				String name = getElementName(pos - 1);
				if (name.equals("icon") || name.equals("component")) {
					Icon icon = getIcon(pos - 1);
					if (icon != null) {
						Rectangle rect = null;
						try {
							rect = modelToView(pos - 1);
						} catch (BadLocationException e) {
							e.printStackTrace();
						}
						if (rect != null) {
							rect.width = icon.getIconWidth();
							rect.height = icon.getIconHeight();
							if (rect.contains(p))
								image = icon;
						}
					}
				}
			} else {
				// detect if the previous element is also an icon
				Icon icon = getIcon(pos - 1);
				if (icon != null) {
					Rectangle rect = null;
					try {
						rect = modelToView(pos - 1);
					} catch (BadLocationException e) {
						e.printStackTrace();
					}
					// detect if the click point falls in the previous icon. If so, return the previous icon.
					if (rect != null) {
						rect.width = icon.getIconWidth();
						rect.height = icon.getIconHeight();
						if (rect.contains(p))
							return icon;
					}
				}
			}
		}
		return image;
	}