some fixes

This commit is contained in:
rozenkranzz 2025-02-08 22:30:07 +04:00
parent d00844dfac
commit 2996acbea2
5 changed files with 65 additions and 43 deletions

View File

@ -38,22 +38,22 @@ public class CircularDeckDrawing implements IAdditionalElements {
private void drawLowerDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) { private void drawLowerDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) {
g.setColor(fillColor); g.setColor(fillColor);
g.fillOval(x + 30, y + 20, 100, 100); g.fillOval(x + 30, y + 15, 100, 20);
g.setColor(borderColor); g.setColor(borderColor);
g.drawOval(x + 30, y + 20, 100, 100); g.drawOval(x + 30, y + 15, 100, 20);
} }
private void drawMiddleDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) { private void drawMiddleDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) {
g.setColor(fillColor); g.setColor(fillColor);
g.fillOval(x + 70, y + 10, 50, 50); g.fillOval(x + 70, y + 10, 50, 20);
g.setColor(borderColor); g.setColor(borderColor);
g.drawOval(x + 70, y + 10, 50, 50); g.drawOval(x + 70, y + 10, 50, 20);
} }
private void drawUpperDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) { private void drawUpperDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) {
g.setColor(fillColor); g.setColor(fillColor);
g.fillOval(x + 85, y, 25, 25); g.fillOval(x + 85, y, 25, 20);
g.setColor(borderColor); g.setColor(borderColor);
g.drawOval(x + 85, y, 25, 25); g.drawOval(x + 85, y, 25, 20);
} }
} }

View File

