001    /**
002     * Created by IntelliJ IDEA.
003     * User: Wei Wang
004     * Date: Feb 14, 2003
005     * Time: 9:35:02 PM
006     */
007    
008    package EVolve.util.painters.shapes;
009    
010    import java.awt.Graphics2D;
011    
012    public class Ball extends Shape{
013        private int diameter;
014    
015        public Ball(long entity_type, long entity_id, int diameter) {
016            super(entity_type,entity_id);
017            this.entity_type = entity_type;
018            this.diameter = diameter;
019        }
020    
021        public String getName() {
022            return "Box";
023        }
024    
025        public void draw(Graphics2D g) {
026            if (color != null) {
027                g.setColor(color);
028            } else {
029                g.setColor(defaultColor);
030            }
031            g.drawOval(x,y,diameter,diameter);
032    
033            if (consumerMap == null) return;
034    
035            drawArrows(g);
036        }
037    
038        public void fill(Graphics2D g) {
039            if (color != null) g.fillOval(x,y,diameter,diameter);
040        }
041    
042        public boolean insideShape(int x, int y) {
043            if ((x<=this.x+diameter) && (x>=this.x) &&
044                (y<=this.y+diameter) && (y>=this.y))
045                return true;
046            return false;
047        }
048    
049        public int getWidth() {
050            return diameter;
051        }
052    
053        public int getHeight() {
054            return diameter;
055        }
056    
057        public void setSize(int width, int height) {
058            diameter = width;
059        }
060    }