PIbd-23-Radaev-A.V.-Catamar.../DrawningOars.java
2023-12-10 11:59:44 +04:00

88 lines
3.2 KiB
Java

import java.awt.*;
public class DrawningOars implements IDraw {
private NumberType OarsNumb;
public int Cont;
public int OarPosX, OarPosY;
private Color OarsColor;
// vesla Oars
public DrawningOars(int oarPosX, int oarPosY, Color oarsColor) {
OarPosX = oarPosX;
OarPosY = oarPosY;
OarsColor = oarsColor;
}
public void ChangeOarsNumb(int x) {
if (x <= 1)
OarsNumb = NumberType.One;
if (x == 2)
OarsNumb = NumberType.Two;
if (x >= 3)
OarsNumb = NumberType.Three;
}
public void ChangeX(int x) {
OarPosX = x;
}
public void ChangeY(int y) {
OarPosY = y;
}
public NumberType OarsNumb() {
return OarsNumb;
}
public void DrawOars(Graphics2D g2d) {
g2d.setColor(OarsColor);
int ind = 0;
// 1 veslo
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);
g2d.setColor(Color.BLACK);
g2d.drawPolygon(x_oar1, y_oar1, 4);
g2d.setColor(OarsColor);
g2d.fillPolygon(x_lop1, y_lop1, 4);
g2d.setColor(Color.BLACK);
g2d.drawPolygon(x_lop1, y_lop1, 4);
// 2 vesla
if (OarsNumb == NumberType.Two || OarsNumb == NumberType.Three) {
ind = 30;
g2d.setColor(OarsColor);
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);
g2d.setColor(Color.BLACK);
g2d.drawPolygon(x_oar2, y_oar2, 4);
g2d.setColor(OarsColor);
g2d.fillPolygon(x_lop2, y_lop2, 4);
g2d.setColor(Color.BLACK);
g2d.drawPolygon(x_lop2, y_lop2, 4);
}
// 3 vesla
if (OarsNumb == NumberType.Three) {
ind = 0;
g2d.setColor(OarsColor);
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);
g2d.setColor(Color.BLACK);
g2d.drawPolygon(x_oar3, y_oar3, 4);
g2d.setColor(OarsColor);
g2d.fillPolygon(x_lop3, y_lop3, 4);
g2d.setColor(Color.BLACK);
g2d.drawPolygon(x_lop3, y_lop3, 4);
}
}
}