58 lines
1.7 KiB
Java
58 lines
1.7 KiB
Java
|
import javax.swing.*;
|
||
|
import java.awt.*;
|
||
|
|
||
|
public class DrawningDoor {
|
||
|
JPanel DoubleDeckerBusPanel;
|
||
|
private DoorNumberType DoorNumberType;
|
||
|
private Color blackColor;
|
||
|
private int Width;
|
||
|
private int Height;
|
||
|
public int CurX;
|
||
|
public int CurY;
|
||
|
|
||
|
public boolean Init(int width, int height, int curX, int curY, JPanel doubleDeckerBusPanel) {
|
||
|
Width = width;
|
||
|
Height = height;
|
||
|
CurX = curX;
|
||
|
CurY = curY;
|
||
|
blackColor = Color.BLACK;
|
||
|
DoubleDeckerBusPanel = doubleDeckerBusPanel;
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
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 DrawDoors() {
|
||
|
Graphics2D g2d = (Graphics2D) DoubleDeckerBusPanel.getGraphics();
|
||
|
g2d.setColor(blackColor);
|
||
|
g2d.fillRect(CurX + 55, CurY + 65, 10, 15);
|
||
|
g2d.fillRect(CurX + 70, CurY + 65, 10, 15);
|
||
|
|
||
|
if (DoorNumberType() == DoorNumberType.Three || DoorNumberType() == DoorNumberType.Four || DoorNumberType() == DoorNumberType.Five) {
|
||
|
g2d.fillRect(CurX + 85, CurY + 65, 10, 15);
|
||
|
}
|
||
|
|
||
|
if (DoorNumberType() == DoorNumberType.Four || DoorNumberType() == DoorNumberType.Five) {
|
||
|
g2d.fillRect(CurX + 100, CurY + 65, 10, 15);
|
||
|
}
|
||
|
|
||
|
if (DoorNumberType() == DoorNumberType.Five) {
|
||
|
g2d.fillRect(CurX + 115, CurY + 65, 10, 15);
|
||
|
}
|
||
|
}
|
||
|
}
|