package de.uni_jena.iaa.linktype.atomic.editors.grapheditor.figures;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.GroupBoxBorder;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Insets;
import org.eclipse.draw2d.geometry.Rectangle;

import de.uni_jena.iaa.linktype.atomic.editors.grapheditor.util.PartUtils;

public class NodeFigureBorder extends GroupBoxBorder {
	
	private int modelType;

	public NodeFigureBorder(String visualID, int modelType) {
		super(visualID);
		this.modelType = modelType;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.draw2d.Border#paint(org.eclipse.draw2d.IFigure, org.eclipse.draw2d.Graphics, org.eclipse.draw2d.geometry.Insets)
	 */
	@Override
	public void paint(IFigure figure, Graphics graphics, Insets insets) {
		graphics.pushState();
        Rectangle rect = figure.getBounds();
        graphics.clipRect(rect);
        Rectangle r = rect.getResized(-1, -9).translate(0, 8);
        PartUtils.setColor(graphics, PartUtils.VERYLIGHTGREY, false);
        graphics.drawRoundRectangle(r, 10, 10);
        switch (modelType) {
		case NodeFigure.TOKEN_MODEL:
			graphics.setForegroundColor(ColorConstants.red);
	        break;
		case NodeFigure.STRUCTURE_MODEL:
			graphics.setForegroundColor(ColorConstants.green);
	        break;
		case NodeFigure.SPAN_MODEL:
			graphics.setForegroundColor(ColorConstants.yellow);
	        break;

		default:
			break;
		}
        PartUtils.setColor(graphics, PartUtils.MEDIUMLIGHTGREY, true);
        graphics.fillText(getLabel(), r.x + 8, r.y - 8);
        graphics.popState();
	}

	/* (non-Javadoc)
	 * @see org.eclipse.draw2d.AbstractLabeledBorder#calculateInsets(org.eclipse.draw2d.IFigure)
	 */
	@Override
	protected Insets calculateInsets(IFigure figure) {
		return new Insets(15, 2, 2, 2); // TODO calculate Insets possible?
	}
}
@@ -982,32 +982,87 @@
 (0, 8);%0A        
+switch (modelType) %7B%0A%09%09case NodeFigure.TOKEN_MODEL:%0A%09%09%09
 PartUtils.setCol
@@ -1103,24 +1103,25 @@
 EY, false);%0A
+%09
         grap
@@ -1160,36 +1160,141 @@
 0);%0A
-        switch (modelType) %7B
+%09%09%09graphics.setForegroundColor(ColorConstants.red);%0A%09%09%09PartUtils.setColor(graphics, PartUtils.MEDIUMLIGHTGREY, true);%0A%09        break;
 %0A%09%09c
@@ -1300,37 +1300,41 @@
 case NodeFigure.
-TOKEN
+STRUCTURE
 _MODEL:%0A%09%09%09graph
@@ -1367,27 +1367,33 @@
 orConstants.
-red
+lightGray
 );%0A%09        
@@ -1396,49 +1396,47 @@
     
-break;%0A%09%09case NodeFigure.STRUCTURE_MODEL:
+graphics.drawRoundRectangle(r, 10, 10);
 %0A%09%09%09
@@ -1482,16 +1482,86 @@
 nts.
-g
+darkG
 reen);%0A
+%09%09%09PartUtils.setColor(graphics, PartUtils.MEDIUMLIGHTGREY, true);%0A
 %09   
@@ -1652,14 +1652,172 @@
 nts.
-yellow
+orange);%0A%09        graphics.drawRoundRectangle(r, 10, 10);%0A%09%09%09graphics.setForegroundColor(ColorConstants.black);%0A%09%09%09graphics.setBackgroundColor(ColorConstants.orange
 );%0A%09
@@ -1831,17 +1831,16 @@
  break;%0A
-%0A
 %09%09defaul
@@ -1860,79 +1860,8 @@
 %09%09%7D%0A
-        PartUtils.setColor(graphics, PartUtils.MEDIUMLIGHTGREY, true);%0A
     

Set different colours in NodeFigureBorder