PIbd21.LyovushkinaA.A.Conta.../DrawingContainerShip.java

76 lines
3.6 KiB
Java
Raw Normal View History

2023-09-25 18:40:25 +04:00
import java.awt.*;
2023-10-07 21:42:37 +04:00
public class DrawingContainerShip extends DrawingShip{
2023-10-09 23:11:13 +04:00
2023-09-25 18:40:25 +04:00
private DrawingDecks drawingDecks;
2023-10-09 23:11:13 +04:00
private DrawingDecksTrapez drawingDecksTrapez;
private DrawingDecksRect drawingDecksRect;
2023-10-07 21:42:37 +04:00
public DrawingContainerShip(int speed, double weight, Color bodyColor, Color
2023-10-09 23:11:13 +04:00
additionalColor, boolean crane, boolean containers,int deck, int deckType, int width, int height)
{
super(speed, weight, bodyColor,width, height, 110, 65);
2023-10-07 21:42:37 +04:00
if (EntityShip != null)
2023-09-25 18:40:25 +04:00
{
2023-10-07 21:42:37 +04:00
EntityShip = new EntityContainerShip(speed, weight, bodyColor,
2023-10-09 23:11:13 +04:00
additionalColor, crane, containers,deck, deckType);
drawingDecks = new DrawingDecks();
drawingDecksTrapez = new DrawingDecksTrapez();
drawingDecksRect = new DrawingDecksRect();
drawingDecksRect.setNumDecks(deck);
drawingDecksTrapez.setNumDecks(deck);
drawingDecks.setNumDecks(deck);
2023-09-25 18:40:25 +04:00
}
2023-10-07 21:42:37 +04:00
}
2023-10-09 23:11:13 +04:00
@Override
2023-09-25 18:40:25 +04:00
public void DrawShip(Graphics2D g)
{
2023-10-09 23:11:13 +04:00
super.DrawShip(g);
if (EntityShip == null)
{
return;
}
2023-09-25 18:40:25 +04:00
//контейнеры
2023-10-09 23:11:13 +04:00
if (((EntityContainerShip)EntityShip).Conteiners)
2023-09-25 18:40:25 +04:00
{
2023-10-09 23:11:13 +04:00
g.setPaint(((EntityContainerShip)EntityShip).AdditionalColor);
2023-09-25 18:40:25 +04:00
g.fillRect(_startPosX + 50, _startPosY + 55, 35, 10);
g.fillRect(_startPosX + 85, _startPosY + 55, 20, 10);
g.fillRect(_startPosX + 105, _startPosY + 50, 15, 15);
g.fillRect(_startPosX + 50, _startPosY + 45, 15, 10);
g.fillRect(_startPosX + 65, _startPosY + 45, 55, 5);
g.fillRect(_startPosX + 65, _startPosY + 50, 40, 5);
g.setPaint(Color.BLACK);
g.drawRect(_startPosX + 50, _startPosY + 55, 35, 10);
g.drawRect(_startPosX + 85, _startPosY + 55, 20, 10);
g.drawRect(_startPosX + 105, _startPosY + 50, 15, 15);
g.drawRect(_startPosX + 50, _startPosY + 45, 15, 10);
g.drawRect(_startPosX + 65, _startPosY + 45, 55, 5);
g.drawRect(_startPosX + 65, _startPosY + 50, 40, 5);
}
//кран
2023-10-09 23:11:13 +04:00
if (((EntityContainerShip)EntityShip).Crane)
2023-09-25 18:40:25 +04:00
{
2023-10-09 23:11:13 +04:00
g.setPaint(((EntityContainerShip)EntityShip).AdditionalColor);
2023-09-25 18:40:25 +04:00
g.fillRect(_startPosX + 43, _startPosY+20, 5, 45);
g.fillRect(_startPosX + 47, _startPosY + 30, 20, 3);
g.setPaint(Color.BLACK);
g.drawRect(_startPosX + 43, _startPosY+20, 5, 45);
g.drawRect(_startPosX + 47, _startPosY + 30, 20, 3);
g.drawLine(_startPosX + 47, _startPosY+20, _startPosX + 67, _startPosY + 30);
g.drawLine(_startPosX + 67, _startPosY + 33, _startPosX + 67, _startPosY + 45);
}
2023-10-09 23:11:13 +04:00
if(((EntityContainerShip)EntityShip).DeckType == 1){
drawingDecks.DrawDeck(_startPosX, _startPosY,EntityShip.BodyColor ,g);
}
if(((EntityContainerShip)EntityShip).DeckType == 2){
drawingDecksTrapez.DrawDeck(_startPosX, _startPosY,EntityShip.BodyColor, g);
}
if(((EntityContainerShip)EntityShip).DeckType == 3){
drawingDecksRect.DrawDeck(_startPosX, _startPosY, EntityShip.BodyColor, g);
}
2023-09-25 18:40:25 +04:00
}
}