Compare commits
7 Commits
LabWork_5
...
LabWorking
| Author | SHA1 | Date | |
|---|---|---|---|
| 89940488db | |||
| 6d230a8bb7 | |||
| 6e048994f4 | |||
| d6544b387a | |||
| 0020757f27 | |||
| 7b7d2bb3a3 | |||
| 4c5819779a |
22
ProjectMonorail/.idea/workspace.xml
generated
22
ProjectMonorail/.idea/workspace.xml
generated
@@ -5,15 +5,14 @@
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="39e7c520-e505-4e53-a269-c949d7c9f5d1" name="Changes" comment="">
|
||||
<change afterPath="$PROJECT_DIR$/src/Scripts/Drawing/ExtentionDrawningMonorail.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/CountWheels.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/DirectionType.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/DrawingField.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/DrawingModernMonorail.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/DrawingWheels.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/EntityModernMonorail.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/FormModernMonorail.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Program.java" beforeDir="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/CollectionGenericObjects/ListGenericObjects.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/ListGenericObjects.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/CollectionGenericObjects/StorageCollection.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/CollectionGenericObjects/StorageCollection.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Entities/EntityModernMonorail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Entities/EntityModernMonorail.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/Scripts/Entities/EntityMonorail.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Scripts/Entities/EntityMonorail.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -23,6 +22,7 @@
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
<list>
|
||||
<option value="Interface" />
|
||||
<option value="Class" />
|
||||
</list>
|
||||
</option>
|
||||
@@ -44,8 +44,9 @@
|
||||
"Application.Program.executor": "Run",
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "LabWorking__2",
|
||||
"kotlin-language-version-configured": "true"
|
||||
"git-widget-placeholder": "LabWorking__6",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"last_opened_file_path": "C:/Учеба/AgarioGame"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="RunManager">
|
||||
@@ -61,7 +62,6 @@
|
||||
<attachedChunks>
|
||||
<set>
|
||||
<option value="jdk-21.0.2-openjdk-21.0.2-4caba194b151-4f524021" />
|
||||
<option value="jdk-22-openjdk-22-3183f394aec4-bad0321e" />
|
||||
</set>
|
||||
</attachedChunks>
|
||||
</component>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -44,7 +44,7 @@ public class AdditionalCollection <T extends EntityMonorail, U extends IDrawingW
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public DrawingMonorail CreateAdditionalCollectionMonorail() {
|
||||
public DrawingMonorail CreateAdditionalCollectionStormtrooper() {
|
||||
Random random = new Random();
|
||||
if (CollectionEntity == null || CollectionWheels == null) return null;
|
||||
T entity = CollectionEntity[random.nextInt(CountEntities)];
|
||||
|
||||
@@ -7,4 +7,7 @@ public interface ICollectionGenericObjects<T>
|
||||
int Insert(T obj);
|
||||
T Remove(int position);
|
||||
T Get(int position);
|
||||
CollectionType GetCollectionType();
|
||||
Iterable<T> GetItems();
|
||||
void ClearCollection();
|
||||
}
|
||||
@@ -1,16 +1,24 @@
|
||||
package Scripts.CollectionGenericObjects;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class ListGenericObjects<T> implements ICollectionGenericObjects<T> {
|
||||
private List<T> _collection;
|
||||
private CollectionType collectionType = CollectionType.List;
|
||||
private int _maxCount;
|
||||
|
||||
public int getCount() {
|
||||
return _collection.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CollectionType GetCollectionType() {
|
||||
return collectionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetMaxCount(int size) {
|
||||
if (size > 0) {
|
||||
@@ -45,4 +53,36 @@ public class ListGenericObjects<T> implements ICollectionGenericObjects<T> {
|
||||
_collection.remove(position);
|
||||
return obj;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<T> GetItems() {
|
||||
return new Iterable<T>() {
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return new Iterator<T>() {
|
||||
private int currentIndex = 0;
|
||||
//нужен ли count
|
||||
private int count = 0;
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return currentIndex < getCount();
|
||||
}
|
||||
@Override
|
||||
public T next() {
|
||||
if (hasNext()) {
|
||||
count++;
|
||||
return _collection.get(currentIndex++);
|
||||
}
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public void ClearCollection() {
|
||||
for (T ship : _collection) {
|
||||
ship = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,10 +3,13 @@ package Scripts.CollectionGenericObjects;
|
||||
import Scripts.Drawing.DrawingMonorail;
|
||||
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.Iterator;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T>
|
||||
{
|
||||
private T[] _collection;
|
||||
private CollectionType collectionType = CollectionType.Massive;
|
||||
private int Count;
|
||||
public void SetMaxCount(int size) {
|
||||
if (size > 0) {
|
||||
@@ -17,6 +20,11 @@ public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public CollectionType GetCollectionType() {
|
||||
return collectionType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return Count;
|
||||
@@ -49,4 +57,36 @@ public class MassiveGenericObjects<T> implements ICollectionGenericObjects<T>
|
||||
if (position >= getCount() || position < 0) return null;
|
||||
return (T) _collection[position];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<T> GetItems() {
|
||||
return new Iterable<T>() {
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return new Iterator<T>() {
|
||||
private int currentIndex = 0;
|
||||
//нужен ли count
|
||||
private int count = 0;
|
||||
@Override
|
||||
public boolean hasNext() {
|
||||
return currentIndex < getCount();
|
||||
}
|
||||
@Override
|
||||
public T next() {
|
||||
if (hasNext()) {
|
||||
count++;
|
||||
return _collection[currentIndex++];
|
||||
}
|
||||
throw new NoSuchElementException();
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
public void ClearCollection() {
|
||||
for (T ship : _collection) {
|
||||
ship = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
package Scripts.CollectionGenericObjects;
|
||||
|
||||
import Scripts.Drawing.DrawingMonorail;
|
||||
import Scripts.Drawing.ExtentionDrawningMonorail;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
public class StorageCollection<T> {
|
||||
public class StorageCollection<T extends DrawingMonorail> {
|
||||
private Map<String, ICollectionGenericObjects<T>> _storages;
|
||||
public StorageCollection()
|
||||
{
|
||||
@@ -38,4 +42,154 @@ public class StorageCollection<T> {
|
||||
return null;
|
||||
}
|
||||
|
||||
private String _collectionKey = "CollectionsStorage";
|
||||
private String _collectionName = "StorageCollection";
|
||||
private String _separatorForKeyValueS = "|";
|
||||
private String _separatorForKeyValue = "\\|";
|
||||
private String _separatorItemsS = ";";
|
||||
private String _separatorItems = "\\;";
|
||||
public boolean SaveData(String filename) {
|
||||
if (_storages.isEmpty()) return false;
|
||||
File file = new File(filename);
|
||||
if (file.exists()) file.delete();
|
||||
try {
|
||||
file.createNewFile();
|
||||
FileWriter writer = new FileWriter(file);
|
||||
writer.write(_collectionKey);
|
||||
writer.write("\n");
|
||||
for (Map.Entry<String, ICollectionGenericObjects<T>> value : _storages.entrySet()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(value.getKey());
|
||||
sb.append(_separatorForKeyValueS);
|
||||
sb.append(value.getValue().GetCollectionType());
|
||||
sb.append(_separatorForKeyValueS);
|
||||
sb.append(value.getValue().getCount());
|
||||
sb.append(_separatorForKeyValueS);
|
||||
for (T monorail : value.getValue().GetItems()) {
|
||||
String data = ExtentionDrawningMonorail.GetDataForSave((DrawingMonorail) monorail);
|
||||
if (data.isEmpty()) continue;
|
||||
sb.append(data);
|
||||
sb.append(_separatorItemsS);
|
||||
}
|
||||
sb.append("\n");
|
||||
writer.write(String.valueOf(sb));
|
||||
}
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean SaveOneCollection(String filename, String name) {
|
||||
if (_storages.isEmpty()) return false;
|
||||
File file = new File(filename);
|
||||
if (file.exists()) file.delete();
|
||||
try {
|
||||
file.createNewFile();
|
||||
FileWriter writer = new FileWriter(file);
|
||||
writer.write(_collectionName);
|
||||
writer.write("\n");
|
||||
ICollectionGenericObjects<T> value = _storages.get(name);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(name);
|
||||
sb.append(_separatorForKeyValueS);
|
||||
sb.append(value.GetCollectionType());
|
||||
sb.append(_separatorForKeyValueS);
|
||||
sb.append(value.getCount());
|
||||
sb.append(_separatorForKeyValueS);
|
||||
for (T monorail : value.GetItems()) {
|
||||
String data = ExtentionDrawningMonorail.GetDataForSave((DrawingMonorail) monorail);
|
||||
if (data.isEmpty()) continue;
|
||||
sb.append(data);
|
||||
sb.append(_separatorItemsS);
|
||||
}
|
||||
writer.append(sb);
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public boolean LoadData(String filename) {
|
||||
File file = new File(filename);
|
||||
if (!file.exists()) return false;
|
||||
try (BufferedReader fs = new BufferedReader(new FileReader(filename))) {
|
||||
String s = fs.readLine();
|
||||
if (s == null || s.isEmpty() || !s.startsWith(_collectionKey))
|
||||
return false;
|
||||
_storages.clear();
|
||||
s = "";
|
||||
while ((s = fs.readLine()) != null) {
|
||||
String[] record = s.split(_separatorForKeyValue);
|
||||
if (record.length != 4) {
|
||||
continue;
|
||||
}
|
||||
ICollectionGenericObjects<T> collection = CreateCollection(record[1]);
|
||||
if (collection == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
collection.SetMaxCount(Integer.parseInt(record[2]));
|
||||
String[] set = record[3].split(_separatorItems);
|
||||
for (String elem : set) {
|
||||
DrawingMonorail ship = ExtentionDrawningMonorail.CreateDrawingShip(elem);
|
||||
if (collection.Insert((T) ship) == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_storages.put(record[0], collection);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public boolean LoadOneCollection(String filename) {
|
||||
File file = new File(filename);
|
||||
if (!file.exists()) return false;
|
||||
try (BufferedReader fs = new BufferedReader(new FileReader(filename))) {
|
||||
String s = fs.readLine();
|
||||
if (s == null || s.isEmpty() || !s.startsWith(_collectionName))
|
||||
return false;
|
||||
if (_storages.containsKey(s)) {
|
||||
_storages.get(s).ClearCollection();
|
||||
}
|
||||
s = fs.readLine();
|
||||
String[] record = s.split(_separatorForKeyValue);
|
||||
if (record.length != 4) {
|
||||
return false;
|
||||
}
|
||||
ICollectionGenericObjects<T> collection = CreateCollection(record[1]);
|
||||
if (collection == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
collection.SetMaxCount(Integer.parseInt(record[2]));
|
||||
String[] set = record[3].split(_separatorItems);
|
||||
for (String elem : set) {
|
||||
DrawingMonorail monorail = ExtentionDrawningMonorail.CreateDrawingShip(elem);
|
||||
if (collection.Insert((T) monorail) == -1)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
_storages.put(record[0], collection);
|
||||
return true;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public ICollectionGenericObjects<T> CreateCollection(String s) {
|
||||
switch (s) {
|
||||
case "Massive":
|
||||
return new MassiveGenericObjects<T>();
|
||||
case "List":
|
||||
return new ListGenericObjects<T>();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package Scripts.Drawing;
|
||||
|
||||
import Scripts.Entities.EntityModernMonorail;
|
||||
import Scripts.Entities.EntityMonorail;
|
||||
import Scripts.Wheels.IDrawingWheels;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
||||
public class ExtentionDrawningMonorail {
|
||||
private static String _separatorForObjectS = ":";
|
||||
private static String _separatorForObject = "\\:";
|
||||
public static DrawingMonorail CreateDrawingShip(String info) {
|
||||
String[] strs = info.split(_separatorForObject);
|
||||
EntityMonorail entityMonorail;
|
||||
IDrawingWheels wheels = null;
|
||||
if (strs.length == 8)
|
||||
{
|
||||
String s = strs[8];
|
||||
switch (s) {
|
||||
case "DrawingDecksType1":
|
||||
wheels = new DrawingDecksType1();
|
||||
case "DrawingDecksType2":
|
||||
wheels = new DrawingDecksType2();
|
||||
case "DrawingDecksType3":
|
||||
wheels = new DrawingDecksType3();
|
||||
}
|
||||
if (wheels != null) wheels.SetCountWheels(Integer.parseInt(strs[7]));
|
||||
}
|
||||
else if (strs.length == 6) {
|
||||
String s = strs[5];
|
||||
switch (s) {
|
||||
case "DrawingDecksType1":
|
||||
wheels = new DrawingDecksType1();
|
||||
case "DrawingDecksType2":
|
||||
wheels = new DrawingDecksType2();
|
||||
case "DrawingDecksType3":
|
||||
wheels = new DrawingDecksType3();
|
||||
}
|
||||
if (wheels != null) wheels.SetCountWheels(Integer.parseInt(strs[4]));
|
||||
}
|
||||
entityMonorail = EntityModernMonorail.CreateEntityModernMonorail(strs);
|
||||
if (entityMonorail != null)
|
||||
{
|
||||
return new DrawingModernMonorail((EntityModernMonorail) entityMonorail, wheels);
|
||||
}
|
||||
entityMonorail = EntityMonorail.CreateEntityMonorail(strs);
|
||||
if (entityMonorail != null)
|
||||
{
|
||||
return new DrawingMonorail(entityMonorail, wheels);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public static String GetDataForSave(DrawingMonorail drawningMonorail)
|
||||
{
|
||||
if (drawningMonorail == null) return "";
|
||||
String[] array1 = drawningMonorail.getMonorail().GetStringRepresentation();
|
||||
String[] array2 = drawningMonorail.GetStringRepresentationDecks();
|
||||
if (array1 == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
ArrayList<String> list = new ArrayList<>();
|
||||
Collections.addAll(list, array1);
|
||||
if (array2 == null) {
|
||||
Collections.addAll(list, "0", " ");
|
||||
}
|
||||
else Collections.addAll(list, array2);
|
||||
return String.join(_separatorForObjectS, list);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package Scripts.Entities;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
public class EntityModernMonorail extends EntityMonorail {
|
||||
@@ -12,7 +13,7 @@ public class EntityModernMonorail extends EntityMonorail {
|
||||
public boolean getMonorailTrack() {return _monorailTrack;}
|
||||
public boolean getCabin() {return _cabin;}
|
||||
|
||||
public void setAdditionalColor(Color value) {_additionalColor = value;}
|
||||
public void setAdditionalColor(Color value) {_additionalColor = _additionalColor;}
|
||||
public void setMonorailTrack(Boolean value) { _monorailTrack = value;}
|
||||
public void setCabin(Boolean value) { _cabin = value;}
|
||||
|
||||
@@ -26,7 +27,25 @@ public class EntityModernMonorail extends EntityMonorail {
|
||||
_monorailTrack = monorailTrack;
|
||||
_cabin = cabin;
|
||||
|
||||
Step = _speed * 100/ (int)_weight;
|
||||
Step = _speed * 100/ (float)_weight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] GetStringRepresentation()
|
||||
{
|
||||
return new String[]{"EntityModernMonorail", _speed.toString(), _weight.toString(),
|
||||
colorToHexString(getBodyColor()), colorToHexString(getAdditionalColor()),
|
||||
String.valueOf(_monorailTrack), String.valueOf(_cabin)};
|
||||
}
|
||||
|
||||
public static EntityModernMonorail CreateEntityModernMonorail(String[] strs)
|
||||
{
|
||||
if (strs.length != 10 || !Objects.equals(strs[0], "EntityModernMonorail"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new EntityModernMonorail(Integer.parseInt(strs[1]), Float.parseFloat(strs[2]), hexStringToColor(strs[3]),
|
||||
hexStringToColor(strs[4]), Boolean.parseBoolean(strs[5]), Boolean.parseBoolean(strs[6]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package Scripts.Entities;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
public class EntityMonorail {
|
||||
public float Step;
|
||||
protected int _speed;
|
||||
protected float _weight;
|
||||
protected Integer _speed;
|
||||
protected Float _weight;
|
||||
protected Color _bodyColor;
|
||||
|
||||
public int getSpeed() {
|
||||
@@ -29,6 +30,28 @@ public class EntityMonorail {
|
||||
_weight = weight <= 0 ? rnd.nextInt(100)+500 : weight;
|
||||
_bodyColor = bodyColor;
|
||||
|
||||
Step = _speed * 100/ (int)_weight;
|
||||
Step = _speed * 100/ (float)_weight;
|
||||
}
|
||||
|
||||
public String[] GetStringRepresentation()
|
||||
{
|
||||
return new String[]{"EntityMonorail", _speed.toString(), _weight.toString(), colorToHexString(_bodyColor)};
|
||||
}
|
||||
|
||||
public static EntityMonorail CreateEntityMonorail(String[] strs)
|
||||
{
|
||||
if (strs.length != 6 || !Objects.equals(strs[0], "EntityMonorail"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new EntityMonorail(Integer.parseInt(strs[1]), Float.parseFloat(strs[2]), hexStringToColor(strs[3]));
|
||||
}
|
||||
|
||||
public static String colorToHexString(Color color) {
|
||||
return String.format("#%02x%02x%02x", color.getRed(), color.getGreen(), color.getBlue());
|
||||
}
|
||||
|
||||
public static Color hexStringToColor(String hexString) {
|
||||
return Color.decode(hexString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class FormAdditionalCollection extends JFrame {
|
||||
private JButton buttonGenerate = new JButton("Создать");
|
||||
private JButton buttonGoToCollection = new JButton("В коллекцию");
|
||||
private JList<String> listEntity = new JList<String>();
|
||||
private JList<String> listWheels = new JList<String>();
|
||||
private JList<String> listEngines = new JList<String>();
|
||||
public FormAdditionalCollection() {
|
||||
setTitle("Случайные монорельсы");
|
||||
setMinimumSize(new Dimension(970,310));
|
||||
@@ -45,7 +45,7 @@ public class FormAdditionalCollection extends JFrame {
|
||||
buttonGenerate.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
_drawingMonorail = _additionalCollection.CreateAdditionalCollectionMonorail();
|
||||
_drawingMonorail = _additionalCollection.CreateAdditionalCollectionStormtrooper();
|
||||
_drawingMonorail.SetPictureSize(getWidth(), getHeight());
|
||||
_drawingMonorail.SetPosition(360,30);
|
||||
_canvasMonorail._drawingMonorail = _drawingMonorail;
|
||||
@@ -60,11 +60,11 @@ public class FormAdditionalCollection extends JFrame {
|
||||
buttonGoToCollection.setBounds(830,200,120,60);
|
||||
buttonGenerate.setBounds(830, 130, 120, 60);
|
||||
listEntity.setBounds(10,200,400,60);
|
||||
listWheels.setBounds(420,200,400,60);
|
||||
listEngines.setBounds(420,200,400,60);
|
||||
add(buttonGenerate);
|
||||
add(buttonGoToCollection);
|
||||
add(listEntity);
|
||||
add(listWheels);
|
||||
add(listEngines);
|
||||
add(_canvasMonorail);
|
||||
setVisible(true);
|
||||
}
|
||||
@@ -128,6 +128,6 @@ public class FormAdditionalCollection extends JFrame {
|
||||
data2[i] = ToString(wheels);
|
||||
}
|
||||
listEntity.setListData(data1);
|
||||
listWheels.setListData(data2);
|
||||
listEngines.setListData(data2);
|
||||
}
|
||||
}
|
||||
@@ -35,9 +35,9 @@ public class FormMonorailConfig extends JFrame {
|
||||
private JLabel labelBodyColor = new JLabel("Основной цвет", SwingConstants.CENTER);
|
||||
private JLabel labelAdditionalColor = new JLabel("Дополнительный цвет", SwingConstants.CENTER);
|
||||
private JLabel labelWheels = new JLabel("Тип двигателей",SwingConstants.CENTER);
|
||||
private JLabel labelDefaultWheels = new JLabel("Классические",SwingConstants.CENTER);
|
||||
private JLabel labelOvalOrnament = new JLabel("Овальные", SwingConstants.CENTER);
|
||||
private JLabel labelTriangleOrnament = new JLabel("Треугольные", SwingConstants.CENTER);
|
||||
private JLabel labelDefaultEngines = new JLabel("Классические",SwingConstants.CENTER);
|
||||
private JLabel labelOvalEngines = new JLabel("Овальные", SwingConstants.CENTER);
|
||||
private JLabel labelTriangleEngines = new JLabel("Треугольные", SwingConstants.CENTER);
|
||||
|
||||
private JSpinner spinnerSpeed = new JSpinner();
|
||||
private JSpinner spinnerWeight = new JSpinner();
|
||||
@@ -121,9 +121,9 @@ public class FormMonorailConfig extends JFrame {
|
||||
labelModernMonorail.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||
labelBodyColor.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||
labelAdditionalColor.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||
labelDefaultWheels.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||
labelOvalOrnament.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||
labelTriangleOrnament.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||
labelDefaultEngines.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||
labelOvalEngines.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||
labelTriangleEngines.setBorder(BorderFactory.createLineBorder(Color.BLACK, 2));
|
||||
MouseAdapter labelObjectsMouseDown = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
@@ -146,17 +146,17 @@ public class FormMonorailConfig extends JFrame {
|
||||
labelModernMonorail.addMouseListener(labelObjectsMouseDown);
|
||||
labelModernMonorail.setTransferHandler(labelObjectsTransferHandler);
|
||||
|
||||
MouseAdapter labelWheelsMouseDown = new MouseAdapter() {
|
||||
MouseAdapter labelEnginesMouseDown = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
((JLabel) e.getComponent()).getTransferHandler().exportAsDrag(((JLabel) e.getComponent()), e, TransferHandler.COPY);
|
||||
}
|
||||
};
|
||||
|
||||
labelDefaultWheels.addMouseListener(labelWheelsMouseDown);
|
||||
labelOvalOrnament.addMouseListener(labelWheelsMouseDown);
|
||||
labelTriangleOrnament.addMouseListener(labelWheelsMouseDown);
|
||||
labelDefaultWheels.setTransferHandler(new TransferHandler() {
|
||||
labelDefaultEngines.addMouseListener(labelEnginesMouseDown);
|
||||
labelOvalEngines.addMouseListener(labelEnginesMouseDown);
|
||||
labelTriangleEngines.addMouseListener(labelEnginesMouseDown);
|
||||
labelDefaultEngines.setTransferHandler(new TransferHandler() {
|
||||
@Override
|
||||
public int getSourceActions(JComponent c) {return TransferHandler.COPY;}
|
||||
|
||||
@@ -165,7 +165,7 @@ public class FormMonorailConfig extends JFrame {
|
||||
return new WheelsTransferable(new DrawingWheels());
|
||||
}
|
||||
});
|
||||
labelOvalOrnament.setTransferHandler(new TransferHandler() {
|
||||
labelOvalEngines.setTransferHandler(new TransferHandler() {
|
||||
@Override
|
||||
public int getSourceActions(JComponent c) {return TransferHandler.COPY;}
|
||||
|
||||
@@ -174,7 +174,7 @@ public class FormMonorailConfig extends JFrame {
|
||||
return new WheelsTransferable(new DrawOrnamentOval());
|
||||
}
|
||||
});
|
||||
labelTriangleOrnament.setTransferHandler(new TransferHandler() {
|
||||
labelTriangleEngines.setTransferHandler(new TransferHandler() {
|
||||
@Override
|
||||
public int getSourceActions(JComponent c) {return TransferHandler.COPY;}
|
||||
|
||||
@@ -300,8 +300,12 @@ public class FormMonorailConfig extends JFrame {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (_drawingMonorail == null) return;
|
||||
|
||||
company._collection.Insert(_drawingMonorail);
|
||||
DrawingMonorail copyDrawingMonorail;
|
||||
if (_drawingMonorail instanceof DrawingModernMonorail)
|
||||
copyDrawingMonorail = new DrawingModernMonorail((EntityModernMonorail) _drawingMonorail.getMonorail(), _drawingMonorail.getWheels());
|
||||
else
|
||||
copyDrawingMonorail = new DrawingMonorail(_drawingMonorail.getMonorail(), _drawingMonorail.getWheels());
|
||||
company._collection.Insert(copyDrawingMonorail);
|
||||
FormMonorailCollection.canvasShow();
|
||||
dispose();
|
||||
}
|
||||
@@ -326,9 +330,9 @@ public class FormMonorailConfig extends JFrame {
|
||||
labelBodyColor.setBounds(500,5,100, 40);
|
||||
labelAdditionalColor.setBounds(605,5,170,40);
|
||||
labelWheels.setBounds(225,190,150,15);
|
||||
labelDefaultWheels.setBounds(140, 210, 100, 40);
|
||||
labelOvalOrnament.setBounds(250, 210, 100,40);
|
||||
labelTriangleOrnament.setBounds(360,210,100,40);
|
||||
labelDefaultEngines.setBounds(140, 210, 100, 40);
|
||||
labelOvalEngines.setBounds(250, 210, 100,40);
|
||||
labelTriangleEngines.setBounds(360,210,100,40);
|
||||
labelColor.setBounds(200,10,50,15);
|
||||
panelColorRed.setBounds(200, 30, 40, 40);
|
||||
panelColorGreen.setBounds(250, 30, 40,40);
|
||||
@@ -350,10 +354,10 @@ public class FormMonorailConfig extends JFrame {
|
||||
add(labelColor);
|
||||
add(labelBodyColor);
|
||||
add(labelAdditionalColor);
|
||||
add(labelDefaultWheels);
|
||||
add(labelDefaultWheels);
|
||||
add(labelOvalOrnament);
|
||||
add(labelTriangleOrnament);
|
||||
add(labelDefaultEngines);
|
||||
add(labelDefaultEngines);
|
||||
add(labelOvalEngines);
|
||||
add(labelTriangleEngines);
|
||||
add(spinnerSpeed);
|
||||
add(spinnerWeight);
|
||||
add(spinnerNumberOfWheels);
|
||||
|
||||
Reference in New Issue
Block a user