import javax.swing.*; import java.awt.*; import java.awt.geom.Ellipse2D; public class DrawningWheels { JPanel TankPanel; private WheelQuantityType WheelsQuantity; private Color Color; private int Width, Height; public int currentX, currentY; boolean Init(int width, int height, int x, int y, Color color, JPanel tankPanel){ Width = width; Height = height; currentX = x; currentY = y; Color = color; TankPanel = tankPanel; return true; } public void ChangeWheelsQuantity(int x){ if(x <= 4) WheelsQuantity = WheelsQuantity.Four; if(x == 5) WheelsQuantity = WheelsQuantity.Five; if(x >= 6) WheelsQuantity = WheelsQuantity.Six; } public void DrawWheels(){ Graphics2D g2d = (Graphics2D)TankPanel.getGraphics(); g2d.setColor(Color); g2d.fill(new Ellipse2D.Double(currentX + 1, currentY + Height - 5 - 25, 25, 25)); if (WheelsQuantity == WheelQuantityType.Four) { for (int i = 1; i <= 2; i++) { g2d.fill(new Ellipse2D.Double(currentX + 40 + (5 * i) + (35 * (i - 1)), currentY + Height - 5 - 17, 20, 20)); } } if (WheelsQuantity == WheelQuantityType.Five) { for (int i = 1; i <= 3; i++) { g2d.fill(new Ellipse2D.Double(currentX + 30 + (5 * i) + (25 * (i - 1)), currentY + Height - 5 - 20, 20, 20)); } } if (WheelsQuantity == WheelQuantityType.Six) { for (int i = 1; i <= 4; i++) { g2d.fill(new Ellipse2D.Double(currentX + 30 + (5 * i) + (15 * (i - 1)), currentY + Height - 5 - 15, 15, 15)); } } g2d.fill(new Ellipse2D.Double(currentX + Width - 25 - 1, currentY + Height - 5 - 25, 25, 25)); } }