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

53 lines
1.8 KiB
Java
Raw Permalink Normal View History

package DoubleDeckerBus.DrawningObjects;
import DoubleDeckerBus.Entities.EntityDoubleDeckerBus;
import javax.swing.*;
import java.awt.*;
public class DrawningDoubleDeckerBus extends DrawningBus {
public DrawningDoubleDeckerBus(int speed, double weight, Color bodyColor, Color additionalColor, int doorNumber,
int width, int height, boolean secondFloor, boolean tailpipe, JPanel busPanel) {
super(speed, weight, bodyColor, width, height, busPanel);
if (EntityBus != null) {
EntityBus = new EntityDoubleDeckerBus(speed, weight, bodyColor, additionalColor, doorNumber, secondFloor, tailpipe);
}
}
@Override
public void DrawTransport() {
if (!(EntityBus instanceof EntityDoubleDeckerBus)) {
return;
}
super.DrawTransport();
EntityDoubleDeckerBus _bus = (EntityDoubleDeckerBus) EntityBus;
Graphics2D g2d = (Graphics2D)BusPanel.getGraphics();
// второй этаж
if (_bus.SecondFloor())
{
g2d.setColor(_bus.BodyColor());
// Границы второго этажа автобуса
g2d.setColor(_bus.AdditionalColor());
g2d.fillRect(_startPosX + 40, _startPosY, 120, 40);
// Окна второго этажа
g2d.setColor(Color.BLUE);
g2d.setColor(Color.blue);
g2d.fillOval(_startPosX + 50, _startPosY +10,20, 20);
g2d.fillOval(_startPosX + 75, _startPosY +10, 20, 20);
g2d.fillOval(_startPosX + 100, _startPosY +10,20, 20);
g2d.fillOval(_startPosX + 125, _startPosY +10,20,20);
}
if (_bus.Tailpipe())
{
g2d.setColor(_bus.AdditionalColor());
g2d.fillRect(_startPosX, _startPosY + 65, 40, 15);
}
}
}