Добавление логики новых форм
This commit is contained in:
parent
2a90e0d4b0
commit
0391fff9dc
158
src/FormMapWithSetWarships.form
Normal file
158
src/FormMapWithSetWarships.form
Normal file
@ -0,0 +1,158 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="FormMapWithSetWarships">
|
||||
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="1" 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="884" height="479"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="ae53a" binding="PictureBox" 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>
|
||||
<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">
|
||||
<preferred-size width="727" height="24"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<hspacer id="815b1">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="7" anchor="0" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="716" height="11"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="16c60" binding="GroupBoxTools" layout-manager="GridLayoutManager" row-count="11" 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="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="bevel-lowered" title="Tools" title-justification="1" title-position="2">
|
||||
<font/>
|
||||
</border>
|
||||
<children>
|
||||
<component id="d5ebd" class="javax.swing.JComboBox" binding="СomboBoxSelectorMap">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<model>
|
||||
<item value="Первая карта"/>
|
||||
<item value="Вторая карта"/>
|
||||
</model>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="9e5dd" class="javax.swing.JButton" binding="ButtonAddWarship">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Add warship"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="16e2c" class="javax.swing.JButton" binding="ButtonRemoveWarship">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Remove warship"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="1fc5b" class="javax.swing.JButton" binding="ButtonShowStorage">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Show storage"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="3dd40" class="javax.swing.JButton" binding="ButtonShowOnMap">
|
||||
<constraints>
|
||||
<grid row="7" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Show map"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="608d7" class="javax.swing.JTextField" binding="TextBoxPosition">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="3" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="2ea34" class="javax.swing.JButton" binding="ButtonRight">
|
||||
<constraints>
|
||||
<grid row="10" column="2" 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="daf62" class="javax.swing.JButton" binding="ButtonDown">
|
||||
<constraints>
|
||||
<grid row="10" column="1" 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="76b8a" class="javax.swing.JButton" binding="ButtonLeft">
|
||||
<constraints>
|
||||
<grid row="10" column="0" 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="675d4" class="javax.swing.JButton" binding="ButtonUp">
|
||||
<constraints>
|
||||
<grid row="9" column="1" 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>
|
||||
<vspacer id="aa195">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<vspacer id="fa6fc">
|
||||
<constraints>
|
||||
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<vspacer id="f6c4c">
|
||||
<constraints>
|
||||
<grid row="8" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
155
src/FormMapWithSetWarships.java
Normal file
155
src/FormMapWithSetWarships.java
Normal file
@ -0,0 +1,155 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
|
||||
public class FormMapWithSetWarships extends JFrame{
|
||||
private JPanel mainPanel;
|
||||
private JPanel PictureBox;
|
||||
private JPanel GroupBoxTools;
|
||||
private JComboBox СomboBoxSelectorMap;
|
||||
private JButton ButtonAddWarship;
|
||||
private JButton ButtonRemoveWarship;
|
||||
private JButton ButtonShowStorage;
|
||||
private JButton ButtonShowOnMap;
|
||||
private JTextField TextBoxPosition;
|
||||
private JButton ButtonRight;
|
||||
private JButton ButtonUp;
|
||||
private JButton ButtonDown;
|
||||
private JButton ButtonLeft;
|
||||
private Image bufferedImage;
|
||||
private MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap> _mapWarshipsCollectionGeneric;
|
||||
|
||||
public FormMapWithSetWarships(){
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void InitializeComponent(){
|
||||
setContentPane(mainPanel);
|
||||
setTitle("Warship");
|
||||
setSize(1000, 685);
|
||||
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
|
||||
setVisible(true);
|
||||
|
||||
Icon iconUp = new ImageIcon("src\\Images\\ArrowUp.jpg");
|
||||
ButtonUp.setIcon(iconUp);
|
||||
Icon iconDown = new ImageIcon("src\\Images\\ArrowDown.jpg");
|
||||
ButtonDown.setIcon(iconDown);
|
||||
Icon iconLeft = new ImageIcon("src\\Images\\ArrowLeft.jpg");
|
||||
ButtonLeft.setIcon(iconLeft);
|
||||
Icon iconRight = new ImageIcon("src\\Images\\ArrowRight.jpg");
|
||||
ButtonRight.setIcon(iconRight);
|
||||
|
||||
СomboBoxSelectorMap.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
AbstractMap map = null;
|
||||
switch ((String) СomboBoxSelectorMap.getSelectedItem()){
|
||||
case "Простая карта":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "Преграды-линии":
|
||||
map = new LineMap();
|
||||
break;
|
||||
}
|
||||
if( map != null){
|
||||
_mapWarshipsCollectionGeneric = new MapWithSetWarshipsGeneric<DrawingObjectWarship, AbstractMap>(
|
||||
PictureBox.getWidth(), PictureBox.getHeight(), map);
|
||||
}
|
||||
else
|
||||
{
|
||||
_mapWarshipsCollectionGeneric = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ButtonAddWarship.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(_mapWarshipsCollectionGeneric == null){
|
||||
return;
|
||||
}
|
||||
FormWarship form = new FormWarship();
|
||||
form.setSize(1200,700);
|
||||
form.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
||||
form.setVisible(true);
|
||||
form.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
DrawingObjectWarship warship = new DrawingObjectWarship(form.getSelectedCar());
|
||||
if (_mapWarshipsCollectionGeneric.add(warship) > 0)
|
||||
{
|
||||
if (form.DialogResult)
|
||||
JOptionPane.showMessageDialog(null, "Объект добавлен");
|
||||
bufferedImage = _mapWarshipsCollectionGeneric.ShowSet();
|
||||
repaint();
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
ButtonRemoveWarship.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String text = TextBoxPosition.getText();
|
||||
if (text == null || _mapWarshipsCollectionGeneric == null || text.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
int result = JOptionPane.showConfirmDialog(
|
||||
null,
|
||||
"Удалить объект?",
|
||||
"Удаление",
|
||||
JOptionPane.YES_NO_CANCEL_OPTION);
|
||||
if (result == JOptionPane.NO_OPTION)
|
||||
{
|
||||
return;
|
||||
}
|
||||
int pos = Integer.parseInt(text);
|
||||
if (_mapWarshipsCollectionGeneric.remove(pos) != null)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null,"Объект удален","Успех",JOptionPane.INFORMATION_MESSAGE);
|
||||
bufferedImage = _mapWarshipsCollectionGeneric.ShowSet();
|
||||
repaint();
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog(null,"Не удалось удалить объект","Ошибка",JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ButtonShowStorage.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(_mapWarshipsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bufferedImage = _mapWarshipsCollectionGeneric.ShowSet();
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
|
||||
ButtonShowOnMap.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (_mapWarshipsCollectionGeneric == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bufferedImage = _mapWarshipsCollectionGeneric.ShowOnMap();
|
||||
repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
@ -8,7 +8,7 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="dfecd" binding="drawPanel" layout-manager="GridLayoutManager" row-count="3" column-count="6" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="dfecd" binding="drawPanel" layout-manager="GridLayoutManager" row-count="3" 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="3" col-span="6" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@ -44,7 +44,7 @@
|
||||
</component>
|
||||
<component id="55933" class="javax.swing.JButton" binding="buttonRight">
|
||||
<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">
|
||||
<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"/>
|
||||
@ -56,7 +56,7 @@
|
||||
</component>
|
||||
<component id="bb79e" class="javax.swing.JButton" binding="buttonDown">
|
||||
<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">
|
||||
<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"/>
|
||||
@ -69,7 +69,7 @@
|
||||
</component>
|
||||
<component id="82cc1" class="javax.swing.JButton" binding="buttonUp">
|
||||
<constraints>
|
||||
<grid row="1" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<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"/>
|
||||
@ -81,7 +81,7 @@
|
||||
</component>
|
||||
<component id="32714" class="javax.swing.JButton" binding="buttonLeft">
|
||||
<constraints>
|
||||
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false">
|
||||
<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"/>
|
||||
@ -91,6 +91,14 @@
|
||||
<text value=""/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b9b11" class="javax.swing.JButton" binding="buttonSelect">
|
||||
<constraints>
|
||||
<grid row="2" column="3" 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="Select"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<toolbar id="3697c" binding="toolBar">
|
||||
|
@ -4,11 +4,15 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.awt.event.ComponentAdapter;
|
||||
import java.awt.event.ComponentEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Random;
|
||||
|
||||
public class FormWarship extends JFrame {
|
||||
private DrawingWarship _warship;
|
||||
public DrawingWarship selectedWarship;
|
||||
public DrawingWarship getSelectedCar(){
|
||||
return selectedWarship;
|
||||
}
|
||||
public boolean DialogResult = false;
|
||||
private JPanel mainPanel;
|
||||
private JPanel drawPanel;
|
||||
private JButton buttonCreate;
|
||||
@ -21,6 +25,7 @@ public class FormWarship extends JFrame {
|
||||
private JLabel toolBarLabelWieght;
|
||||
private JLabel toolBarLabelColor;
|
||||
private JButton buttonCreateModif;
|
||||
private JButton buttonSelect;
|
||||
|
||||
public FormWarship(){
|
||||
InitializeComponent();
|
||||
@ -89,6 +94,16 @@ public class FormWarship extends JFrame {
|
||||
}
|
||||
});
|
||||
|
||||
buttonSelect.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if(_warship != null){
|
||||
selectedWarship =_warship;
|
||||
DialogResult = true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
buttonLeft.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
242
src/FormWarshipCreator.form
Normal file
242
src/FormWarshipCreator.form
Normal file
@ -0,0 +1,242 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="FormWarshipCreator">
|
||||
<grid id="27dc6" binding="PictureBox" layout-manager="GridLayoutManager" row-count="1" 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="838" height="633"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<grid id="b8cad" binding="PropertiesPanel" layout-manager="GridLayoutManager" row-count="8" 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>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<opaque value="true"/>
|
||||
</properties>
|
||||
<border type="etched" title="Настройки"/>
|
||||
<children>
|
||||
<vspacer id="3ff70">
|
||||
<constraints>
|
||||
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<grid id="fee11" layout-manager="GridLayoutManager" row-count="2" 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>
|
||||
<grid row="2" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="etched" title="Тип корабля:"/>
|
||||
<children>
|
||||
<component id="387d2" class="javax.swing.JRadioButton" binding="BasicRadioButton">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Обычный корабль"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="dc133" class="javax.swing.JRadioButton" binding="AdvancedRadioButton">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Продвинутый корабль"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="f9f1b" 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>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="etched" title="Характеристики корабля:"/>
|
||||
<children>
|
||||
<component id="10585" class="javax.swing.JTextField" binding="WeightTextField">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="8b062" class="javax.swing.JTextField" binding="SpeedTextField">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="d443" class="javax.swing.JLabel" binding="SetWeightLabel">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Вес"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="4ca48" class="javax.swing.JLabel" binding="SetSpeedLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Скорость"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="41669" binding="CargoPanel" layout-manager="GridLayoutManager" row-count="3" 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>
|
||||
<grid row="4" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="etched" title="Характеристики груза:"/>
|
||||
<children>
|
||||
<component id="40e8a" class="javax.swing.JRadioButton" binding="TriangleFormRadioButton">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Треугольные ящики"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="339d6" class="javax.swing.JRadioButton" binding="RoundFormRadioButton">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<label value="Круглые ящики"/>
|
||||
<text value="Круглые ящики"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="ad164" class="javax.swing.JRadioButton" binding="RectangleFormRadioButton">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Прямоугольные ящики"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="21a40" binding="CountOfBlocksPanel" layout-manager="GridLayoutManager" row-count="3" 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>
|
||||
<grid row="3" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="etched" title="Количество ящиков:"/>
|
||||
<children>
|
||||
<component id="e77e" class="javax.swing.JRadioButton" binding="SixRadioButton">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="6"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="90578" class="javax.swing.JRadioButton" binding="FourRadioButton">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="4"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="d9b90" class="javax.swing.JRadioButton" binding="TwoRadioButton">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="2"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="15d71" layout-manager="GridLayoutManager" row-count="2" 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>
|
||||
<grid row="6" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="a819c" class="javax.swing.JButton" binding="ShowWarshipButton">
|
||||
<constraints>
|
||||
<grid row="0" 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>
|
||||
<label value="Показать"/>
|
||||
<text value="Показать"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="821c8" class="javax.swing.JButton" binding="ChooseButton">
|
||||
<constraints>
|
||||
<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>
|
||||
<label value="Выбрать"/>
|
||||
<text value="Выбрать"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<vspacer id="6c05e">
|
||||
<constraints>
|
||||
<grid row="5" 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>
|
||||
<grid id="5220b" layout-manager="GridLayoutManager" row-count="3" 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>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="etched" title="Улучшения:"/>
|
||||
<children>
|
||||
<component id="c96ee" class="javax.swing.JCheckBox" binding="MissileCheckBox">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<label value="Боевые ракеты"/>
|
||||
<text value="Боевые ракеты"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="385c6" class="javax.swing.JCheckBox" binding="AntennaCheckBox">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<label value="Антенна"/>
|
||||
<text value="Антенна"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="63fa9" class="javax.swing.JCheckBox" binding="HelipadCheckBox">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<label value="Вертолетная площадка"/>
|
||||
<text value="Вертолетная площадка"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<hspacer id="2bb5c">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</hspacer>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
30
src/FormWarshipCreator.java
Normal file
30
src/FormWarshipCreator.java
Normal file
@ -0,0 +1,30 @@
|
||||
import javax.swing.*;
|
||||
|
||||
public class FormWarshipCreator extends JDialog{
|
||||
private JPanel PictureBox;
|
||||
private JPanel PropertiesPanel;
|
||||
private JRadioButton BasicRadioButton;
|
||||
private JRadioButton AdvancedRadioButton;
|
||||
private JTextField WeightTextField;
|
||||
private JTextField SpeedTextField;
|
||||
private JLabel SetWeightLabel;
|
||||
private JLabel SetSpeedLabel;
|
||||
private JPanel CargoPanel;
|
||||
private JRadioButton TriangleFormRadioButton;
|
||||
private JRadioButton RoundFormRadioButton;
|
||||
private JRadioButton RectangleFormRadioButton;
|
||||
private JPanel CountOfBlocksPanel;
|
||||
private JRadioButton SixRadioButton;
|
||||
private JRadioButton FourRadioButton;
|
||||
private JRadioButton TwoRadioButton;
|
||||
private JButton ShowWarshipButton;
|
||||
private JButton ChooseButton;
|
||||
private JCheckBox MissileCheckBox;
|
||||
private JCheckBox AntennaCheckBox;
|
||||
private JCheckBox HelipadCheckBox;
|
||||
BlockCount block=null;
|
||||
IDrawingObjectBlock fblock=null;
|
||||
private final CreaterGeneric<EntityWarship,IDrawingObjectBlock> createrGeneric=new CreaterGeneric<>(40,40);
|
||||
private DrawingWarship _warship;
|
||||
private DrawingWarship selectedWarship;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
new FormMap();
|
||||
new FormMapWithSetWarships();
|
||||
}
|
||||
|
||||
}
|
||||
|
41
src/WarshipCreatorGeneric.java
Normal file
41
src/WarshipCreatorGeneric.java
Normal file
@ -0,0 +1,41 @@
|
||||
import java.util.Random;
|
||||
|
||||
public class WarshipCreatorGeneric <T extends EntityWarship, U extends IDrawingObjectBlock>{
|
||||
T[] Warships;
|
||||
U[] Blocks;
|
||||
int WarshipsCount = 0;
|
||||
int BlocksCount = 0;
|
||||
public WarshipCreatorGeneric(int warshipsCount, int blocksCount){
|
||||
Warships = (T[])new Object[warshipsCount];
|
||||
Blocks = (U[]) new Object[blocksCount];
|
||||
WarshipsCount = warshipsCount;
|
||||
BlocksCount = blocksCount;
|
||||
}
|
||||
|
||||
public int AddWarship(T warship){
|
||||
if(WarshipsCount<Warships.length){
|
||||
Warships[WarshipsCount]=warship;
|
||||
WarshipsCount++;
|
||||
return WarshipsCount-1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public int AddBlock(U block){
|
||||
if(BlocksCount<Blocks.length){
|
||||
Blocks[BlocksCount]=block;
|
||||
BlocksCount++;
|
||||
return BlocksCount-1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
public DrawingWarship NewWarshipCreating()
|
||||
{
|
||||
Random rand=new Random();
|
||||
T warship = Warships[rand.nextInt(WarshipsCount)];
|
||||
U block = Blocks[rand.nextInt(BlocksCount)];
|
||||
if(warship instanceof EntityAircraftCarrier){
|
||||
return new DrawingAircraftCarrier(warship,block);
|
||||
}
|
||||
return new DrawingWarship(warship,block);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user