Lab5 pull request
This commit is contained in:
parent
a5e9097d61
commit
9ccf11fee9
@ -23,7 +23,6 @@ public class DrawingBus {
|
|||||||
public int getHeight() {
|
public int getHeight() {
|
||||||
return busHeight;
|
return busHeight;
|
||||||
}
|
}
|
||||||
public int doorsNumber;
|
|
||||||
private IDrawDoors drawingDoors;
|
private IDrawDoors drawingDoors;
|
||||||
public DrawingBus(int speed, double weight, Color bodyColor, int width, int height, int doorsNumber, int doorsType) {
|
public DrawingBus(int speed, double weight, Color bodyColor, int width, int height, int doorsNumber, int doorsType) {
|
||||||
if (width < busWidth || height < busHeight)
|
if (width < busWidth || height < busHeight)
|
||||||
@ -136,11 +135,11 @@ public class DrawingBus {
|
|||||||
graphics2D.drawRect(_startPosX + 196, _startPosY + 91, 10, 20);
|
graphics2D.drawRect(_startPosX + 196, _startPosY + 91, 10, 20);
|
||||||
}
|
}
|
||||||
public IMoveableObject GetMoveableObject() { return new DrawingObjectBus(this);}
|
public IMoveableObject GetMoveableObject() { return new DrawingObjectBus(this);}
|
||||||
public void setDrawingDoors(IDrawDoors obj){
|
public void setDrawingDoors(IDrawDoors doors){
|
||||||
drawingDoors = obj;
|
drawingDoors = doors;
|
||||||
}
|
}
|
||||||
public void setDoorsNum(int num){
|
public void setDoorsNumber(int number){
|
||||||
drawingDoors.setNumber(num);
|
drawingDoors.setNumber(number);
|
||||||
}
|
}
|
||||||
public void setBodyColor(Color color){
|
public void setBodyColor(Color color){
|
||||||
entityBus.bodyColor = color;
|
entityBus.bodyColor = color;
|
||||||
|
@ -105,31 +105,23 @@ public class FrameBusCollection extends JFrame {
|
|||||||
if(listBoxStorages.getSelectedIndex() == -1) {
|
if(listBoxStorages.getSelectedIndex() == -1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BusesGenericCollection<DrawingBus, DrawingObjectBus> drawingBus = storage.getCollection(listBoxStorages.getSelectedValue());
|
BusesGenericCollection<DrawingBus, DrawingObjectBus> drawingBuses = storage.getCollection(listBoxStorages.getSelectedValue());
|
||||||
FrameBusConfig frameBusConfig = new FrameBusConfig();
|
FrameBusConfig frameBusConfig = new FrameBusConfig();
|
||||||
frameBusConfig.addButton.addActionListener(new ActionListener() {
|
frameBusConfig.addButton.addActionListener(e -> {
|
||||||
@Override
|
if (drawingBuses.insert(frameBusConfig.drawingBus))
|
||||||
public void actionPerformed(ActionEvent e) {
|
{
|
||||||
if (drawingBus.insert(frameBusConfig.drawingBus))
|
|
||||||
{
|
|
||||||
frameBusConfig.dispose();
|
|
||||||
frameBusConfig.drawingBus.pictureWidth = pictureBoxCollection.getWidth();
|
|
||||||
frameBusConfig.drawingBus.pictureHeight = pictureBoxCollection.getHeight();
|
|
||||||
JOptionPane.showMessageDialog(null, "Объект добавлен", "Информация", JOptionPane.INFORMATION_MESSAGE);
|
|
||||||
pictureBoxCollection.repaint();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(null, "Не удалось добавить объект", "Информация", JOptionPane.INFORMATION_MESSAGE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
frameBusConfig.cancelButton.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
frameBusConfig.dispose();
|
frameBusConfig.dispose();
|
||||||
|
frameBusConfig.drawingBus.pictureWidth = pictureBoxCollection.getWidth();
|
||||||
|
frameBusConfig.drawingBus.pictureHeight = pictureBoxCollection.getHeight();
|
||||||
|
JOptionPane.showMessageDialog(null, "Объект добавлен", "Информация", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
pictureBoxCollection.repaint();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
JOptionPane.showMessageDialog(null, "Не удалось добавить объект", "Информация", JOptionPane.INFORMATION_MESSAGE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
frameBusConfig.cancelButton.addActionListener(e -> frameBusConfig.dispose());
|
||||||
}
|
}
|
||||||
private void buttonRemoveBusClick() {
|
private void buttonRemoveBusClick() {
|
||||||
if (listBoxStorages.getSelectedIndex() == -1)
|
if (listBoxStorages.getSelectedIndex() == -1)
|
||||||
@ -186,15 +178,14 @@ public class FrameBusCollection extends JFrame {
|
|||||||
private void buttonTrashClick(){
|
private void buttonTrashClick(){
|
||||||
if(queue.size() == 0)
|
if(queue.size() == 0)
|
||||||
return;
|
return;
|
||||||
FrameTrolleybus form;
|
FrameTrolleybus frame;
|
||||||
try{
|
try{
|
||||||
form = new FrameTrolleybus();
|
frame = new FrameTrolleybus();
|
||||||
form.ChangeTrolleybus(queue.peek());
|
frame.ChangeTrolleybus(queue.peek());
|
||||||
queue.remove();
|
queue.remove();
|
||||||
}
|
}
|
||||||
catch (IOException e){
|
catch (IOException e){
|
||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -236,18 +236,18 @@ public class FrameBusConfig extends JFrame {
|
|||||||
try {
|
try {
|
||||||
int speed = ((Number) speedSpinner.getValue()).intValue();
|
int speed = ((Number) speedSpinner.getValue()).intValue();
|
||||||
int weight = ((Number) weightSpinner.getValue()).intValue();
|
int weight = ((Number) weightSpinner.getValue()).intValue();
|
||||||
int blocksNumber = ((Number) doorsNumberSpinner.getValue()).intValue();
|
int doorsNumber = ((Number) doorsNumberSpinner.getValue()).intValue();
|
||||||
switch ((String) support.getTransferable().getTransferData(DataFlavor.stringFlavor)) {
|
switch ((String) support.getTransferable().getTransferData(DataFlavor.stringFlavor)) {
|
||||||
case "Простой" -> {
|
case "Простой" -> {
|
||||||
drawingBus = new DrawingBus(speed, weight, Color.WHITE,
|
drawingBus = new DrawingBus(speed, weight, Color.WHITE,
|
||||||
pictureBoxWidth, pictureBoxHeight, 0, blocksNumber);
|
pictureBoxWidth, pictureBoxHeight, 0, doorsNumber);
|
||||||
drawingBus.setDoorsNum(blocksNumber);
|
drawingBus.setDoorsNumber(doorsNumber);
|
||||||
}
|
}
|
||||||
case "Продвинутый" -> {
|
case "Продвинутый" -> {
|
||||||
drawingBus = new DrawingTrolleybus(speed, weight, Color.WHITE, Color.BLACK,
|
drawingBus = new DrawingTrolleybus(speed, weight, Color.WHITE, Color.BLACK,
|
||||||
checkBoxRoga.isSelected(), checkBoxBattery.isSelected(),
|
checkBoxRoga.isSelected(), checkBoxBattery.isSelected(),
|
||||||
pictureBoxWidth, pictureBoxHeight, 0, blocksNumber);
|
pictureBoxWidth, pictureBoxHeight, 0, doorsNumber);
|
||||||
drawingBus.setDoorsNum(blocksNumber);
|
drawingBus.setDoorsNumber(doorsNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
drawingBus.setPosition(pictureBoxWidth / 2 - drawingBus.getWidth() / 2,
|
drawingBus.setPosition(pictureBoxWidth / 2 - drawingBus.getWidth() / 2,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user