134 lines
5.3 KiB
Java
134 lines
5.3 KiB
Java
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 int getRollersCount() {
|
|
return rollersCount.getValue();
|
|
}
|
|
|
|
public void DrawRollers(Graphics2D g, float _startPosX, float _startPosY){
|
|
Color penColor = Color.BLACK;
|
|
Color mainColor = colorRollers==null ? Color.LIGHT_GRAY : colorRollers;
|
|
|
|
// Крупные катки - всегда
|
|
// Узор для больших катков
|
|
Polygon bigRomb = new Polygon(
|
|
new int[]{(int)_startPosX + 5, (int)_startPosX + 16, (int)_startPosX + 27, (int)_startPosX + 16},
|
|
new int[]{(int)_startPosY + 71, (int)_startPosY + 60, (int)_startPosY + 71, (int)_startPosY + 82},
|
|
4
|
|
);
|
|
Polygon bigCube = new Polygon(
|
|
new int[]{(int)_startPosX + 10, (int)_startPosX + 22, (int)_startPosX + 22, (int)_startPosX + 10},
|
|
new int[]{(int)_startPosY + 65, (int)_startPosY + 65, (int)_startPosY + 77, (int)_startPosY + 77},
|
|
4
|
|
);
|
|
// 1
|
|
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);
|
|
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 + 46, (int)_startPosX + 49, (int)_startPosX + 46},
|
|
new int[]{(int)_startPosY + 61, (int)_startPosY + 58, (int)_startPosY + 61, (int)_startPosY + 64},
|
|
4
|
|
);
|
|
Polygon smallCube = new Polygon(
|
|
new int[]{(int)_startPosX + 44, (int)_startPosX + 48, (int)_startPosX + 48, (int)_startPosX + 44},
|
|
new int[]{(int)_startPosY + 59, (int)_startPosY + 63, (int)_startPosY + 63, (int)_startPosY + 59},
|
|
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 + 38, (int)_startPosX + 43, (int)_startPosX + 38},
|
|
new int[]{(int)_startPosY + 78, (int)_startPosY + 73, (int)_startPosY + 78, (int)_startPosY + 83},
|
|
4
|
|
);
|
|
Polygon middleCube = new Polygon(
|
|
new int[]{(int)_startPosX + 35, (int)_startPosX + 41, (int)_startPosX + 41, (int)_startPosX + 35},
|
|
new int[]{(int)_startPosY + 75, (int)_startPosY + 75, (int)_startPosY + 81, (int)_startPosY + 81},
|
|
4
|
|
);
|
|
switch (rollersCount){
|
|
case Six:
|
|
// 1
|
|
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);
|
|
// 2
|
|
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);
|
|
}
|
|
|
|
public void setColor(Color color) {
|
|
this.colorRollers = color;
|
|
}
|
|
}
|