PIbd-21_Zhirnova_A_E_Double.../DoubleDeckerBus/DrawningObjects/DrawningDoor.java

70 lines
1.9 KiB
Java
Raw Permalink Normal View History

package DoubleDeckerBus.DrawningObjects;
import DoubleDeckerBus.DoorNumberType;
import javax.swing.*;
import java.awt.*;
public class DrawningDoor implements IDraw {
JPanel BusPanel;
private DoorNumberType DoorNumberType;
private Color blackColor;
private int Width;
private int Height;
public int CurX;
public int CurY;
public DrawningDoor(int width, int height, int curX, int curY, JPanel busPanel) {
Width = width;
Height = height;
CurX = curX;
CurY = curY;
blackColor = Color.BLACK;
BusPanel = busPanel;
}
public void ChangeX(int x){
CurX = x;
}
public void ChangeY(int y){
CurY = y;
}
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;
}
public void DrawDoor(int x, int y){
Graphics2D g2d = (Graphics2D)BusPanel.getGraphics();
g2d.fillRect(x, y, 10, 15);
}
public void DrawDoors() {
Graphics2D g2d = (Graphics2D) BusPanel.getGraphics();
g2d.setColor(blackColor);
DrawDoor(CurX + 55, CurY + 65);
DrawDoor(CurX + 70, CurY + 65);
if (DoorNumberType() == DoorNumberType.Three || DoorNumberType() == DoorNumberType.Four || DoorNumberType() == DoorNumberType.Five) {
DrawDoor(CurX + 85, CurY + 65);
}
if (DoorNumberType() == DoorNumberType.Four || DoorNumberType() == DoorNumberType.Five) {
DrawDoor(CurX + 100, CurY + 65);
}
if (DoorNumberType() == DoorNumberType.Five) {
DrawDoor(CurX + 115, CurY + 65);
}
}
}