PIbd-21_MasenkinMS_LabWork03 #3
1
.idea/misc.xml
generated
1
.idea/misc.xml
generated
@ -1,4 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" default="true" project-jdk-name="20" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
|
@ -3,12 +3,12 @@
|
||||
<grid id="27dc6" binding="pictureBox" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="638" height="400"/>
|
||||
<xy x="20" y="20" width="792" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="b336e" binding="createPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="b336e" binding="createPanel" layout-manager="GridLayoutManager" row-count="1" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="10" fill="0" indent="0" use-parent-layout="false"/>
|
||||
@ -32,6 +32,14 @@
|
||||
<text value="Создать автобус"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="7cf79" class="javax.swing.JButton" binding="buttonSelectBus">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="10" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Выбрать автобус"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<vspacer id="b9759">
|
||||
|
@ -6,7 +6,7 @@ import java.awt.event.ActionListener;
|
||||
import java.util.Random;
|
||||
|
||||
public class AccordionBusForm {
|
||||
private DrawingBus drawingBus;
|
||||
public DrawingBus drawingBus;
|
||||
private AbstractStrategy abstractStrategy;
|
||||
|
||||
private JPanel pictureBox;
|
||||
@ -25,6 +25,7 @@ public class AccordionBusForm {
|
||||
private JButton buttonCreateBus;
|
||||
private JComboBox comboBoxStrategy;
|
||||
private JButton buttonStep;
|
||||
public JButton buttonSelectBus;
|
||||
|
||||
public AccordionBusForm() {
|
||||
buttonUp.setName("buttonUp");
|
||||
@ -37,10 +38,12 @@ public class AccordionBusForm {
|
||||
|
||||
buttonCreateAccordionBus.addActionListener(e -> {
|
||||
Random random = new Random();
|
||||
Color bodyColor = JColorChooser.showDialog(this.pictureBox, "Выберите цвет", Color.BLACK);
|
||||
Color additionalColor = JColorChooser.showDialog(this.pictureBox, "Выберите дополнительный цвет", Color.BLACK);
|
||||
drawingBus = new DrawingAccordionBus(random.nextInt(100, 300),
|
||||
random.nextInt(1000, 3000),
|
||||
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
|
||||
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
|
||||
bodyColor,
|
||||
additionalColor,
|
||||
random.nextBoolean(),
|
||||
random.nextBoolean(),
|
||||
pictureBox.getWidth(),
|
||||
@ -52,9 +55,10 @@ public class AccordionBusForm {
|
||||
|
||||
buttonCreateBus.addActionListener(e -> {
|
||||
Random random = new Random();
|
||||
Color bodyColor = JColorChooser.showDialog(this.pictureBox, "Выберите цвет", Color.BLACK);
|
||||
drawingBus = new DrawingBus(random.nextInt(100, 300),
|
||||
random.nextInt(1000, 3000),
|
||||
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
|
||||
bodyColor,
|
||||
pictureBox.getWidth(),
|
||||
pictureBox.getHeight());
|
||||
drawingBus.SetPosition(random.nextInt(10, 100),
|
||||
|
@ -1,9 +1,6 @@
|
||||
package AccordionBus;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
import java.util.Random;
|
||||
|
||||
// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
public class DrawingAccordionBus extends DrawingBus {
|
||||
@ -15,6 +12,12 @@ public class DrawingAccordionBus extends DrawingBus {
|
||||
}
|
||||
}
|
||||
|
||||
// Конструктор
|
||||
public DrawingAccordionBus(EntityBus bus, IDrawingDoors door, int width, int height) {
|
||||
super(bus, door, width, height);
|
||||
drawingDoors = door;
|
||||
}
|
||||
|
||||
// Прорисовка объекта
|
||||
public void DrawTransport(Graphics g) {
|
||||
if (EntityBus == null) {
|
||||
|
@ -1,9 +1,7 @@
|
||||
package AccordionBus;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.Random;
|
||||
import javax.swing.*;
|
||||
|
||||
// Класс, отвечающий за прорисовку и перемещение объекта-сущности
|
||||
public class DrawingBus {
|
||||
@ -43,6 +41,11 @@ public class DrawingBus {
|
||||
// Высота объекта
|
||||
public int GetHeigth() { return _busHeight; }
|
||||
|
||||
// Получение объекта IMoveableObject из объекта DrawingBus
|
||||
public IMoveableObject GetMoveableObject() {
|
||||
return new DrawingObjectBus(this);
|
||||
}
|
||||
|
||||
// Проверка, что объект может перемещаться по указанному направлению
|
||||
public boolean CanMove(DirectionType direction) {
|
||||
if (EntityBus == null) {
|
||||
@ -127,6 +130,14 @@ public class DrawingBus {
|
||||
drawingDoors.setNumDoors(random.nextInt(3, 6));
|
||||
}
|
||||
|
||||
// Конструктор
|
||||
public DrawingBus(EntityBus bus, IDrawingDoors door, int width, int height) {
|
||||
EntityBus = bus;
|
||||
drawingDoors = door;
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
}
|
||||
|
||||
// Установка позиции
|
||||
public void SetPosition(int x, int y) {
|
||||
if (x < 0 || y < 0) {
|
||||
|
@ -4,7 +4,7 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class FrameAccordionBus extends JFrame {
|
||||
private AccordionBusForm accordionBusForm;
|
||||
public AccordionBusForm accordionBusForm;
|
||||
|
||||
public FrameAccordionBus() {
|
||||
super();
|
||||
|
@ -2,6 +2,6 @@ package AccordionBus;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
new MainFrameAccordionBus();
|
||||
new FrameBusCollection();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user