PIbd-21_Markov_D.P._Contain.../DrawingContainerShip.java

77 lines
4.6 KiB
Java
Raw Normal View History

2022-12-02 00:06:03 +04:00
import java.awt.*;
public class DrawingContainerShip extends DrawingShip
{
2022-12-08 20:41:31 +04:00
public DrawingContainerShip(int speed, float weight, Color bodyColor, Color dopColor, boolean crane, boolean containers)
2022-12-02 00:06:03 +04:00
{
super(speed,weight,bodyColor,130,45);
2022-12-08 20:41:31 +04:00
Ship = new EntityContainerShip(speed, weight, bodyColor, dopColor, crane, containers);
2022-12-08 21:14:01 +04:00
}
protected DrawingContainerShip(EntityShip ship,IAdditionalDrawingObject deck)
{
super(ship,deck);
Ship=ship;
2022-12-02 00:06:03 +04:00
}
@Override
public void DrawTransport(Graphics g) {
if (!(GetShip() instanceof EntityContainerShip containerShip))
{
return;
}
super.DrawTransport(g);
Graphics2D g2d = (Graphics2D) g;
Deck.DrawDeck(Ship.GetBodyColor(), g, _startPosX, _startPosY);
if (containerShip.GetContainers())
{
g2d.setPaint(containerShip.GetDopColor());
//Заливка контейнеров
int[] xValuesFirstContainer = {(int) _startPosX + 16, (int) _startPosX + 16 + 29, (int) _startPosX + 16 + 29, (int) _startPosX + 16};
int[] yValuesFirstContainer = {(int) _startPosY + 16, (int) _startPosY + 16, (int) _startPosY + 16 + 14, (int) _startPosY + 16 + 14};
g2d.fillPolygon(xValuesFirstContainer, yValuesFirstContainer, 4);
int[] xValuesSecondContainer = {(int) _startPosX + 56, (int) _startPosX + 56 + 29, (int) _startPosX + 56 + 29, (int) _startPosX + 56};
int[] yValuesSecondContainer = {(int) _startPosY + 16, (int) _startPosY + 16, (int) _startPosY + 16 + 14, (int) _startPosY + 16 + 14};
g2d.fillPolygon(xValuesSecondContainer, yValuesSecondContainer, 4);
//Заливка центральных полос на контейнерах
g2d.setPaint(Color.ORANGE);
int[] xValuesFirstContainerLine = {(int) _startPosX + 16, (int) _startPosX + 16 + 29, (int) _startPosX + 16 + 29, (int) _startPosX + 16};
int[] yValuesFirstContainerLine = {(int) _startPosY + 20, (int) _startPosY + 20, (int) _startPosY + 25, (int) _startPosY + 25};
g2d.fillPolygon(xValuesFirstContainerLine, yValuesFirstContainerLine, 4);
int[] xValuesSecondContainerLine = {(int) _startPosX + 56, (int) _startPosX + 56 + 29, (int) _startPosX + 56 + 29, (int) _startPosX + 56};
int[] yValuesSecondContainerLine = {(int) _startPosY + 20, (int) _startPosY + 20, (int) _startPosY + 25, (int) _startPosY + 25};
g2d.fillPolygon(xValuesSecondContainerLine, yValuesSecondContainerLine, 4);
//Границы контейнеров
g2d.setPaint(Color.BLACK);
g2d.drawPolygon(xValuesFirstContainer, yValuesFirstContainer, 4);
g2d.drawPolygon(xValuesSecondContainer, yValuesSecondContainer, 4);
}
if (containerShip.GetCrane())
{
int[] xValuesBorderTown = {(int) _startPosX + 45, (int) _startPosX + 55, (int) _startPosX + 55, (int) _startPosX + 45};
int[] yValuesBorderTown = {(int) _startPosY, (int) _startPosY, (int) _startPosY + 30, (int) _startPosY + 30};
g.drawPolygon(xValuesBorderTown, yValuesBorderTown, 4);
g.fillPolygon(xValuesBorderTown, yValuesBorderTown, 4);
//Граница заливки стрелы крана
int[] xValuesBorderCrane = {(int) _startPosX + 50, (int) _startPosX + 90, (int) _startPosX + 50};
int[] yValuesBorderCrane = {(int) _startPosY + 10, (int) _startPosY + 13, (int) _startPosY + 16};
g2d.fillPolygon(xValuesBorderCrane,yValuesBorderCrane,3);
//Трос и крепление
g2d.setColor(Color.BLACK);
g2d.drawLine((int)_startPosX + 90, (int)_startPosY + 14, (int)_startPosX + 90, (int)_startPosY + 40);
g2d.drawLine((int)_startPosX + 90, (int)_startPosY + 40, (int)_startPosX + 85, (int)_startPosY + 43);
g2d.drawLine((int)_startPosX + 90, (int)_startPosY + 40, (int)_startPosX + 90, (int)_startPosY + 45);
g2d.drawLine((int)_startPosX + 90, (int)_startPosY + 40, (int)_startPosX + 95, (int)_startPosY + 43);
//Граница стрелы крана
g2d.drawPolygon(xValuesBorderCrane, yValuesBorderCrane, 3);
}
g2d.setPaint(Ship.GetBodyColor());
int xValues[]={(int) _startPosX,(int) _startPosX + 100,(int) _startPosX + 80,(int) _startPosX + 20};
int yValues[]={(int) _startPosY + 30,(int) _startPosY + 30,(int) _startPosY + 60,(int) _startPosY + 60};
g2d.fillPolygon(xValues,yValues,4);
g2d.setPaint(Color.BLACK);
g2d.drawPolygon(xValues,yValues,4);
}
}