44 lines
1.7 KiB
Java
44 lines
1.7 KiB
Java
import java.awt.*;
|
|
|
|
public class DrawingRollers implements IDrawingRollers {
|
|
private RollersCount rollersCount;
|
|
private Color color;
|
|
|
|
public DrawingRollers(int rollersCount, Color bodyColor) {
|
|
setRollersCount(rollersCount);
|
|
color = bodyColor;
|
|
}
|
|
|
|
public void setRollersCount(int num) {
|
|
if (num <= 4) {
|
|
rollersCount = RollersCount.Four;
|
|
} else if (num >= 6) {
|
|
rollersCount = RollersCount.Six;
|
|
} else {
|
|
rollersCount = RollersCount.Five;
|
|
}
|
|
}
|
|
|
|
public void draw(Graphics2D g, int x, int y, int artilleryWidth, int artilleryHeight) {
|
|
g.setColor(color != null ? color : Color.BLACK);
|
|
g.fillOval(x + artilleryWidth / 20, y + artilleryHeight * 7 / 15, artilleryWidth * 4 / 20, artilleryHeight * 10 / 32);
|
|
g.fillOval(x + artilleryWidth * 15 / 20, y + artilleryHeight * 7 / 15, artilleryWidth * 4 / 20, artilleryHeight * 10 / 32);
|
|
switch (rollersCount) {
|
|
case Six: {
|
|
g.fillOval(x + artilleryWidth * 8 / 20, y + artilleryHeight * 10 / 16, artilleryWidth * 2 / 20, artilleryHeight * 6 / 32);
|
|
}
|
|
case Five: {
|
|
g.fillOval(x + artilleryWidth * 10 / 20, y + artilleryHeight * 10 / 16, artilleryWidth * 2 / 20, artilleryHeight * 6 / 32);
|
|
}
|
|
case Four: {
|
|
g.fillOval(x + artilleryWidth * 5 / 20, y + artilleryHeight * 9 / 16, artilleryWidth * 3 / 20, artilleryHeight * 8 / 32);
|
|
g.fillOval(x + artilleryWidth * 12 / 20, y + artilleryHeight * 9 / 16, artilleryWidth * 3 / 20, artilleryHeight * 8 / 32);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void setColor(Color color) {
|
|
this.color = color;
|
|
}
|
|
}
|