еще чуть чуть
This commit is contained in:
parent
2c9b5d5c13
commit
1647f7b4b8
121
FormMap.form
121
FormMap.form
@ -1,121 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="FormMap">
|
||||
<grid id="27dc6" 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="500" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="b59ef" binding="Mainpanel" layout-manager="GridLayoutManager" row-count="4" column-count="7" 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="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<opaque value="true"/>
|
||||
<preferredSize width="800" height="600"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="64b3e" class="javax.swing.JButton" binding="ButtonDown">
|
||||
<constraints>
|
||||
<grid row="2" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" 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>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="d18ed" class="javax.swing.JButton" binding="ButtonLeft">
|
||||
<constraints>
|
||||
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" 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>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="f1131" class="javax.swing.JButton" binding="ButtonRight">
|
||||
<constraints>
|
||||
<grid row="2" column="6" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" 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>
|
||||
<horizontalAlignment value="0"/>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<toolbar id="ca5d0" binding="StatusStrip">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="7" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="-1" height="20"/>
|
||||
<preferred-size width="-1" height="20"/>
|
||||
<maximum-size width="-1" height="20"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties>
|
||||
<enabled value="false"/>
|
||||
</properties>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</toolbar>
|
||||
<component id="ac7fe" class="javax.swing.JButton" binding="ButtonCreate">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Создать"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="bf993" binding="PictureBox" layout-manager="FlowLayout" hgap="5" vgap="5" flow-align="1">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="7" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
<component id="2202b" class="javax.swing.JButton" binding="ButtonUp">
|
||||
<constraints>
|
||||
<grid row="1" column="5" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" 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>
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4b50c" class="javax.swing.JButton" binding="ButtonModif">
|
||||
<constraints>
|
||||
<grid row="2" column="1" 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="db7c6" class="javax.swing.JComboBox" binding="comboBoxSelector">
|
||||
<constraints>
|
||||
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<toolTipText value="Простая карта"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
125
FormMap.java
125
FormMap.java
@ -1,125 +0,0 @@
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Random;
|
||||
|
||||
public class FormMap extends JFrame{
|
||||
public JPanel Mainpanel;
|
||||
private JButton ButtonCreate;
|
||||
private JButton ButtonLeft;
|
||||
private JButton ButtonUp;
|
||||
private JButton ButtonDown;
|
||||
private JButton ButtonRight;
|
||||
private JPanel PictureBox;
|
||||
private JToolBar StatusStrip;
|
||||
private JButton ButtonModif;
|
||||
private JComboBox comboBoxSelector;
|
||||
private final JLabel JLabelSpeed = new JLabel();
|
||||
private final JLabel JLabelWeight = new JLabel();
|
||||
private final JLabel JLabelColor = new JLabel();
|
||||
private AbstractMap _abstractMap;
|
||||
|
||||
private void ButtonMove_Click(String name)
|
||||
{
|
||||
Direction dir = Direction.None;
|
||||
switch (name)
|
||||
{
|
||||
case "buttonLeft":
|
||||
dir = Direction.Left;
|
||||
break;
|
||||
case "buttonUp":
|
||||
dir = Direction.Up;
|
||||
break;
|
||||
case "buttonRight":
|
||||
dir = Direction.Right;
|
||||
break;
|
||||
case "buttonDown":
|
||||
dir = Direction.Down;
|
||||
break;
|
||||
}
|
||||
PictureBox.removeAll();
|
||||
JLabel imageWithMapAndObject = new JLabel();
|
||||
imageWithMapAndObject.setPreferredSize(PictureBox.getSize());
|
||||
imageWithMapAndObject.setMinimumSize(new Dimension(1, 1));
|
||||
imageWithMapAndObject.setIcon(new ImageIcon(_abstractMap.MoveObject(dir)));
|
||||
PictureBox.add(imageWithMapAndObject, BorderLayout.CENTER);
|
||||
PictureBox.revalidate();
|
||||
PictureBox.repaint();
|
||||
}
|
||||
|
||||
private void SetData(DrawningPlane _plane){
|
||||
PictureBox.removeAll();
|
||||
JLabelSpeed.setText("Cкорость: " + _plane.GetPlane().GetSpeed() + " ");
|
||||
JLabelWeight.setText("Вес: " + _plane.GetPlane().GetWeight() + " ");
|
||||
JLabelColor.setText(("Цвет: " + _plane.GetPlane().GetBodyColor() + " "));
|
||||
JLabel imageWithMapAndObject = new JLabel();
|
||||
imageWithMapAndObject.setPreferredSize(PictureBox.getSize());
|
||||
imageWithMapAndObject.setMinimumSize(new Dimension(1, 1));
|
||||
imageWithMapAndObject.setIcon(new ImageIcon(_abstractMap.CreateMap(PictureBox.getWidth(),PictureBox.getHeight(), new DrawningObjectPlane(_plane))));
|
||||
PictureBox.add(imageWithMapAndObject, BorderLayout.CENTER);
|
||||
PictureBox.revalidate();
|
||||
}
|
||||
public FormMap() {
|
||||
comboBoxSelector.addItem("Простая карта");
|
||||
comboBoxSelector.addItem("Вторая карта");
|
||||
_abstractMap = new SimpleMap();
|
||||
Box LabelBox = Box.createHorizontalBox();
|
||||
LabelBox.setMinimumSize(new Dimension(1, 20));
|
||||
LabelBox.add(JLabelSpeed);
|
||||
LabelBox.add(JLabelWeight);
|
||||
LabelBox.add(JLabelColor);
|
||||
StatusStrip.add(LabelBox);
|
||||
try {
|
||||
Image img = ImageIO.read(FormMap.class.getResource("/Resource/arrowUp.jpg"));
|
||||
ButtonUp.setIcon(new ImageIcon(img));
|
||||
img = ImageIO.read(FormMap.class.getResource("/Resource/arrowDown.jpg"));
|
||||
ButtonDown.setIcon(new ImageIcon(img));
|
||||
img = ImageIO.read(FormMap.class.getResource("/Resource/arrowLeft.jpg"));
|
||||
ButtonLeft.setIcon(new ImageIcon(img));
|
||||
img = ImageIO.read(FormMap.class.getResource("/Resource/arrowRight.jpg"));
|
||||
ButtonRight.setIcon(new ImageIcon(img));
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex);
|
||||
}
|
||||
ButtonCreate.addActionListener(e -> {
|
||||
Random random = new Random();
|
||||
var _plane = new DrawningPlane(random.nextInt(100, 300),random.nextInt(1000, 2000),new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)));
|
||||
SetData(_plane);
|
||||
});
|
||||
ButtonModif.addActionListener(e -> {
|
||||
Random random = new Random();
|
||||
var _plane = new DrawningAirbus(random.nextInt(100, 300), random.nextInt(1000, 2000), new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)), new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)), random.nextBoolean(), random.nextBoolean(), random.nextBoolean());
|
||||
SetData(_plane);
|
||||
});
|
||||
ButtonUp.addActionListener(e -> {
|
||||
ButtonMove_Click("buttonUp");
|
||||
});
|
||||
ButtonDown.addActionListener(e -> {
|
||||
ButtonMove_Click("buttonDown");
|
||||
});
|
||||
ButtonLeft.addActionListener(e -> {
|
||||
ButtonMove_Click("buttonLeft");
|
||||
});
|
||||
ButtonRight.addActionListener(e -> {
|
||||
ButtonMove_Click("buttonRight");
|
||||
});
|
||||
comboBoxSelector.addActionListener(e -> {
|
||||
comboBoxSelector = (JComboBox)e.getSource();
|
||||
String item = (String)comboBoxSelector.getSelectedItem();
|
||||
switch (item) {
|
||||
case "Простая карта" -> {
|
||||
_abstractMap = new SimpleMap();
|
||||
break;
|
||||
}
|
||||
case "Вторая карта" -> {
|
||||
_abstractMap = new MyMap();
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
@ -31,7 +31,7 @@
|
||||
<grid row="1" 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="Добавить корабль"/>
|
||||
<text value="Добавить самолёт"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="2e61e" class="javax.swing.JComboBox" binding="comboBoxSelectorMap">
|
||||
@ -47,7 +47,7 @@
|
||||
<grid row="3" 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="Удалить корабль"/>
|
||||
<text value="Удалить самолёт"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="e24b9" class="javax.swing.JButton" binding="buttonShowStorage">
|
||||
|
@ -64,13 +64,13 @@ public class FormMapWithSetPlanes extends JFrame {
|
||||
comboBoxSelectorMap.addItem("Простая карта");
|
||||
comboBoxSelectorMap.addItem("Вторая карта");
|
||||
try {
|
||||
Image img = ImageIO.read(FormMap.class.getResource("/Resource/arrowUp.jpg"));
|
||||
Image img = ImageIO.read(FormMapWithSetPlanes.class.getResource("/Resource/arrowUp.jpg"));
|
||||
buttonUp.setIcon(new ImageIcon(img));
|
||||
img = ImageIO.read(FormMap.class.getResource("/Resource/arrowDown.jpg"));
|
||||
img = ImageIO.read(FormMapWithSetPlanes.class.getResource("/Resource/arrowDown.jpg"));
|
||||
buttonDown.setIcon(new ImageIcon(img));
|
||||
img = ImageIO.read(FormMap.class.getResource("/Resource/arrowLeft.jpg"));
|
||||
img = ImageIO.read(FormMapWithSetPlanes.class.getResource("/Resource/arrowLeft.jpg"));
|
||||
buttonLeft.setIcon(new ImageIcon(img));
|
||||
img = ImageIO.read(FormMap.class.getResource("/Resource/arrowRight.jpg"));
|
||||
img = ImageIO.read(FormMapWithSetPlanes.class.getResource("/Resource/arrowRight.jpg"));
|
||||
buttonRight.setIcon(new ImageIcon(img));
|
||||
} catch (Exception ex) {
|
||||
System.out.println(ex);
|
||||
|
Loading…
Reference in New Issue
Block a user