@Override public Image stereotypeIconToDisplay() { // retrieve the first stereotype in the list of displayed stereotype // String firstStereotypeName = tokenizer.nextToken(); EList<Stereotype> stereotype_list = getUMLElement().getAppliedStereotypes(); if (stereotype_list.size() != 0) { Stereotype stereotype = stereotype_list.get(0); if (stereotype.getName().equals("DataFlowPort") || stereotype.getName().equals("ServicePort")) { Image icon = Activator.getIconElement(getUMLElement(), stereotype, false); IFigure portView = getHostFigure(); IFigure parentView = portView.getParent().getParent(); Rectangle parentBounds = parentView.getBounds(); Rectangle portBounds = portView.getBounds(); if (portBounds.x() <= parentBounds.x()) { // left return icon; } else if (portBounds.x() >= (parentBounds.right() - portBounds.width())) { // right return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, 180)); } else if (portBounds.y() <= parentBounds.y()) { // top return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, 90)); } else if (portBounds.y() >= parentBounds.bottom() - portBounds.height()) { // bottom return new Image(icon.getDevice(), RotationHelper.rotateImage(icon, -90)); } else { return null; } } return Activator.getIconElement(getUMLElement(), stereotype, false); } return null; }