Лабораторная работа №4
This commit is contained in:
parent
7b7d2bb3a3
commit
0020757f27
17
ProjectMonorail/.idea/workspace.xml
generated
17
ProjectMonorail/.idea/workspace.xml
generated
@ -5,16 +5,15 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="39e7c520-e505-4e53-a269-c949d7c9f5d1" name="Changes" comment="">
|
<list default="true" id="39e7c520-e505-4e53-a269-c949d7c9f5d1" name="Changes" comment="">
|
||||||
<change afterPath="$PROJECT_DIR$/src/Scripts/Wheels/IDrawingWheels.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/CollectionType.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/ListGenericObjects.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/StorageCollection.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/Wheels/DrawingWheels.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjectMonorail/Scripts/Wheels/DrawingWheels.class" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/AbstractCompany.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/AbstractCompany.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/AdditionalCollection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/AdditionalCollection.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/DepotSharingService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/DepotSharingService.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/DepotSharingService.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/DepotSharingService.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Drawing/DrawingModernMonorail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Drawing/DrawingModernMonorail.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/ICollectionGenericObjects.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/ICollectionGenericObjects.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Drawing/DrawingMonorail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Drawing/DrawingMonorail.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/MassiveGenericObjects.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/MassiveGenericObjects.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Forms/FormAdditionalCollection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Forms/FormAdditionalCollection.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Forms/FormMonorailCollection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Forms/FormMonorailCollection.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/src/Scripts/Forms/FormMonorailCollection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Forms/FormMonorailCollection.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Wheels/DrawingWheels.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Wheels/DrawingWheels.java" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -24,8 +23,8 @@
|
|||||||
<component name="FileTemplateManagerImpl">
|
<component name="FileTemplateManagerImpl">
|
||||||
<option name="RECENT_TEMPLATES">
|
<option name="RECENT_TEMPLATES">
|
||||||
<list>
|
<list>
|
||||||
<option value="Class" />
|
|
||||||
<option value="Interface" />
|
<option value="Interface" />
|
||||||
|
<option value="Class" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
</component>
|
</component>
|
||||||
@ -46,7 +45,7 @@
|
|||||||
"Application.Program.executor": "Run",
|
"Application.Program.executor": "Run",
|
||||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"git-widget-placeholder": "LabWorking__3",
|
"git-widget-placeholder": "LabWorking__4",
|
||||||
"kotlin-language-version-configured": "true",
|
"kotlin-language-version-configured": "true",
|
||||||
"last_opened_file_path": "D:/Учеба/PIbd-11_Tarasov_V.D._Hard/ProjectMonorail"
|
"last_opened_file_path": "D:/Учеба/PIbd-11_Tarasov_V.D._Hard/ProjectMonorail"
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public abstract class AbstractCompany {
|
|||||||
_pictureHeight = picHeight;
|
_pictureHeight = picHeight;
|
||||||
_collection = collection;
|
_collection = collection;
|
||||||
System.out.println(_pictureHeight+" "+_pictureWidth+" "+_placeSizeHeight+" "+_placeSizeWidth);
|
System.out.println(_pictureHeight+" "+_pictureWidth+" "+_placeSizeHeight+" "+_placeSizeWidth);
|
||||||
_collection.SetMaxCount(GetMaxCount(), (Class) DrawingMonorail.class);
|
_collection.SetMaxCount(GetMaxCount());
|
||||||
}
|
}
|
||||||
//Перегрузок нет
|
//Перегрузок нет
|
||||||
public DrawingMonorail GetRandomObject()
|
public DrawingMonorail GetRandomObject()
|
||||||
|
@ -0,0 +1,7 @@
|
|||||||
|
package Scripts.CollectionGenericObjects;
|
||||||
|
|
||||||
|
public enum CollectionType {
|
||||||
|
None,
|
||||||
|
Massive,
|
||||||
|
List
|
||||||
|
}
|
@ -18,7 +18,7 @@ public class DepotSharingService extends AbstractCompany {
|
|||||||
graphics.setColor(Color.BLACK);
|
graphics.setColor(Color.BLACK);
|
||||||
for (int i = 0; i < width; i++)
|
for (int i = 0; i < width; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < height + 1; ++j)
|
for (int j = 0; j < height; ++j)
|
||||||
{
|
{
|
||||||
graphics.drawLine(i * _offsetX + i * _placeSizeWidth, j * _placeSizeHeight, _placeSizeWidth + i * _offsetX + i * _placeSizeWidth, j * _placeSizeHeight);
|
graphics.drawLine(i * _offsetX + i * _placeSizeWidth, j * _placeSizeHeight, _placeSizeWidth + i * _offsetX + i * _placeSizeWidth, j * _placeSizeHeight);
|
||||||
graphics.drawLine(i * _offsetX + i * _placeSizeWidth, j * _placeSizeHeight, i * _offsetX + i * _placeSizeWidth, _placeSizeHeight + j * _placeSizeHeight);
|
graphics.drawLine(i * _offsetX + i * _placeSizeWidth, j * _placeSizeHeight, i * _offsetX + i * _placeSizeWidth, _placeSizeHeight + j * _placeSizeHeight);
|
||||||
@ -36,7 +36,7 @@ public class DepotSharingService extends AbstractCompany {
|
|||||||
|
|
||||||
int currnetIndex = 0;
|
int currnetIndex = 0;
|
||||||
|
|
||||||
for (int j = height; j >= 0; j--) {
|
for (int j = height - 1; j >= 0; j--) {
|
||||||
for (int i = 0; i < width; i++, currnetIndex++) {
|
for (int i = 0; i < width; i++, currnetIndex++) {
|
||||||
if (_collection.Get(currnetIndex) == null) continue;
|
if (_collection.Get(currnetIndex) == null) continue;
|
||||||
|
|
||||||
|
@ -3,9 +3,8 @@ package Scripts.CollectionGenericObjects;
|
|||||||
public interface ICollectionGenericObjects<T>
|
public interface ICollectionGenericObjects<T>
|
||||||
{
|
{
|
||||||
int getCount();
|
int getCount();
|
||||||
void SetMaxCount(int count, Class<T> type);
|
void SetMaxCount(int count);
|
||||||
int Insert(T obj);
|
int Insert(T obj);
|
||||||
int Insert(T obj, int position);
|
|
||||||
T Remove(int position);
|
T Remove(int position);
|
||||||
T Get(int position);
|
T Get(int position);
|
||||||
}
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
package Scripts.CollectionGenericObjects;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class ListGenericObjects<T> implements ICollectionGenericObjects<T> {
|
||||||
|
private List<T> _collection;
|
||||||
|
private int _maxCount;
|
||||||
|
|
||||||
|
public int getCount() {
|
||||||
|
return _collection.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void SetMaxCount(int size) {
|
||||||
|
if (size > 0) {
|
||||||
|
_maxCount = size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ListGenericObjects() {
|
||||||
|
_collection = new ArrayList<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T Get(int position)
|
||||||
|
{
|
||||||
|
if (position >= getCount() || position < 0) return null;
|
||||||
|
return _collection.get(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int Insert(T obj)
|
||||||
|
{
|
||||||
|
if (getCount() == _maxCount) return -1;
|
||||||
|
_collection.add(obj);
|
||||||
|
return getCount();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public T Remove(int position)
|
||||||
|
{
|
||||||
|
if (position >= getCount() || position < 0) return null;
|
||||||
|
T obj = _collection.get(position);
|
||||||
|
_collection.remove(position);
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
}
|
@ -1,21 +1,27 @@
|
|||||||
package Scripts.CollectionGenericObjects;
|
package Scripts.CollectionGenericObjects;
|
||||||
|
|
||||||
|
import Scripts.Drawing.DrawingMonorail;
|
||||||
|
|
||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
|
|
||||||
public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T>
|
public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T>
|
||||||
{
|
{
|
||||||
private T[] _collection;
|
private T[] _collection;
|
||||||
private int Count;
|
private int Count;
|
||||||
public void SetMaxCount(int size, Class<T> type) {
|
public void SetMaxCount(int size) {
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
_collection = (T[]) Array.newInstance(type, size);
|
if (_collection == null) {
|
||||||
Count = size;
|
_collection = (T[]) Array.newInstance((Class) DrawingMonorail.class, size);
|
||||||
|
Count = size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCount() {
|
public int getCount() {
|
||||||
return Count;
|
return Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int Insert(T obj) {
|
public int Insert(T obj) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
@ -31,36 +37,6 @@ public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T>
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int Insert(T obj, int position) {
|
|
||||||
if (position >= getCount() || position < 0)
|
|
||||||
return -1;
|
|
||||||
if (_collection[position] == null) {
|
|
||||||
_collection[position] = obj;
|
|
||||||
return position;
|
|
||||||
}
|
|
||||||
int index = position + 1;
|
|
||||||
while (index < getCount())
|
|
||||||
{
|
|
||||||
if (_collection[index] == null)
|
|
||||||
{
|
|
||||||
_collection[index] = obj;
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
++index;
|
|
||||||
}
|
|
||||||
index = position - 1;
|
|
||||||
while (index >= 0)
|
|
||||||
{
|
|
||||||
if (_collection[index] == null)
|
|
||||||
{
|
|
||||||
_collection[index] = obj;
|
|
||||||
return index;
|
|
||||||
}
|
|
||||||
--index;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public T Remove(int position) {
|
public T Remove(int position) {
|
||||||
if (position >= getCount() || position < 0)
|
if (position >= getCount() || position < 0)
|
||||||
return null;
|
return null;
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package Scripts.CollectionGenericObjects;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class StorageCollection<T> {
|
||||||
|
private Map<String, ICollectionGenericObjects<T>> _storages;
|
||||||
|
public StorageCollection()
|
||||||
|
{
|
||||||
|
_storages = new HashMap<String, ICollectionGenericObjects<T>>();
|
||||||
|
}
|
||||||
|
public Set<String> Keys() {
|
||||||
|
Set<String> keys = _storages.keySet();
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
public void AddCollection(String name, CollectionType collectionType)
|
||||||
|
{
|
||||||
|
if (_storages.containsKey(name)) return;
|
||||||
|
if (collectionType == CollectionType.None) return;
|
||||||
|
else if (collectionType == CollectionType.Massive)
|
||||||
|
_storages.put(name, new MassiveGenericObjects<T>());
|
||||||
|
else if (collectionType == CollectionType.List)
|
||||||
|
_storages.put(name, new ListGenericObjects<T>());
|
||||||
|
}
|
||||||
|
public void DelCollection(String name)
|
||||||
|
{
|
||||||
|
if (_storages.containsKey(name))
|
||||||
|
_storages.remove(name);
|
||||||
|
}
|
||||||
|
public ICollectionGenericObjects<T> getCollectionObject(String name) {
|
||||||
|
if (_storages.containsKey(name))
|
||||||
|
return _storages.get(name);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T getObject(String name, int position) {
|
||||||
|
if(_storages.containsKey(name))
|
||||||
|
return _storages.get(name).Get(position);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T remove(String name, int position){
|
||||||
|
if(_storages.containsKey(name))
|
||||||
|
return _storages.get(name).Remove(position);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
package Scripts.Forms;
|
package Scripts.Forms;
|
||||||
|
|
||||||
import Scripts.CollectionGenericObjects.AbstractCompany;
|
import Scripts.CollectionGenericObjects.*;
|
||||||
import Scripts.CollectionGenericObjects.DepotSharingService;
|
|
||||||
import Scripts.CollectionGenericObjects.MassiveGenericObjects;
|
|
||||||
import Scripts.Drawing.DrawingModernMonorail;
|
import Scripts.Drawing.DrawingModernMonorail;
|
||||||
import Scripts.Drawing.DrawingMonorail;
|
import Scripts.Drawing.DrawingMonorail;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Queue;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.*;
|
import java.awt.event.*;
|
||||||
@ -18,9 +18,21 @@ public class FormMonorailCollection extends JFrame{
|
|||||||
private Dimension dimension;
|
private Dimension dimension;
|
||||||
public static CanvasFormMonorailCollection<DrawingMonorail> _canvasMonorail = new CanvasFormMonorailCollection<DrawingMonorail>();
|
public static CanvasFormMonorailCollection<DrawingMonorail> _canvasMonorail = new CanvasFormMonorailCollection<DrawingMonorail>();
|
||||||
private static AbstractCompany _company = null;
|
private static AbstractCompany _company = null;
|
||||||
private JButton CreateButton = new JButton("Создать современный монорельс");;
|
|
||||||
private JButton CreateShipButton = new JButton("Создать монорельс");
|
private Queue<DrawingMonorail> _collectionRemovedObjects = new LinkedList<DrawingMonorail>();
|
||||||
private JButton RemoveButton = new JButton("Удалить");
|
private StorageCollection<DrawingMonorail> _storageCollection = new StorageCollection<DrawingMonorail>();
|
||||||
|
private JTextField textBoxCollection = new JTextField();
|
||||||
|
private JRadioButton radioButtonMassive = new JRadioButton("Массив");
|
||||||
|
private JRadioButton radioButtonList = new JRadioButton("Список");
|
||||||
|
private JButton buttonAddCollection = new JButton("Добавить");
|
||||||
|
private JList listBoxCollection = new JList();
|
||||||
|
private JButton buttonRemoveCollection = new JButton("Удалить");
|
||||||
|
private JButton buttonCreateCompany = new JButton("Создать компанию");
|
||||||
|
private JButton createButton = new JButton("Создать современный монорельс");;
|
||||||
|
private JButton createModernButton = new JButton("Создать монорельс");
|
||||||
|
private JButton removeButton = new JButton("Удалить");
|
||||||
|
private JButton removeObjectsButton = new JButton("Удаленные объекты");
|
||||||
|
|
||||||
private JButton GoToCheckButton = new JButton("На проверку");
|
private JButton GoToCheckButton = new JButton("На проверку");
|
||||||
private JButton RandomButton = new JButton("Случайные");
|
private JButton RandomButton = new JButton("Случайные");
|
||||||
private JButton RefreshButton = new JButton("Обновить");
|
private JButton RefreshButton = new JButton("Обновить");
|
||||||
@ -53,7 +65,7 @@ public class FormMonorailCollection extends JFrame{
|
|||||||
break;
|
break;
|
||||||
default: return;
|
default: return;
|
||||||
}
|
}
|
||||||
if (_company._collection.Insert(drawingMonorail, 0) != -1) {
|
if (_company._collection.Insert(drawingMonorail) != -1) {
|
||||||
JOptionPane.showMessageDialog(null, "Объект добавлен");
|
JOptionPane.showMessageDialog(null, "Объект добавлен");
|
||||||
canvasShow();
|
canvasShow();
|
||||||
}
|
}
|
||||||
@ -84,20 +96,20 @@ public class FormMonorailCollection extends JFrame{
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CreateShipButton.addActionListener(new ActionListener() {
|
createModernButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
CreateObject("DrawingMonorail");
|
CreateObject("DrawingMonorail");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
CreateButton.addActionListener(new ActionListener() {
|
createButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
CreateObject("DrawingModernMonorail");
|
CreateObject("DrawingModernMonorail");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
RemoveButton.addActionListener(new ActionListener() {
|
removeButton.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
if (_company == null || TextField.getText() == null) {
|
if (_company == null || TextField.getText() == null) {
|
||||||
@ -106,12 +118,14 @@ public class FormMonorailCollection extends JFrame{
|
|||||||
int pos = parseInt(TextField.getText());
|
int pos = parseInt(TextField.getText());
|
||||||
int resultConfirmDialog = JOptionPane.showConfirmDialog(null, "Удалить", "Удаление", JOptionPane.YES_NO_OPTION);
|
int resultConfirmDialog = JOptionPane.showConfirmDialog(null, "Удалить", "Удаление", JOptionPane.YES_NO_OPTION);
|
||||||
if (resultConfirmDialog == JOptionPane.NO_OPTION) return;
|
if (resultConfirmDialog == JOptionPane.NO_OPTION) return;
|
||||||
if (_company._collection.Remove(pos) != null) {
|
|
||||||
System.out.println(pos);
|
DrawingMonorail obj = _storageCollection.remove(listBoxCollection.getSelectedValue().toString(), pos);
|
||||||
|
System.out.println(obj);
|
||||||
|
if (obj != null) {
|
||||||
JOptionPane.showMessageDialog(null, "Объект удален");
|
JOptionPane.showMessageDialog(null, "Объект удален");
|
||||||
|
_collectionRemovedObjects.add(obj);
|
||||||
canvasShow();
|
canvasShow();
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
JOptionPane.showMessageDialog(null, "Не удалось удалить объект");
|
JOptionPane.showMessageDialog(null, "Не удалось удалить объект");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -171,41 +185,137 @@ public class FormMonorailCollection extends JFrame{
|
|||||||
form.setCompany(_company);
|
form.setCompany(_company);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_canvasMonorail.setBounds(0, 0, getWidth()-200, getHeight());
|
|
||||||
ComboBoxCollections.setBounds(getWidth()-190, 10, 150, 20);
|
|
||||||
CreateShipButton.setBounds(getWidth()-190, 60, 150, 30);
|
|
||||||
CreateButton.setBounds(getWidth()-190, 100, 150, 30);
|
|
||||||
RandomButton.setBounds(getWidth()-190, 140, 150, 30);
|
|
||||||
TextField.setBounds(getWidth()-190,200,150,30);
|
|
||||||
RemoveButton.setBounds(getWidth()-190, 240, 150, 30);
|
|
||||||
GoToCheckButton.setBounds(getWidth()-190, 280, 150, 30);
|
|
||||||
RefreshButton.setBounds(getWidth()-190, getHeight()-90, 150, 30);
|
|
||||||
|
|
||||||
setSize(dimension.width,dimension.height);
|
buttonAddCollection.addActionListener(new ActionListener() {
|
||||||
setLayout(null);
|
@Override
|
||||||
add(_canvasMonorail);
|
public void actionPerformed(ActionEvent e) {
|
||||||
add(ComboBoxCollections);
|
if (textBoxCollection.getText().isEmpty() || (!radioButtonMassive.isSelected()
|
||||||
add(CreateShipButton);
|
&& !radioButtonList.isSelected())) {
|
||||||
add(CreateButton);
|
JOptionPane.showMessageDialog(null, "Не все данные заполнены");
|
||||||
add(TextField);
|
return;
|
||||||
add(RemoveButton);
|
}
|
||||||
add(GoToCheckButton);
|
CollectionType collectionType = CollectionType.None;
|
||||||
add(RandomButton);
|
if (radioButtonMassive.isSelected()) {
|
||||||
add(RefreshButton);
|
collectionType = CollectionType.Massive;
|
||||||
setVisible(true);
|
} else if (radioButtonList.isSelected()) {
|
||||||
|
collectionType = CollectionType.List;
|
||||||
addComponentListener(new ComponentAdapter() {
|
}
|
||||||
public void componentResized(ComponentEvent e) {
|
_storageCollection.AddCollection(textBoxCollection.getText(), collectionType);
|
||||||
_canvasMonorail.setBounds(0, 0, getWidth()-200, getHeight()-70);
|
RerfreshListBoxItems();
|
||||||
ComboBoxCollections.setBounds(getWidth()-190, 10, 150, 20);
|
|
||||||
CreateShipButton.setBounds(getWidth()-190, 60, 150, 30);
|
|
||||||
CreateButton.setBounds(getWidth()-190, 100, 150, 30);
|
|
||||||
TextField.setBounds(getWidth()-190,200,150,30);
|
|
||||||
RemoveButton.setBounds(getWidth()-190, 240, 150, 30);
|
|
||||||
GoToCheckButton.setBounds(getWidth()-190, 280, 150, 30);
|
|
||||||
RandomButton.setBounds(getWidth()-190, 140, 150, 30);
|
|
||||||
RefreshButton.setBounds(getWidth()-190, getHeight()-90, 150, 30);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
buttonRemoveCollection.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (listBoxCollection.getSelectedIndex() < 0 || listBoxCollection.getSelectedValue() == null) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Коллекция не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int resultConfirmDialog = JOptionPane.showConfirmDialog(null,
|
||||||
|
"Удалить", "Удаление",
|
||||||
|
JOptionPane.YES_NO_OPTION);
|
||||||
|
if (resultConfirmDialog == JOptionPane.NO_OPTION) return;
|
||||||
|
_storageCollection.DelCollection(listBoxCollection.getSelectedValue().toString());
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttonCreateCompany.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (listBoxCollection.getSelectedIndex() < 0 || listBoxCollection.getSelectedValue() == null) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Коллекция не выбрана");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ICollectionGenericObjects<DrawingMonorail> collection =
|
||||||
|
_storageCollection.getCollectionObject(listBoxCollection.getSelectedValue().toString());
|
||||||
|
if (collection == null) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Коллекция не проинициализирована");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (ComboBoxCollections.getSelectedItem().toString()) {
|
||||||
|
case "Хранилище":
|
||||||
|
_company = new DepotSharingService(getWidth() - 200, getHeight() - 110,
|
||||||
|
collection);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
RerfreshListBoxItems();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
removeObjectsButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (_collectionRemovedObjects.isEmpty()) {
|
||||||
|
JOptionPane.showMessageDialog(null, "Коллекция пуста");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DrawingMonorail drawingMonorail = null;
|
||||||
|
drawingMonorail = _collectionRemovedObjects.remove();
|
||||||
|
if (drawingMonorail == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FormModernMonorail form = new FormModernMonorail();
|
||||||
|
form.Init(drawingMonorail);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ButtonGroup radioButtonsGroup = new ButtonGroup();
|
||||||
|
JLabel labelCollectionName = new JLabel("Название коллекции");
|
||||||
|
radioButtonsGroup.add(radioButtonMassive);
|
||||||
|
radioButtonsGroup.add(radioButtonList);
|
||||||
|
_canvasMonorail.setBounds(0, 0, getWidth() - 200, getHeight());
|
||||||
|
labelCollectionName.setBounds(getWidth()-190, 10, 150, 20);
|
||||||
|
textBoxCollection.setBounds(getWidth()-190,35,150,25);
|
||||||
|
radioButtonMassive.setBounds(getWidth()-190, 60, 75, 20);
|
||||||
|
radioButtonList.setBounds(getWidth()-105, 60, 75, 20);
|
||||||
|
buttonAddCollection.setBounds(getWidth()-190, 85, 150, 20);
|
||||||
|
listBoxCollection.setBounds(getWidth()-190, 115, 150, 70);
|
||||||
|
buttonRemoveCollection.setBounds(getWidth()-190, 195, 150, 20);
|
||||||
|
ComboBoxCollections.setBounds(getWidth() - 190, 225, 150, 20);
|
||||||
|
buttonCreateCompany.setBounds(getWidth()-190, 255, 150, 20);
|
||||||
|
createModernButton.setBounds(getWidth() - 190, 285, 150, 30);
|
||||||
|
createButton.setBounds(getWidth() - 190, 325, 150, 30);
|
||||||
|
RandomButton.setBounds(getWidth() - 190, 365, 150, 30);
|
||||||
|
removeObjectsButton.setBounds(getWidth()-190, 505, 150, 30);
|
||||||
|
TextField.setBounds(getWidth() - 190, 545, 150, 30);
|
||||||
|
removeButton.setBounds(getWidth() - 190, 585, 150, 30);
|
||||||
|
GoToCheckButton.setBounds(getWidth() - 190, 625, 150, 30);
|
||||||
|
RefreshButton.setBounds(getWidth() - 190, 665, 150, 30);
|
||||||
|
setSize(dimension.width, dimension.height);
|
||||||
|
setLayout(null);
|
||||||
|
|
||||||
|
add(textBoxCollection);
|
||||||
|
add(radioButtonMassive);
|
||||||
|
add(radioButtonList);
|
||||||
|
add(buttonAddCollection);
|
||||||
|
add(listBoxCollection);
|
||||||
|
add(buttonRemoveCollection);
|
||||||
|
add(buttonCreateCompany);
|
||||||
|
add(labelCollectionName);
|
||||||
|
add(removeObjectsButton);
|
||||||
|
|
||||||
|
add(_canvasMonorail);
|
||||||
|
add(ComboBoxCollections);
|
||||||
|
add(createModernButton);
|
||||||
|
add(createButton);
|
||||||
|
add(TextField);
|
||||||
|
add(GoToCheckButton);
|
||||||
|
add(RandomButton);
|
||||||
|
add(removeButton);
|
||||||
|
add(RefreshButton);
|
||||||
|
setVisible(true);
|
||||||
}
|
}
|
||||||
|
private void RerfreshListBoxItems() {
|
||||||
|
DefaultListModel<String> list = new DefaultListModel<String>();
|
||||||
|
for (String name : _storageCollection.Keys()) {
|
||||||
|
if (name != "") {
|
||||||
|
list.addElement(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
listBoxCollection.setModel(list);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user