Лабораторная работа №1

This commit is contained in:
xom9k 2024-04-17 12:13:48 +04:00
parent 9dd4fc3827
commit 9fb0c70d1f
8 changed files with 74 additions and 73 deletions

View File

@ -8,8 +8,8 @@ public class DrawningAntiAircraftGun extends JPanel{
private Integer picture_height;
private Integer _StartPosX;
private Integer _StartPosY;
private int drawningCarWidth = 185;
private int drawningCarHeight = 100;
private int drawningCarWidth = 120;
private int drawningCarHeight = 90;
public void Init(int speed, double weight, Color bodycolor, Color additionalcolor, boolean tower, boolean radar) {
EntityAntiAircraftGun = new EntityAntiAircraftGun();
EntityAntiAircraftGun.Init(speed, weight, bodycolor, additionalcolor, tower, radar);
@ -89,55 +89,65 @@ public class DrawningAntiAircraftGun extends JPanel{
public void DrawTransport(Graphics2D g) {
if (EntityAntiAircraftGun == null) {
if (EntityAntiAircraftGun == null ) {
return;
}
// иллюминаторы
_rollers.Draw(g, _StartPosX+30, _StartPosY+34);
;
g.drawOval(_StartPosX + 10, _StartPosY + 75, 30, 30);
g.drawOval(_StartPosX + 100, _StartPosY + 75, 30, 30);
g.drawRect(_StartPosX + 25, _StartPosY + 75, 90, 30);
//границы цвет
g.setColor(EntityAntiAircraftGun.getBodyColor());
g.fillRect(_StartPosX + 35, _StartPosY + 40, 35, 30);
g.fillOval(_StartPosX + 10, _StartPosY + 75, 30, 30);
g.fillOval(_StartPosX + 100, _StartPosY+ 75, 30, 30);
g.fillRect(_StartPosX+ 25, _StartPosY + 75, 90, 30);
// границы арт. установки
g.setColor(Color.BLACK);
//Тело
g.drawRect(_StartPosX + 5, _StartPosY + 50, 170, 30);
g.drawArc(_StartPosX - 5, _StartPosY + 50, 20, 30, 90, 180);
//Заднее крыло
g.drawLine( _StartPosX, _StartPosY, _StartPosX + 50, _StartPosY + 50);
g.drawLine( _StartPosX, _StartPosY, _StartPosX, _StartPosY + 52);
//Заднее боковые крылья
g.drawOval(_StartPosX - 7, _StartPosY + 45, 30, 8);
g.fillOval(_StartPosX - 7, _StartPosY + 45, 30, 8);
//Нос
g.drawLine( _StartPosX + 175, _StartPosY + 50, _StartPosX + 200, _StartPosY + 65);
g.drawLine( _StartPosX + 200, _StartPosY + 65, _StartPosX + 175, _StartPosY + 80);
g.drawLine( _StartPosX + 175, _StartPosY + 50, _StartPosX + 175, _StartPosY + 80);
g.drawLine( _StartPosX + 175, _StartPosY + 65, _StartPosX + 200, _StartPosY + 65);
//Крылья
g.drawArc(_StartPosX + 49, _StartPosY + 62, 5, 5, 90, 180);
g.drawLine( _StartPosX + 51, _StartPosY + 62, _StartPosX + 140, _StartPosY + 62);
g.drawArc( _StartPosX + 137, _StartPosY + 62, 5, 5, 2790, 180);
g.drawLine( _StartPosX + 51, _StartPosY + 67, _StartPosX + 140, _StartPosY + 67);
//Задние шасси
g.drawLine(_StartPosX + 55, _StartPosY + 80, _StartPosX + 55, _StartPosY + 90);
g.drawOval(_StartPosX + 47, _StartPosY + 90, 5, 5);
g.drawOval( _StartPosX + 57, _StartPosY + 90, 5, 5);
//Передние шасси
g.drawLine( _StartPosX + 165, _StartPosY + 80, _StartPosX + 165, _StartPosY + 90);
g.drawOval( _StartPosX + 163, _StartPosY + 91, 5, 5);
//Пассажирсакий доп. отсек
g.drawRect(_StartPosX+ 35, _StartPosY + 40, 35, 30);
g.drawRect(_StartPosX+ 10, _StartPosY + 65, 120, 13);
//Большие катки ЦВЕТ
g.setColor(Color.GRAY);
g.fillOval(_StartPosX + 13, _StartPosY + 78, 24, 24);
g.fillOval( _StartPosX + 103, _StartPosY + 78, 24, 24);
//Большие катки ОТРИСОВКА
g.setColor(Color.BLACK);
g.drawOval( _StartPosX + 13, _StartPosY + 78, 24, 24);
g.drawOval( _StartPosX + 103, _StartPosY + 78, 24, 24);
g.setColor(EntityAntiAircraftGun.getBodyColor());
g.fillRect(_StartPosX + 10, _StartPosY+ 65, 120, 13);
_rollers.Draw(g,_StartPosX, _StartPosY);
//отрисовки башни
if (EntityAntiAircraftGun.getIsTower())
{
g.setColor(EntityAntiAircraftGun.getAdditionalColor());
g.drawArc(_StartPosX + 60, _StartPosY + 28, 115, 45, 0, 180);
g.fillArc(_StartPosX + 60, _StartPosY + 28, 115, 45, 0, 180);
g.fillRect(_StartPosX + 35, _StartPosY+ 50, 35, 15);
g.setColor(Color.BLACK);
g.drawRect(_StartPosX + 35, _StartPosY + 50, 35, 15);
g.drawLine(_StartPosX + 45, _StartPosY + 50, _StartPosX + 90, _StartPosY + 20);
g.drawLine( _StartPosX + 60, _StartPosY + 50, _StartPosX + 95, _StartPosY + 27);
g.drawLine( _StartPosX + 45, _StartPosY + 50, _StartPosX + 60, _StartPosY + 50);
g.drawLine( _StartPosX + 90, _StartPosY + 20, _StartPosX + 95, _StartPosY + 27);
g.drawLine( _StartPosX + 90, _StartPosY + 20, _StartPosX + 100, _StartPosY + 20);
g.drawLine( _StartPosX + 100, _StartPosY + 20, _StartPosX + 95, _StartPosY + 27);
}
// Доп. двигатели
//отрисовка радара
if (EntityAntiAircraftGun.getIsRadar())
{
g.drawLine(_StartPosX + 95, _StartPosY + 68, _StartPosX + 95, _StartPosY + 75);
{;
g.drawLine(_StartPosX + 20, _StartPosY + 65, _StartPosX + 20, _StartPosY + 40);
g.drawRect( _StartPosX + 10, _StartPosY + 20, 20, 20);
g.setColor(EntityAntiAircraftGun.getAdditionalColor());
int[] xPolygon = { _StartPosX + 83, _StartPosX + 103, _StartPosX + 103, _StartPosX + 83, _StartPosX + 83};
int[] yPolygon = {_StartPosY + 78, _StartPosY + 73, _StartPosY + 93, _StartPosY + 88, _StartPosY + 78};
g.drawPolygon(xPolygon, yPolygon, xPolygon.length);
g.fillPolygon(xPolygon, yPolygon, xPolygon.length);
g.fillRect(_StartPosX + 10, _StartPosY + 20, 20, 20);
}
}
}

View File

@ -23,40 +23,31 @@ public class DrawningRollers {
}
}
public void Draw(Graphics2D g, int _startPosx, int _startPoxY) {
public void Draw(Graphics2D g, int _StartPosX, int _StartPosY) {
g.setColor(Color.BLACK);
if (_rollers == null) {
return;
}
for (int i = 0; i < 10; ++i) {
g.setColor(Color.cyan);
g.fillOval(_startPosx + 19 + i * 8, _startPoxY + 21, 3, 3);
g.setColor(Color.black);
g.drawOval(_startPosx + 19 + i * 8, _startPoxY + 21, 3, 3);
}
//нижние катки ЦВЕТ
g.setColor(Color.GRAY);
g.fillOval(_StartPosX + 40, _StartPosY + 90, 15, 15);
g.fillOval(_StartPosX + 55, _StartPosY + 90, 15, 15);
if (_rollers != CountRollers.Four) {
for (int i = 0; i < 5; ++i) {
g.setColor(Color.cyan);
g.fillOval(_startPosx - 15 + i * 5, _startPoxY + 28, 3, 3);
g.setColor(Color.black);
g.drawOval(_startPosx - 15 + i * 5, _startPoxY + 28, 3, 3);
}
for (int i = 0; i < 5; ++i) {
g.setColor(Color.cyan);
g.fillOval(_startPosx + 115 + i * 5, _startPoxY + 28, 3, 3);
g.setColor(Color.black);
g.drawOval(_startPosx + 115 + i * 5, _startPoxY + 28, 3, 3);
}
g.fillOval(_StartPosX + 70, _StartPosY + 90, 15, 15);
}
if (_rollers == CountRollers.Six) {
for (int i = 0; i < 10; ++i) {
g.setColor(Color.cyan);
g.fillOval(_startPosx + 19 + i * 8, _startPoxY + 37, 3, 3);
g.setColor(Color.black);
g.drawOval(_startPosx + 19 + i * 8, _startPoxY + 37, 3, 3);
}
g.fillOval(_StartPosX + 85, _StartPosY + 90, 15, 15);
}
//нижние катки ОТРИСОВКА
g.setColor(Color.BLACK);
g.drawOval(_StartPosX + 40, _StartPosY + 90, 15, 15);
g.drawOval( _StartPosX + 55, _StartPosY + 90, 15, 15);
if (_rollers != CountRollers.Four) {
g.drawOval( _StartPosX+ 70, _StartPosY + 90, 15, 15);
}
if (_rollers == CountRollers.Six) {
g.drawOval(_StartPosX + 85, _StartPosY + 90, 15, 15);
}
}
}

View File

@ -28,17 +28,17 @@ public class FormAntiAircraftGun extends JFrame {
Height = getHeight() - 35;
CreateButton.setName("CREATE");
Icon iconUp = new ImageIcon("src\\up.jpg");
Icon iconUp = new ImageIcon("src\\images\\up.jpg");
UpButton.setIcon(iconUp);
UpButton.setName("UP");
DownButton.setName("DOWN");
Icon iconDown = new ImageIcon("src\\down.jpg");
Icon iconDown = new ImageIcon("src\\images\\down.jpg");
DownButton.setIcon(iconDown);
LeftButton.setName("LEFT");
Icon iconLeft = new ImageIcon("src\\left.jpg");
Icon iconLeft = new ImageIcon("src\\images\\left.jpg");
LeftButton.setIcon(iconLeft);
RightButton.setName("RIGHT");
Icon iconRight = new ImageIcon("src\\right.jpg");
Icon iconRight = new ImageIcon("src\\images\\right.jpg");
RightButton.setIcon(iconRight);
CreateButton.addActionListener(new ActionListener() {

View File

@ -2,7 +2,7 @@ import java.awt.*;
public class Main {
public static void main(String[] args) {
FormAntiAircraftGun form = new FormAntiAircraftGun("Зенитная установка", new Dimension(500, 500));
FormAntiAircraftGun form = new FormAntiAircraftGun("Зенитная установка", new Dimension(600, 600));
form.Init();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 KiB