PIbd-23_Yunusov.N.N_Trolley.../src/DrawingTrolleybus.java

42 lines
2.1 KiB
Java
Raw Normal View History

2023-10-29 02:06:47 +04:00
import java.awt.*;
2023-11-04 02:32:04 +04:00
2023-11-04 02:04:16 +04:00
public class DrawingTrolleybus extends DrawingBus{
public DrawingTrolleybus(int speed, double weight, Color bodyColor, Color additionalColor,
boolean roga, boolean battery, int width, int height, int doorsNumber, int doorsType)
2023-10-29 02:06:47 +04:00
{
2023-11-04 02:04:16 +04:00
super(speed, weight, bodyColor, width, height, doorsNumber,doorsType);
if (entityBus != null)
entityBus = new EntityTrolleybus(speed, weight, bodyColor, additionalColor, roga, battery);
2023-10-29 02:06:47 +04:00
}
2023-12-07 20:36:56 +04:00
public void setAdditionalColor(Color color){
((EntityTrolleybus)entityBus).additionalColor = color;
}
2023-10-29 02:06:47 +04:00
public void drawTransport(Graphics2D graphics2D) {
2023-11-04 02:04:16 +04:00
if (!(entityBus instanceof EntityTrolleybus))
2023-10-29 02:06:47 +04:00
return;
2023-11-04 02:04:16 +04:00
EntityTrolleybus entityTrolleybus = (EntityTrolleybus) entityBus;
2023-10-29 02:06:47 +04:00
BasicStroke pen = new BasicStroke(2);
graphics2D.setStroke(pen);
Color additionalColor = entityTrolleybus.getAdditionalColor();
2023-11-04 02:04:16 +04:00
super.drawTransport(graphics2D);
2023-10-29 02:06:47 +04:00
//рога
graphics2D.setPaint(Color.BLACK);
if (entityTrolleybus.getRoga()) {
graphics2D.setPaint(Color.BLACK);
graphics2D.drawLine(_startPosX + 186, _startPosY + 31, _startPosX + 86, _startPosY + 1);
graphics2D.drawLine(_startPosX + 86, _startPosY + 1, _startPosX + 126, _startPosY + 31);
graphics2D.drawLine(_startPosX + 146, _startPosY + 31, _startPosX + 46, _startPosY + 1);
graphics2D.drawLine(_startPosX + 46, _startPosY + 1, _startPosX + 86, _startPosY + 31);
}
//батарея
if (entityTrolleybus.getBattery()) {
graphics2D.setPaint(additionalColor);
graphics2D.fillRect(_startPosX + 176, _startPosY + 101, 15, 20);
graphics2D.setPaint(Color.YELLOW);
graphics2D.drawLine(_startPosX + 183, _startPosY + 103, _startPosX + 178, _startPosY + 111);
graphics2D.drawLine(_startPosX + 178, _startPosY + 111, _startPosX + 189, _startPosY + 111);
graphics2D.drawLine(_startPosX + 189, _startPosY + 111, _startPosX + 183, _startPosY + 119);
}
}
2023-12-07 20:36:56 +04:00
}