public void loadElements(VisibleElements type) {

		this.visibleElements = type;

		// ZOrder index
		int index = 0;

		// Remove all drawed elements.
		draw.removeAll();

		List<GenericTreeNode<LayoutParserTreeElement>> list = this.layoutParser.XMLTree
				.build(GenericTreeTraversalOrderEnum.PRE_ORDER);

		// Go through all elements.
		for (int i = 0; i < list.size(); i++) {

			LayoutParserTreeElement e = list.get(i).getData();

			// Check if element is of selected type.
			if (e.elementType == type.toType()) {

				GElement panel = new GElement(list.get(i));

				// Set height and width so that the element is visible..
				int width = e.right - e.left > 1 ? e.right - e.left : 3;
				int height = e.bottom - e.top > 1 ? e.bottom - e.top : 3;

				// Check direction.
				if (this.layoutParser.direction == Direction.DESCENDING) {
					panel.setBounds(e.left, e.top, width, height);
				} else {
					int m_height = this.image.getHeight(this);
					panel.setBounds(e.left, m_height - e.bottom, width, height);
				}

				if (this.visCombo.getSelectedItem().toString()
						.compareTo(ElementsVisibility.S_IMAGE.toString()) == 0) {
					panel.setTextArea(width, height, false);
				} else {
					if (panel.element.getData().elementType == type.toType()) {
						panel.setTextArea(width, height, true);
					} else {
						panel.setTextArea(width, height, false);
					}
				}

				// Create the popup menu for the current panel
				GPopup popupMenu = new GPopup();

				/*
				 * Action listener pentru popupMenu Primeste ca parametru
				 * ElementJPanel pentru a extrage LayoutParserTreeElement
				 */
				ActionListener actionListener = new PopupItemListener(panel,
						this);

				// Face analiza OCR.
				JMenuItem ocrItem = new JMenuItem(
						ElementActions.S_OCR.toString());
				ocrItem.addActionListener(actionListener);
				popupMenu.add(ocrItem);

				// Sparge blocul de text orizontal.
				JMenuItem splitItemH = new JMenuItem(
						ElementActions.S_BREAK_H.toString());
				splitItemH.addActionListener(actionListener);
				splitItemH.addMouseListener(new PopupItemMouseListener(panel,
						draw));
				popupMenu.add(splitItemH);

				// Sparge blocul de text veritcal.
				JMenuItem splitItemV = new JMenuItem(
						ElementActions.S_BREAK_V.toString());
				splitItemV.addActionListener(actionListener);
				splitItemV.addMouseListener(new PopupItemMouseListener(panel,
						draw));
				popupMenu.add(splitItemV);

				// Marcheaza blocul de text ca fiind numar pagina.
				if (panel.element.getData().elementType.toString().compareTo(
						"TextBlock") == 0) {
					JMenuItem paginaItem = new JMenuItem(
							ElementActions.S_PAGE.toString());
					paginaItem.addActionListener(actionListener);
					popupMenu.add(paginaItem);
				}

				// Marcheaza blocul de text ca fiind numar pagina.
				JMenuItem deleteItem = new JMenuItem(
						ElementActions.S_DELETE.toString());
				deleteItem.addActionListener(actionListener);
				popupMenu.add(deleteItem);

				// Vezi textul.
				JMenuItem textItem = new JMenuItem(
						ElementActions.S_TEXT.toString());
				textItem.addActionListener(actionListener);
				popupMenu.add(textItem);

				// Bring to front.
				JMenuItem frontItem = new JMenuItem(
						ElementActions.S_FRONT.toString());
				frontItem.addActionListener(actionListener);
				popupMenu.add(frontItem);

				// Sent to Back.
				JMenuItem backItem = new JMenuItem(
						ElementActions.S_BACK.toString());
				backItem.addActionListener(actionListener);
				popupMenu.add(backItem);

				// Redimensioneaza
				JMenuItem redimItem = new JMenuItem(
						ElementActions.S_RESIZE.toString());
				redimItem.addActionListener(actionListener);
				popupMenu.add(redimItem);

				// Set popup menu.
				panel.setPopup(popupMenu);

				// Draw panel.
				draw.add(panel);

				// Set zOrder for a component
				draw.setComponentZOrder(panel, index++);
			}
		}
	}