diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/ProjectAirbus.iml b/.idea/ProjectAirbus.iml
new file mode 100644
index 0000000..b107a2d
--- /dev/null
+++ b/.idea/ProjectAirbus.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..104cfef
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 0000000..bed92e1
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Direction.java b/Direction.java
new file mode 100644
index 0000000..d82266b
--- /dev/null
+++ b/Direction.java
@@ -0,0 +1,7 @@
+public enum Direction {
+ Up(1),
+ Down(2),
+ Left(3),
+ Right(4);
+ Direction(int value){}
+}
\ No newline at end of file
diff --git a/DrawningIlluminator.java b/DrawningIlluminator.java
new file mode 100644
index 0000000..86de975
--- /dev/null
+++ b/DrawningIlluminator.java
@@ -0,0 +1,36 @@
+import javax.swing.*;
+import java.awt.*;
+
+public class DrawningIlluminator extends JComponent {
+ private IlluminatorCount _Illuminator;
+
+ public void SetIlluminatorCount(int numOfIllum) {
+ _Illuminator = IlluminatorCount.GetIlluminatorCount(numOfIllum);
+ }
+
+ public void DrawIlluminator(Graphics g, int _startPosX, int _startPosY) {
+ super.paintComponent(g);
+ Graphics2D g2d = (Graphics2D) g;
+ g2d.setColor(Color.BLACK);
+ int numOfIlluminator = 0;
+ switch (_Illuminator)
+ {
+ case Ten:
+ numOfIlluminator = 10;
+ break;
+ case Twenty:
+ numOfIlluminator = 20;
+ break;
+ case Thirty:
+ numOfIlluminator = 30;
+ break;
+ }
+
+ for(int i = numOfIlluminator; i >= 1; --i){
+ g2d.setColor(Color.CYAN);
+ g2d.fillOval(_startPosX + 105 - 3 * i, _startPosY + 35, 3, 3);
+ g2d.setColor(Color.BLACK);
+ g2d.drawOval(_startPosX + 105 - 3 * i, _startPosY + 35, 3, 3);
+ }
+ }
+}
diff --git a/DrawningPlane.java b/DrawningPlane.java
new file mode 100644
index 0000000..6600f0a
--- /dev/null
+++ b/DrawningPlane.java
@@ -0,0 +1,145 @@
+import javax.swing.*;
+import java.awt.*;
+import java.util.Random;
+import java.util.random.RandomGenerator;
+
+public class DrawningPlane extends JPanel {
+
+ private EntityPlane Plane;
+ public EntityPlane GetPlane(){
+ return Plane;
+ }
+
+ private int _startPosX;
+ private int _startPosY;
+ public DrawningIlluminator IlluminatorDraw;
+ public Integer _pictureWidth = null;
+ public Integer _pictureHeight = null;
+ private final int _PlaneWidth = 130;
+ private final int _PlaneHeight = 70;
+
+ public void SetIlluminator() {
+ Random r = new Random();
+ int numIllum = r.nextInt(1,4);
+ numIllum = numIllum * 10;
+ IlluminatorDraw.SetIlluminatorCount(numIllum);
+ }
+
+ public void Init(int speed, float weight, Color bodyColor)
+ {
+ Plane = new EntityPlane();
+ Plane.Init(speed, weight, bodyColor);
+ IlluminatorDraw = new DrawningIlluminator();
+ SetIlluminator();
+ }
+
+ public void SetPosition(int x, int y, int width, int height)
+ {
+ if (x >= 0 && x + _PlaneWidth <= width && y >= 0 && y + _PlaneHeight <= height) {
+ _startPosX = x;
+ _startPosY = y;
+ _pictureWidth = width;
+ _pictureHeight = height;
+ }
+ }
+
+ public void MoveTransport(Direction direction)
+ {
+ if (_pictureWidth == null || _pictureHeight == null)
+ {
+ return;
+ }
+ switch (direction)
+ {
+ case Right:
+ if (_startPosX + _PlaneWidth + Plane.Step < _pictureWidth)
+ {
+ _startPosX += Plane.Step;
+ }
+ break;
+ case Left:
+ if (_startPosX - Plane.Step > 0)
+ {
+ _startPosX -= Plane.Step;
+ }
+ break;
+ case Up:
+ if (_startPosY - Plane.Step > 0)
+ {
+ _startPosY -= Plane.Step;
+ }
+ break;
+ case Down:
+ if (_startPosY + _PlaneHeight + Plane.Step < _pictureHeight)
+ {
+ _startPosY += Plane.Step;
+ }
+ break;
+ }
+ }
+
+ public void DrawTransport() {
+ if (_startPosX < 0 || _startPosY < 0 || _pictureWidth == null || _pictureHeight == null) {
+ return;
+ }
+ repaint();
+ }
+ @Override
+ public void paintComponent(Graphics g) {
+ if (GetPlane() == null) {
+ return;
+ }
+ if (_startPosX < 0 || _startPosY < 0 || _pictureWidth == null || _pictureHeight == null) {
+ return;
+ }
+ super.paintComponent(g);
+ Graphics2D g2d = (Graphics2D) g;
+
+ g2d.setColor(Color.BLACK);
+ g2d.drawOval(_startPosX, _startPosY + 30, 20, 20);
+ g2d.drawRect(_startPosX + 10, _startPosY + 30, 100, 20);
+
+ g2d.drawLine(_startPosX + 110, _startPosY + 30, _startPosX + 130, _startPosY+40);
+ g2d.drawLine(_startPosX + 110, _startPosY+50, _startPosX + 130, _startPosY+40);
+
+ g2d.drawLine(_startPosX, _startPosY, _startPosX, _startPosY+40);
+ g2d.drawLine(_startPosX, _startPosY, _startPosX + 30, _startPosY+30);
+
+ g2d.drawLine(_startPosX + 40, _startPosY + 50, _startPosX + 40, _startPosY+55);
+ g2d.drawLine(_startPosX + 100, _startPosY + 50, _startPosX + 100, _startPosY+55);
+
+ g2d.drawOval(_startPosX + 95, _startPosY + 55, 10, 10);
+ g2d.drawOval(_startPosX + 29, _startPosY + 55, 10, 10);
+ g2d.drawOval(_startPosX + 41, _startPosY + 55, 10, 10);
+
+ g2d.setPaint(Plane.GetBodyColor());
+ g2d.fillOval(_startPosX, _startPosY + 31, 20, 19);
+ g2d.fillRect(_startPosX + 10, _startPosY + 31, 100, 19);
+
+ g2d.setPaint(Color.BLACK);
+ g2d.fillOval(_startPosX + 40, _startPosY + 40, 60, 5);
+ g2d.fillOval(_startPosX - 5, _startPosY + 25, 30, 10);
+
+ IlluminatorDraw.DrawIlluminator(g, _startPosX, _startPosY);
+ }
+
+ public void ChangeBorders(int width, int height)
+ {
+ _pictureWidth = width;
+ _pictureHeight = height;
+ if (_pictureWidth <= _PlaneWidth || _pictureHeight <= _PlaneHeight)
+ {
+ _pictureWidth = null;
+ _pictureHeight = null;
+ return;
+ }
+ if (_startPosX + _PlaneWidth > _pictureWidth)
+ {
+ _startPosX = _pictureWidth - _PlaneWidth;
+ }
+ if (_startPosY + _PlaneHeight > _pictureHeight)
+ {
+ _startPosY = _pictureHeight - _PlaneHeight;
+ }
+ }
+}
diff --git a/EntityPlane.java b/EntityPlane.java
new file mode 100644
index 0000000..dd00e40
--- /dev/null
+++ b/EntityPlane.java
@@ -0,0 +1,29 @@
+import java.awt.*;
+import java.util.Random;
+
+public class EntityPlane {
+ private int Speed;
+ public int GetSpeed() {
+ return Speed;
+ }
+
+ private float Weight;
+ public float GetWeight() {
+ return Weight;
+ }
+
+ private Color BodyColor;
+ public Color GetBodyColor() {
+ return BodyColor;
+ }
+ public float Step;
+
+ public void Init(int speed, float weight, Color bodyColor)
+ {
+ Random rnd = new Random();
+ Speed = speed <= 0 ? rnd.nextInt(50,150) : speed;
+ Weight = weight <= 0 ? rnd.nextInt(40,70) : weight;
+ BodyColor = bodyColor;
+ Step = Speed * 100 / (int)Weight;
+ }
+}
diff --git a/FormPlane.form b/FormPlane.form
new file mode 100644
index 0000000..4e8ede6
--- /dev/null
+++ b/FormPlane.form
@@ -0,0 +1,103 @@
+
+
diff --git a/FormPlane.java b/FormPlane.java
new file mode 100644
index 0000000..b4f9c5f
--- /dev/null
+++ b/FormPlane.java
@@ -0,0 +1,80 @@
+import javax.imageio.ImageIO;
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ComponentAdapter;
+import java.awt.event.ComponentEvent;
+import java.util.Random;
+public class FormPlane {
+ public JPanel Mainpanel;
+ private JButton ButtonCreate;
+ private JButton ButtonLeft;
+ private JButton ButtonUp;
+ private JButton ButtonDown;
+ private JButton ButtonRight;
+ protected DrawningPlane PictureBoxPlane;
+ private JToolBar StatusStrip;
+ private JLabel JLabelSpeed = new JLabel();
+ private JLabel JLabelWeight = new JLabel();
+ private JLabel JLabelColor = new JLabel();
+ public void Draw() {
+ if (PictureBoxPlane.GetPlane() == null) {
+ return;
+ }
+ PictureBoxPlane.DrawTransport();
+ }
+ public FormPlane() {
+ Box LabelBox = Box.createHorizontalBox();
+ LabelBox.setMinimumSize(new Dimension(1, 20));
+ LabelBox.add(JLabelSpeed);
+ LabelBox.add(JLabelWeight);
+ LabelBox.add(JLabelColor);
+ StatusStrip.add(LabelBox);
+ try {
+ Image img = ImageIO.read(FormPlane.class.getResource("/Resource/arrowUp.jpg"));
+ ButtonUp.setIcon(new ImageIcon(img));
+ img = ImageIO.read(FormPlane.class.getResource("/Resource/arrowDown.jpg"));
+ ButtonDown.setIcon(new ImageIcon(img));
+ img = ImageIO.read(FormPlane.class.getResource("/Resource/arrowLeft.jpg"));
+ ButtonLeft.setIcon(new ImageIcon(img));
+ img = ImageIO.read(FormPlane.class.getResource("/Resource/arrowRight.jpg"));
+ ButtonRight.setIcon(new ImageIcon(img));
+ } catch (Exception ex) {
+ System.out.println(ex);
+ }
+ ButtonCreate.addActionListener(e -> {
+ Random random = new Random();
+ PictureBoxPlane.Init(random.nextInt(100, 300), random.nextInt(1000, 2000), new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)));
+ PictureBoxPlane.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100), PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight());
+ JLabelSpeed.setText("Cкорость: " + PictureBoxPlane.GetPlane().GetSpeed() + " ");
+ JLabelWeight.setText("Вес: " + PictureBoxPlane.GetPlane().GetWeight() + " ");
+ JLabelColor.setText(("Цвет: " + PictureBoxPlane.GetPlane().GetBodyColor() + " "));
+ Draw();
+ });
+ PictureBoxPlane.addComponentListener(new ComponentAdapter() {
+ @Override
+ public void componentResized(ComponentEvent e) {
+ super.componentResized(e);
+ PictureBoxPlane.ChangeBorders(PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight());
+ Draw();
+ }
+ });
+ ButtonUp.addActionListener(e -> {
+ PictureBoxPlane.MoveTransport(Direction.Up);
+ Draw();
+ });
+ ButtonDown.addActionListener(e -> {
+ PictureBoxPlane.MoveTransport(Direction.Down);
+ Draw();
+ });
+ ButtonRight.addActionListener(e -> {
+ PictureBoxPlane.MoveTransport(Direction.Right);
+ Draw();
+ });
+ ButtonLeft.addActionListener(e -> {
+ PictureBoxPlane.MoveTransport(Direction.Left);
+ Draw();
+ });
+ }
+}
diff --git a/IlluminatorCount.java b/IlluminatorCount.java
new file mode 100644
index 0000000..7beef64
--- /dev/null
+++ b/IlluminatorCount.java
@@ -0,0 +1,22 @@
+public enum IlluminatorCount {
+ Ten,
+ Twenty,
+ Thirty;
+
+ public static IlluminatorCount GetIlluminatorCount(int Value)
+ {
+ switch(Value)
+ {
+ case 10:
+ return Ten;
+
+ case 20:
+ return Twenty;
+
+ case 30:
+ return Thirty;
+
+ }
+ return null;
+ }
+}
diff --git a/Main.java b/Main.java
new file mode 100644
index 0000000..dfdda90
--- /dev/null
+++ b/Main.java
@@ -0,0 +1,14 @@
+import javax.swing.*;
+
+public class Main {
+
+ public static void main(String[] args) {
+ JFrame frame = new JFrame("Корабль");
+ frame.setContentPane(new FormPlane().Mainpanel);
+ frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ frame.setLocation(500, 200);
+ frame.pack();
+ frame.setSize(800, 600);
+ frame.setVisible(true);
+ }
+}
diff --git a/Resource/arrowDown.jpg b/Resource/arrowDown.jpg
new file mode 100644
index 0000000..2751bb7
Binary files /dev/null and b/Resource/arrowDown.jpg differ
diff --git a/Resource/arrowLeft.jpg b/Resource/arrowLeft.jpg
new file mode 100644
index 0000000..c25c05c
Binary files /dev/null and b/Resource/arrowLeft.jpg differ
diff --git a/Resource/arrowRight.jpg b/Resource/arrowRight.jpg
new file mode 100644
index 0000000..195d279
Binary files /dev/null and b/Resource/arrowRight.jpg differ
diff --git a/Resource/arrowUp.jpg b/Resource/arrowUp.jpg
new file mode 100644
index 0000000..31b8fe1
Binary files /dev/null and b/Resource/arrowUp.jpg differ