@ -14,6 +14,7 @@ public class DrawingBaseLiner {
protected Integer startPosY; protected Integer startPosY;
private int drawingLinerWidth; private int drawingLinerWidth;
private int drawingLinerHeight; private int drawingLinerHeight;
private IAdditionalElements deck;
private DrawingBaseLiner() { private DrawingBaseLiner() {
this.drawingLinerWidth = 140; this.drawingLinerWidth = 140;
@ -103,19 +104,30 @@ public class DrawingBaseLiner {
int x = this.startPosX; int x = this.startPosX;
int y = this.startPosY; int y = this.startPosY;
Graphics2D g2d = (Graphics2D)g; Graphics2D g2d = (Graphics2D)g;
Color bodyColor = this.baseLiner.getPrimaryColor();
Color deckColor = Color.WHITE; Color deckColor = Color.WHITE;
Color borderColor = Color.BLACK; Color borderColor = Color.BLACK;
this.drawLinerBase(g);
this.deck = new SquareDeckDrawing();
this.deck.setNumericalValue(1);
this.deck.drawAdditionalElement(x, y - 20, borderColor, deckColor, g2d);
// g2d.setColor(deckColor);
// g2d.fillRect(x + 30, y, 100, 10);
// g2d.setColor(borderColor);
// g2d.drawRect(x + 30, y, 100, 10);
}
}
public void drawLinerBase(Graphics g) {
int x = this.startPosX;
int y = this.startPosY;
Graphics2D g2d = (Graphics2D)g;
Color bodyColor = this.baseLiner.getPrimaryColor();
Color borderColor = Color.BLACK;
Point[] hullPoints = new Point[]{new Point(x + 20, y + 40), new Point(x + 120, y + 40), new Point(x + 140, y + 10), new Point(x, y + 10)}; Point[] hullPoints = new Point[]{new Point(x + 20, y + 40), new Point(x + 120, y + 40), new Point(x + 140, y + 10), new Point(x, y + 10)};
g2d.setColor(bodyColor); g2d.setColor(bodyColor);
g2d.fillPolygon(new int[]{hullPoints[0].x, hullPoints[1].x, hullPoints[2].x, hullPoints[3].x}, new int[]{hullPoints[0].y, hullPoints[1].y, hullPoints[2].y, hullPoints[3].y}, 4); g2d.fillPolygon(new int[]{hullPoints[0].x, hullPoints[1].x, hullPoints[2].x, hullPoints[3].x}, new int[]{hullPoints[0].y, hullPoints[1].y, hullPoints[2].y, hullPoints[3].y}, 4);
g2d.setColor(borderColor); g2d.setColor(borderColor);
g2d.drawPolygon(new int[]{hullPoints[0].x, hullPoints[1].x, hullPoints[2].x, hullPoints[3].x}, new int[]{hullPoints[0].y, hullPoints[1].y, hullPoints[2].y, hullPoints[3].y}, 4); g2d.drawPolygon(new int[]{hullPoints[0].x, hullPoints[1].x, hullPoints[2].x, hullPoints[3].x}, new int[]{hullPoints[0].y, hullPoints[1].y, hullPoints[2].y, hullPoints[3].y}, 4);
g2d.setColor(deckColor);
g2d.fillRect(x + 30, y, 100, 10);
g2d.setColor(borderColor);
g2d.drawRect(x + 30, y, 100, 10);
}
} }
public BaseLinerEntity getBaseLiner() { public BaseLinerEntity getBaseLiner() {

View File

@ -9,7 +9,9 @@ import projectliner.Entities.LinerEntityType;
public class DrawingLiner extends DrawingBaseLiner { public class DrawingLiner extends DrawingBaseLiner {
private IAdditionalElements deck; private IAdditionalElements deck;
public DrawingLiner(int speed, double weight, Color primaryColor, Color secondaryColor, LinerEntityType type, int capacity, int maxPassengers, boolean hasExtraDeck, boolean hasPool) { public DrawingLiner(int speed, double weight, Color primaryColor,
Color secondaryColor, LinerEntityType type, int capacity,
int maxPassengers, boolean hasExtraDeck, boolean hasPool) {
super(140, 60); super(140, 60);
this.baseLiner = new LinerEntity(speed, weight, primaryColor, secondaryColor, type, capacity, maxPassengers, hasExtraDeck, hasPool); this.baseLiner = new LinerEntity(speed, weight, primaryColor, secondaryColor, type, capacity, maxPassengers, hasExtraDeck, hasPool);
} }
@ -34,9 +36,9 @@ public class DrawingLiner extends DrawingBaseLiner {
int y = this.startPosY; int y = this.startPosY;
Graphics2D g2d = (Graphics2D)g; Graphics2D g2d = (Graphics2D)g;
this.startPosY = this.startPosY + 20; this.startPosY = this.startPosY + 20;
super.drawTransport(g); super.drawLinerBase(g);
this.startPosY = this.startPosY - 20; this.startPosY = this.startPosY - 20;
LinerEntity linerEntity = (LinerEntity)this.baseLiner; if (this.baseLiner instanceof LinerEntity linerEntity) {
Color deckColor = linerEntity.getSecondaryColor(); Color deckColor = linerEntity.getSecondaryColor();
Color borderColor = Color.BLACK; Color borderColor = Color.BLACK;
this.deck.drawAdditionalElement(x, y, borderColor, deckColor, g); this.deck.drawAdditionalElement(x, y, borderColor, deckColor, g);
@ -46,7 +48,7 @@ public class DrawingLiner extends DrawingBaseLiner {
g2d.setColor(Color.BLACK); g2d.setColor(Color.BLACK);
g2d.drawOval(x + 35, y + 15, 30, 10); g2d.drawOval(x + 35, y + 15, 30, 10);
} }
}
} }
} }
} }

View File

