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

71 lines
1.9 KiB
Java

package DoubleDeckerBus.DrawningObjects;
import DoubleDeckerBus.DoorNumberType;
import javax.swing.*;
import java.awt.*;
public class DrawningDoorOval implements IDraw {
JPanel BusPanel;
private DoorNumberType DoorNumberType;
private Color blackColor;
private int Width;
private int Height;
public int CurX;
public int CurY;
public DrawningDoorOval(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.fillOval(x, y, 10, 20);
}
public void DrawDoors() {
Graphics2D g2d = (Graphics2D) BusPanel.getGraphics();
g2d.setColor(blackColor);
DrawDoor(CurX + 55, CurY + 60);
DrawDoor(CurX + 70, CurY + 60);
if (DoorNumberType() == DoorNumberType.Three || DoorNumberType() == DoorNumberType.Four || DoorNumberType() == DoorNumberType.Five) {
DrawDoor(CurX + 85, CurY + 60);
}
if (DoorNumberType() == DoorNumberType.Four || DoorNumberType() == DoorNumberType.Five) {
DrawDoor(CurX + 100, CurY + 60);
}
if (DoorNumberType() == DoorNumberType.Five) {
DrawDoor(CurX + 115, CurY + 60);
}
}
}