Compare commits
No commits in common. "LabWork01" and "main" have entirely different histories.
124
ProjectAirbus/.idea/uiDesigner.xml
generated
124
ProjectAirbus/.idea/uiDesigner.xml
generated
@ -1,124 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="Palette2">
|
|
||||||
<group name="Swing">
|
|
||||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="Button" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="RadioButton" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="CheckBox" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
|
||||||
<initial-values>
|
|
||||||
<property name="text" value="Label" />
|
|
||||||
</initial-values>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
|
||||||
<preferred-size width="150" height="-1" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
|
||||||
<preferred-size width="150" height="50" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
|
||||||
<preferred-size width="200" height="200" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
|
||||||
<preferred-size width="200" height="200" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
|
||||||
<preferred-size width="-1" height="20" />
|
|
||||||
</default-constraints>
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
|
||||||
</item>
|
|
||||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
|
||||||
</item>
|
|
||||||
</group>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
@ -3,7 +3,6 @@
|
|||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/Resources" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
Before Width: | Height: | Size: 1.3 KiB |
@ -1,24 +0,0 @@
|
|||||||
/**
|
|
||||||
* Направление перемещения
|
|
||||||
*/
|
|
||||||
public enum DirectionType {
|
|
||||||
/**
|
|
||||||
* Вверх
|
|
||||||
*/
|
|
||||||
Up,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Вниз
|
|
||||||
*/
|
|
||||||
Down,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Влево
|
|
||||||
*/
|
|
||||||
Left,
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Вправо
|
|
||||||
*/
|
|
||||||
Right,
|
|
||||||
}
|
|
@ -1,231 +0,0 @@
|
|||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Класс отрисовки и перемещения объекта-сущности
|
|
||||||
*/
|
|
||||||
public class DrawningAirbus extends JPanel {
|
|
||||||
/**
|
|
||||||
* Класс-сущность
|
|
||||||
*/
|
|
||||||
public EntityAirbus EntityAirbus;
|
|
||||||
public EntityAirbus getEntityAirbus() {
|
|
||||||
return EntityAirbus;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Обхект класса отрисовки иллюминаторов
|
|
||||||
*/
|
|
||||||
private DrawningAirbusPortholes _drawningAirbusPortholes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ширина окна
|
|
||||||
*/
|
|
||||||
private Integer _pictureWidth;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Высота окна
|
|
||||||
*/
|
|
||||||
private Integer _pictureHeight;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Начальная координата x
|
|
||||||
*/
|
|
||||||
private Integer _startPosX;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Начальная координата y
|
|
||||||
*/
|
|
||||||
private Integer _startPosY;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Ширина самолёта
|
|
||||||
*/
|
|
||||||
public final int _drawningAirbusWidth = 145;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Высота самолёта
|
|
||||||
*/
|
|
||||||
public final int _drawningAirbusHeight = 50;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Инициализация свойств
|
|
||||||
*
|
|
||||||
* @param speed Скорость
|
|
||||||
* @param weight Вес
|
|
||||||
* @param bodyColor Основной цвет
|
|
||||||
* @param additionalColor Дополнительный цвет
|
|
||||||
* @param additionalEngine Опция наличия дополнительного двигателя
|
|
||||||
* @param passengerCompartment Опция наличия дополнительного отсека для пассажиров
|
|
||||||
*/
|
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, boolean additionalEngine, boolean passengerCompartment) {
|
|
||||||
EntityAirbus = new EntityAirbus();
|
|
||||||
EntityAirbus.Init(speed, weight, bodyColor, additionalColor, additionalEngine, passengerCompartment);
|
|
||||||
_pictureWidth = null;
|
|
||||||
_pictureHeight = null;
|
|
||||||
_startPosX = null;
|
|
||||||
_startPosY = null;
|
|
||||||
|
|
||||||
_drawningAirbusPortholes = new DrawningAirbusPortholes();
|
|
||||||
Random random = new Random();
|
|
||||||
int portholesCount = random.nextInt(1,4);
|
|
||||||
_drawningAirbusPortholes.setPortholesCount(portholesCount * 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Установка границ поля
|
|
||||||
*
|
|
||||||
* @param width Ширина поля
|
|
||||||
* @param height Высота поля
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean SetPictureSize(int width, int height) {
|
|
||||||
if (width > _drawningAirbusWidth && height > _drawningAirbusHeight) {
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
|
|
||||||
if (_startPosX != null && _startPosY != null) {
|
|
||||||
if (_startPosX + _drawningAirbusWidth > _pictureWidth) {
|
|
||||||
_startPosX = _pictureWidth - _drawningAirbusWidth;
|
|
||||||
}
|
|
||||||
if (_startPosY + _drawningAirbusHeight > _pictureHeight) {
|
|
||||||
_startPosY = _pictureHeight - _drawningAirbusHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Установка позиции самолёта
|
|
||||||
*
|
|
||||||
* @param x Координата x
|
|
||||||
* @param y Координата y
|
|
||||||
*/
|
|
||||||
public void SetPosition(int x, int y) {
|
|
||||||
if (_pictureHeight == null || _pictureWidth == null) {
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
_startPosX = x;
|
|
||||||
_startPosY = y;
|
|
||||||
|
|
||||||
if (_startPosX < 0) _startPosX = 0;
|
|
||||||
if (_startPosY < 0) _startPosY = 0;
|
|
||||||
|
|
||||||
if (_startPosX + _drawningAirbusWidth > _pictureWidth) {
|
|
||||||
_startPosX = _pictureWidth - _drawningAirbusWidth;
|
|
||||||
}
|
|
||||||
if (_startPosY + _drawningAirbusHeight > _pictureHeight) {
|
|
||||||
_startPosY = _pictureHeight - _drawningAirbusHeight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Выбр направления перемещения
|
|
||||||
*
|
|
||||||
* @param direction Направление
|
|
||||||
* @return true - перемещение возможно и выполнено, false - перемещение невозможно и не выполнено
|
|
||||||
*/
|
|
||||||
public boolean MoveTransport(DirectionType direction) {
|
|
||||||
if (EntityAirbus == null || _startPosX == null || _startPosY == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (direction) {
|
|
||||||
case DirectionType.Left:
|
|
||||||
if (_startPosX - EntityAirbus.getStep() > 0) {
|
|
||||||
_startPosX -= (int) EntityAirbus.getStep();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case DirectionType.Up:
|
|
||||||
if (_startPosY - EntityAirbus.getStep() > 0) {
|
|
||||||
_startPosY -= (int) EntityAirbus.getStep();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case DirectionType.Right:
|
|
||||||
if (_startPosX + EntityAirbus.getStep() < _pictureWidth - _drawningAirbusWidth) {
|
|
||||||
_startPosX += (int) EntityAirbus.getStep();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
case DirectionType.Down:
|
|
||||||
if (_startPosY + EntityAirbus.getStep() < _pictureHeight - _drawningAirbusHeight) {
|
|
||||||
_startPosY += (int) EntityAirbus.getStep();
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Отрисовка самолёта
|
|
||||||
*
|
|
||||||
* @param g
|
|
||||||
*/
|
|
||||||
public void DrawTransport(Graphics g) {
|
|
||||||
if (EntityAirbus == null || _startPosX == null || _startPosY == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Graphics2D g2d = (Graphics2D) g;
|
|
||||||
|
|
||||||
// дополнительный отсек для пассажиров
|
|
||||||
if (EntityAirbus.withPassengerCompartment()) {
|
|
||||||
g2d.setColor(Color.BLACK);
|
|
||||||
g2d.drawRect(_startPosX + 60, _startPosY + 10, 40, 10);
|
|
||||||
g2d.drawOval(_startPosX + 50, _startPosY + 10, 20, 20);
|
|
||||||
g2d.drawOval(_startPosX + 90, _startPosY + 10, 20, 20);
|
|
||||||
|
|
||||||
g2d.setColor(EntityAirbus.getAdditionalColor());
|
|
||||||
g2d.fillRect(_startPosX + 60, _startPosY + 11, 40, 10);
|
|
||||||
g2d.fillOval(_startPosX + 50, _startPosY + 10, 20, 20);
|
|
||||||
g2d.fillOval(_startPosX + 90, _startPosY + 10, 20, 20);
|
|
||||||
}
|
|
||||||
|
|
||||||
// фюзеляж самолёта
|
|
||||||
int[] xPointsBorders = {_startPosX, _startPosX, _startPosX + 10, _startPosX + 120, _startPosX + 145, _startPosX + 120, _startPosX + 20};
|
|
||||||
int[] yPointsBorders = {_startPosY, _startPosY + 30, _startPosY + 40, _startPosY + 40, _startPosY + 30, _startPosY + 20, _startPosY + 20};
|
|
||||||
|
|
||||||
g2d.setColor(Color.BLACK);
|
|
||||||
g2d.drawOval(_startPosX, _startPosY + 20, 20, 20);
|
|
||||||
g2d.drawPolygon(xPointsBorders, yPointsBorders, 7);
|
|
||||||
|
|
||||||
g2d.setColor(EntityAirbus.getBodyColor());
|
|
||||||
g2d.fillOval(_startPosX, _startPosY + 20, 20, 20);
|
|
||||||
g2d.fillPolygon(xPointsBorders, yPointsBorders, 7);
|
|
||||||
g2d.setColor(Color.BLACK);
|
|
||||||
g2d.drawLine(_startPosX + 120, _startPosY + 30, _startPosX + 145, _startPosY + 30);
|
|
||||||
g2d.drawLine(_startPosX + 120, _startPosY + 20, _startPosX + 120, _startPosY + 40);
|
|
||||||
|
|
||||||
//шасси
|
|
||||||
g2d.drawLine(_startPosX + 40, _startPosY + 40, _startPosX + 40, _startPosY + 44);
|
|
||||||
g2d.drawOval(_startPosX + 34, _startPosY + 44, 6, 6);
|
|
||||||
g2d.drawOval(_startPosX + 40, _startPosY + 44, 6, 6);
|
|
||||||
g2d.drawLine(_startPosX + 110, _startPosY + 40, _startPosX + 110, _startPosY + 44);
|
|
||||||
g2d.drawOval(_startPosX + 107, _startPosY + 44, 6, 6);
|
|
||||||
|
|
||||||
//двигатель в хвосте
|
|
||||||
g2d.setColor(Color.BLACK);
|
|
||||||
g2d.fillOval(_startPosX, _startPosY + 15, 8, 8);
|
|
||||||
g2d.fillOval(_startPosX + 12, _startPosY + 15, 8, 8);
|
|
||||||
g2d.fillRect(_startPosX + 4, _startPosY + 15, 12, 8);
|
|
||||||
|
|
||||||
//иллюминаторы
|
|
||||||
_drawningAirbusPortholes.drawAirbusPortholes(g2d, _startPosX + 2, _startPosY + 25);
|
|
||||||
|
|
||||||
//дополнительный двигатель на крыле
|
|
||||||
if (EntityAirbus.withAdditionalEngine()) {
|
|
||||||
g2d.fillOval(_startPosX + 48, _startPosY + 30, 8, 8);
|
|
||||||
g2d.fillOval(_startPosX + 60, _startPosY + 30, 8, 8);
|
|
||||||
g2d.fillRect(_startPosX + 52, _startPosY + 30, 12, 8);
|
|
||||||
}
|
|
||||||
|
|
||||||
//крыло
|
|
||||||
g2d.fillRect(_startPosX + 40, _startPosY + 28, 40, 4);
|
|
||||||
g2d.fillOval(_startPosX + 38, _startPosY + 28, 4, 4);
|
|
||||||
g2d.fillOval(_startPosX + 78, _startPosY + 28, 4, 4);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
import java.awt.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Класс отрисовки иллюминаторов
|
|
||||||
*/
|
|
||||||
public class DrawningAirbusPortholes {
|
|
||||||
/**
|
|
||||||
* Количество иллюминаторов
|
|
||||||
*/
|
|
||||||
private PortholesEnum _portholesCount;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Установка значения количества иллюминаторов
|
|
||||||
*
|
|
||||||
* @param portholesCount Устанавливаемое количество иллюминаторов
|
|
||||||
*/
|
|
||||||
public void setPortholesCount(int portholesCount) {
|
|
||||||
for (PortholesEnum value : PortholesEnum.values()) {
|
|
||||||
if (value.portholesEnumNumber == portholesCount) {
|
|
||||||
_portholesCount = value;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Класс отрисовки иллюминаторов
|
|
||||||
*
|
|
||||||
* @param g
|
|
||||||
* @param startPosX
|
|
||||||
* @param startPosY
|
|
||||||
*/
|
|
||||||
public void drawAirbusPortholes(Graphics g, float startPosX, float startPosY) {
|
|
||||||
Graphics2D g2d = (Graphics2D) g;
|
|
||||||
int intervalBetweenPortholes = 120 / _portholesCount.getPortholesEnumNumber();
|
|
||||||
|
|
||||||
for (int i = 0; i < _portholesCount.getPortholesEnumNumber(); i++) {
|
|
||||||
int posX = (int) (startPosX + i * intervalBetweenPortholes);
|
|
||||||
drawPortholeKit(g2d, posX, (int) startPosY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Отрисовка иллюминатора
|
|
||||||
*
|
|
||||||
* @param g2d
|
|
||||||
* @param posX
|
|
||||||
* @param posY
|
|
||||||
*/
|
|
||||||
private void drawPortholeKit(Graphics2D g2d, int posX, int posY) {
|
|
||||||
g2d.setColor(Color.CYAN);
|
|
||||||
g2d.fillOval(posX, posY, 5, 5);
|
|
||||||
g2d.setColor(Color.BLACK);
|
|
||||||
g2d.drawOval(posX, posY, 5, 5);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
import java.awt.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Класс-сущность "Аэробус"
|
|
||||||
*/
|
|
||||||
public class EntityAirbus {
|
|
||||||
/**
|
|
||||||
* Скорость
|
|
||||||
*/
|
|
||||||
private int Speed;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Вес
|
|
||||||
*/
|
|
||||||
private double Weight;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Основной цвет
|
|
||||||
*/
|
|
||||||
private Color BodyColor;
|
|
||||||
public Color getBodyColor() {
|
|
||||||
return BodyColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Дополнительный цвет
|
|
||||||
*/
|
|
||||||
private Color AdditionalColor;
|
|
||||||
public Color getAdditionalColor() {
|
|
||||||
return AdditionalColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Опция наличия дополнительного двигателя
|
|
||||||
*/
|
|
||||||
private boolean AdditionalEngine;
|
|
||||||
public boolean withAdditionalEngine() {
|
|
||||||
return AdditionalEngine;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Опция наличия дополнительного отсека для пассажиров
|
|
||||||
*/
|
|
||||||
private boolean PassengerCompartment;
|
|
||||||
public boolean withPassengerCompartment() {
|
|
||||||
return PassengerCompartment;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Шаг перемещения автомобиля
|
|
||||||
*/
|
|
||||||
private double Step;
|
|
||||||
public double getStep() {
|
|
||||||
return (double) Speed * 100 / Weight;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Инициализация полей объекта-класса аэробуса
|
|
||||||
*
|
|
||||||
* @param speed Скорость
|
|
||||||
* @param weight Вес
|
|
||||||
* @param bodyColor Основной цвет
|
|
||||||
* @param additionalColor Дополнительный цвет
|
|
||||||
* @param additionalEngine Опция наличия дополнительного двигателя
|
|
||||||
* @param passengerCompartment Опция наличия дополнительного отсека для пассажиров
|
|
||||||
*/
|
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor,
|
|
||||||
boolean additionalEngine, boolean passengerCompartment) {
|
|
||||||
Speed = speed;
|
|
||||||
Weight = weight;
|
|
||||||
BodyColor = bodyColor;
|
|
||||||
AdditionalColor = additionalColor;
|
|
||||||
AdditionalEngine = additionalEngine;
|
|
||||||
PassengerCompartment = passengerCompartment;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,93 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="FormAirbus">
|
|
||||||
<grid id="27dc6" binding="PanelWrapper" layout-manager="GridLayoutManager" row-count="1" column-count="1" 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="728" height="549"/>
|
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
<border type="none"/>
|
|
||||||
<children>
|
|
||||||
<grid id="e30f5" binding="PictureBox" layout-manager="GridLayoutManager" row-count="3" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
|
||||||
<margin top="0" left="0" bottom="0" right="0"/>
|
|
||||||
<constraints>
|
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties/>
|
|
||||||
<border type="none"/>
|
|
||||||
<children>
|
|
||||||
<component id="62c2e" class="javax.swing.JButton" binding="buttonCreate">
|
|
||||||
<constraints>
|
|
||||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<text value="Создать"/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<component id="a3af8" class="javax.swing.JButton" binding="buttonRight">
|
|
||||||
<constraints>
|
|
||||||
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
|
||||||
<minimum-size width="30" height="30"/>
|
|
||||||
<preferred-size width="30" height="30"/>
|
|
||||||
<maximum-size width="30" height="30"/>
|
|
||||||
</grid>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<icon value="RightArrow1.jpg"/>
|
|
||||||
<text value=""/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<component id="2b352" class="javax.swing.JButton" binding="buttonDown">
|
|
||||||
<constraints>
|
|
||||||
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
|
||||||
<minimum-size width="30" height="30"/>
|
|
||||||
<preferred-size width="30" height="30"/>
|
|
||||||
<maximum-size width="30" height="30"/>
|
|
||||||
</grid>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<icon value="DownArrow1.jpg"/>
|
|
||||||
<text value=""/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<component id="84615" class="javax.swing.JButton" binding="buttonUp">
|
|
||||||
<constraints>
|
|
||||||
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
|
||||||
<minimum-size width="30" height="30"/>
|
|
||||||
<preferred-size width="30" height="30"/>
|
|
||||||
<maximum-size width="30" height="30"/>
|
|
||||||
</grid>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<icon value="UpArrow1.jpg"/>
|
|
||||||
<text value=""/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<component id="cfcfa" class="javax.swing.JButton" binding="buttonLeft">
|
|
||||||
<constraints>
|
|
||||||
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false">
|
|
||||||
<minimum-size width="30" height="30"/>
|
|
||||||
<preferred-size width="30" height="30"/>
|
|
||||||
<maximum-size width="30" height="30"/>
|
|
||||||
</grid>
|
|
||||||
</constraints>
|
|
||||||
<properties>
|
|
||||||
<icon value="LeftArrow1.jpg"/>
|
|
||||||
<text value=""/>
|
|
||||||
</properties>
|
|
||||||
</component>
|
|
||||||
<vspacer id="c1567">
|
|
||||||
<constraints>
|
|
||||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
</vspacer>
|
|
||||||
<hspacer id="b267f">
|
|
||||||
<constraints>
|
|
||||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
|
||||||
</constraints>
|
|
||||||
</hspacer>
|
|
||||||
</children>
|
|
||||||
</grid>
|
|
||||||
</children>
|
|
||||||
</grid>
|
|
||||||
</form>
|
|
@ -1,133 +0,0 @@
|
|||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Форма, работающая с объектом "самолёт"
|
|
||||||
*/
|
|
||||||
public class FormAirbus {
|
|
||||||
/**
|
|
||||||
* Поле-объект для отрисовки объекта
|
|
||||||
*/
|
|
||||||
private DrawningAirbus _drawningAirbus;
|
|
||||||
|
|
||||||
private JPanel PanelWrapper;
|
|
||||||
public JPanel getPanelWrapper() {
|
|
||||||
return PanelWrapper;
|
|
||||||
}
|
|
||||||
|
|
||||||
private JPanel PictureBox;
|
|
||||||
|
|
||||||
private JButton buttonCreate;
|
|
||||||
|
|
||||||
private JButton buttonUp;
|
|
||||||
|
|
||||||
private JButton buttonLeft;
|
|
||||||
|
|
||||||
private JButton buttonRight;
|
|
||||||
|
|
||||||
private JButton buttonDown;
|
|
||||||
|
|
||||||
private List<JComponent> controls;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Конструктор формы
|
|
||||||
*/
|
|
||||||
public FormAirbus() {
|
|
||||||
buttonUp.setName("buttonUp");
|
|
||||||
buttonDown.setName("buttonDown");
|
|
||||||
buttonLeft.setName("buttonLeft");
|
|
||||||
buttonRight.setName("buttonRight");
|
|
||||||
|
|
||||||
InitializeControlsRepaintList();
|
|
||||||
|
|
||||||
buttonCreate.addActionListener(new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
_drawningAirbus = new DrawningAirbus();
|
|
||||||
Random random = new Random();
|
|
||||||
|
|
||||||
_drawningAirbus.Init(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)),
|
|
||||||
random.nextBoolean(), random.nextBoolean());
|
|
||||||
_drawningAirbus.SetPictureSize(PictureBox.getWidth(), PictureBox.getHeight());
|
|
||||||
_drawningAirbus.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100));
|
|
||||||
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
ActionListener buttonMoveClickedListener = new ActionListener() {
|
|
||||||
@Override
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
|
||||||
String buttonName = ((JButton) e.getSource()).getName();
|
|
||||||
boolean result = false;
|
|
||||||
|
|
||||||
switch (buttonName) {
|
|
||||||
case "buttonUp":
|
|
||||||
result = _drawningAirbus.MoveTransport(DirectionType.Up);
|
|
||||||
break;
|
|
||||||
case "buttonDown":
|
|
||||||
result = _drawningAirbus.MoveTransport(DirectionType.Down);
|
|
||||||
break;
|
|
||||||
case "buttonLeft":
|
|
||||||
result = _drawningAirbus.MoveTransport(DirectionType.Left);
|
|
||||||
break;
|
|
||||||
case "buttonRight":
|
|
||||||
result = _drawningAirbus.MoveTransport(DirectionType.Right);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result)
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
buttonRight.addActionListener(buttonMoveClickedListener);
|
|
||||||
buttonDown.addActionListener(buttonMoveClickedListener);
|
|
||||||
buttonLeft.addActionListener(buttonMoveClickedListener);
|
|
||||||
buttonUp.addActionListener(buttonMoveClickedListener);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Метод прорисовки аэробуса
|
|
||||||
*/
|
|
||||||
private void Draw() {
|
|
||||||
if (_drawningAirbus.getEntityAirbus() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Graphics g = PictureBox.getGraphics();
|
|
||||||
g.setColor(PictureBox.getBackground());
|
|
||||||
g.fillRect(0, 0, PictureBox.getWidth(), PictureBox.getHeight());
|
|
||||||
_drawningAirbus.DrawTransport(g);
|
|
||||||
|
|
||||||
RepaintControls();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Перерисовка кнопок
|
|
||||||
*/
|
|
||||||
private void RepaintControls() {
|
|
||||||
for (JComponent control : controls) {
|
|
||||||
control.repaint();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Обновление списка кнопок
|
|
||||||
*/
|
|
||||||
private void InitializeControlsRepaintList() {
|
|
||||||
controls = new LinkedList<>();
|
|
||||||
controls.add(buttonCreate);
|
|
||||||
controls.add(buttonUp);
|
|
||||||
controls.add(buttonLeft);
|
|
||||||
controls.add(buttonRight);
|
|
||||||
controls.add(buttonDown);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,17 +1,5 @@
|
|||||||
import javax.swing.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Точка входа в приложение
|
|
||||||
*/
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
JFrame.setDefaultLookAndFeelDecorated(false);
|
|
||||||
JFrame frame = new JFrame("Аэробус");
|
|
||||||
frame.setContentPane(new FormAirbus().getPanelWrapper());
|
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
||||||
frame.setLocation(200, 200);
|
|
||||||
frame.pack();
|
|
||||||
frame.setSize(1000, 600);
|
|
||||||
frame.setVisible(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,29 +0,0 @@
|
|||||||
/**
|
|
||||||
* Перечисление возможного количества иллюминаторов
|
|
||||||
*/
|
|
||||||
public enum PortholesEnum {
|
|
||||||
/**
|
|
||||||
* Десять (10)
|
|
||||||
*/
|
|
||||||
Ten(10),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Двадцать (20)
|
|
||||||
*/
|
|
||||||
Twenty(20),
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Тридцать (30)
|
|
||||||
*/
|
|
||||||
Thirty(30);
|
|
||||||
|
|
||||||
|
|
||||||
public final int portholesEnumNumber;
|
|
||||||
public int getPortholesEnumNumber() {
|
|
||||||
return portholesEnumNumber;
|
|
||||||
}
|
|
||||||
|
|
||||||
PortholesEnum (int number) {
|
|
||||||
this.portholesEnumNumber = number;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user