@ -37,8 +37,8 @@ public class TriangularDeckDrawing implements IAdditionalElements {
} }
private void drawLowerDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) { private void drawLowerDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) {
int[] xPoints = new int[]{x + 30, x + 80, x - 20}; int[] xPoints = new int[]{x + 130, x + 130, x};
int[] yPoints = new int[]{y + 20, y + 120, y + 120}; int[] yPoints = new int[]{y + 15, y + 30, y + 25};
g.setColor(fillColor); g.setColor(fillColor);
g.fillPolygon(xPoints, yPoints, 3); g.fillPolygon(xPoints, yPoints, 3);
g.setColor(borderColor); g.setColor(borderColor);
@ -46,8 +46,8 @@ public class TriangularDeckDrawing implements IAdditionalElements {
} }
private void drawMiddleDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) { private void drawMiddleDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) {
int[] xPoints = new int[]{x + 70, x + 95, x + 45}; int[] xPoints = new int[]{x + 120, x + 120, x + 60};
int[] yPoints = new int[]{y + 10, y + 60, y + 60}; int[] yPoints = new int[]{y + 10, y + 20, y + 15};
g.setColor(fillColor); g.setColor(fillColor);
g.fillPolygon(xPoints, yPoints, 3); g.fillPolygon(xPoints, yPoints, 3);
g.setColor(borderColor); g.setColor(borderColor);
@ -55,8 +55,8 @@ public class TriangularDeckDrawing implements IAdditionalElements {
} }
private void drawUpperDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) { private void drawUpperDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) {
int[] xPoints = new int[]{x + 85, x + 97, x + 73}; int[] xPoints = new int[]{x + 110, x + 110, x + 80};
int[] yPoints = new int[]{y, y + 25, y + 25}; int[] yPoints = new int[]{y + 5, y + 15, y + 10};
g.setColor(fillColor); g.setColor(fillColor);
g.fillPolygon(xPoints, yPoints, 3); g.fillPolygon(xPoints, yPoints, 3);
g.setColor(borderColor); g.setColor(borderColor);

View File

@ -178,18 +178,26 @@ public class FormLiner extends JFrame {
Random random = new Random(); Random random = new Random();
switch (type) { switch (type) {
case "Liner": case "Liner":
this.drawingLiner = new DrawingLiner(random.nextInt(200) + 100, (double)(random.nextInt(2000) + 1000), new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)), new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)), LinerEntityType.CARGO, random.nextInt(9000) + 1000, random.nextInt(90) + 10, random.nextBoolean(), random.nextBoolean()); this.drawingLiner = new DrawingLiner(random.nextInt(200) + 100,
DrawingLiner liner = (DrawingLiner)this.drawingLiner; (double)(random.nextInt(2000) + 1000),
new Color(random.nextInt(256), random.nextInt(256),
random.nextInt(256)), new Color(random.nextInt(256),
random.nextInt(256), random.nextInt(256)), LinerEntityType.CARGO,
random.nextInt(9000) + 1000, random.nextInt(90) + 10,
random.nextBoolean(), random.nextBoolean());
if (this.drawingLiner instanceof DrawingLiner liner) {
if (this.comboBoxDeckForm.getSelectedItem() != null) { if (this.comboBoxDeckForm.getSelectedItem() != null) {
liner.setDeckForm((String)this.comboBoxDeckForm.getSelectedItem()); liner.setDeckForm((String) this.comboBoxDeckForm.getSelectedItem());
} else { } else {
liner.setDeckForm("Square Deck"); liner.setDeckForm("Square Deck");
} }
liner.setDeckNum(this.numberOfDecks); liner.setDeckNum(this.numberOfDecks);
}
break; break;
case "Base Liner": case "Base Liner":
this.drawingLiner = new DrawingBaseLiner(random.nextInt(200) + 100, (double)(random.nextInt(2000) + 1000), new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256))); this.drawingLiner = new DrawingBaseLiner(random.nextInt(200) + 100,
(double)(random.nextInt(2000) + 1000), new Color(random.nextInt(256),
random.nextInt(256), random.nextInt(256)));
} }
this.drawingLiner.setPictureSize(this.pictureBoxLiner.getWidth(), this.pictureBoxLiner.getHeight()); this.drawingLiner.setPictureSize(this.pictureBoxLiner.getWidth(), this.pictureBoxLiner.getHeight());