PIbd-23-Radaev-A.V.-Catamar.../DrawningOars.java

89 lines
3.2 KiB
Java
Raw Normal View History

2023-12-11 14:47:27 +04:00
2023-12-01 20:37:58 +04:00
import java.awt.*;
2023-12-10 11:59:44 +04:00
public class DrawningOars implements IDraw {
2023-12-01 20:37:58 +04:00
private NumberType OarsNumb;
2023-12-10 11:59:44 +04:00
public int Cont;
2023-12-01 20:37:58 +04:00
public int OarPosX, OarPosY;
private Color OarsColor;
// vesla Oars
2023-12-10 11:59:44 +04:00
public DrawningOars(int oarPosX, int oarPosY, Color oarsColor) {
2023-12-01 20:37:58 +04:00
OarPosX = oarPosX;
OarPosY = oarPosY;
OarsColor = oarsColor;
}
2023-12-10 11:59:44 +04:00
public void ChangeOarsNumb(int x) {
if (x <= 1)
2023-12-01 20:37:58 +04:00
OarsNumb = NumberType.One;
2023-12-10 11:59:44 +04:00
if (x == 2)
2023-12-01 20:37:58 +04:00
OarsNumb = NumberType.Two;
2023-12-10 11:59:44 +04:00
if (x >= 3)
2023-12-01 20:37:58 +04:00
OarsNumb = NumberType.Three;
}
2023-12-10 11:59:44 +04:00
public void ChangeX(int x) {
OarPosX = x;
}
public void ChangeY(int y) {
OarPosY = y;
}
public NumberType OarsNumb() {
2023-12-01 20:37:58 +04:00
return OarsNumb;
}
2023-12-10 11:59:44 +04:00
public void DrawOars(Graphics2D g2d) {
2023-12-01 20:37:58 +04:00
g2d.setColor(OarsColor);
int ind = 0;
// 1 veslo
2023-12-10 11:59:44 +04:00
int[] x_lop1 = { OarPosX + ind, OarPosX + 15 + ind, OarPosX + 25 + ind, OarPosX + 10 + ind };
int[] y_lop1 = { OarPosY + 5, OarPosY, OarPosY + 10, OarPosY + 15 };
int[] x_oar1 = { OarPosX + 10 + ind, OarPosX + 20 + ind, OarPosX + 36 + ind, OarPosX + 26 + ind };
int[] y_oar1 = { OarPosY + 10, OarPosY + 10, OarPosY + 26, OarPosY + 26 };
g2d.fillPolygon(x_oar1, y_oar1, 4);
2023-12-01 20:37:58 +04:00
g2d.setColor(Color.BLACK);
2023-12-10 11:59:44 +04:00
g2d.drawPolygon(x_oar1, y_oar1, 4);
2023-12-01 20:37:58 +04:00
g2d.setColor(OarsColor);
2023-12-10 11:59:44 +04:00
g2d.fillPolygon(x_lop1, y_lop1, 4);
2023-12-01 20:37:58 +04:00
g2d.setColor(Color.BLACK);
2023-12-10 11:59:44 +04:00
g2d.drawPolygon(x_lop1, y_lop1, 4);
// 2 vesla
if (OarsNumb == NumberType.Two || OarsNumb == NumberType.Three) {
2023-12-01 20:37:58 +04:00
ind = 30;
g2d.setColor(OarsColor);
2023-12-10 11:59:44 +04:00
int[] x_lop2 = { OarPosX + ind, OarPosX + 15 + ind, OarPosX + 25 + ind, OarPosX + 10 + ind };
int[] y_lop2 = { OarPosY + 5, OarPosY, OarPosY + 10, OarPosY + 15 };
int[] x_oar2 = { OarPosX + 10 + ind, OarPosX + 20 + ind, OarPosX + 36 + ind, OarPosX + 26 + ind };
int[] y_oar2 = { OarPosY + 10, OarPosY + 10, OarPosY + 26, OarPosY + 26 };
g2d.fillPolygon(x_oar2, y_oar2, 4);
2023-12-01 20:37:58 +04:00
g2d.setColor(Color.BLACK);
2023-12-10 11:59:44 +04:00
g2d.drawPolygon(x_oar2, y_oar2, 4);
2023-12-01 20:37:58 +04:00
g2d.setColor(OarsColor);
2023-12-10 11:59:44 +04:00
g2d.fillPolygon(x_lop2, y_lop2, 4);
2023-12-01 20:37:58 +04:00
g2d.setColor(Color.BLACK);
2023-12-10 11:59:44 +04:00
g2d.drawPolygon(x_lop2, y_lop2, 4);
2023-12-01 20:37:58 +04:00
}
2023-12-10 11:59:44 +04:00
// 3 vesla
if (OarsNumb == NumberType.Three) {
2023-12-01 20:37:58 +04:00
ind = 0;
g2d.setColor(OarsColor);
2023-12-10 11:59:44 +04:00
int[] x_oar3 = { OarPosX + 36 + ind, OarPosX + 26 + ind, OarPosX + 10 + ind, OarPosX + 20 + ind };
int[] y_oar3 = { OarPosY + 55, OarPosY + 55, OarPosY + 71, OarPosY + 71 };
int[] y_lop3 = { OarPosY + 71, OarPosY + 80, OarPosY + 76, OarPosY + 67 };
int[] x_lop3 = { OarPosX + 24 + ind, OarPosX + 16 + ind, OarPosX + 3 + ind, OarPosX + 10 + ind };
g2d.fillPolygon(x_oar3, y_oar3, 4);
2023-12-01 20:37:58 +04:00
g2d.setColor(Color.BLACK);
2023-12-10 11:59:44 +04:00
g2d.drawPolygon(x_oar3, y_oar3, 4);
2023-12-01 20:37:58 +04:00
g2d.setColor(OarsColor);
2023-12-10 11:59:44 +04:00
g2d.fillPolygon(x_lop3, y_lop3, 4);
2023-12-01 20:37:58 +04:00
g2d.setColor(Color.BLACK);
2023-12-10 11:59:44 +04:00
g2d.drawPolygon(x_lop3, y_lop3, 4);
2023-12-01 20:37:58 +04:00
}
}
}