PIbd-23_Mochalov_D.V._Locom.../ExtraRoundWheelDraw.java

49 lines
1.4 KiB
Java
Raw Normal View History

2022-10-08 23:13:09 +04:00
import java.awt.*;
public class ExtraRoundWheelDraw implements IDrawningExtra{
private WheelsCount wheelsCount = WheelsCount.Two;
private ExtraWheelsDraw extraWheelsDraw;
private Color color;
2022-10-08 23:13:09 +04:00
public void setExtraNum(int num) {
switch (num) {
2022-11-19 19:47:16 +04:00
case 3: {
2022-10-08 23:13:09 +04:00
wheelsCount = WheelsCount.Three;
break;
}
2022-11-19 19:47:16 +04:00
case 4: {
2022-10-08 23:13:09 +04:00
wheelsCount = WheelsCount.Four;
break;
}
default:
break;
}
}
public ExtraRoundWheelDraw (int num, Color bodyColor) {
2022-10-08 23:13:09 +04:00
setExtraNum(num);
extraWheelsDraw = new ExtraWheelsDraw(num, bodyColor);
2022-10-08 23:13:09 +04:00
}
public void SetColor(Color color) {
this.color = color;
}
2022-10-08 23:13:09 +04:00
public void DrawExtra(int startPosX, int startPosY, Graphics2D g) {
extraWheelsDraw.DrawExtra(startPosX, startPosY, g);
g.setColor(color);
2022-10-08 23:13:09 +04:00
g.fillOval(startPosX + 5, startPosY + 35, 10, 10);
g.fillOval(startPosX + 95, startPosY + 35, 10, 10);
switch (wheelsCount) {
case Four: {
g.fillOval(startPosX + 75, startPosY + 35, 10, 10);
}
case Three: {
g.fillOval(startPosX + 25, startPosY + 35, 10, 10);
break;
}
default:
break;
}
}
}