import java.awt.*; public class DrawningSquaredRollers implements IDrawningRollers { private RollersCount rollersCount; private Color colorRollers; public void setRollersCount(int count){ switch (count) { case 4 -> rollersCount = RollersCount.Four; case 5 -> rollersCount = RollersCount.Five; case 6 -> rollersCount = RollersCount.Six; default -> rollersCount = RollersCount.Four; } } public DrawningSquaredRollers(int count, Color colorRollers){ setRollersCount(count); this.colorRollers = colorRollers; } public void DrawRollers(Graphics2D g, float _startPosX, float _startPosY){ Color penColor = Color.BLACK; Color mainColor = colorRollers==null ? Color.LIGHT_GRAY : colorRollers; // Крупные катки - всегда g.setColor(mainColor); g.fillOval((int)_startPosX + 5, (int)_startPosY + 60, 22, 22); g.setColor(penColor); g.drawOval((int)_startPosX + 5, (int)_startPosY + 60, 22, 22); // Узор для больших катков //1 Polygon bigRomb = new Polygon( new int[]{(int)_startPosX + 5, (int)_startPosX + 5 + 11, (int)_startPosX + 5 + 22, (int)_startPosX + 5 + 11}, new int[]{(int)_startPosY + 60 + 11, (int)_startPosY + 60, (int)_startPosY + 60 + 11, (int)_startPosY + 60 + 22}, 4 ); Polygon bigCube = new Polygon( new int[]{(int)_startPosX + 5 + 5, (int)_startPosX + 5 + 22 - 5, (int)_startPosX + 5 + 22 - 5, (int)_startPosX + 5 + 5}, new int[]{(int)_startPosY + 60 + 5, (int)_startPosY + 60 + 5, (int)_startPosY + 60 + 22 - 5, (int)_startPosY + 60 + 22 - 5}, 4 ); g.drawPolygon(bigRomb); g.drawPolygon(bigCube); // Сдвиг bigRomb.translate(78,0); bigCube.translate(78,0); //2 g.setColor(mainColor); g.fillOval((int)_startPosX + 83, (int)_startPosY + 60, 22, 22); g.setColor(penColor); g.drawOval((int)_startPosX + 83, (int)_startPosY + 60, 22, 22); g.drawPolygon(bigRomb); g.drawPolygon(bigCube); // Малые катки - всегда // Polygon smallRomb = new Polygon( new int[]{(int)_startPosX + 43, (int)_startPosX + 43 + 3, (int)_startPosX + 43 + 6, (int)_startPosX + 43 + 3}, new int[]{(int)_startPosY + 58 + 3, (int)_startPosY + 58, (int)_startPosY + 58 + 3, (int)_startPosY + 58 + 6}, 4 ); Polygon smallCube = new Polygon( new int[]{(int)_startPosX + 43 + 1, (int)_startPosX + 43 + 6 - 1, (int)_startPosX + 43 + 6 - 1, (int)_startPosX + 43 + 1}, new int[]{(int)_startPosY + 58 + 1, (int)_startPosY + 58 + 6 - 1, (int)_startPosY + 58 + 6 - 1, (int)_startPosY + 58 + 1}, 4 ); // 1 g.setColor(mainColor); g.fillOval((int)_startPosX + 43, (int)_startPosY + 58, 6, 6); g.setColor(penColor); g.drawOval((int)_startPosX + 43, (int)_startPosY + 58, 6, 6); g.drawPolygon(smallRomb); g.drawPolygon(smallCube); // Сдвиг smallRomb.translate(18,0); smallCube.translate(18,0); // 2 g.setColor(mainColor); g.fillOval((int)_startPosX + 61, (int)_startPosY + 58, 6, 6); g.setColor(penColor); g.drawOval((int)_startPosX + 61, (int)_startPosY + 58, 6, 6); g.drawPolygon(smallRomb); g.drawPolygon(smallCube); Polygon middleRomb = new Polygon( new int[]{(int)_startPosX + 33, (int)_startPosX + 33 + 5, (int)_startPosX + 33 + 10, (int)_startPosX + 33 + 5}, new int[]{(int)_startPosY + 73 + 5, (int)_startPosY + 73, (int)_startPosY + 73 + 5, (int)_startPosY + 73 + 10}, 4 ); Polygon middleCube = new Polygon( new int[]{(int)_startPosX + 33 + 2, (int)_startPosX + 33 + 8, (int)_startPosX + 33 + 8, (int)_startPosX + 33 + 2}, new int[]{(int)_startPosY + 73 + 2, (int)_startPosY + 73 + 2, (int)_startPosY + 73 + 8, (int)_startPosY + 73 + 8}, 4 ); // Средние катки - не всегда switch (rollersCount){ case Six: g.setColor(mainColor); g.fillOval((int)_startPosX + 33, (int)_startPosY + 73, 10, 10); g.setColor(penColor); g.drawOval((int)_startPosX + 33, (int)_startPosY + 73, 10, 10); g.drawPolygon(middleRomb); g.drawPolygon(middleCube); case Five: // Сдвиг middleRomb.translate(35,0); middleCube.translate(35,0); g.setColor(mainColor); g.fillOval((int)_startPosX + 68, (int)_startPosY + 73, 10, 10); g.setColor(penColor); g.drawOval((int)_startPosX + 68, (int)_startPosY + 73, 10, 10); g.drawPolygon(middleRomb); g.drawPolygon(middleCube); } // Центры крупных катков g.setColor(Color.BLACK); g.fillOval((int)_startPosX + 13, (int)_startPosY + 68, 6, 6); g.fillOval((int)_startPosX + 91, (int)_startPosY + 68, 6, 6); } }