/**
 * This program and the accompanying materials
 * are made available under the terms of the License
 * which accompanies this distribution in the file LICENSE.txt
 */
package com.archimatetool.editor.diagram.figures.elements;

import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Graphics;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;

import com.archimatetool.editor.diagram.figures.AbstractTextControlContainerFigure;


/**
 * Equipment Figure
 * 
 * @author Phillip Beauvoir
 */
public class EquipmentFigure extends AbstractTextControlContainerFigure {
    
    public EquipmentFigure() {
        super(TEXT_FLOW_CONTROL);
        setFigureDelegate(new BoxFigureDelegate(this, 20 - getTextControlMarginWidth()));
    }
    
    
    @Override
    protected void drawFigure(Graphics graphics) {
        super.drawFigure(graphics);
        drawIcon(graphics);
    }
    
    /**
     * Draw the icon
     */
    protected void drawIcon(Graphics graphics) {
        graphics.pushState();
        
        graphics.setForegroundColor(isEnabled() ? ColorConstants.black : ColorConstants.gray);
        Point pt = getIconOrigin();
        
        
        
        graphics.popState();
    }
    
    /**
     * @return The icon start position
     */
    protected Point getIconOrigin() {
        Rectangle bounds = getBounds();
        return new Point(bounds.x + bounds.width - 33, bounds.y + 27);
    }
}

@@ -379,25 +379,109 @@
 eometry.
-Rectangle
+PointList;%0Aimport org.eclipse.draw2d.geometry.Rectangle;%0Aimport org.eclipse.swt.graphics.Path
 ;%0A%0Aimpor
@@ -559,16 +559,76 @@
 Figure;%0A
+import com.archimatetool.editor.diagram.figures.PolarPoint;%0A
 %0A%0A/**%0A *
@@ -1188,32 +1188,66 @@
 ate();%0A        %0A
+        graphics.setLineWidth(1);%0A
         graphics
@@ -1382,42 +1382,1158 @@
     
-%0A        %0A        graphics.popStat
+drawCog(graphics, pt, 8, 3, 6, 8);%0A        drawCog(graphics, pt.getTranslated(10, -8), 6, 2, 4, 5);%0A        %0A        graphics.popState();%0A    %7D%0A    %0A    /**%0A     * %0A     * Draw a Cog with choosen number of %22segments%22%0A     */%0A    protected void drawCog(Graphics graphics, Point center, int segments, int r1, int r2, int r3) %7B%0A    %09// Draw outer Cog%0A    %09PointList outer = new PointList();%0A    %09final double halfSeg = Math.PI / (2*segments); %0A    %09final double delta = halfSeg / 4;%0A    %09%0A    %09for(int i = 0; i%3Csegments; i++) %7B%0A    %09%09outer.addPoint(new PolarPoint(r2, 2*Math.PI*i/segments-halfSeg).toAbsolutePoint(center));%0A    %09%09outer.addPoint(new PolarPoint(r3, 2*Math.PI*i/segments-halfSeg+delta).toAbsolutePoint(center));%0A    %09%09outer.addPoint(new PolarPoint(r3, 2*Math.PI*i/segments+halfSeg-delta).toAbsolutePoint(center));%0A    %09%09outer.addPoint(new PolarPoint(r2, 2*Math.PI*i/segments+halfSeg).toAbsolutePoint(center));%0A    %09%7D%0A    %09graphics.drawPolygon(outer);%0A    %09%0A    %09// Draw inner circle%0A    %09Path path = new Path(null);%0A        path.addArc(center.x - r1, center.y - r1, 2*r1, 2*r1, 0, 360);%0A        graphics.drawPath(path);%0A        path.dispos
 e();
@@ -2747,10 +2747,10 @@
 y + 
-27
+30
 );%0A 

Add Equipment icon (cogs)