Лабораторная работа №2
This commit is contained in:
parent
7aa6219c78
commit
52c006a00a
@ -1,5 +1,5 @@
|
||||
package DrawingShip;
|
||||
import Entities.EntityContainerShip;
|
||||
import DiffDecks.DecksCount;
|
||||
import Entities.EntityContainerShip;
|
||||
|
||||
import java.awt.*;
|
||||
@ -9,28 +9,39 @@ public class DrawingContainerShip extends DrawingShip {
|
||||
EntityShip = new EntityContainerShip(speed, weight, bodycolor, additionalcolor, crane, container);
|
||||
SetAmountandTypeDecks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DrawTransport(Graphics2D g) {
|
||||
if (EntityShip == null || !(EntityShip instanceof EntityContainerShip containerShip) || _StartPosX == null || _StartPosY == null)
|
||||
return;
|
||||
int y = _StartPosY;
|
||||
|
||||
int originalStartPosY = _StartPosY;
|
||||
int containerOffsetY = 0;
|
||||
|
||||
if (containerShip.Crane) {
|
||||
int craneX = _StartPosX + drawingShipWidth - 40;
|
||||
int craneY = _StartPosY + drawingShipHeight - 90;
|
||||
//кран
|
||||
|
||||
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawLine(craneX + 10, craneY + 40, craneX + 10, craneY);
|
||||
g.drawLine(craneX + 10, craneY, craneX + 50, craneY);
|
||||
g.drawLine(craneX + 10, craneY, craneX + 50, craneY + 5);
|
||||
g.drawLine(craneX + 50, craneY, craneX + 50, craneY + 30);
|
||||
|
||||
// хваталка крана
|
||||
|
||||
g.drawLine(craneX + 40, craneY + 30, craneX + 60, craneY + 30);
|
||||
g.drawLine(craneX + 40, craneY + 30, craneX + 40, craneY + 35);
|
||||
g.drawLine(craneX + 60, craneY + 30, craneX + 60, craneY + 35);
|
||||
_StartPosY += 30;
|
||||
containerOffsetY += 30;
|
||||
}
|
||||
|
||||
|
||||
_StartPosY += containerOffsetY;
|
||||
super.DrawTransport(g);
|
||||
_StartPosY = originalStartPosY;
|
||||
|
||||
|
||||
int count_decks = 0;
|
||||
if (drawingDecks.getNumberOfDecks() != null) {
|
||||
switch (drawingDecks.getNumberOfDecks()) {
|
||||
@ -45,19 +56,27 @@ public class DrawingContainerShip extends DrawingShip {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (containerShip.Container) {
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawRect(_StartPosX + 70, _StartPosY + 15, 40, 15);
|
||||
g.setColor(containerShip.getAdditionalColor());
|
||||
g.fillRect(_StartPosX + 70, _StartPosY + 15, 40, 15);
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawRect(_StartPosX + 90, _StartPosY + 20, 40, 15);
|
||||
g.setColor(containerShip.getAdditionalColor());
|
||||
g.fillRect(_StartPosX + 90, _StartPosY + 20, 40, 15);
|
||||
|
||||
int containerY;
|
||||
if (count_decks == 0) {
|
||||
containerY = _StartPosY + 15;
|
||||
} else {
|
||||
containerY = _StartPosY + 15 + containerOffsetY;
|
||||
}
|
||||
|
||||
if (containerShip.Container) {
|
||||
// Draw containers
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawRect(_StartPosX + 40, containerY, 40, 15);
|
||||
g.setColor(containerShip.getAdditionalColor());
|
||||
g.fillRect(_StartPosX + 40, containerY, 40, 15);
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawRect(_StartPosX + 60, containerY + 5, 40, 15);
|
||||
g.setColor(containerShip.getAdditionalColor());
|
||||
g.fillRect(_StartPosX + 60, containerY + 5, 40, 15);
|
||||
}
|
||||
|
||||
if (containerShip.Crane) {
|
||||
_StartPosY -= 30;
|
||||
drawingShipHeight += 30;
|
||||
}
|
||||
}
|
||||
|
@ -119,6 +119,7 @@ public class DrawingShip extends JPanel {
|
||||
int y = _StartPosY;
|
||||
g.setColor(EntityShip.getBodyColor());
|
||||
if (drawingDecks.getNumberOfDecks() != null) {
|
||||
y += 30;
|
||||
switch (drawingDecks.getNumberOfDecks()) {
|
||||
case OneDeck:
|
||||
drawingDecks.DrawDecks(g, _StartPosX + 30, y, 80, 15, EntityShip.getBodyColor());
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user