diff --git a/Liner_Advanced/src/projectliner/Drawings/CircularDeckDrawing.java b/Liner_Advanced/src/projectliner/Drawings/CircularDeckDrawing.java index 4f8e5fb..651a967 100644 --- a/Liner_Advanced/src/projectliner/Drawings/CircularDeckDrawing.java +++ b/Liner_Advanced/src/projectliner/Drawings/CircularDeckDrawing.java @@ -38,22 +38,22 @@ public class CircularDeckDrawing implements IAdditionalElements { private void drawLowerDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) { g.setColor(fillColor); - g.fillOval(x + 30, y + 20, 100, 100); + g.fillOval(x + 30, y + 15, 100, 20); 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) { g.setColor(fillColor); - g.fillOval(x + 70, y + 10, 50, 50); + g.fillOval(x + 70, y + 10, 50, 20); 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) { g.setColor(fillColor); - g.fillOval(x + 85, y, 25, 25); + g.fillOval(x + 85, y, 25, 20); g.setColor(borderColor); - g.drawOval(x + 85, y, 25, 25); + g.drawOval(x + 85, y, 25, 20); } } diff --git a/Liner_Advanced/src/projectliner/Drawings/DrawingBaseLiner.java b/Liner_Advanced/src/projectliner/Drawings/DrawingBaseLiner.java index c6ab1ef..27e7c24 100644 --- a/Liner_Advanced/src/projectliner/Drawings/DrawingBaseLiner.java +++ b/Liner_Advanced/src/projectliner/Drawings/DrawingBaseLiner.java @@ -14,6 +14,7 @@ public class DrawingBaseLiner { protected Integer startPosY; private int drawingLinerWidth; private int drawingLinerHeight; + private IAdditionalElements deck; private DrawingBaseLiner() { this.drawingLinerWidth = 140; @@ -103,21 +104,32 @@ public class DrawingBaseLiner { int x = this.startPosX; int y = this.startPosY; Graphics2D g2d = (Graphics2D)g; - Color bodyColor = this.baseLiner.getPrimaryColor(); Color deckColor = Color.WHITE; 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)}; - 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.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.setColor(deckColor); - g2d.fillRect(x + 30, y, 100, 10); - g2d.setColor(borderColor); - g2d.drawRect(x + 30, y, 100, 10); + 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)}; + 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.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); + } + public BaseLinerEntity getBaseLiner() { return this.baseLiner; } diff --git a/Liner_Advanced/src/projectliner/Drawings/DrawingLiner.java b/Liner_Advanced/src/projectliner/Drawings/DrawingLiner.java index 3688d03..f11ad38 100644 --- a/Liner_Advanced/src/projectliner/Drawings/DrawingLiner.java +++ b/Liner_Advanced/src/projectliner/Drawings/DrawingLiner.java @@ -9,7 +9,9 @@ import projectliner.Entities.LinerEntityType; public class DrawingLiner extends DrawingBaseLiner { 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); this.baseLiner = new LinerEntity(speed, weight, primaryColor, secondaryColor, type, capacity, maxPassengers, hasExtraDeck, hasPool); } @@ -34,19 +36,19 @@ public class DrawingLiner extends DrawingBaseLiner { int y = this.startPosY; Graphics2D g2d = (Graphics2D)g; this.startPosY = this.startPosY + 20; - super.drawTransport(g); + super.drawLinerBase(g); this.startPosY = this.startPosY - 20; - LinerEntity linerEntity = (LinerEntity)this.baseLiner; - Color deckColor = linerEntity.getSecondaryColor(); - Color borderColor = Color.BLACK; - this.deck.drawAdditionalElement(x, y, borderColor, deckColor, g); - if (linerEntity.hasPool()) { - g2d.setColor(Color.CYAN); - g2d.fillOval(x + 35, y + 15, 30, 10); - g2d.setColor(Color.BLACK); - g2d.drawOval(x + 35, y + 15, 30, 10); + if (this.baseLiner instanceof LinerEntity linerEntity) { + Color deckColor = linerEntity.getSecondaryColor(); + Color borderColor = Color.BLACK; + this.deck.drawAdditionalElement(x, y, borderColor, deckColor, g); + if (linerEntity.hasPool()) { + g2d.setColor(Color.CYAN); + g2d.fillOval(x + 35, y + 15, 30, 10); + g2d.setColor(Color.BLACK); + g2d.drawOval(x + 35, y + 15, 30, 10); + } } - } } } diff --git a/Liner_Advanced/src/projectliner/Drawings/TriangularDeckDrawing.java b/Liner_Advanced/src/projectliner/Drawings/TriangularDeckDrawing.java index adf9838..85a829d 100644 --- a/Liner_Advanced/src/projectliner/Drawings/TriangularDeckDrawing.java +++ b/Liner_Advanced/src/projectliner/Drawings/TriangularDeckDrawing.java @@ -37,8 +37,8 @@ public class TriangularDeckDrawing implements IAdditionalElements { } private void drawLowerDeck(int x, int y, Color borderColor, Color fillColor, Graphics g) { - int[] xPoints = new int[]{x + 30, x + 80, x - 20}; - int[] yPoints = new int[]{y + 20, y + 120, y + 120}; + int[] xPoints = new int[]{x + 130, x + 130, x}; + int[] yPoints = new int[]{y + 15, y + 30, y + 25}; g.setColor(fillColor); g.fillPolygon(xPoints, yPoints, 3); 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) { - int[] xPoints = new int[]{x + 70, x + 95, x + 45}; - int[] yPoints = new int[]{y + 10, y + 60, y + 60}; + int[] xPoints = new int[]{x + 120, x + 120, x + 60}; + int[] yPoints = new int[]{y + 10, y + 20, y + 15}; g.setColor(fillColor); g.fillPolygon(xPoints, yPoints, 3); 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) { - int[] xPoints = new int[]{x + 85, x + 97, x + 73}; - int[] yPoints = new int[]{y, y + 25, y + 25}; + int[] xPoints = new int[]{x + 110, x + 110, x + 80}; + int[] yPoints = new int[]{y + 5, y + 15, y + 10}; g.setColor(fillColor); g.fillPolygon(xPoints, yPoints, 3); g.setColor(borderColor); diff --git a/Liner_Advanced/src/projectliner/FormLiner.java b/Liner_Advanced/src/projectliner/FormLiner.java index 961797b..c0d3f03 100644 --- a/Liner_Advanced/src/projectliner/FormLiner.java +++ b/Liner_Advanced/src/projectliner/FormLiner.java @@ -178,18 +178,26 @@ public class FormLiner extends JFrame { Random random = new Random(); switch (type) { 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()); - DrawingLiner liner = (DrawingLiner)this.drawingLiner; - if (this.comboBoxDeckForm.getSelectedItem() != null) { - liner.setDeckForm((String)this.comboBoxDeckForm.getSelectedItem()); - } else { - liner.setDeckForm("Square Deck"); + 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()); + if (this.drawingLiner instanceof DrawingLiner liner) { + if (this.comboBoxDeckForm.getSelectedItem() != null) { + liner.setDeckForm((String) this.comboBoxDeckForm.getSelectedItem()); + } else { + liner.setDeckForm("Square Deck"); + } + liner.setDeckNum(this.numberOfDecks); } - - liner.setDeckNum(this.numberOfDecks); break; 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());