From 650b42c43a8baa7519a147e8593aa3c2aaeec384 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 24 Oct 2023 12:36:12 +0400 Subject: [PATCH 1/5] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=20SetGeneric?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlanesGenericCollection.java | 2 +- ProjectStormtrooper/SetGeneric.java | 61 +++++++++---------- 2 files changed, 30 insertions(+), 33 deletions(-) diff --git a/ProjectStormtrooper/PlanesGenericCollection.java b/ProjectStormtrooper/PlanesGenericCollection.java index 9142cf1..3b8417a 100644 --- a/ProjectStormtrooper/PlanesGenericCollection.java +++ b/ProjectStormtrooper/PlanesGenericCollection.java @@ -55,7 +55,7 @@ public class PlanesGenericCollection { - private T[] _places; - public int Count; + private final ArrayList _places; + + public int Count() { + return _places.size(); + } + + private final int _maxCount; public SetGeneric(int count) { - _places = (T[]) new DrawingPlane[count]; - Count = count; + _maxCount = count; + _places = new ArrayList<>(count); } public int Insert(T plane) { @@ -15,51 +23,40 @@ public class SetGeneric { public int Insert(T plane, int position) { // Проверка позиции - if (position < 0 || position >= Count) { + if (position < 0 || position >= _maxCount) { return -1; } - // Проверка, что элемент массива по этой позиции пустой - if (_places[position] != null) { - // Проверка, что после вставляемого элемента в массиве есть пустой элемент - int nullIndex = -1; - for (int i = position + 1; i < Count; i++) { - if (_places[i] == null) { - nullIndex = i; - break; - } - } - // Если пустого элемента нет, то выходим - if (nullIndex < 0) { - return -1; - } - // Сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента - int j = nullIndex - 1; - while (j >= position) { - _places[j + 1] = _places[j]; - j--; - } - } // Вставка по позиции - _places[position] = plane; + _places.add(position, plane); return position; } public T Remove(int position) { // Проверка позиции - if (position < 0 || position >= Count) { + if (position < 0 || position >= Count()) { return null; } // Удаление объекта из массива, присвоив элементу массива значение null - T plane = _places[position]; - _places[position] = null; + T plane = _places.get(position); + _places.set(position, null); return plane; } public T Get(int position) { // Проверка позиции - if (position < 0 || position >= Count) { + if (position < 0 || position >= Count()) { return null; } - return _places[position]; + return _places.get(position); + } + + public void Set(int position, T plane) { + // Проверка позиции + // Проверка свободных мест в списке + if (position < 0 || position >= _maxCount || Count() == _maxCount) { + return; + } + // Вставка в список по позиции + _places.set(position, plane); } } -- 2.25.1 From d140d781b749a99c44648ae8bcb225d96342bdce Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 24 Oct 2023 12:43:15 +0400 Subject: [PATCH 2/5] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=20PlanesGenericCollection?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlanesGenericCollection.java | 29 +++++++++++-------- ProjectStormtrooper/SetGeneric.java | 4 +++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/ProjectStormtrooper/PlanesGenericCollection.java b/ProjectStormtrooper/PlanesGenericCollection.java index 3b8417a..6c8f481 100644 --- a/ProjectStormtrooper/PlanesGenericCollection.java +++ b/ProjectStormtrooper/PlanesGenericCollection.java @@ -25,7 +25,11 @@ public class PlanesGenericCollection { // Вставка в список по позиции _places.set(position, plane); } + + public ArrayList GetEnumerator() { + return _places; + } } -- 2.25.1 From 88eea507fe111801445b1feccc5b405ce3a4f943 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 24 Oct 2023 12:50:32 +0400 Subject: [PATCH 3/5] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?UTF-8?q?=20PlanesGenericStorage?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectStormtrooper/PlanesGenericStorage.java | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ProjectStormtrooper/PlanesGenericStorage.java diff --git a/ProjectStormtrooper/PlanesGenericStorage.java b/ProjectStormtrooper/PlanesGenericStorage.java new file mode 100644 index 0000000..e015164 --- /dev/null +++ b/ProjectStormtrooper/PlanesGenericStorage.java @@ -0,0 +1,36 @@ +package ProjectStormtrooper; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +public class PlanesGenericStorage { + final HashMap> _planeStorages; + + public ArrayList Keys() { + return (ArrayList) _planeStorages.keySet().stream().toList(); + } + + private final int _pictureWidth; + private final int _pictureHeight; + + public PlanesGenericStorage(int pictureWidth, int pictureHeight) { + _planeStorages = new HashMap<>(); + _pictureWidth = pictureWidth; + _pictureHeight = pictureHeight; + } + + public void AddSet(String name) { + _planeStorages.put(name, new PlanesGenericCollection<>(_pictureWidth, _pictureHeight)); + } + + public void DelSet(String name) { + _planeStorages.remove(name); + } + + public PlanesGenericCollection Get(String ind) { + if (_planeStorages.containsKey(ind)) + return _planeStorages.get(ind); + return null; + } +} -- 2.25.1 From deab7a4c3f2c854f0afb33ebec0e1876d2d2089b Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 24 Oct 2023 14:17:48 +0400 Subject: [PATCH 4/5] =?UTF-8?q?=D0=A0=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=B1=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectStormtrooper/FormPlaneCollection.form | 65 +++++++++++-- ProjectStormtrooper/FormPlaneCollection.java | 91 ++++++++++++++++++- ProjectStormtrooper/PlanesGenericStorage.java | 4 +- 3 files changed, 144 insertions(+), 16 deletions(-) diff --git a/ProjectStormtrooper/FormPlaneCollection.form b/ProjectStormtrooper/FormPlaneCollection.form index aba2572..7377d0e 100644 --- a/ProjectStormtrooper/FormPlaneCollection.form +++ b/ProjectStormtrooper/FormPlaneCollection.form @@ -14,7 +14,7 @@ - + @@ -22,7 +22,7 @@ - + @@ -30,12 +30,12 @@ - + - + @@ -43,7 +43,7 @@ - + @@ -51,7 +51,7 @@ - + @@ -59,22 +59,69 @@ - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ProjectStormtrooper/FormPlaneCollection.java b/ProjectStormtrooper/FormPlaneCollection.java index ce48a8a..81ece05 100644 --- a/ProjectStormtrooper/FormPlaneCollection.java +++ b/ProjectStormtrooper/FormPlaneCollection.java @@ -1,11 +1,13 @@ package ProjectStormtrooper; import javax.swing.*; +import javax.swing.event.ListSelectionEvent; import java.awt.*; import java.awt.event.ActionEvent; +import java.util.Objects; public class FormPlaneCollection { - PlanesGenericCollection _planes; + final PlanesGenericStorage _storage; FrameDoubleParametrized _frameDoubleParametrized; private JPanel PanelWrapper; private JPanel GroupBoxInstruments; @@ -15,6 +17,11 @@ public class FormPlaneCollection { private JButton buttonRemovePlane; private JButton buttonRefreshCollection; private JButton buttonOpenGenerateWindow; + private JTextField textFieldStorageName; + private JButton buttonAddStorage; + private JList listBoxStorages; + private JButton buttonRemoveStorage; + private JPanel storagesPanel; public DrawingPlane SelectedPlane; @@ -24,21 +31,81 @@ public class FormPlaneCollection { public FormPlaneCollection() { PictureBoxCollection.setPreferredSize(new Dimension(600, 500)); - _planes = new PlanesGenericCollection<>(600, 500); + _storage = new PlanesGenericStorage(600, 500); buttonAddPlane.addActionListener(this::buttonAddPlaneClicked); buttonRemovePlane.addActionListener(this::buttonRemovePlaneClicked); buttonRefreshCollection.addActionListener(this::buttonRefreshCollectionClicked); buttonOpenGenerateWindow.addActionListener(this::buttonOpenGenerateWindowClicked); + buttonAddStorage.addActionListener(this::buttonAddStorageClicked); + buttonRemoveStorage.addActionListener(this::buttonRemoveStorageClicked); + listBoxStorages.addListSelectionListener(this::listBoxObjectsSelectedIndexChanged); + } + + private void ReloadObjects() { + int index = listBoxStorages.getSelectedIndex(); + listBoxStorages.setListData(_storage.Keys().toArray()); + if (listBoxStorages.getModel().getSize() > 0 && (index == -1 || index >= listBoxStorages.getModel().getSize())) { + listBoxStorages.setSelectedIndex(0); + } else if (listBoxStorages.getModel().getSize() > 0 && index > -1 && index < listBoxStorages.getModel().getSize()) { + listBoxStorages.setSelectedIndex(index); + } + listBoxStorages.invalidate(); + } + + private void buttonAddStorageClicked(ActionEvent e) { + String storageName = textFieldStorageName.getText(); + if (Objects.equals(storageName, "")) { + JOptionPane.showMessageDialog(this.getPanelWrapper(), + "Введите название", + "Ошибка", + JOptionPane.ERROR_MESSAGE); + return; + } + _storage.AddSet(storageName); + ReloadObjects(); + } + + private void listBoxObjectsSelectedIndexChanged(ListSelectionEvent e) { + refreshPictureBox(); + } + + private void buttonRemoveStorageClicked(ActionEvent e) { + if (listBoxStorages.getSelectedIndex() == -1) { + return; + } + Object[] options = {"Да", "Нет"}; + int n = JOptionPane.showOptionDialog(this.getPanelWrapper(), + "Удалить объект?", + "Все серьезно", + JOptionPane.YES_NO_OPTION, + JOptionPane.QUESTION_MESSAGE, + null, + options, + options[0] + ); + if (n == 1) { + return; + } + _storage.DelSet(listBoxStorages.getSelectedValue().toString()); + ReloadObjects(); } public void buttonAddPlaneClicked(ActionEvent e) { + if (listBoxStorages.getSelectedIndex() == -1) { + return; + } + var obj = _storage.Get(listBoxStorages.getSelectedValue().toString()); + if (obj == null) { + return; + } + FrameStormtrooper frameStormtrooper = new FrameStormtrooper(); frameStormtrooper.setVisible(true); frameStormtrooper._formPlaneCollection.buttonSelectPlane.addActionListener(ev -> { SelectedPlane = frameStormtrooper._formPlaneCollection._drawingPlane; frameStormtrooper.dispose(); if (SelectedPlane != null) { - if (_planes.Add(SelectedPlane) > -1) { + if (obj.Add(SelectedPlane) > -1) { refreshPictureBox(); JOptionPane.showMessageDialog(this.getPanelWrapper(), "Объект добавлен", @@ -55,6 +122,13 @@ public class FormPlaneCollection { } public void buttonRemovePlaneClicked(ActionEvent e) { + if (listBoxStorages.getSelectedIndex() == -1) { + return; + } + var obj = _storage.Get(listBoxStorages.getSelectedValue().toString()); + if (obj == null) { + return; + } int pos; try { pos = Integer.parseInt(textFieldNumber.getText()); @@ -78,7 +152,7 @@ public class FormPlaneCollection { if (n == 1) { return; } - if (_planes.Sub(pos) != null) { + if (obj.Sub(pos) != null) { refreshPictureBox(); JOptionPane.showMessageDialog(this.getPanelWrapper(), "Объект удален", @@ -105,8 +179,15 @@ public class FormPlaneCollection { } public void refreshPictureBox() { + if (listBoxStorages.getSelectedIndex() == -1) { + return; + } + var obj = _storage.Get(listBoxStorages.getSelectedValue().toString()); + if (obj == null) { + return; + } Graphics g = PictureBoxCollection.getGraphics(); PictureBoxCollection.paint(g); - _planes.ShowPlanes(g); + obj.ShowPlanes(g); } } diff --git a/ProjectStormtrooper/PlanesGenericStorage.java b/ProjectStormtrooper/PlanesGenericStorage.java index e015164..18f4864 100644 --- a/ProjectStormtrooper/PlanesGenericStorage.java +++ b/ProjectStormtrooper/PlanesGenericStorage.java @@ -7,8 +7,8 @@ import java.util.List; public class PlanesGenericStorage { final HashMap> _planeStorages; - public ArrayList Keys() { - return (ArrayList) _planeStorages.keySet().stream().toList(); + public List Keys() { + return _planeStorages.keySet().stream().toList(); } private final int _pictureWidth; -- 2.25.1 From 25b615e736c6c608355ff9d94f0a4c8fa4a9d928 Mon Sep 17 00:00:00 2001 From: "ns.potapov" Date: Tue, 7 Nov 2023 12:57:17 +0400 Subject: [PATCH 5/5] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=8B=20=D1=83=D0=B4?= =?UTF-8?q?=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B8=20=D0=BE=D1=82?= =?UTF-8?q?=D1=80=D0=B8=D1=81=D0=BE=D0=B2=D0=BA=D0=B8=20=D0=BE=D0=B1=D1=8A?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProjectStormtrooper/DrawingPlane.java | 3 +- ProjectStormtrooper/FormPlaneCollection.form | 10 ++- ProjectStormtrooper/FormPlaneCollection.java | 28 ++++++- ProjectStormtrooper/FormStormtrooper.form | 2 +- ProjectStormtrooper/FormStormtrooper.java | 79 +++++++++++-------- ProjectStormtrooper/FrameStormtrooper.java | 6 +- .../PlanesGenericCollection.java | 1 + ProjectStormtrooper/PlanesGenericStorage.java | 6 ++ 8 files changed, 93 insertions(+), 42 deletions(-) diff --git a/ProjectStormtrooper/DrawingPlane.java b/ProjectStormtrooper/DrawingPlane.java index 80f8b25..db224d4 100644 --- a/ProjectStormtrooper/DrawingPlane.java +++ b/ProjectStormtrooper/DrawingPlane.java @@ -1,9 +1,10 @@ package ProjectStormtrooper; +import javax.swing.*; import java.awt.*; import java.util.Random; -public class DrawingPlane { +public class DrawingPlane extends JPanel { public EntityPlane EntityPlane; protected IDrawingEngines _drawingEngines; protected int _pictureWidth; diff --git a/ProjectStormtrooper/FormPlaneCollection.form b/ProjectStormtrooper/FormPlaneCollection.form index 7377d0e..c0cb0dd 100644 --- a/ProjectStormtrooper/FormPlaneCollection.form +++ b/ProjectStormtrooper/FormPlaneCollection.form @@ -14,7 +14,7 @@ - + @@ -122,6 +122,14 @@ + + + + + + + + diff --git a/ProjectStormtrooper/FormPlaneCollection.java b/ProjectStormtrooper/FormPlaneCollection.java index 81ece05..e975064 100644 --- a/ProjectStormtrooper/FormPlaneCollection.java +++ b/ProjectStormtrooper/FormPlaneCollection.java @@ -5,10 +5,12 @@ import javax.swing.event.ListSelectionEvent; import java.awt.*; import java.awt.event.ActionEvent; import java.util.Objects; +import java.util.Stack; public class FormPlaneCollection { final PlanesGenericStorage _storage; FrameDoubleParametrized _frameDoubleParametrized; + FrameStormtrooper _frameRemovedPlanes; private JPanel PanelWrapper; private JPanel GroupBoxInstruments; private JPanel PictureBoxCollection; @@ -22,7 +24,9 @@ public class FormPlaneCollection { private JList listBoxStorages; private JButton buttonRemoveStorage; private JPanel storagesPanel; + private JButton buttonShowRemovedPlanes; public DrawingPlane SelectedPlane; + Stack _removedPlanes; public JPanel getPanelWrapper() { @@ -32,6 +36,7 @@ public class FormPlaneCollection { public FormPlaneCollection() { PictureBoxCollection.setPreferredSize(new Dimension(600, 500)); _storage = new PlanesGenericStorage(600, 500); + _removedPlanes = new Stack<>(); buttonAddPlane.addActionListener(this::buttonAddPlaneClicked); buttonRemovePlane.addActionListener(this::buttonRemovePlaneClicked); buttonRefreshCollection.addActionListener(this::buttonRefreshCollectionClicked); @@ -39,6 +44,7 @@ public class FormPlaneCollection { buttonAddStorage.addActionListener(this::buttonAddStorageClicked); buttonRemoveStorage.addActionListener(this::buttonRemoveStorageClicked); listBoxStorages.addListSelectionListener(this::listBoxObjectsSelectedIndexChanged); + buttonShowRemovedPlanes.addActionListener(this::buttonShowRemovedPlanesClicked); } private void ReloadObjects() { @@ -101,8 +107,8 @@ public class FormPlaneCollection { FrameStormtrooper frameStormtrooper = new FrameStormtrooper(); frameStormtrooper.setVisible(true); - frameStormtrooper._formPlaneCollection.buttonSelectPlane.addActionListener(ev -> { - SelectedPlane = frameStormtrooper._formPlaneCollection._drawingPlane; + frameStormtrooper._formStromtrooper.buttonSelectPlane.addActionListener(ev -> { + SelectedPlane = frameStormtrooper._formStromtrooper._drawingPlane; frameStormtrooper.dispose(); if (SelectedPlane != null) { if (obj.Add(SelectedPlane) > -1) { @@ -152,7 +158,9 @@ public class FormPlaneCollection { if (n == 1) { return; } - if (obj.Sub(pos) != null) { + DrawingPlane removedPlane = obj.Sub(pos); + if (removedPlane != null) { + _removedPlanes.push(removedPlane); refreshPictureBox(); JOptionPane.showMessageDialog(this.getPanelWrapper(), "Объект удален", @@ -178,6 +186,20 @@ public class FormPlaneCollection { _frameDoubleParametrized.setVisible(true); } + public void buttonShowRemovedPlanesClicked(ActionEvent e) { + if (_removedPlanes.empty()) { + JOptionPane.showMessageDialog(this.getPanelWrapper(), + "Нет удаленных объектов", + "Инфо", + JOptionPane.INFORMATION_MESSAGE); + return; + } + _frameRemovedPlanes = new FrameStormtrooper(); + _frameRemovedPlanes._formStromtrooper._drawingPlane = _removedPlanes.pop(); + _frameRemovedPlanes.setVisible(true); + _frameRemovedPlanes._formStromtrooper.Draw(); + } + public void refreshPictureBox() { if (listBoxStorages.getSelectedIndex() == -1) { return; diff --git a/ProjectStormtrooper/FormStormtrooper.form b/ProjectStormtrooper/FormStormtrooper.form index 6993efe..e24fe2e 100644 --- a/ProjectStormtrooper/FormStormtrooper.form +++ b/ProjectStormtrooper/FormStormtrooper.form @@ -1,6 +1,6 @@
- + diff --git a/ProjectStormtrooper/FormStormtrooper.java b/ProjectStormtrooper/FormStormtrooper.java index 04f0ead..7a52f25 100644 --- a/ProjectStormtrooper/FormStormtrooper.java +++ b/ProjectStormtrooper/FormStormtrooper.java @@ -3,6 +3,7 @@ package ProjectStormtrooper; import javax.swing.*; import java.awt.*; import javax.swing.JColorChooser; +import java.awt.event.ActionEvent; import java.util.Random; import java.awt.event.ActionListener; @@ -10,27 +11,43 @@ public class FormStormtrooper extends JDialog { public DrawingPlane _drawingPlane; AbstractStrategy _abstractStrategy; private JButton buttonCreateStormtrooper; - private JPanel pictureBox; + private JComponent pictureBox; private JButton buttonDown; private JButton buttonUp; private JButton buttonLeft; - private JButton buttonRight; + public JButton buttonRight; private JButton buttonCreatePlane; private JComboBox comboBoxStrategy; private JButton buttonStep; public JButton buttonSelectPlane; - public JPanel getPictureBox() { + public JComponent getPictureBox() { return pictureBox; } + private class Canvas extends JPanel{ + public Canvas(){ + } + public void paintComponent (Graphics g){ + if (_drawingPlane == null){ + return; + } + + Graphics2D g2d = (Graphics2D)g; + g2d.setColor(getBackground()); + g2d.fillRect(0, 0, getWidth(), getHeight()); + super.paintComponents(g); + _drawingPlane.DrawTransport(g2d); + super.repaint(); + } + } + public FormStormtrooper() { buttonUp.setName("buttonUp"); buttonDown.setName("buttonDown"); buttonLeft.setName("buttonLeft"); buttonRight.setName("buttonRight"); - buttonCreateStormtrooper.addActionListener(e -> { Random random = new Random(); @@ -100,42 +117,36 @@ public class FormStormtrooper extends JDialog { } }); + buttonUp.addActionListener(this::buttonMoveClickedListener); + buttonDown.addActionListener(this::buttonMoveClickedListener); + buttonLeft.addActionListener(this::buttonMoveClickedListener); + buttonRight.addActionListener(this::buttonMoveClickedListener); + } - ActionListener buttonMoveClickedListener = e -> { - String buttonName = ((JButton) e.getSource()).getName(); + public void buttonMoveClickedListener(ActionEvent e) { + String buttonName = ((JButton) e.getSource()).getName(); - switch (buttonName) { - case ("buttonUp") -> { - _drawingPlane.MoveTransport(EnumDirectionType.Up); - } - case ("buttonDown") -> { - _drawingPlane.MoveTransport(EnumDirectionType.Down); - } - case ("buttonLeft") -> { - _drawingPlane.MoveTransport(EnumDirectionType.Left); - } - case ("buttonRight") -> { - _drawingPlane.MoveTransport(EnumDirectionType.Right); - } + switch (buttonName) { + case ("buttonUp") -> { + _drawingPlane.MoveTransport(EnumDirectionType.Up); } + case ("buttonDown") -> { + _drawingPlane.MoveTransport(EnumDirectionType.Down); + } + case ("buttonLeft") -> { + _drawingPlane.MoveTransport(EnumDirectionType.Left); + } + case ("buttonRight") -> { + _drawingPlane.MoveTransport(EnumDirectionType.Right); + } + default -> _drawingPlane.MoveTransport(EnumDirectionType.Right); + } - Draw(); - }; - - buttonUp.addActionListener(buttonMoveClickedListener); - buttonDown.addActionListener(buttonMoveClickedListener); - buttonLeft.addActionListener(buttonMoveClickedListener); - buttonRight.addActionListener(buttonMoveClickedListener); + Draw(); } public void Draw() { - if (_drawingPlane == null) { - return; - } - - Graphics g = pictureBox.getGraphics(); - pictureBox.paint(g); - _drawingPlane.DrawTransport(g); + pictureBox.repaint(); } private void createUIComponents() { @@ -144,5 +155,7 @@ public class FormStormtrooper extends JDialog { "MoveToRightBottom" }; comboBoxStrategy = new JComboBox(strategiesList); + pictureBox = new Canvas(); + pictureBox.setBounds(new Rectangle(400, 300)); } } diff --git a/ProjectStormtrooper/FrameStormtrooper.java b/ProjectStormtrooper/FrameStormtrooper.java index c4dcebb..302a6d0 100644 --- a/ProjectStormtrooper/FrameStormtrooper.java +++ b/ProjectStormtrooper/FrameStormtrooper.java @@ -3,13 +3,13 @@ package ProjectStormtrooper; import javax.swing.*; public class FrameStormtrooper extends JFrame { - public FormStormtrooper _formPlaneCollection; + public FormStormtrooper _formStromtrooper; public FrameStormtrooper() { super(); setTitle("Штурмовик"); setDefaultCloseOperation(DISPOSE_ON_CLOSE); - _formPlaneCollection = new FormStormtrooper(); - setContentPane(_formPlaneCollection.getPictureBox()); + _formStromtrooper = new FormStormtrooper(); + setContentPane(_formStromtrooper.getPictureBox()); setDefaultLookAndFeelDecorated(false); setLocation(300, 100); pack(); diff --git a/ProjectStormtrooper/PlanesGenericCollection.java b/ProjectStormtrooper/PlanesGenericCollection.java index 6c8f481..d263455 100644 --- a/ProjectStormtrooper/PlanesGenericCollection.java +++ b/ProjectStormtrooper/PlanesGenericCollection.java @@ -1,6 +1,7 @@ package ProjectStormtrooper; import java.awt.*; +import java.util.Stack; public class PlanesGenericCollection { private int _pictureWidth; diff --git a/ProjectStormtrooper/PlanesGenericStorage.java b/ProjectStormtrooper/PlanesGenericStorage.java index 18f4864..a86d59d 100644 --- a/ProjectStormtrooper/PlanesGenericStorage.java +++ b/ProjectStormtrooper/PlanesGenericStorage.java @@ -33,4 +33,10 @@ public class PlanesGenericStorage { return _planeStorages.get(ind); return null; } + public DrawingObjectPlane GetByDoubleParameter(String storageName, int planeIndex) { + if (_planeStorages.containsKey(storageName)) { + return _planeStorages.get(storageName).GetU(planeIndex); + } + return null; + } } -- 2.25.1