2023-12-04 16:53:15 +04:00
|
|
|
package DoubleDeckerBus.DrawningObjects;
|
|
|
|
|
|
|
|
import DoubleDeckerBus.DoorNumberType;
|
|
|
|
|
2023-12-01 11:48:37 +04:00
|
|
|
import javax.swing.*;
|
|
|
|
import java.awt.*;
|
|
|
|
|
2023-12-04 16:53:15 +04:00
|
|
|
public class DrawningDoorTriangle implements IDraw {
|
|
|
|
JPanel BusPanel;
|
|
|
|
private DoubleDeckerBus.DoorNumberType DoorNumberType;
|
2023-12-01 11:48:37 +04:00
|
|
|
private Color blackColor;
|
|
|
|
private int Width;
|
|
|
|
private int Height;
|
|
|
|
public int CurX;
|
|
|
|
public int CurY;
|
|
|
|
|
2023-12-04 16:53:15 +04:00
|
|
|
public DrawningDoorTriangle(int width, int height, int curX, int curY, JPanel busPanel) {
|
2023-12-01 11:48:37 +04:00
|
|
|
Width = width;
|
|
|
|
Height = height;
|
|
|
|
CurX = curX;
|
|
|
|
CurY = curY;
|
|
|
|
blackColor = Color.BLACK;
|
2023-12-04 16:53:15 +04:00
|
|
|
BusPanel = busPanel;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void ChangeX(int x){
|
|
|
|
CurX = x;
|
|
|
|
}
|
|
|
|
public void ChangeY(int y){
|
|
|
|
CurY = y;
|
2023-12-01 11:48:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void ChangeDoorsNumber(int x) {
|
|
|
|
if (x <= 3) {
|
|
|
|
DoorNumberType = DoorNumberType.Three;
|
|
|
|
}
|
|
|
|
if (x == 4) {
|
|
|
|
DoorNumberType = DoorNumberType.Four;
|
|
|
|
}
|
|
|
|
if (x >= 5) {
|
|
|
|
DoorNumberType = DoorNumberType.Five;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public DoorNumberType DoorNumberType() {
|
|
|
|
return DoorNumberType;
|
|
|
|
}
|
|
|
|
|
2023-12-04 16:53:15 +04:00
|
|
|
public void DrawDoor(int x, int y){
|
|
|
|
Graphics2D g2d = (Graphics2D)BusPanel.getGraphics();
|
|
|
|
int[] xPoints = {x, x + 5, x + 10};
|
|
|
|
int[] yPoints = {y + 20, y, y + 20};
|
|
|
|
g2d.fillPolygon(xPoints, yPoints, 3);
|
|
|
|
}
|
|
|
|
|
2023-12-01 11:48:37 +04:00
|
|
|
public void DrawDoors() {
|
2023-12-04 16:53:15 +04:00
|
|
|
Graphics2D g2d = (Graphics2D) BusPanel.getGraphics();
|
2023-12-01 11:48:37 +04:00
|
|
|
g2d.setColor(blackColor);
|
2023-12-04 16:53:15 +04:00
|
|
|
DrawDoor(CurX + 55, CurY + 60);
|
|
|
|
DrawDoor(CurX + 70, CurY + 60);
|
2023-12-01 11:48:37 +04:00
|
|
|
|
|
|
|
if (DoorNumberType() == DoorNumberType.Three || DoorNumberType() == DoorNumberType.Four || DoorNumberType() == DoorNumberType.Five) {
|
2023-12-04 16:53:15 +04:00
|
|
|
DrawDoor(CurX + 85, CurY + 60);
|
2023-12-01 11:48:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (DoorNumberType() == DoorNumberType.Four || DoorNumberType() == DoorNumberType.Five) {
|
2023-12-04 16:53:15 +04:00
|
|
|
DrawDoor(CurX + 100, CurY + 60);
|
2023-12-01 11:48:37 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (DoorNumberType() == DoorNumberType.Five) {
|
2023-12-04 16:53:15 +04:00
|
|
|
DrawDoor(CurX + 115, CurY + 60);
|
2023-12-01 11:48:37 +04:00
|
|
|
}
|
|
|
|
}
|
2023-12-04 16:53:15 +04:00
|
|
|
}
|