Lab6 pull
This commit is contained in:
parent
7acc834a14
commit
7f348e64d9
@ -53,8 +53,7 @@ public class BusesGenericCollection<T extends DrawingBus, U extends IMoveableObj
|
|||||||
g.setStroke(pen);
|
g.setStroke(pen);
|
||||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) {
|
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++) {
|
||||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
for (int j = 0; j < _pictureHeight / _placeSizeHeight +
|
||||||
1; ++j) {
|
1; ++j) {g.drawLine(i * _placeSizeWidth, j *
|
||||||
g.drawLine(i * _placeSizeWidth, j *
|
|
||||||
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
|
_placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j *
|
||||||
_placeSizeHeight);
|
_placeSizeHeight);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import java.io.*;
|
|||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
public class BusesGenericStorage {
|
public class BusesGenericStorage {
|
||||||
final HashMap<String, BusesGenericCollection<DrawingBus, DrawingObjectBus>> _busStorages;
|
public HashMap<String, BusesGenericCollection<DrawingBus, DrawingObjectBus>> _busStorages;
|
||||||
private static final char _separatorForKeyValue = '|';
|
private static final char _separatorForKeyValue = '|';
|
||||||
private final char _separatorRecords = ';';
|
private final char _separatorRecords = ';';
|
||||||
private static final char _separatorForObject = ':';
|
private static final char _separatorForObject = ':';
|
||||||
|
@ -67,9 +67,9 @@ public class ExtentionDrawingBus {
|
|||||||
if(!(bus instanceof EntityTrolleybus)){
|
if(!(bus instanceof EntityTrolleybus)){
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
return String.format("%s%c%b%c%b%c%s%c", str, separatorForObject,
|
return String.format("%s%c%b%c%b%c%s", str, separatorForObject,
|
||||||
((EntityTrolleybus) bus).getRoga(), separatorForObject,
|
((EntityTrolleybus) bus).getRoga(), separatorForObject,
|
||||||
((EntityTrolleybus) bus).getBattery(), separatorForObject,
|
((EntityTrolleybus) bus).getBattery(), separatorForObject,
|
||||||
getName(((EntityTrolleybus) bus).getAdditionalColor()), separatorForObject);
|
getName(((EntityTrolleybus) bus).getAdditionalColor()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,12 @@
|
|||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.StrokeBorder;
|
import javax.swing.border.StrokeBorder;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
import javax.swing.filechooser.FileFilter;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.FileWriter;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class FrameBusCollection extends JFrame {
|
public class FrameBusCollection extends JFrame {
|
||||||
private BusesGenericStorage storage;
|
private BusesGenericStorage storage;
|
||||||
@ -24,7 +15,7 @@ public class FrameBusCollection extends JFrame {
|
|||||||
JComponent pictureBoxCollection;
|
JComponent pictureBoxCollection;
|
||||||
TextField textFieldNumber;
|
TextField textFieldNumber;
|
||||||
TextField textFieldStorageName;
|
TextField textFieldStorageName;
|
||||||
Queue<DrawingBus> queue = new ArrayDeque<>();
|
Queue<DrawingBus> trashCollection = new ArrayDeque<>();
|
||||||
|
|
||||||
public FrameBusCollection() {
|
public FrameBusCollection() {
|
||||||
super("Набор автобусов");
|
super("Набор автобусов");
|
||||||
@ -154,7 +145,7 @@ public class FrameBusCollection extends JFrame {
|
|||||||
if (obj == null)
|
if (obj == null)
|
||||||
return;
|
return;
|
||||||
int pos = Integer.parseInt(textFieldNumber.getText());
|
int pos = Integer.parseInt(textFieldNumber.getText());
|
||||||
queue.add(obj.Get(pos));
|
trashCollection.add(obj.Get(pos));
|
||||||
if (obj.remove(pos)) {
|
if (obj.remove(pos)) {
|
||||||
JOptionPane.showMessageDialog(this, "Объект удалён");
|
JOptionPane.showMessageDialog(this, "Объект удалён");
|
||||||
pictureBoxCollection.repaint();
|
pictureBoxCollection.repaint();
|
||||||
@ -197,18 +188,18 @@ public class FrameBusCollection extends JFrame {
|
|||||||
private void buttonDeleteCollectionClick() {
|
private void buttonDeleteCollectionClick() {
|
||||||
if (listBoxStorages.getSelectedIndex() == -1)
|
if (listBoxStorages.getSelectedIndex() == -1)
|
||||||
return;
|
return;
|
||||||
storage.delSet(listBoxStorages.getSelectedValue(), queue);
|
storage.delSet(listBoxStorages.getSelectedValue(), trashCollection);
|
||||||
reloadObjects();
|
reloadObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buttonTrashClick() {
|
private void buttonTrashClick() {
|
||||||
if (queue.size() == 0)
|
if (trashCollection.size() == 0)
|
||||||
return;
|
return;
|
||||||
FrameTrolleybus frame;
|
FrameTrolleybus frame;
|
||||||
try {
|
try {
|
||||||
frame = new FrameTrolleybus();
|
frame = new FrameTrolleybus();
|
||||||
frame.ChangeTrolleybus(queue.peek());
|
frame.ChangeTrolleybus(trashCollection.peek());
|
||||||
queue.remove();
|
trashCollection.remove();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user