2023-09-14 23:02:37 +04:00
|
|
|
package ProjectElectricLocomotive;
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
|
|
|
public class DrawingWheel {
|
|
|
|
private WheelsCount _wheelsCount;
|
2023-10-08 20:20:04 +04:00
|
|
|
public void SetWheelsCount(int wheelsCount) {
|
2023-09-14 23:02:37 +04:00
|
|
|
for (WheelsCount val : WheelsCount.values()) {
|
2023-10-08 20:20:04 +04:00
|
|
|
if (val.count == wheelsCount) {
|
|
|
|
_wheelsCount = val;
|
2023-09-14 23:02:37 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void DrawWheel(Graphics2D g2d, Color color, int x, int y, int w, int h) {
|
|
|
|
g2d.setColor(Color.BLACK);
|
|
|
|
g2d.fillOval(x, y, w, h);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DrawWheels(Graphics g, Color color, int startPosX, int startPosY, int drawingWidth, int drawingHeight) {
|
|
|
|
if (_wheelsCount == null) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Graphics2D g2d = (Graphics2D) g;
|
|
|
|
int wheelWidth = 5;
|
|
|
|
int wheelHeight = 5;
|
|
|
|
|
|
|
|
if (_wheelsCount.count >= _wheelsCount.Three.count) {
|
|
|
|
DrawWheel(g2d, color, startPosX + 105, startPosY + 45, wheelWidth, wheelHeight
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_wheelsCount.count >= _wheelsCount.Four.count) {
|
|
|
|
DrawWheel(g2d, color, startPosX + 105, startPosY + 45, wheelWidth, wheelHeight
|
|
|
|
);
|
|
|
|
DrawWheel(g2d, color, startPosX + 130, startPosY + 45, wheelWidth, wheelHeight
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|