PIbd-23_Minhasapov_R.H._Exc.../DrawningTrackedVehicle.java

73 lines
3.0 KiB
Java

import java.awt.*;
public class DrawningTrackedVehicle extends DrawningTracktor {
public DrawningTrackedVehicle(int speed, float weight, Color bodyColor, int countRollers, Color dopColor, boolean bucket, boolean supports){
super(speed, weight, bodyColor, countRollers, 130, 87);
Tracktor = new EntityTrackedVehicle(speed, weight, bodyColor, dopColor, bucket, supports);
}
public DrawningTrackedVehicle(EntityTrackedVehicle entity, IDrawningRollers rollers) {
super(entity, rollers);
}
@Override
public void DrawTransport(Graphics2D g){
if (!(Tracktor instanceof EntityTrackedVehicle trackedVehicle))
{
return;
}
Color pen;
Color dopBrush = trackedVehicle.getDopColor();
if (trackedVehicle.getBucket())
{
pen = trackedVehicle.getDopColor();
g.setStroke(new BasicStroke(5));
g.setColor(pen);
g.drawLine((int)_startPosX + 1, (int)_startPosY + 90, (int)_startPosX + 15, (int)_startPosY + 70);
g.drawLine((int)_startPosX + 15, (int)_startPosY + 72, (int)_startPosX + 15, (int)_startPosY + 50);
g.drawLine((int)_startPosX + 15, (int)_startPosY + 52, (int)_startPosX + 10, (int)_startPosY + 45);
g.drawLine((int)_startPosX + 15, (int)_startPosY + 60, (int)_startPosX + 40, (int)_startPosY + 50);
g.setStroke(new BasicStroke(1));
}
_startPosX += 20;
_startPosY += 5;
super.DrawTransport(g);
_startPosX -= 20;
_startPosY -= 5;
if (trackedVehicle.getSupports())
{
pen = Color.BLACK;
g.setColor(dopBrush);
g.fillRect((int)_startPosX + 100, (int)_startPosY + 50, 10, 42);
g.setColor(pen);
g.drawRect((int)_startPosX + 100, (int)_startPosY + 50, 10, 42);
g.setColor(dopBrush);
g.fillRect((int)_startPosX + 90, (int)_startPosY + 82, 30, 10);
g.setColor(pen);
g.drawRect((int)_startPosX + 90, (int)_startPosY + 82, 30, 10);
g.setColor(dopBrush);
g.fillRect((int)_startPosX + 45, (int)_startPosY + 50, 10, 42);
g.setColor(pen);
g.drawRect((int)_startPosX + 45, (int)_startPosY + 50, 10, 42);
g.setColor(dopBrush);
g.fillRect((int)_startPosX + 35, (int)_startPosY + 82, 30, 10);
g.setColor(pen);
g.drawRect((int)_startPosX + 35, (int)_startPosY + 82, 30, 10);
}
}
@Override
public void setColor(Color color) {
var tmp = (EntityTrackedVehicle) Tracktor;
Tracktor = new EntityTrackedVehicle(tmp.getSpeed(), tmp.getWeight(), color, tmp.getDopColor(), tmp.getBucket(), tmp.getSupports());
}
public void setDopColor(Color color) {
var tmp = (EntityTrackedVehicle) Tracktor;
Tracktor = new EntityTrackedVehicle(tmp.getSpeed(), tmp.getWeight(), tmp.getBodyColor(), color, tmp.getBucket(), tmp.getSupports());
}
}