This commit is contained in:
GokaPek 2023-11-21 18:08:39 +04:00
parent 1949aadf52
commit bbf868ac7d
5 changed files with 117 additions and 35 deletions

View File

@ -33,13 +33,16 @@ public class DrawningClamps implements IDrawable {
@Override
public void Draw(){
Ellipse2D ellipse1 = new Ellipse2D.Double(startPosX + 10, startPosY + 55, 10, 10);
Ellipse2D ellipse2 = new Ellipse2D.Double(startPosX + 35, startPosY + 55, 10, 10);
Ellipse2D ellipse3 = new Ellipse2D.Double(startPosX + 60, startPosY + 55, 10, 10);
Ellipse2D ellipse4 = new Ellipse2D.Double(startPosX + 85, startPosY + 55, 10, 10);
Ellipse2D ellipse5 = new Ellipse2D.Double(startPosX + 110, startPosY + 55, 10, 10);
Ellipse2D ellipse6 = new Ellipse2D.Double(startPosX + 127, startPosY + 60, 5, 5);
g2d.setPaint(color);
g2d.setPaint(Color.BLACK);
Ellipse2D ellipse7 = new Ellipse2D.Double(startPosX + 10, startPosY + 55, 120, 20);
Ellipse2D ellipse1 = new Ellipse2D.Double(startPosX + 5, startPosY + 50, 20, 20);
Ellipse2D ellipse2 = new Ellipse2D.Double(startPosX + 30, startPosY + 50, 20, 20);
Ellipse2D ellipse3 = new Ellipse2D.Double(startPosX + 55, startPosY + 50, 20, 20);
Ellipse2D ellipse4 = new Ellipse2D.Double(startPosX + 80, startPosY + 50, 20, 20);
Ellipse2D ellipse5 = new Ellipse2D.Double(startPosX + 105, startPosY + 50, 20, 20);
Ellipse2D ellipse6 = new Ellipse2D.Double(startPosX + 125, startPosY + 60, 10, 10);
g2d.draw(ellipse7);
switch (_numbeRollers) {
case Min:
g2d.fill(ellipse1);
@ -63,5 +66,36 @@ public class DrawningClamps implements IDrawable {
g2d.fill(ellipse6);
break;
}
Ellipse2D ellipse11 = new Ellipse2D.Double(startPosX + 10, startPosY + 55, 10, 10);
Ellipse2D ellipse12 = new Ellipse2D.Double(startPosX + 35, startPosY + 55, 10, 10);
Ellipse2D ellipse13 = new Ellipse2D.Double(startPosX + 60, startPosY + 55, 10, 10);
Ellipse2D ellipse14 = new Ellipse2D.Double(startPosX + 85, startPosY + 55, 10, 10);
Ellipse2D ellipse15 = new Ellipse2D.Double(startPosX + 110, startPosY + 55, 10, 10);
Ellipse2D ellipse16 = new Ellipse2D.Double(startPosX + 127, startPosY + 60, 5, 5);
g2d.setPaint(color);
switch (_numbeRollers) {
case Min:
g2d.fill(ellipse11);
g2d.fill(ellipse12);
g2d.fill(ellipse13);
g2d.fill(ellipse14);
break;
case Mid:
g2d.fill(ellipse11);
g2d.fill(ellipse12);
g2d.fill(ellipse13);
g2d.fill(ellipse14);
g2d.fill(ellipse15);
break;
case Max:
g2d.fill(ellipse11);
g2d.fill(ellipse12);
g2d.fill(ellipse13);
g2d.fill(ellipse14);
g2d.fill(ellipse15);
g2d.fill(ellipse16);
break;
}
}
}

View File

@ -33,13 +33,17 @@ public class DrawningNails implements IDrawable {
@Override
public void Draw(){
Ellipse2D ellipse1 = new Ellipse2D.Double(startPosX + 15, startPosY + 60, 2, 2);
Ellipse2D ellipse2 = new Ellipse2D.Double(startPosX + 40, startPosY + 60, 2, 2);
Ellipse2D ellipse3 = new Ellipse2D.Double(startPosX + 65, startPosY + 60, 2, 2);
Ellipse2D ellipse4 = new Ellipse2D.Double(startPosX + 90, startPosY + 60, 2, 2);
Ellipse2D ellipse5 = new Ellipse2D.Double(startPosX + 115, startPosY + 60, 2, 2);
Ellipse2D ellipse6 = new Ellipse2D.Double(startPosX + 130, startPosY + 65, 1, 1);
g2d.setPaint(Color.BLACK);
Ellipse2D ellipse7 = new Ellipse2D.Double(startPosX + 10, startPosY + 55, 120, 20);
Ellipse2D ellipse1 = new Ellipse2D.Double(startPosX + 5, startPosY + 50, 20, 20);
Ellipse2D ellipse2 = new Ellipse2D.Double(startPosX + 30, startPosY + 50, 20, 20);
Ellipse2D ellipse3 = new Ellipse2D.Double(startPosX + 55, startPosY + 50, 20, 20);
Ellipse2D ellipse4 = new Ellipse2D.Double(startPosX + 80, startPosY + 50, 20, 20);
Ellipse2D ellipse5 = new Ellipse2D.Double(startPosX + 105, startPosY + 50, 20, 20);
Ellipse2D ellipse6 = new Ellipse2D.Double(startPosX + 125, startPosY + 60, 10, 10);
g2d.draw(ellipse7);
switch (_numbeRollers) {
case Min:
g2d.fill(ellipse1);
@ -63,5 +67,36 @@ public class DrawningNails implements IDrawable {
g2d.fill(ellipse6);
break;
}
Ellipse2D ellipse11 = new Ellipse2D.Double(startPosX + 15, startPosY + 62, 2, 2);
Ellipse2D ellipse12 = new Ellipse2D.Double(startPosX + 40, startPosY + 62, 2, 2);
Ellipse2D ellipse13 = new Ellipse2D.Double(startPosX + 65, startPosY + 62, 2, 2);
Ellipse2D ellipse14 = new Ellipse2D.Double(startPosX + 90, startPosY + 62, 2, 2);
Ellipse2D ellipse15 = new Ellipse2D.Double(startPosX + 115, startPosY + 62, 2, 2);
Ellipse2D ellipse16 = new Ellipse2D.Double(startPosX + 130, startPosY + 65, 1, 1);
g2d.setPaint(color);
switch (_numbeRollers) {
case Min:
g2d.fill(ellipse11);
g2d.fill(ellipse12);
g2d.fill(ellipse13);
g2d.fill(ellipse14);
break;
case Mid:
g2d.fill(ellipse11);
g2d.fill(ellipse12);
g2d.fill(ellipse13);
g2d.fill(ellipse14);
g2d.fill(ellipse15);
break;
case Max:
g2d.fill(ellipse11);
g2d.fill(ellipse12);
g2d.fill(ellipse13);
g2d.fill(ellipse14);
g2d.fill(ellipse15);
g2d.fill(ellipse16);
break;
}
}
}

View File

@ -1,6 +1,5 @@
package SelfPropelledArtilleryUnit.DrawningObjects;
import java.awt.*;
import java.awt.geom.Line2D;
import java.awt.geom.Path2D;
import SelfPropelledArtilleryUnit.DirectionType;
@ -14,6 +13,7 @@ public class DrawningSPAU {
protected int startPosX;
protected int startPosY;
private int _numbeRollers;
private int rollVar;
private int carWidth = 135;
private int carHeight = 75;
@ -25,9 +25,10 @@ public class DrawningSPAU {
return EntitySPAU;
}
public DrawningSPAU(int _numbeRollers, int speed, double weight, Color bodyColor, int width, int height)
public DrawningSPAU(int _numbeRollers, int rollVar, int speed, double weight, Color bodyColor, int width, int height)
{
this._numbeRollers = _numbeRollers;
this.rollVar = rollVar;
this.pictureWidth = width;
this.pictureHeight = height;
if (this.carHeight >= height)
@ -41,9 +42,10 @@ public class DrawningSPAU {
EntitySPAU = new EntitySPAU(speed, weight, bodyColor);
}
public DrawningSPAU(int _numbeRollers, int speed, double weight, Color bodyColor, int width, int height, int carWidth, int carHeight)
public DrawningSPAU(int _numbeRollers, int rollVar, int speed, double weight, Color bodyColor, int width, int height, int carWidth, int carHeight)
{
this._numbeRollers = _numbeRollers;
this.rollVar = rollVar;
this.pictureWidth = width;
this.pictureHeight = height;
this.carWidth = carWidth;
@ -105,18 +107,23 @@ public class DrawningSPAU {
}
Graphics2D g2d = (Graphics2D) g;
BasicStroke penBlack = new BasicStroke(1);
Color bodyColor = EntitySPAU.BodyColor;
Path2D.Double path = new Path2D.Double();
//гусеницы
DrawningRollers Rollers = new DrawningRollers(g2d, startPosX, startPosY, bodyColor, _numbeRollers);
IDrawable Rollers = new DrawningRollers(g2d, startPosX, startPosY, bodyColor, _numbeRollers);
switch (rollVar) {
case 2:
Rollers = new DrawningClamps(g2d, startPosX, startPosY, bodyColor, _numbeRollers);
break;
case 3:
Rollers = new DrawningNails(g2d, startPosX, startPosY, bodyColor, _numbeRollers);
break;
default:
break;
}
Rollers.Draw();
DrawningClamps Clamps = new DrawningClamps(g2d, startPosX, startPosY, bodyColor, _numbeRollers);
Clamps.Draw();
DrawningNails Nails = new DrawningNails(g2d, startPosX, startPosY, bodyColor, _numbeRollers);
Nails.Draw();
// пушка
path.moveTo(startPosX + 35, startPosY + 40);

View File

@ -3,8 +3,6 @@ package SelfPropelledArtilleryUnit.DrawningObjects;
import java.awt.*;
import java.awt.geom.Line2D;
import java.awt.geom.Path2D;
import SelfPropelledArtilleryUnit.DirectionType;
import SelfPropelledArtilleryUnit.Entities.EntitySPAUchild;
public class DrawningSPAUchild extends DrawningSPAU {
@ -14,8 +12,8 @@ public class DrawningSPAUchild extends DrawningSPAU {
this.EntitySPAU = entitySPAU;
}
public DrawningSPAUchild(int _numbeRollers, int speed, double weight, Color bodyColor, Color additionalColor, boolean bodyKit, boolean ballone, int width, int height) {
super(_numbeRollers, speed, weight, bodyColor, width, height);
public DrawningSPAUchild(int _numbeRollers, int rollVar, int speed, double weight, Color bodyColor, Color additionalColor, boolean bodyKit, boolean ballone, int width, int height) {
super(_numbeRollers, rollVar, speed, weight, bodyColor, width, height);
EntitySPAU = new EntitySPAUchild(speed, weight, bodyColor, additionalColor, bodyKit, ballone);
}

View File

@ -12,6 +12,7 @@ import SelfPropelledArtilleryUnit.MovementStrategy.Status;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import java.awt.image.BufferedImage;
import java.util.Random;
@ -21,7 +22,8 @@ public class Form extends JFrame {
private JButton buttonCreate;
private JButton buttonCreateParent;
private JButton buttonStep;
private JComboBox<String> comboBoxStrategy = new JComboBox<>();
private JComboBox<String> comboBoxStrategy;
private JComboBox<String> comboBoxRoll;
private JButton buttonUp;
private JButton buttonDown;
private JButton buttonLeft;
@ -101,6 +103,13 @@ public class Form extends JFrame {
}
});
// comboBoxRoll
comboBoxRoll = new JComboBox<>();
mainPanel.add(comboBoxRoll);
comboBoxRoll.setModel(new DefaultComboBoxModel<>(new String[] { "1", "2", "3" }));
comboBoxRoll.setBounds(767, 232, 103, 28);
// comboBoxStrategy
comboBoxStrategy = new JComboBox<>();
mainPanel.add(comboBoxStrategy);
@ -109,7 +118,7 @@ public class Form extends JFrame {
buttonUp.setBounds(804, 336, 30, 30);
mainPanel.add(buttonUp);
ImageIcon iconUp = new ImageIcon("Arrows/upper-arrow.png");
ImageIcon iconUp = new ImageIcon("C:\\Users\\Egor\\Desktop\\ULSTU\\RPP\\Hard_\\PIbd-22_Petrushin_E.A._SelfPropelledArtilleryUnit_Hard_-1\\Arrows\\upper-arrow.png");
buttonUp.setIcon(iconUp);
buttonUp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -119,7 +128,7 @@ public class Form extends JFrame {
buttonDown.setBounds(804, 409, 30, 30);
mainPanel.add(buttonDown);
ImageIcon iconDown = new ImageIcon("Arrows/down-arrow.png");
ImageIcon iconDown = new ImageIcon("C:\\Users\\Egor\\Desktop\\ULSTU\\RPP\\Hard_\\PIbd-22_Petrushin_E.A._SelfPropelledArtilleryUnit_Hard_-1\\Arrows\\down-arrow.png");
buttonDown.setIcon(iconDown);
buttonDown.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -129,7 +138,7 @@ public class Form extends JFrame {
buttonLeft.setBounds(768, 372, 30, 30);
mainPanel.add(buttonLeft);
ImageIcon iconLeft = new ImageIcon("Arrows/left-arrow.png");
ImageIcon iconLeft = new ImageIcon("C:\\Users\\Egor\\Desktop\\ULSTU\\RPP\\Hard_\\PIbd-22_Petrushin_E.A._SelfPropelledArtilleryUnit_Hard_-1\\Arrows\\left-arrow.png");
buttonLeft.setIcon(iconLeft);
buttonLeft.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -139,7 +148,7 @@ public class Form extends JFrame {
buttonRight.setBounds(840, 372, 30, 30);
mainPanel.add(buttonRight);
ImageIcon iconRight = new ImageIcon("Arrows/right-arrow.png");
ImageIcon iconRight = new ImageIcon("C:\\Users\\Egor\\Desktop\\ULSTU\\RPP\\Hard_\\PIbd-22_Petrushin_E.A._SelfPropelledArtilleryUnit_Hard_-1\\Arrows\\right-arrow.png");
buttonRight.setIcon(iconRight);
buttonRight.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
@ -150,7 +159,6 @@ public class Form extends JFrame {
buttonDown.setName("buttonDown");
buttonLeft.setName("buttonLeft");
buttonRight.setName("buttonRight");
setPreferredSize(new Dimension(882, 453));
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
@ -166,7 +174,7 @@ public class Form extends JFrame {
if (wheelCount > 0) {
Random random = new Random();
drawningSPAU = new DrawningSPAUchild(wheelCount, random.nextInt(200) + 100,
drawningSPAU = new DrawningSPAUchild(wheelCount, Integer.parseInt((String) comboBoxRoll.getSelectedItem()), 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)),
@ -187,7 +195,7 @@ public class Form extends JFrame {
if (wheelCount > 0) {
Random random = new Random();
drawningSPAU = new DrawningSPAU(wheelCount, random.nextInt(200) + 100,
drawningSPAU = new DrawningSPAU(wheelCount, Integer.parseInt((String) comboBoxRoll.getSelectedItem()), random.nextInt(200) + 100,
(double) random.nextInt(2000) + 1000,
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
pictureBoxSPAU.getWidth(), pictureBoxSPAU.getHeight());