From 02db6481fc113bb128bd8ad4a303f9324a4603e9 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sat, 5 Nov 2022 21:26:27 +0400 Subject: [PATCH 01/14] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20Generic.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/MapWithSetPlanesGeneric.java | 205 +++++++++++++++++++++++ Project/src/SetPlanesGeneric.java | 93 ++++++++++ 2 files changed, 298 insertions(+) create mode 100644 Project/src/MapWithSetPlanesGeneric.java create mode 100644 Project/src/SetPlanesGeneric.java diff --git a/Project/src/MapWithSetPlanesGeneric.java b/Project/src/MapWithSetPlanesGeneric.java new file mode 100644 index 0000000..8050679 --- /dev/null +++ b/Project/src/MapWithSetPlanesGeneric.java @@ -0,0 +1,205 @@ +import java.awt.*; +import java.awt.image.BufferedImage; + +public class MapWithSetPlanesGeneric +{ + //ширина окна отрисовки + private final int _pictureWidth; + + //высота окна отрисовки + private final int _pictureHeight; + + //размер занимаемого объектом места (ширина) + private final int _placeSizeWidth = 210; + + //размер занимаемого объектом места (высота) + private final int _placeSizeHeight = 90; + + //набор объектов + private final SetPlanesGeneric _setPlanes; + + //карта + private final U _map; + + //конструктор + public MapWithSetPlanesGeneric(int picWidth, int picHeight, U map) + { + int width = picWidth / _placeSizeWidth; + int height = picHeight / _placeSizeHeight; + _setPlanes = new SetPlanesGeneric(width * height); + _pictureWidth = picWidth; + _pictureHeight = picHeight; + _map = map; + } + + /* + //пеергрузка оператора сложения + public static int operator +(MapWithSetPlanesGeneric map, T plane) + { + return map._setPlanes.Insert(plane); + } + + //перегрузка оператора вычитания + public static T operator -(MapWithSetPlanesGeneric map, int position) + { + return map._setPlanes.Remove(position); + } + */ + + //вывод всего набора объектов + public BufferedImage ShowSet() + { + BufferedImage bmp = new BufferedImage(_pictureWidth, _pictureHeight, BufferedImage.TYPE_INT_RGB); + Graphics gr = bmp.getGraphics(); + DrawBackground(gr); + DrawPlanes(gr); + return bmp; + } + + //просмотр объекта на карте + public BufferedImage ShowOnMap() + { + Shaking(); + + for(int i = 0; i < _setPlanes.Count(); i++) + { + var plane = _setPlanes.Get(i); + + if(plane != null) + { + return _map.CreateMap(_pictureWidth, _pictureHeight, plane); + } + } + + return new BufferedImage(_pictureWidth, _pictureHeight, BufferedImage.TYPE_INT_RGB); + } + + //пеермещение объекта по карте + public BufferedImage MoveObject(Direction direction) + { + if(_map != null) + { + return _map.MoveObject(direction); + } + + return new BufferedImage(_pictureWidth, _pictureHeight, BufferedImage.TYPE_INT_RGB); + } + + //"взламываем" набор, чтобы все элементы оказались в начале + private void Shaking() + { + int j = _setPlanes.Count() - 1; + + for (int i = 0; i < _setPlanes.Count(); i++) + { + if (_setPlanes.Get(i) == null) + { + for (; j > i; j--) + { + var plane = _setPlanes.Get(j); + + if (plane != null) + { + _setPlanes.Insert(plane, i); + _setPlanes.Remove(j); + break; + } + } + + if (j <= i) + { + return; + } + } + } + } + + //метод отрисовки фона + public void DrawBackground(Graphics g) + { + Graphics2D g2d = (Graphics2D) g; + + //заливаем область в цвет бетона + g2d.setPaint(Color.LIGHT_GRAY); + g.fillRect(0, 0, _pictureWidth, _pictureHeight); + + g2d.setStroke(new BasicStroke(3)); + g2d.setColor(Color.BLACK); + for(int i = 0; i < _pictureWidth / _placeSizeWidth - 1; i++) + { + for(int j = 2; j < _pictureHeight / _placeSizeHeight + 1; ++j) + {//линия разметки места + g2d.drawLine(i * _placeSizeWidth + 5, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2 + 5, j * _placeSizeHeight); + } + + g2d.drawLine(i * _placeSizeWidth + 5, _placeSizeHeight * 2, i * _placeSizeWidth + 5, (_pictureHeight / _placeSizeHeight) * _placeSizeHeight); + } + + //отрисовка разметки взлётной полосы + g2d.setColor(Color.WHITE); + g2d.fillRect(_placeSizeWidth * 2 + 30, 0, 185, _pictureHeight); + g2d.fillRect(_placeSizeWidth * 2 + 35, 0, 175, _pictureHeight); + + g2d.setStroke(new BasicStroke(5)); + g2d.setColor(Color.WHITE); + g2d.drawLine(_placeSizeWidth * 2 + 210, 0, _placeSizeWidth * 2 + 210, _pictureHeight); + g2d.drawLine(_placeSizeWidth * 2 + 35, 0, _placeSizeWidth * 2 + 35, _pictureHeight); + g2d.drawLine(_placeSizeWidth * 2 + 215, 0, _placeSizeWidth * 2 + 215, _pictureHeight); + g2d.drawLine(_placeSizeWidth * 2 + 30, 0, _placeSizeWidth * 2 + 30, _pictureHeight); + + g2d.setStroke(new BasicStroke(5)); + g2d.setColor(new Color(0xFF, 0x45, 0x00)); + for (int i = 0; i < _pictureHeight / _placeSizeHeight; ++i) + { + g2d.drawLine(_placeSizeWidth * 2 + 125, 20 + i * _placeSizeHeight, _placeSizeWidth * 2 + 125, (i + 1) * _placeSizeHeight - 20); + } + + for(int i = 0; i < _pictureHeight / 20; i++) + { + g2d.drawLine(_placeSizeWidth * 2 + 15, 20 + i * _placeSizeHeight / 2, _placeSizeWidth * 2 + 15, (i + 1) * _placeSizeHeight / 2 - 20); + g2d.drawLine(_placeSizeWidth * 3 + 20, 20 + i * _placeSizeHeight / 2, _placeSizeWidth * 3 + 20, (i + 1) * _placeSizeHeight / 2 - 20); + } + + //отрисовка сочков + for(int i = 1; i < 6; i++) + { + g2d.setColor(new Color(0xFF, 0xB6, 0xC1)); + int[] xPoint = {(i * 70 - 10) + 45, i * 70 - 10, i * 70 - 10}; + int[] yPoint = {30, 50, 10}; + g.fillPolygon(xPoint, yPoint, xPoint.length); + + g2d.setStroke(new BasicStroke(3)); + g2d.setColor(Color.BLACK); + g2d.drawLine(i * 70 - 10, 10, i * 70 - 10, 80); + g2d.drawLine(i * 70 - 10, 10, (i * 70 - 10) + 45, 30); + g2d.drawLine(i * 70 - 10, 50, (i * 70 - 10) + 45, 30); + + } + } + + //метод прорисовки объеков + public void DrawPlanes(Graphics g) + { + int position = 0; + int currentWidth = 1; + int currentHeight = 5; + + for (int i = 0; i < _setPlanes.Count(); i++) + { + _setPlanes.Get(i).SetObject(currentWidth * _placeSizeWidth + 20, currentHeight * _placeSizeHeight + 20, _pictureWidth, _pictureHeight); + _setPlanes.Get(i).DrawningObject(g); + + if(position % 2 == 0) + { + position++; + currentWidth--; + } + else + { + position = 0; + currentWidth = 1; + currentHeight--; + } + } + } +} diff --git a/Project/src/SetPlanesGeneric.java b/Project/src/SetPlanesGeneric.java new file mode 100644 index 0000000..b1c3848 --- /dev/null +++ b/Project/src/SetPlanesGeneric.java @@ -0,0 +1,93 @@ +public class SetPlanesGeneric +{ + //массив объектов, которые храним + private final Object[] _places; + + //количество объектов в массиве + public int Count() + { + return _places.length; + } + + //конструктор + public SetPlanesGeneric(int count) + { + _places = new Object[count]; + } + + //добавление объекта в набор + public int Insert(T plane) + { + return Insert(plane, 0); + } + + //добавление объекта в набор на конкретную позицию + public int Insert(T plane, int position) + { + // проверка позиции + if (position >= _places.length || position < 0) + { + return -1; + } + + //проверка, что элемент массива по этой позиции пустой, если нет, то + if (_places[position] == null) + { + _places[position] = plane; + return position; + } + + //проверка, что после вставляемого элемента в массиве есть пустой элемент + int findEmptyPos = -1; + + for (int i = position + 1; i < Count(); i++) + { + if (_places[i] == null) + { + findEmptyPos = i; + break; + } + } + + if (findEmptyPos < 0) + { + return -1; + } + + // вставка по позиции + _places[position] = plane; + + return position; + } + + //удаление объекта из набора с конкретной позиции + public T Remove(int position) + { + // проверка позиции + if (position >= _places.length || position < 0) + { + return null; + } + + // удаление объекта из массива, присовив элементу массива значение null + T temp = (T)_places[position]; + _places[position] = null; + + return temp; + } + + //получение объекта из набора по позиции + public T Get(int position) + { + if (position >= _places.length || position < 0) + { + return null; + } + else if (_places[position] == null) + { + return null; + } + + return (T)_places[position]; + } +} -- 2.25.1 From 6474259b5f0f00de9e8a8d09e269f7c82bcb99fc Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sat, 5 Nov 2022 22:19:32 +0400 Subject: [PATCH 02/14] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BD=D0=BE=D0=B2=D0=BE=D0=B9=20=D1=84=D0=BE?= =?UTF-8?q?=D1=80=D0=BC=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/FormMapWithSetPlanes.form | 190 ++++++++++++++++++++++++++ Project/src/FormMapWithSetPlanes.java | 17 +++ 2 files changed, 207 insertions(+) create mode 100644 Project/src/FormMapWithSetPlanes.form create mode 100644 Project/src/FormMapWithSetPlanes.java diff --git a/Project/src/FormMapWithSetPlanes.form b/Project/src/FormMapWithSetPlanes.form new file mode 100644 index 0000000..3ca34c9 --- /dev/null +++ b/Project/src/FormMapWithSetPlanes.form @@ -0,0 +1,190 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Project/src/FormMapWithSetPlanes.java b/Project/src/FormMapWithSetPlanes.java new file mode 100644 index 0000000..d6d4ea5 --- /dev/null +++ b/Project/src/FormMapWithSetPlanes.java @@ -0,0 +1,17 @@ +import javax.swing.*; + +public class FormMapWithSetPlanes { + private JPanel MainPanel; + private JPanel PictureBoxPlane; + private JPanel ButtonGroupPanel; + private JComboBox ComboBoxSelectorMap; + private JButton ButtonLeft; + private JButton ButtonDown; + private JButton ButtonRight; + private JButton ButtonUp; + private JButton ButtonShowOnMap; + private JButton ButtonShowStorage; + private JButton ButtonAddPlane; + private JTextField __TextField; + private JButton ButtonRemovePlane; +} -- 2.25.1 From 571b302e4be59df0352539b90493b7151e3fd962 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sun, 6 Nov 2022 00:34:21 +0400 Subject: [PATCH 03/14] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B,=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D0=B8=D1=84=D0=B8=D0=BA=D0=BA=D0=B0=D1=86=D0=B8?= =?UTF-8?q?=D1=8F=20FormPlane=20=D0=B8=20=D0=BE=D0=B4=D0=BD=D0=BE=D0=B3?= =?UTF-8?q?=D0=BE=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=B0=20Generic.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/FormMapWithSetPlanes.java | 17 -- ....form => FormMapWithSetPlanesGeneric.form} | 4 +- Project/src/FormMapWithSetPlanesGeneric.java | 271 ++++++++++++++++++ Project/src/FormPlane.form | 82 ++++-- Project/src/FormPlane.java | 125 ++++++-- Project/src/MapWithSetPlanesGeneric.java | 12 +- 6 files changed, 428 insertions(+), 83 deletions(-) delete mode 100644 Project/src/FormMapWithSetPlanes.java rename Project/src/{FormMapWithSetPlanes.form => FormMapWithSetPlanesGeneric.form} (99%) create mode 100644 Project/src/FormMapWithSetPlanesGeneric.java diff --git a/Project/src/FormMapWithSetPlanes.java b/Project/src/FormMapWithSetPlanes.java deleted file mode 100644 index d6d4ea5..0000000 --- a/Project/src/FormMapWithSetPlanes.java +++ /dev/null @@ -1,17 +0,0 @@ -import javax.swing.*; - -public class FormMapWithSetPlanes { - private JPanel MainPanel; - private JPanel PictureBoxPlane; - private JPanel ButtonGroupPanel; - private JComboBox ComboBoxSelectorMap; - private JButton ButtonLeft; - private JButton ButtonDown; - private JButton ButtonRight; - private JButton ButtonUp; - private JButton ButtonShowOnMap; - private JButton ButtonShowStorage; - private JButton ButtonAddPlane; - private JTextField __TextField; - private JButton ButtonRemovePlane; -} diff --git a/Project/src/FormMapWithSetPlanes.form b/Project/src/FormMapWithSetPlanesGeneric.form similarity index 99% rename from Project/src/FormMapWithSetPlanes.form rename to Project/src/FormMapWithSetPlanesGeneric.form index 3ca34c9..dd21465 100644 --- a/Project/src/FormMapWithSetPlanes.form +++ b/Project/src/FormMapWithSetPlanesGeneric.form @@ -1,5 +1,5 @@ -
+ @@ -133,7 +133,7 @@ - + diff --git a/Project/src/FormMapWithSetPlanesGeneric.java b/Project/src/FormMapWithSetPlanesGeneric.java new file mode 100644 index 0000000..75b63af --- /dev/null +++ b/Project/src/FormMapWithSetPlanesGeneric.java @@ -0,0 +1,271 @@ +import javax.imageio.ImageIO; +import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.image.BufferedImage; + +public class FormMapWithSetPlanesGeneric { + private JPanel MainPanel; + private JPanel PictureBoxPlane; + private JPanel ButtonGroupPanel; + private JComboBox ComboBoxSelectorMap; + private JButton ButtonLeft; + private JButton ButtonDown; + private JButton ButtonRight; + private JButton ButtonUp; + private JButton ButtonShowOnMap; + private JButton ButtonShowStorage; + private JButton ButtonAddPlane; + private JTextField MaskedTextBoxPosition; + private JButton ButtonRemovePlane; + + //объект от класса карты с набором объектов + private MapWithSetPlanesGeneric _mapPlanesCollectionGeneric; + + //обновление отрисовки + public void UpdateWindow(BufferedImage bmp) + { + PictureBoxPlane.removeAll(); + JLabel imageWithMapAndObject = new JLabel(); + imageWithMapAndObject.setPreferredSize(PictureBoxPlane.getSize()); + imageWithMapAndObject.setMinimumSize(new Dimension(1, 1)); + imageWithMapAndObject.setIcon(new ImageIcon(bmp)); + PictureBoxPlane.add(imageWithMapAndObject, BorderLayout.CENTER); + PictureBoxPlane.revalidate(); + } + + public FormMapWithSetPlanesGeneric() + { + //загрузка изображений для кнопок + try + { + Image img = ImageIO.read(getClass().getResource("resourses/Up.png")); + ButtonUp.setIcon(new ImageIcon(img)); + img = ImageIO.read(getClass().getResource("resourses/Left.png")); + ButtonLeft.setIcon(new ImageIcon(img)); + img = ImageIO.read(getClass().getResource("resourses/Down.png")); + ButtonDown.setIcon(new ImageIcon(img)); + img = ImageIO.read(getClass().getResource("resourses/Right.png")); + ButtonRight.setIcon(new ImageIcon(img)); + } + catch (Exception ex) + { + System.out.println(ex.getMessage()); + } + + //добавление самолёта + ButtonAddPlane.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(_mapPlanesCollectionGeneric == null) + { + return; + } + + FormPlane form = new FormPlane(); + form.setSize(1000,700); + form.setVisible(true); + form.setModal(true); + DrawningObjectPlane plane = new DrawningObjectPlane(form.GetSelectedShip()); + + if(_mapPlanesCollectionGeneric.Add(plane) != -1) + { + JOptionPane.showMessageDialog(null,"Объект добавлен"); + UpdateWindow(_mapPlanesCollectionGeneric.ShowSet()); + } + else + { + JOptionPane.showMessageDialog(null,"Не удалось добавить объект"); + } + } + }); + + //удаление самолёта + ButtonRemovePlane.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (MaskedTextBoxPosition.getText().isEmpty()) + { + return; + } + + int result = JOptionPane.showConfirmDialog(null,"Удалить объект?","Удаление", + JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE); + if(result==JOptionPane.NO_OPTION) + { + return; + } + + int pos = Integer.parseInt(MaskedTextBoxPosition.getText()); + + if(_mapPlanesCollectionGeneric.Delete(pos) != null) + { + JOptionPane.showMessageDialog(null,"Объект удалён"); + UpdateWindow(_mapPlanesCollectionGeneric.ShowSet()); + } + else + { + JOptionPane.showMessageDialog(null,"Не удалось удалить объект"); + } + } + }); + + //показ хранилища + ButtonShowStorage.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(_mapPlanesCollectionGeneric == null) + { + return; + } + + UpdateWindow(_mapPlanesCollectionGeneric.ShowSet()); + } + }); + + //показ карты + ButtonShowOnMap.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (_mapPlanesCollectionGeneric == null) + { + return; + } + + UpdateWindow(_mapPlanesCollectionGeneric.ShowSet()); + } + }); + + ButtonUp.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(_mapPlanesCollectionGeneric == null) + { + return; + } + + PictureBoxPlane.removeAll(); + + JLabel imageWithMapAndObject = new JLabel(); + imageWithMapAndObject.setPreferredSize(PictureBoxPlane.getSize()); + imageWithMapAndObject.setMinimumSize(new Dimension(1, 1)); + imageWithMapAndObject.setIcon(new ImageIcon(_mapPlanesCollectionGeneric.MoveObject((Direction.Up)))); + + PictureBoxPlane.add(imageWithMapAndObject, BorderLayout.CENTER); + PictureBoxPlane.revalidate(); + PictureBoxPlane.repaint(); + } + }); + + ButtonLeft.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(_mapPlanesCollectionGeneric == null) + { + return; + } + + PictureBoxPlane.removeAll(); + + JLabel imageWithMapAndObject = new JLabel(); + imageWithMapAndObject.setPreferredSize(PictureBoxPlane.getSize()); + imageWithMapAndObject.setMinimumSize(new Dimension(1, 1)); + imageWithMapAndObject.setIcon(new ImageIcon(_mapPlanesCollectionGeneric.MoveObject((Direction.Left)))); + + PictureBoxPlane.add(imageWithMapAndObject, BorderLayout.CENTER); + PictureBoxPlane.revalidate(); + PictureBoxPlane.repaint(); + } + }); + + ButtonDown.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(_mapPlanesCollectionGeneric == null) + { + return; + } + + PictureBoxPlane.removeAll(); + + JLabel imageWithMapAndObject = new JLabel(); + imageWithMapAndObject.setPreferredSize(PictureBoxPlane.getSize()); + imageWithMapAndObject.setMinimumSize(new Dimension(1, 1)); + imageWithMapAndObject.setIcon(new ImageIcon(_mapPlanesCollectionGeneric.MoveObject((Direction.Down)))); + + PictureBoxPlane.add(imageWithMapAndObject, BorderLayout.CENTER); + PictureBoxPlane.revalidate(); + PictureBoxPlane.repaint(); + } + }); + + ButtonRight.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if(_mapPlanesCollectionGeneric == null) + { + return; + } + + PictureBoxPlane.removeAll(); + + JLabel imageWithMapAndObject = new JLabel(); + imageWithMapAndObject.setPreferredSize(PictureBoxPlane.getSize()); + imageWithMapAndObject.setMinimumSize(new Dimension(1, 1)); + imageWithMapAndObject.setIcon(new ImageIcon(_mapPlanesCollectionGeneric.MoveObject((Direction.Right)))); + + PictureBoxPlane.add(imageWithMapAndObject, BorderLayout.CENTER); + PictureBoxPlane.revalidate(); + PictureBoxPlane.repaint(); + } + }); + + //выпадающий список с вариантами карт + ComboBoxSelectorMap.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + AbstractMap map = null; + + ComboBoxSelectorMap = (JComboBox)e.getSource(); + String item = (String)ComboBoxSelectorMap.getSelectedItem(); + switch(item) + { + case "Простая карта": + map = new SimpleMap(); + break; + case "Буря в пустыне": + map = new DesertStormMap(); + break; + case "Звёздные войны": + map = new StarWarsMap(); + break; + } + + if(map != null) + { + _mapPlanesCollectionGeneric = new MapWithSetPlanesGeneric( + PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight(), map); + } + else + { + _mapPlanesCollectionGeneric = null; + } + } + }); + + + MaskedTextBoxPosition.addKeyListener(new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + char c = e.getKeyChar(); + + if ( ((c < '0') || (c > '9')) || MaskedTextBoxPosition.getText().length() >= 2) { + e.consume(); + } + } + }); + } +} diff --git a/Project/src/FormPlane.form b/Project/src/FormPlane.form index 9f4bf18..a801c1a 100644 --- a/Project/src/FormPlane.form +++ b/Project/src/FormPlane.form @@ -1,16 +1,16 @@ - + - + - + @@ -23,7 +23,7 @@ - + @@ -36,36 +36,28 @@ - + + + + + - - - - + + + + - - - - - - - - - - - - - + @@ -73,7 +65,7 @@ - + @@ -86,7 +78,7 @@ - + @@ -97,14 +89,46 @@ - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Project/src/FormPlane.java b/Project/src/FormPlane.java index 27b4444..de4e378 100644 --- a/Project/src/FormPlane.java +++ b/Project/src/FormPlane.java @@ -1,16 +1,12 @@ 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.awt.event.*; +import java.awt.image.BufferedImage; import java.util.Random; -public class FormPlane +public class FormPlane extends JDialog { - protected DrawingPlane plane; - public JPanel MainPanel; private JButton ButtonCreate; private JButton ButtonLeft; @@ -19,12 +15,54 @@ public class FormPlane private JButton ButtonUp; private JToolBar StatusStrip; private JPanel PictureBoxPlane; + private JButton ButtonCreateModif; + private JButton ButtonSelectPlane; private JLabel LabelSpeed = new JLabel(); private JLabel LabelWeight = new JLabel(); private JLabel LabelColor = new JLabel(); + protected DrawingPlane plane; + protected DrawingPlane _selectedPlane; + + public DrawingPlane GetSelectedShip() + { + return _selectedPlane; + } + + //метод отрисовки + public void Draw(DrawingPlane _plane) { + PictureBoxPlane.removeAll(); + BufferedImage bmp = new BufferedImage(PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight(), BufferedImage.TYPE_INT_RGB); + Graphics gr = bmp.getGraphics(); + + gr.setColor(new Color(238, 238, 238)); + gr.fillRect(0, 0, PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight()); + + if (plane.GetPlane() != null) { + _plane.DrawTransport(gr); + JLabel imageOfLogo = new JLabel(); + imageOfLogo.setPreferredSize(PictureBoxPlane.getSize()); + imageOfLogo.setMinimumSize(new Dimension(1, 1)); + imageOfLogo.setIcon(new ImageIcon(bmp)); + PictureBoxPlane.add(imageOfLogo, BorderLayout.CENTER); + } + + validate(); + } + + //создание всплывающего окна public FormPlane() { + super(new Frame("Airbus")); + CreateWindow(); + setModal(true); + getContentPane().add(MainPanel); + } + + public void CreateWindow() + { + setModal(true); + //создание строки отображения скорости, веса и цвета объекта Box LableBox = Box.createHorizontalBox(); LableBox.setMinimumSize(new Dimension(1, 20)); @@ -49,30 +87,60 @@ public class FormPlane System.out.println(ex.getMessage()); } + _selectedPlane = plane; ButtonCreate.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Random rnd = new Random(); + Color colorSimple = JColorChooser.showDialog(null, "Выберите цвет", null); + plane = new DrawingPlane(rnd.nextInt(100, 300), rnd.nextInt(1000, 2000), - new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256))); + colorSimple); plane.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100), PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight()); + LabelSpeed.setText("Скорость: " + plane.GetPlane().GetSpeed() + " "); LabelWeight.setText("Вес: " + plane.GetPlane().GetWeight() + " "); LabelColor.setText("Цвет: r = " + plane.GetPlane().GetColor().getRed() + " g = " + plane.GetPlane().GetColor().getGreen() + " b = " + plane.GetPlane().GetColor().getBlue()); - Draw(); + + Draw(plane); } }); - //обновление размеров формы - MainPanel.addComponentListener(new ComponentAdapter() { + ButtonCreateModif.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Random rnd = new Random(); + Color colorSimple = JColorChooser.showDialog(null, "Выберите цвет", null); + Color colorModif = JColorChooser.showDialog(null, "Выберите цвет", null); + + plane = new DrawingAirbus(rnd.nextInt(100, 300), rnd.nextInt(1000, 2000), + colorSimple, colorModif, rnd.nextBoolean(), rnd.nextBoolean()); + plane.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100), + PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight()); + + LabelSpeed.setText("Скорость: " + plane.GetPlane().GetSpeed() + " "); + LabelWeight.setText("Вес: " + plane.GetPlane().GetWeight() + " "); + LabelColor.setText("Цвет: r = " + plane.GetPlane().GetColor().getRed() + " g = " + plane.GetPlane().GetColor().getGreen() + + " b = " + plane.GetPlane().GetColor().getBlue()); + + Draw(plane); + } + }); + + PictureBoxPlane.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { super.componentResized(e); - plane.ChangeBorders(PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight()); - Draw(); + + if(plane != null) + { + plane.ChangeBorders(PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight()); + PictureBoxPlane.revalidate(); + Draw(plane); + } } }); @@ -80,7 +148,8 @@ public class FormPlane @Override public void actionPerformed(ActionEvent e) { plane.MoveTransport(Direction.Up); - Draw(); + PictureBoxPlane.revalidate(); + Draw(plane); } }); @@ -88,7 +157,8 @@ public class FormPlane @Override public void actionPerformed(ActionEvent e) { plane.MoveTransport(Direction.Left); - Draw(); + PictureBoxPlane.revalidate(); + Draw(plane); } }); @@ -96,7 +166,8 @@ public class FormPlane @Override public void actionPerformed(ActionEvent e) { plane.MoveTransport(Direction.Down); - Draw(); + PictureBoxPlane.revalidate(); + Draw(plane); } }); @@ -104,18 +175,18 @@ public class FormPlane @Override public void actionPerformed(ActionEvent e) { plane.MoveTransport(Direction.Right); - Draw(); + PictureBoxPlane.revalidate(); + Draw(plane); + } + }); + + //кнопка подтверждение выбора + ButtonSelectPlane.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + _selectedPlane = plane; + dispose(); } }); } - - public void Draw() - { - if(plane.GetPlane() == null) - { - return; - } - - plane.DrawTransport(PictureBoxPlane.getGraphics()); - } } diff --git a/Project/src/MapWithSetPlanesGeneric.java b/Project/src/MapWithSetPlanesGeneric.java index 8050679..1a56b30 100644 --- a/Project/src/MapWithSetPlanesGeneric.java +++ b/Project/src/MapWithSetPlanesGeneric.java @@ -32,19 +32,15 @@ public class MapWithSetPlanesGeneric map, T plane) + public int Add(T plane) { - return map._setPlanes.Insert(plane); + return _setPlanes.Insert(plane); } - //перегрузка оператора вычитания - public static T operator -(MapWithSetPlanesGeneric map, int position) + public T Delete(int position) { - return map._setPlanes.Remove(position); + return _setPlanes.Remove(position); } - */ //вывод всего набора объектов public BufferedImage ShowSet() -- 2.25.1 From 3818ea591bca474924b2f82ddfdee8bf8d78ff17 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sun, 6 Nov 2022 12:34:47 +0400 Subject: [PATCH 04/14] =?UTF-8?q?=D0=9D=D0=B0=D1=81=D1=82=D1=80=D0=BE?= =?UTF-8?q?=D0=B9=D0=BA=D0=B0=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=85=D1=80=D0=B0=D0=BD=D0=B8=D0=BB?= =?UTF-8?q?=D0=B8=D1=89=D0=B0=20=D0=B8=20=D0=B2=D1=8B=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE=D0=B9=20=D0=BA=D0=B0=D1=80=D1=82=D1=8B,=20?= =?UTF-8?q?=D0=B0=20=D1=82=D0=B0=D0=BA=D0=B6=D0=B5=20=D0=BE=D0=B1=D1=8A?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=BE=D0=B2=20=D0=B2=20=D1=85=D1=80=D0=B0?= =?UTF-8?q?=D0=BD=D0=B8=D0=BB=D0=B8=D1=89=D0=B5.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/DrawingPlane.java | 37 +++- Project/src/FormMap.form | 127 ------------ Project/src/FormMap.java | 201 ------------------- Project/src/FormMapWithSetPlanesGeneric.form | 5 +- Project/src/FormMapWithSetPlanesGeneric.java | 6 +- Project/src/FormPlane.form | 11 +- Project/src/Main.java | 4 +- Project/src/MapWithSetPlanesGeneric.java | 11 +- 8 files changed, 43 insertions(+), 359 deletions(-) delete mode 100644 Project/src/FormMap.form delete mode 100644 Project/src/FormMap.java diff --git a/Project/src/DrawingPlane.java b/Project/src/DrawingPlane.java index 9a3a4d9..6a56d50 100644 --- a/Project/src/DrawingPlane.java +++ b/Project/src/DrawingPlane.java @@ -135,20 +135,15 @@ public class DrawingPlane extends JPanel Graphics2D g2d = (Graphics2D)g; - //корпус + //заливка корпуса g2d.setColor(Plane.GetColor()); g2d.fillRect((int)_startPosX, (int)_startPosY + 10, 40, 10); - //заливает фигуру - g2d.setPaint(Color.BLACK); - //крыло + g2d.setColor(Color.BLACK); g2d.fillRect((int)_startPosX + 10, (int)_startPosY + 15, 20, 2); g2d.fillRect((int)_startPosX + 12, (int)_startPosY + 17, 16, 2); - //заднее поперечное крыло - g2d.fillOval((int)_startPosX - 3, (int)_startPosY + 7, 10, 5); - //задние шасси g2d.fillRect((int)_startPosX + 10, (int)_startPosY + 21, 2, 2); g2d.fillRect((int)_startPosX + 12, (int)_startPosY + 23, 4, 4); @@ -158,15 +153,37 @@ public class DrawingPlane extends JPanel g2d.fillRect((int)_startPosX + 35, (int)_startPosY + 21, 2, 2); g2d.fillRect((int)_startPosX + 35, (int)_startPosY + 23, 4, 4); - //хвостовое крыло + //заливка хвостового крыла + g2d.setColor(Plane.GetColor()); + int[] xCoordFirst = {(int)_startPosX, (int)_startPosX, (int)_startPosX + 10}; + int[] yCoordFirst = {(int)_startPosY + 10, (int)_startPosY, (int)_startPosY + 10}; + g2d.fillPolygon(xCoordFirst, yCoordFirst, xCoordFirst.length); + + //заливка носа самолёта + int[] xCoordSecond = {(int)_startPosX + 40, (int)_startPosX + 47, (int)_startPosX + 40}; + int[] yCoordSecond = {(int)_startPosY + 15, (int)_startPosY + 15, (int)_startPosY + 10}; + g2d.fillPolygon(xCoordSecond, yCoordSecond, xCoordSecond.length); + + int[] xCoordThird = {(int)_startPosX + 40, (int)_startPosX + 50, (int)_startPosX + 40}; + int[] yCoordThird = {(int)_startPosY + 15, (int)_startPosY + 15, (int)_startPosY + 20}; + g2d.fillPolygon(xCoordThird, yCoordThird, xCoordThird.length); + + //контур хвостового крыла + g2d.setColor(Color.BLACK); g2d.drawLine((int)_startPosX, (int)_startPosY + 10, (int)_startPosX, (int)_startPosY); g2d.drawLine((int)_startPosX, (int)_startPosY, (int)_startPosX + 10, (int)_startPosY + 10); - //нос самолёта - g2d.drawLine((int)_startPosX + 40, (int)_startPosY + 15, (int)_startPosX + 50, (int)_startPosY + 16); + //отрисовка контура самолёта + g2d.drawLine((int)_startPosX + 40, (int)_startPosY + 15, (int)_startPosX + 50, (int)_startPosY + 15); g2d.drawLine((int)_startPosX + 40, (int)_startPosY + 10, (int)_startPosX + 47, (int)_startPosY + 15); g2d.drawLine((int)_startPosX + 40, (int)_startPosY + 20, (int)_startPosX + 50, (int)_startPosY + 15); + //контур корпуса + g2d.drawRect((int)_startPosX, (int)_startPosY + 10, 40, 10); + + //заднее поперечное крыло + g2d.fillOval((int)_startPosX - 3, (int)_startPosY + 7, 10, 5); + //отрисовка иллюминаторов _airplaneWindow.DrawAirplaneWindow(Plane.GetColor(), g, _startPosX, _startPosY); } diff --git a/Project/src/FormMap.form b/Project/src/FormMap.form deleted file mode 100644 index 0eeac40..0000000 --- a/Project/src/FormMap.form +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Project/src/FormMap.java b/Project/src/FormMap.java deleted file mode 100644 index e08377f..0000000 --- a/Project/src/FormMap.java +++ /dev/null @@ -1,201 +0,0 @@ -import javax.imageio.ImageIO; -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.image.BufferedImage; -import java.util.Random; - -public class FormMap extends JFrame -{ - public JPanel MainPanel; - private JButton ButtonCreate; - private JButton ButtonCreateModif; - private JButton ButtonLeft; - private JButton ButtonDown; - private JButton ButtonRight; - private JButton ButtonUp; - private JToolBar StatusStrip; - private JPanel PictureBoxPlane; - private JComboBox ComboBoxSelectorMap; - private JLabel LabelSpeed = new JLabel(); - private JLabel LabelWeight = new JLabel(); - private JLabel LabelColor = new JLabel(); - - protected DrawingPlane _plane; - private AbstractMap _abstractMap; - private Random rnd = new Random(); - private BufferedImage bufferImg = null; - - public void Draw() - { - if (bufferImg == null) - { - return; - } - - PictureBoxPlane.getGraphics().drawImage(bufferImg, 0, 0, PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight(), null); - } - - public void SetData(DrawingPlane _plane) - { - PictureBoxPlane.removeAll(); - - LabelSpeed.setText("Скорость: " + _plane.GetPlane().GetSpeed() + " "); - LabelWeight.setText("Вес: " + _plane.GetPlane().GetWeight() + " "); - LabelColor.setText("Цвет: r = " + _plane.GetPlane().GetColor().getRed() + " g = " + _plane.GetPlane().GetColor().getGreen() + - " b = " + _plane.GetPlane().GetColor().getBlue()); - - if (_abstractMap != null) - { - bufferImg = _abstractMap.CreateMap(PictureBoxPlane.getWidth(), - PictureBoxPlane.getHeight(), new DrawningObjectPlane(_plane)); - } - - PictureBoxPlane.revalidate(); - } - - public FormMap() - { - _abstractMap = new SimpleMap(); - - //создание строки отображения скорости, веса и цвета объекта - Box LableBox = Box.createHorizontalBox(); - LableBox.setMinimumSize(new Dimension(1, 20)); - LableBox.add(LabelSpeed); - LableBox.add(LabelWeight); - LableBox.add(LabelColor); - StatusStrip.add(LableBox); - - try - { - Image img = ImageIO.read(getClass().getResource("resourses/Up.png")); - ButtonUp.setIcon(new ImageIcon(img)); - img = ImageIO.read(getClass().getResource("resourses/Left.png")); - ButtonLeft.setIcon(new ImageIcon(img)); - img = ImageIO.read(getClass().getResource("resourses/Down.png")); - ButtonDown.setIcon(new ImageIcon(img)); - img = ImageIO.read(getClass().getResource("resourses/Right.png")); - ButtonRight.setIcon(new ImageIcon(img)); - } - catch (Exception ex) - { - System.out.println(ex.getMessage()); - } - - ButtonCreate.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Random rnd = new Random(); - var plane = new DrawingPlane(rnd.nextInt(100, 300), rnd.nextInt(1000, 2000), - new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256))); - plane.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100), - PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight()); - SetData(plane); - Draw(); - } - }); - - ButtonUp.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - PictureBoxPlane.removeAll(); - - JLabel imageWithMapAndObject = new JLabel(); - imageWithMapAndObject.setPreferredSize(PictureBoxPlane.getSize()); - imageWithMapAndObject.setMinimumSize(new Dimension(1, 1)); - imageWithMapAndObject.setIcon(new ImageIcon(_abstractMap.MoveObject((Direction.Up)))); - - PictureBoxPlane.add(imageWithMapAndObject, BorderLayout.CENTER); - PictureBoxPlane.revalidate(); - PictureBoxPlane.repaint(); - Draw(); - } - }); - - ButtonLeft.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - PictureBoxPlane.removeAll(); - - JLabel imageWithMapAndObject = new JLabel(); - imageWithMapAndObject.setPreferredSize(PictureBoxPlane.getSize()); - imageWithMapAndObject.setMinimumSize(new Dimension(1, 1)); - imageWithMapAndObject.setIcon(new ImageIcon(_abstractMap.MoveObject((Direction.Left)))); - - PictureBoxPlane.add(imageWithMapAndObject, BorderLayout.CENTER); - PictureBoxPlane.revalidate(); - PictureBoxPlane.repaint(); - Draw(); - } - }); - - ButtonDown.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - PictureBoxPlane.removeAll(); - - JLabel imageWithMapAndObject = new JLabel(); - imageWithMapAndObject.setPreferredSize(PictureBoxPlane.getSize()); - imageWithMapAndObject.setMinimumSize(new Dimension(1, 1)); - imageWithMapAndObject.setIcon(new ImageIcon(_abstractMap.MoveObject((Direction.Down)))); - - PictureBoxPlane.add(imageWithMapAndObject, BorderLayout.CENTER); - PictureBoxPlane.revalidate(); - PictureBoxPlane.repaint(); - Draw(); - } - }); - - ButtonRight.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - PictureBoxPlane.removeAll(); - - JLabel imageWithMapAndObject = new JLabel(); - imageWithMapAndObject.setPreferredSize(PictureBoxPlane.getSize()); - imageWithMapAndObject.setMinimumSize(new Dimension(1, 1)); - imageWithMapAndObject.setIcon(new ImageIcon(_abstractMap.MoveObject((Direction.Right)))); - - PictureBoxPlane.add(imageWithMapAndObject, BorderLayout.CENTER); - PictureBoxPlane.revalidate(); - PictureBoxPlane.repaint(); - Draw(); - } - }); - - ButtonCreateModif.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - _plane = new DrawingAirbus(rnd.nextInt(100, 300), rnd.nextInt(1000, 2000), - new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)), - new Color(rnd.nextInt(256), rnd.nextInt(256), rnd.nextInt(256)), - rnd.nextBoolean(), rnd.nextBoolean()); - _plane.SetPosition(rnd.nextInt(100, 500), rnd.nextInt(10, 100), - PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight()); - SetData(_plane); - Draw(); - } - }); - - ComboBoxSelectorMap.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - ComboBoxSelectorMap = (JComboBox)e.getSource(); - String item = (String)ComboBoxSelectorMap.getSelectedItem(); - switch(item) - { - case "Простая карта": - _abstractMap = new SimpleMap(); - break; - case "Буря в пустыне": - _abstractMap = new DesertStormMap(); - break; - case "Звёздные войны": - _abstractMap = new StarWarsMap(); - break; - } - } - }); - } -} diff --git a/Project/src/FormMapWithSetPlanesGeneric.form b/Project/src/FormMapWithSetPlanesGeneric.form index dd21465..77fa7e4 100644 --- a/Project/src/FormMapWithSetPlanesGeneric.form +++ b/Project/src/FormMapWithSetPlanesGeneric.form @@ -8,8 +8,7 @@ - - + @@ -143,7 +142,7 @@ - + diff --git a/Project/src/FormMapWithSetPlanesGeneric.java b/Project/src/FormMapWithSetPlanesGeneric.java index 75b63af..7d3164f 100644 --- a/Project/src/FormMapWithSetPlanesGeneric.java +++ b/Project/src/FormMapWithSetPlanesGeneric.java @@ -8,7 +8,7 @@ import java.awt.event.KeyEvent; import java.awt.image.BufferedImage; public class FormMapWithSetPlanesGeneric { - private JPanel MainPanel; + public JPanel MainPanel; private JPanel PictureBoxPlane; private JPanel ButtonGroupPanel; private JComboBox ComboBoxSelectorMap; @@ -66,7 +66,7 @@ public class FormMapWithSetPlanesGeneric { } FormPlane form = new FormPlane(); - form.setSize(1000,700); + form.setSize(700,400); form.setVisible(true); form.setModal(true); DrawningObjectPlane plane = new DrawningObjectPlane(form.GetSelectedShip()); @@ -135,7 +135,7 @@ public class FormMapWithSetPlanesGeneric { return; } - UpdateWindow(_mapPlanesCollectionGeneric.ShowSet()); + UpdateWindow(_mapPlanesCollectionGeneric.ShowOnMap()); } }); diff --git a/Project/src/FormPlane.form b/Project/src/FormPlane.form index a801c1a..294e38b 100644 --- a/Project/src/FormPlane.form +++ b/Project/src/FormPlane.form @@ -34,15 +34,6 @@ - - - - - - - - - @@ -91,7 +82,7 @@ - + diff --git a/Project/src/Main.java b/Project/src/Main.java index 6387f7b..362eaca 100644 --- a/Project/src/Main.java +++ b/Project/src/Main.java @@ -5,11 +5,11 @@ public class Main public static void main(String[] args) { JFrame frame = new JFrame("Airbus"); - frame.setContentPane(new FormMap().MainPanel); + frame.setContentPane(new FormMapWithSetPlanesGeneric().MainPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocation(500, 200); frame.pack(); - frame.setSize(1000, 500); + frame.setSize(1000, 600); frame.setVisible(true); } } diff --git a/Project/src/MapWithSetPlanesGeneric.java b/Project/src/MapWithSetPlanesGeneric.java index 1a56b30..8183b89 100644 --- a/Project/src/MapWithSetPlanesGeneric.java +++ b/Project/src/MapWithSetPlanesGeneric.java @@ -121,10 +121,12 @@ public class MapWithSetPlanesGeneric Date: Sun, 6 Nov 2022 12:53:10 +0400 Subject: [PATCH 05/14] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D0=BE=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B8=20=D1=85=D1=80=D0=B0=D0=BD=D0=B8=D0=BB=D0=B8=D1=89?= =?UTF-8?q?=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/MapWithSetPlanesGeneric.java | 7 ++++--- Project/src/SetPlanesGeneric.java | 22 ++++++++++++++-------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Project/src/MapWithSetPlanesGeneric.java b/Project/src/MapWithSetPlanesGeneric.java index 8183b89..6c36283 100644 --- a/Project/src/MapWithSetPlanesGeneric.java +++ b/Project/src/MapWithSetPlanesGeneric.java @@ -134,8 +134,7 @@ public class MapWithSetPlanesGeneric //добавление объекта в набор на конкретную позицию public int Insert(T plane, int position) { - // проверка позиции + //проверка на корректность значения индекса if (position >= _places.length || position < 0) { return -1; } - //проверка, что элемент массива по этой позиции пустой, если нет, то + //проверка ячейки на пустоту if (_places[position] == null) { _places[position] = plane; + return position; } - //проверка, что после вставляемого элемента в массиве есть пустой элемент - int findEmptyPos = -1; - + //поиск первой свободной ячейки + int _emptyPositionIndex = -1; for (int i = position + 1; i < Count(); i++) { if (_places[i] == null) { - findEmptyPos = i; + _emptyPositionIndex = i; break; } } - if (findEmptyPos < 0) + //есла пустых ячеек нет + if (_emptyPositionIndex < 0) { return -1; } - // вставка по позиции + //сдвиг объектов + for (int i = _emptyPositionIndex; i > position; i--) + { + _places[i] = _places[i - 1]; + } + _places[position] = plane; return position; -- 2.25.1 From e4aca29884d0a18d2047f130d243e2f76f1eb4ff Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sun, 6 Nov 2022 13:43:57 +0400 Subject: [PATCH 06/14] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=B4=D0=BE=D0=BF.=20=D0=BA=D0=BB?= =?UTF-8?q?=D0=B0=D1=81=D1=81=D0=B0=20=D0=BF=D0=BE=20=D0=B7=D0=B0=D0=B4?= =?UTF-8?q?=D0=B0=D0=BD=D0=B8=D1=8E,=20=D0=B4=D0=BE=D1=80=D0=B0=D0=B1?= =?UTF-8?q?=D0=BE=D1=82=D0=BA=D0=B0=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81=D0=BE?= =?UTF-8?q?=D0=B2=20=D0=BE=D1=82=D1=80=D0=B8=D1=81=D0=BE=D0=B2=D0=BA=D0=B8?= =?UTF-8?q?=20DrawPlane=20=D0=B8=20DrawAirbus=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D0=B2=D0=B7=D0=B0=D0=B8=D0=BC=D0=BE=D0=B4=D0=B5=D0=B9=D1=81?= =?UTF-8?q?=D1=82=D0=B2=D0=B8=D1=8F=20=D1=81=20=D0=BD=D0=B8=D0=BC.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/DrawingAirbus.java | 9 +++- Project/src/DrawingEntities.java | 78 ++++++++++++++++++++++++++++++++ Project/src/DrawingPlane.java | 7 +++ 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 Project/src/DrawingEntities.java diff --git a/Project/src/DrawingAirbus.java b/Project/src/DrawingAirbus.java index 0a46bb8..e5cf23d 100644 --- a/Project/src/DrawingAirbus.java +++ b/Project/src/DrawingAirbus.java @@ -2,13 +2,20 @@ import java.awt.*; public class DrawingAirbus extends DrawingPlane { - //Инициализаци свойств + //Конструктор public DrawingAirbus(int speed, int weight, Color corpusColor, Color addColor, boolean addCompartment, boolean addEngine) { super(speed, weight, corpusColor, 70, 30); Plane = new EntityAirbus(speed, weight, corpusColor, addColor, addCompartment, addEngine); } + //Второй конструктор + public DrawingAirbus(EntityPlane plane, IAdditionalDrawingObject addWindows) + { + super(plane, addWindows); + Plane = plane; + } + @Override public void DrawTransport(Graphics g) { diff --git a/Project/src/DrawingEntities.java b/Project/src/DrawingEntities.java new file mode 100644 index 0000000..c99f11b --- /dev/null +++ b/Project/src/DrawingEntities.java @@ -0,0 +1,78 @@ +import java.util.Random; + +public class DrawingEntities +{ + public EntityPlane[] _arrPlane; + public IAdditionalDrawingObject[] _arrWindow; + int countArrPlane = 0; + int countArrWindows = 0; + String _x_index; + String _y_index; + + //конструктор + public DrawingEntities(int sizeArrPlane, int sizeArrAddElem) + { + _arrPlane = new EntityPlane[sizeArrPlane]; + _arrWindow = new IAdditionalDrawingObject[sizeArrAddElem]; + } + + //добавить сущность-самолёт + public int Insert(T plane) + { + if(countArrPlane < _arrPlane.length) + { + _arrPlane[countArrPlane] = plane; + countArrPlane++; + + return countArrPlane - 1; + } + + return -1; + } + + //добавить кол-во и тип иллюминаторов + public int Insert(U addElement) + { + if(countArrWindows < _arrWindow.length) + { + _arrWindow[countArrWindows] = addElement; + countArrWindows++; + + return countArrWindows - 1; + } + + return -1; + } + + //фиксирование индексов + public void SetIndex(int indexFirst, int indexSecond) + { + _x_index = Integer.toString(indexFirst); + _y_index = Integer.toString(indexSecond); + } + + public DrawingPlane CreatePlane() + { + Random rnd = new Random(); + int indexPlane = 0; + int indexArrWindow = 0; + + if(countArrPlane - 1 != 0 && countArrWindows - 1 != 0) + { + indexPlane = rnd.nextInt(0, countArrPlane - 1); + indexArrWindow = rnd.nextInt(0, countArrWindows - 1); + } + + T plane = (T)_arrPlane[indexPlane]; + U windows = (U)_arrWindow[indexArrWindow]; + + SetIndex(indexPlane, indexArrWindow); + + if(plane instanceof EntityAirbus) + { + return new DrawingAirbus(plane, windows); + } + + return new DrawingPlane(plane, windows); + } +} diff --git a/Project/src/DrawingPlane.java b/Project/src/DrawingPlane.java index 6a56d50..74c5382 100644 --- a/Project/src/DrawingPlane.java +++ b/Project/src/DrawingPlane.java @@ -65,6 +65,13 @@ public class DrawingPlane extends JPanel _airbusHeight = planeHeight; } + //второй конструктор + public DrawingPlane(EntityPlane plane, IAdditionalDrawingObject countWindow) + { + Plane = plane; + _airplaneWindow = countWindow; + } + //установка координат позиции самолёта public void SetPosition(int x, int y, int width, int height) { -- 2.25.1 From 186c08abd83cb5cd3c0eaa64fdc4662d8f1b2322 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sun, 6 Nov 2022 14:04:17 +0400 Subject: [PATCH 07/14] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=B4=D0=BE=D0=BF.=20=D1=84=D0=BE=D1=80=D0=BC?= =?UTF-8?q?=D1=8B=20=D0=BF=D0=BE=20=D0=B4=D0=BE=D0=BF.=20=D0=B7=D0=B0?= =?UTF-8?q?=D0=B4=D0=B0=D0=BD=D0=B8=D1=8E.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/FormParam.form | 100 +++++++++++++++++++++++++++++++++++++ Project/src/FormParam.java | 14 ++++++ 2 files changed, 114 insertions(+) create mode 100644 Project/src/FormParam.form create mode 100644 Project/src/FormParam.java diff --git a/Project/src/FormParam.form b/Project/src/FormParam.form new file mode 100644 index 0000000..37dce4a --- /dev/null +++ b/Project/src/FormParam.form @@ -0,0 +1,100 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/Project/src/FormParam.java b/Project/src/FormParam.java new file mode 100644 index 0000000..f1201f1 --- /dev/null +++ b/Project/src/FormParam.java @@ -0,0 +1,14 @@ +import javax.swing.*; + +public class FormParam +{ + + private JButton ButtonAddPlane; + private JPanel PictureBoxPlane; + private JButton ButtonCreateModif; + private JLabel LabelInfo; + private JLabel LableSpeed; + private JLabel LabelWeight; + private JPanel MainPanel; + private JLabel LabelColor; +} -- 2.25.1 From 8320f6de72206ab3c7c41cddd7d74448ed3df337 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sun, 6 Nov 2022 15:04:39 +0400 Subject: [PATCH 08/14] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D0=B4=D0=BE=D0=BF.=20=D1=84=D0=BE=D1=80?= =?UTF-8?q?=D0=BC=D1=8B=20=D0=BF=D0=BE=20=D0=B7=D0=B0=D0=B4=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8E.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/FormParam.form | 33 ++-------- Project/src/FormParam.java | 129 +++++++++++++++++++++++++++++++++++-- Project/src/Main.java | 6 +- 3 files changed, 131 insertions(+), 37 deletions(-) diff --git a/Project/src/FormParam.form b/Project/src/FormParam.form index 37dce4a..90819ad 100644 --- a/Project/src/FormParam.form +++ b/Project/src/FormParam.form @@ -8,7 +8,7 @@ - + @@ -54,8 +54,7 @@ - - + @@ -65,33 +64,11 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/Project/src/FormParam.java b/Project/src/FormParam.java index f1201f1..5be08b6 100644 --- a/Project/src/FormParam.java +++ b/Project/src/FormParam.java @@ -1,14 +1,131 @@ import javax.swing.*; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.image.BufferedImage; +import java.nio.file.attribute.AclEntryType; +import java.util.Random; +import java.util.Set; -public class FormParam +public class FormParam extends JFrame { - + public JPanel MainPanel; private JButton ButtonAddPlane; private JPanel PictureBoxPlane; private JButton ButtonCreateModif; private JLabel LabelInfo; - private JLabel LableSpeed; - private JLabel LabelWeight; - private JPanel MainPanel; - private JLabel LabelColor; + private JLabel LabelSpeed = new JLabel(); + private JLabel LabelWeight = new JLabel(); + private JLabel LabelColor = new JLabel(); + private JToolBar StatusStrip; + + private DrawingEntities _drawingEntities; + + private IAdditionalDrawingObject SetData() + { + Random rnd = new Random(); + int r = rnd.nextInt(3); + + if(r == 0) + { + return new DrawingAirplaneWindow(); + } + + if(r == 1) + { + return new DrawingTriangleAirplaneWindow(); + } + + //if r == 2 + return new DrawingRectAirplaneWindow(); + } + + private void Draw(DrawingPlane _plane) + { + PictureBoxPlane.removeAll(); + Random rnd = new Random(); + BufferedImage bmp = new BufferedImage(PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight(), BufferedImage.TYPE_INT_RGB); + Graphics gr = bmp.getGraphics(); + gr.setColor(new Color(238, 238, 238)); + gr.fillRect(0, 0, PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight()); + + if(_plane != null) + { + _plane.SetPosition(rnd.nextInt(10, 100), rnd.nextInt(10, 100), + PictureBoxPlane.getWidth(), PictureBoxPlane.getHeight()); + _plane.DrawTransport(gr); + LabelSpeed.setText("Скорость: " + _plane.GetPlane().GetSpeed() + " "); + LabelWeight.setText("Вес: " + _plane.GetPlane().GetWeight() + " "); + LabelColor.setText("Цвет: r = " + _plane.GetPlane().GetColor().getRed() + " g = " + _plane.GetPlane().GetColor().getGreen() + + " b = " + _plane.GetPlane().GetColor().getBlue()); + JLabel imageOfLogo = new JLabel(); + imageOfLogo.setPreferredSize(PictureBoxPlane.getSize()); + imageOfLogo.setMinimumSize(new Dimension(1, 1)); + imageOfLogo.setIcon(new ImageIcon(bmp)); + PictureBoxPlane.add(imageOfLogo, BorderLayout.CENTER); + } + + validate(); + } + + public FormParam() + { + //создание строки отображения скорости, веса и цвета объекта + Box LableBox = Box.createHorizontalBox(); + LableBox.setMinimumSize(new Dimension(1, 20)); + LableBox.add(LabelSpeed); + LableBox.add(LabelWeight); + LableBox.add(LabelColor); + StatusStrip.add(LableBox); + + _drawingEntities = new DrawingEntities<>(10, 10); + + ButtonAddPlane.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Random rnd = new Random(); + Color colorCorpus = JColorChooser.showDialog(null, "Выбор цвета", null); + EntityPlane plane = new EntityPlane(rnd.nextInt(100, 300), rnd.nextInt(1000, 2000), colorCorpus); + IAdditionalDrawingObject addWindows = SetData(); + int countWindows = rnd.nextInt(1, 4); + addWindows.SetAddEnum(countWindows); + + if((_drawingEntities.Insert(plane) != -1) && (_drawingEntities.Insert(addWindows) != -1)) + { + JOptionPane.showMessageDialog(null, "Объект добавлен"); + Draw(_drawingEntities.CreatePlane()); + LabelInfo.setText(_drawingEntities._x_index + " " + _drawingEntities._y_index); + } + else + { + JOptionPane.showMessageDialog(null, "Не удалось добавить объект"); + } + } + }); + + ButtonCreateModif.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + Random rnd = new Random(); + Color colorFirst = JColorChooser.showDialog(null, "Выбор цвета", null); + Color colorSecond = JColorChooser.showDialog(null, "Выбор цвета", null); + EntityAirbus airbus = new EntityAirbus(rnd.nextInt(100, 300), rnd.nextInt(1000, 2000), + colorFirst, colorSecond, rnd.nextBoolean(), rnd.nextBoolean()); + IAdditionalDrawingObject addWindows = SetData(); + int countWindows = rnd.nextInt(1, 4); + addWindows.SetAddEnum(countWindows); + + if((_drawingEntities.Insert(airbus) != -1) && (_drawingEntities.Insert(addWindows) != -1)) + { + JOptionPane.showMessageDialog(null, "Объект добавлен"); + Draw(_drawingEntities.CreatePlane()); + LabelInfo.setText(_drawingEntities._x_index + " " + _drawingEntities._y_index); + } + else + { + JOptionPane.showMessageDialog(null, "Не удалось добавить объект"); + } + } + }); + } } diff --git a/Project/src/Main.java b/Project/src/Main.java index 362eaca..2641f29 100644 --- a/Project/src/Main.java +++ b/Project/src/Main.java @@ -4,12 +4,12 @@ public class Main { public static void main(String[] args) { - JFrame frame = new JFrame("Airbus"); - frame.setContentPane(new FormMapWithSetPlanesGeneric().MainPanel); + JFrame frame = new JFrame("Аэробус"); + frame.setContentPane(new FormParam().MainPanel); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setLocation(500, 200); frame.pack(); - frame.setSize(1000, 600); + frame.setSize(800, 500); frame.setVisible(true); } } -- 2.25.1 From 3ab8e81bd920d104a59aca63330edc7d8d3cb2e1 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sun, 6 Nov 2022 15:06:43 +0400 Subject: [PATCH 09/14] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/FormParam.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/Project/src/FormParam.java b/Project/src/FormParam.java index 5be08b6..7a7be63 100644 --- a/Project/src/FormParam.java +++ b/Project/src/FormParam.java @@ -3,9 +3,7 @@ import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.image.BufferedImage; -import java.nio.file.attribute.AclEntryType; import java.util.Random; -import java.util.Set; public class FormParam extends JFrame { -- 2.25.1 From 3288b08c04b45bbf283e9dfcad100135114d88c8 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Sun, 6 Nov 2022 17:34:50 +0400 Subject: [PATCH 10/14] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/FormMapWithSetPlanesGeneric.form | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project/src/FormMapWithSetPlanesGeneric.form b/Project/src/FormMapWithSetPlanesGeneric.form index 77fa7e4..0604884 100644 --- a/Project/src/FormMapWithSetPlanesGeneric.form +++ b/Project/src/FormMapWithSetPlanesGeneric.form @@ -30,7 +30,7 @@
- + -- 2.25.1 From a58a16db284ad3a9b040b1defefdec8bc0dbeb3b Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Tue, 8 Nov 2022 10:13:23 +0400 Subject: [PATCH 11/14] =?UTF-8?q?=D0=94=D0=BE=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=BA=D0=B0=20=D1=84=D0=BE=D1=80=D0=BC=D1=8B=20=D1=81=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D1=80=D0=B8=D1=81=D0=BE=D0=B2=D0=BA=D0=BE?= =?UTF-8?q?=D0=B9=20=D1=81=D0=BB=D1=83=D1=87=D0=B0=D0=B9=D0=BD=D1=8B=D1=85?= =?UTF-8?q?=20=D0=BD=D0=B0=D0=B1=D0=BE=D1=80=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/DrawingEntities.java | 14 +++++++++----- Project/src/FormParam.java | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/Project/src/DrawingEntities.java b/Project/src/DrawingEntities.java index c99f11b..e40059c 100644 --- a/Project/src/DrawingEntities.java +++ b/Project/src/DrawingEntities.java @@ -1,19 +1,23 @@ +import java.lang.reflect.Array; import java.util.Random; public class DrawingEntities { - public EntityPlane[] _arrPlane; - public IAdditionalDrawingObject[] _arrWindow; + public T[] _arrPlane; + public U[] _arrWindow; int countArrPlane = 0; int countArrWindows = 0; String _x_index; String _y_index; //конструктор - public DrawingEntities(int sizeArrPlane, int sizeArrAddElem) + public DrawingEntities(int sizeArr, Class objectT, Class objectU) { - _arrPlane = new EntityPlane[sizeArrPlane]; - _arrWindow = new IAdditionalDrawingObject[sizeArrAddElem]; + final T[] arrPlane = (T[]) Array.newInstance(objectT, sizeArr); + _arrPlane = arrPlane; + + final U[] arrWindod = (U[]) Array.newInstance(objectU, sizeArr); + _arrWindow = arrWindod; } //добавить сущность-самолёт diff --git a/Project/src/FormParam.java b/Project/src/FormParam.java index 7a7be63..5535e0c 100644 --- a/Project/src/FormParam.java +++ b/Project/src/FormParam.java @@ -76,7 +76,7 @@ public class FormParam extends JFrame LableBox.add(LabelColor); StatusStrip.add(LableBox); - _drawingEntities = new DrawingEntities<>(10, 10); + _drawingEntities = new DrawingEntities<>(10, EntityPlane.class, IAdditionalDrawingObject.class); ButtonAddPlane.addActionListener(new ActionListener() { @Override -- 2.25.1 From b1aa92cbece47ef12716bcad38d234b47870d5e1 Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 10 Nov 2022 23:30:18 +0400 Subject: [PATCH 12/14] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/Direction.java | 2 +- Project/src/EntityPlane.java | 6 ++++-- Project/src/FormMapWithSetPlanesGeneric.java | 1 + Project/src/FormParam.java | 1 - Project/src/FormPlane.java | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Project/src/Direction.java b/Project/src/Direction.java index e2d98d9..aab36d9 100644 --- a/Project/src/Direction.java +++ b/Project/src/Direction.java @@ -8,7 +8,7 @@ public enum Direction private final int DirectionCode; - private Direction(int directionCode) + Direction(int directionCode) { this.DirectionCode = directionCode; } diff --git a/Project/src/EntityPlane.java b/Project/src/EntityPlane.java index d8e678d..2e3ba1f 100644 --- a/Project/src/EntityPlane.java +++ b/Project/src/EntityPlane.java @@ -4,13 +4,15 @@ public class EntityPlane { //скорость public int Speed; - public int GetSpeed(){ + public int GetSpeed() + { return Speed; } //вес public float Weight; - public float GetWeight(){ + public float GetWeight() + { return Weight; } diff --git a/Project/src/FormMapWithSetPlanesGeneric.java b/Project/src/FormMapWithSetPlanesGeneric.java index 7d3164f..0bf2364 100644 --- a/Project/src/FormMapWithSetPlanesGeneric.java +++ b/Project/src/FormMapWithSetPlanesGeneric.java @@ -94,6 +94,7 @@ public class FormMapWithSetPlanesGeneric { int result = JOptionPane.showConfirmDialog(null,"Удалить объект?","Удаление", JOptionPane.YES_NO_OPTION,JOptionPane.WARNING_MESSAGE); + if(result==JOptionPane.NO_OPTION) { return; diff --git a/Project/src/FormParam.java b/Project/src/FormParam.java index 5535e0c..b8b89d1 100644 --- a/Project/src/FormParam.java +++ b/Project/src/FormParam.java @@ -34,7 +34,6 @@ public class FormParam extends JFrame return new DrawingTriangleAirplaneWindow(); } - //if r == 2 return new DrawingRectAirplaneWindow(); } diff --git a/Project/src/FormPlane.java b/Project/src/FormPlane.java index de4e378..cf07032 100644 --- a/Project/src/FormPlane.java +++ b/Project/src/FormPlane.java @@ -50,7 +50,7 @@ public class FormPlane extends JDialog validate(); } - //создание всплывающего окна + //создание всплывающего окна public FormPlane() { super(new Frame("Airbus")); -- 2.25.1 From 194f28b701b4ba2929876af2378523262a27910b Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Thu, 17 Nov 2022 23:13:43 +0400 Subject: [PATCH 13/14] =?UTF-8?q?=D0=9C=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8=20=D0=BF=D0=BE=20=D0=BE?= =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=BB=D0=B5=D0=BD=D0=B8=D1=8E.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/MapWithSetPlanesGeneric.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/Project/src/MapWithSetPlanesGeneric.java b/Project/src/MapWithSetPlanesGeneric.java index 6c36283..0ecbf65 100644 --- a/Project/src/MapWithSetPlanesGeneric.java +++ b/Project/src/MapWithSetPlanesGeneric.java @@ -171,14 +171,12 @@ public class MapWithSetPlanesGeneric Date: Thu, 17 Nov 2022 23:15:40 +0400 Subject: [PATCH 14/14] =?UTF-8?q?=D0=A4=D0=B8=D0=BD=D0=B0=D0=BB=203-=D0=B9?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=BE=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/src/MapWithSetPlanesGeneric.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project/src/MapWithSetPlanesGeneric.java b/Project/src/MapWithSetPlanesGeneric.java index 0ecbf65..acfdb66 100644 --- a/Project/src/MapWithSetPlanesGeneric.java +++ b/Project/src/MapWithSetPlanesGeneric.java @@ -117,7 +117,7 @@ public class MapWithSetPlanesGeneric