57 lines
2.4 KiB
Java
57 lines
2.4 KiB
Java
|
package Trolleybus;
|
||
|
|
||
|
import java.awt.*;
|
||
|
public class DrawingDoors {
|
||
|
private CntOfDoors _cntOfDoors;
|
||
|
public void SetCntOfDoors(int cnt) {
|
||
|
if (cnt < 3 || cnt > 5) {
|
||
|
cnt = 3;
|
||
|
}
|
||
|
//Проход по перечислению
|
||
|
for (CntOfDoors temp : CntOfDoors.values()) {
|
||
|
if (temp.getCnt() == cnt) {
|
||
|
_cntOfDoors = temp;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public void DrawDoors(Graphics2D g, Color BodyColor, int _startPosX, int _startPosY) {
|
||
|
switch (_cntOfDoors.getCnt())
|
||
|
{
|
||
|
case 3:
|
||
|
g.setColor(BodyColor);
|
||
|
g.drawRect(_startPosX + 2, _startPosY + 50, 16, 30);
|
||
|
g.drawRect(_startPosX + 67, _startPosY + 50, 16, 30);
|
||
|
g.drawRect(_startPosX + 132, _startPosY + 50, 16, 30);
|
||
|
g.setColor(Color.CYAN);
|
||
|
g.drawOval(_startPosX + 22, _startPosY + 35, 16, 24);
|
||
|
g.drawOval(_startPosX + 47, _startPosY + 35, 16, 24);
|
||
|
g.drawOval(_startPosX + 87, _startPosY + 35, 16, 24);
|
||
|
g.drawOval(_startPosX + 112, _startPosY + 35, 16, 24);
|
||
|
break;
|
||
|
case 4:
|
||
|
g.setColor(BodyColor);
|
||
|
g.drawRect(_startPosX + 2, _startPosY + 50, 16, 30);
|
||
|
g.drawRect(_startPosX + 48, _startPosY + 50, 16, 30);
|
||
|
g.drawRect(_startPosX + 86, _startPosY + 50, 16, 30);
|
||
|
g.drawRect(_startPosX + 132, _startPosY + 50, 16, 30);
|
||
|
g.setColor(Color.CYAN);
|
||
|
g.drawOval(_startPosX + 25, _startPosY + 35, 16, 24);
|
||
|
g.drawOval(_startPosX + 67, _startPosY + 35, 16, 24);
|
||
|
g.drawOval(_startPosX + 109, _startPosY + 35, 16, 24);
|
||
|
break;
|
||
|
case 5:
|
||
|
g.setColor(BodyColor);
|
||
|
g.drawRect(_startPosX + 2, _startPosY + 50, 16, 30);
|
||
|
g.drawRect(_startPosX + 48, _startPosY + 50, 16, 30);
|
||
|
g.drawRect(_startPosX + 67, _startPosY + 50, 16, 30);
|
||
|
g.drawRect(_startPosX + 86, _startPosY + 50, 16, 30);
|
||
|
g.drawRect(_startPosX + 132, _startPosY + 50, 16, 30);
|
||
|
g.setColor(Color.CYAN);
|
||
|
g.drawOval(_startPosX + 25, _startPosY + 35, 16, 24);
|
||
|
g.drawOval(_startPosX + 109, _startPosY + 35, 16, 24);
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|