blob: 77dacf11cf1e0e731a9fa03ac5aa9d7d50f93bc9 [file] [log] [blame]
package sdl.SIR.sd;
import org.eclipse.draw2d.ColorConstants;
import org.eclipse.draw2d.Graphics;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.widgets.Display;
import org.ascape.model.Agent;
import org.ascape.model.CellOccupant;
import org.ascape.model.HostCell;
import org.ascape.util.vis.DrawFeature;
/**
* <!-- begin-user-doc -->
* SIR Agent Style 2D Java Implementation.
*
* Generated by AMF for model: SIR.metaabm in project: org.eclipse.amp.amf.examples.sd
* <!-- end-user-doc -->
* @generated
*/
public class SIRAgentStyle2DGraphics extends DrawFeature {
/**
* <!-- begin-user-doc -->
*
* <!-- end-user-doc -->
* @generated
*/
enum Shapes {
rectangle, oval, marker
};
/**
* <!-- begin-user-doc -->
*
* <!-- end-user-doc -->
* @generated
*/
Shapes shape = Shapes.rectangle;
/**
* <!-- begin-user-doc -->
*
* <!-- end-user-doc -->
* @generated
*/
public void draw(Graphics g, Object object, int width, int height) {
HostCell actionsCell = (HostCell) object;
if (actionsCell.getOccupant() instanceof SIRAgent) {
SIRAgent actions = (SIRAgent) actionsCell.getOccupant();
SIRAgent defaultSIRAgentStyle = actions;
Color defaultSIRAgentColor = ColorConstants.blue;
g.setForegroundColor(defaultSIRAgentColor);
g.setBackgroundColor(defaultSIRAgentColor);
shape = shape.oval;
if (shape == Shapes.oval) {
g.fillOval(0, 0, width, height);
} else if (shape == Shapes.marker) {
int d = (int) (width * .25 - 1);
int d2 = (int) (width * .5 - 1);
g.fillOval(d, d, d2, d2);
} else if (shape == Shapes.rectangle) {
g.fillRectangle(0, 0, width, height);
}
}
}
}