Compare commits
25 Commits
master
...
SeventhLab
Author | SHA1 | Date | |
---|---|---|---|
|
8ff85461e3 | ||
|
1e3c316731 | ||
|
760c2721aa | ||
|
4e206defed | ||
|
5063d4d157 | ||
|
54dacb11cf | ||
|
6477ad58b7 | ||
|
aa5414867c | ||
|
da6cf36c9d | ||
|
b0f86f1f75 | ||
|
3023f5b279 | ||
|
d7af21d278 | ||
|
f5b2079766 | ||
|
515c1d7f04 | ||
|
d526660dc2 | ||
|
62c4dfbe71 | ||
|
cfec576958 | ||
c5b0aa9297 | |||
b7dba8c76a | |||
55025611d1 | |||
c968474e79 | |||
040fec6b58 | |||
c16145c8f8 | |||
a9acdf4239 | |||
56824e8461 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -34,3 +34,4 @@ dist/
|
||||
nbdist/
|
||||
.nb-gradle/
|
||||
|
||||
/.vs/PIbd-22_DozorovaAA_ArmoredVehicle_Hard/v17/.suo
|
||||
|
3
.vs/ProjectSettings.json
Normal file
3
.vs/ProjectSettings.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"CurrentProjectSetting": null
|
||||
}
|
9
.vs/VSWorkspaceState.json
Normal file
9
.vs/VSWorkspaceState.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"ExpandedNodes": [
|
||||
"",
|
||||
"\\ArmoredVehicle",
|
||||
"\\ArmoredVehicle\\src"
|
||||
],
|
||||
"SelectedNode": "\\ArmoredVehicle\\src\\PolimorphClass.java",
|
||||
"PreviewInSolutionExplorer": false
|
||||
}
|
BIN
.vs/slnx.sqlite
Normal file
BIN
.vs/slnx.sqlite
Normal file
Binary file not shown.
@ -71,7 +71,7 @@ jlink.additionalmodules=
|
||||
jlink.additionalparam=
|
||||
jlink.launcher=true
|
||||
jlink.launcher.name=ArmoredVehicle
|
||||
main.class=
|
||||
main.class=FormMapWithSetMachine
|
||||
manifest.file=manifest.mf
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=false
|
||||
|
195
ArmoredVehicle/src/AbstractMap.java
Normal file
195
ArmoredVehicle/src/AbstractMap.java
Normal file
@ -0,0 +1,195 @@
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
|
||||
public abstract class AbstractMap {
|
||||
private IDrawingObject drawingObject;
|
||||
protected int[][] map = null;
|
||||
protected int width;
|
||||
protected int height;
|
||||
protected float size_x;
|
||||
protected float size_y;
|
||||
protected final Random random = new Random();
|
||||
protected final int _freeRoad = 0;
|
||||
protected final int _barrier = 1;
|
||||
|
||||
public Image CreateMap(int width, int height, IDrawingObject drawingObject)
|
||||
{
|
||||
this.width = width;
|
||||
this.height = height;
|
||||
this.drawingObject = drawingObject;
|
||||
GenerateMap();
|
||||
while (!SetObjectOnMap())
|
||||
{
|
||||
GenerateMap();
|
||||
}
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
|
||||
public Image MoveObject(Direction direction)
|
||||
{
|
||||
if (drawingObject == null)
|
||||
return null;
|
||||
boolean flag = true;
|
||||
float step = drawingObject.getStep();
|
||||
|
||||
HashMap<String, Float> hashMap = drawingObject.GetCurrentPosition();
|
||||
float left = hashMap.get("Left");
|
||||
float right = hashMap.get("Right");
|
||||
float top = hashMap.get("Top");
|
||||
float bottom = hashMap.get("Bottom");
|
||||
|
||||
int x1 = (int)((left - step) / size_x);
|
||||
int y1 = (int)((top - step) / size_y);
|
||||
int x2 = (int)((right + step) / size_x);
|
||||
int y2 = (int)((bottom + step) / size_y);
|
||||
|
||||
int x1_current = (int)(left / size_x);
|
||||
int y1_current = (int)(top / size_y);
|
||||
int x2_current = (int)(right / size_x);
|
||||
int y2_current = (int)(bottom / size_y);
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
case Left:
|
||||
{
|
||||
if (x1 < 0)
|
||||
flag = false;
|
||||
else
|
||||
{
|
||||
for (int i = x1; i <= x1_current; i++)
|
||||
{
|
||||
for (int j = y1_current; j <= y2_current; j++)
|
||||
{
|
||||
if (map[i][j] == _barrier)
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Right:
|
||||
{
|
||||
if (x2 >= map.length)
|
||||
flag = false;
|
||||
else
|
||||
{
|
||||
for (int i = x2_current; i <= x2; i++)
|
||||
{
|
||||
for (int j = y1_current; j <= y2_current; j++)
|
||||
{
|
||||
if (map[i][j] == _barrier)
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Up:
|
||||
{
|
||||
if (y1 < 0)
|
||||
flag = false;
|
||||
else
|
||||
{
|
||||
for (int i = x1_current; i <= x2_current; i++)
|
||||
{
|
||||
for (int j = y1; j <= y1_current; j++)
|
||||
{
|
||||
if (map[i][j] == _barrier)
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Down:
|
||||
{
|
||||
if (y2 >= map.length)
|
||||
flag = false;
|
||||
else
|
||||
{
|
||||
for (int i = x1_current; i <= x2_current; i++)
|
||||
{
|
||||
for (int j = y2_current; j <= y2; j++)
|
||||
{
|
||||
if (map[i][j] == _barrier)
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (flag)
|
||||
{
|
||||
drawingObject.MoveObject(direction);
|
||||
}
|
||||
return DrawMapWithObject();
|
||||
}
|
||||
private boolean SetObjectOnMap()
|
||||
{
|
||||
if (drawingObject == null || map == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
int x = random.nextInt(0, 10);
|
||||
int y = random.nextInt(0, 10);
|
||||
|
||||
HashMap<String, Float> hashMap = drawingObject.GetCurrentPosition();
|
||||
|
||||
int beginI = (int)(x / size_x);
|
||||
int endI = (int)(hashMap.get("Right") / size_x);
|
||||
|
||||
int beginJ = (int)(y / size_y);
|
||||
int endJ = (int)(hashMap.get("Bottom") / size_y);
|
||||
|
||||
for (int i = beginI; i <= endI; i++)
|
||||
{
|
||||
for(int j = beginJ; j <= endJ; j++)
|
||||
{
|
||||
if(map[i][j] == _barrier)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
drawingObject.SetObject(x, y, width, height);
|
||||
return true;
|
||||
}
|
||||
private Image DrawMapWithObject()
|
||||
{
|
||||
BufferedImage bmp = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
|
||||
if(drawingObject == null || map == null)
|
||||
{
|
||||
return bmp;
|
||||
}
|
||||
|
||||
Graphics gr = bmp.getGraphics();
|
||||
Graphics2D g = (Graphics2D)gr;
|
||||
for(int i = 0; i < map.length; ++i)
|
||||
{
|
||||
for(int j = 0; j < map[i].length; ++j)
|
||||
{
|
||||
if (map[i][j] == _freeRoad)
|
||||
{
|
||||
DrawRoadPart(g, i, j);
|
||||
}
|
||||
else if (map[i][j] == _barrier)
|
||||
{
|
||||
DrawBarrierPart(g, i, j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drawingObject.DrawingObject(g);
|
||||
return bmp;
|
||||
}
|
||||
protected abstract void GenerateMap();
|
||||
protected abstract void DrawRoadPart(Graphics2D g, int i, int j);
|
||||
protected abstract void DrawBarrierPart(Graphics2D g, int i, int j);
|
||||
}
|
@ -25,7 +25,7 @@ class ArmoredVehicleEntity {
|
||||
/// <param name="weight"></param>
|
||||
/// <param name="bodyColor"></param>
|
||||
/// <returns></returns>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public ArmoredVehicleEntity(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new Random();
|
||||
Speed = speed <= 0 ? rnd.nextInt(50, 150) : speed;
|
||||
|
@ -2,10 +2,11 @@
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import static java.lang.Math.random;
|
||||
import java.util.HashMap;
|
||||
import java.util.Random;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class DrawingArmoredVehicle extends JPanel{
|
||||
public class DrawingArmoredVehicle{
|
||||
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
@ -14,43 +15,70 @@ public class DrawingArmoredVehicle extends JPanel{
|
||||
/// <summary>
|
||||
/// Левая координата отрисовки
|
||||
/// </summary>
|
||||
private float _startPosX;
|
||||
protected float _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната отрисовки
|
||||
/// </summary>
|
||||
private float _startPosY;
|
||||
protected float _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private int _pictureWidth = 0;
|
||||
protected int _pictureWidth = 100;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private int _pictureHeight = 0;
|
||||
protected int _pictureHeight = 100;
|
||||
/// <summary>
|
||||
/// Ширина отрисовки
|
||||
/// </summary>
|
||||
private int _ArmoredVehicleWidth = 210;
|
||||
protected int _ArmoredVehicleWidth = 210;
|
||||
/// <summary>
|
||||
/// Высота отрисовки
|
||||
/// </summary>
|
||||
private int _ArmoredVehicleHeight = 50;
|
||||
protected int _ArmoredVehicleHeight = 60;
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
|
||||
private Roller rolls = new Roller();;
|
||||
protected IDrawingRoller roller;
|
||||
|
||||
Random rnd = new Random();
|
||||
public int Count;
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес </param>
|
||||
/// <param name="bodyColor">Цвет</param>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public DrawingArmoredVehicle(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
ArmoredVehicle = new ArmoredVehicleEntity();
|
||||
ArmoredVehicle.Init(speed, weight, bodyColor);
|
||||
Random r = new Random();
|
||||
ArmoredVehicle = new ArmoredVehicleEntity(speed, weight, bodyColor);
|
||||
int variant = 0;
|
||||
switch(variant)
|
||||
{
|
||||
case 0:
|
||||
this.roller = new Roller(bodyColor);
|
||||
break;
|
||||
case 1:
|
||||
this.roller = new DrawingFirstRoller(bodyColor);
|
||||
break;
|
||||
case 2:
|
||||
this.roller = new DrawingSecondRoller(bodyColor);
|
||||
break;
|
||||
}
|
||||
|
||||
Count = 6 - rnd.nextInt(0, 3);
|
||||
|
||||
}
|
||||
public DrawingArmoredVehicle(int speed, float weight, Color bodyColor, int ArmoredVehicleWidth,
|
||||
int ArmoredVehicleHeight)
|
||||
{
|
||||
this(speed, weight, bodyColor);
|
||||
_ArmoredVehicleHeight = ArmoredVehicleHeight + 50;
|
||||
_ArmoredVehicleWidth = ArmoredVehicleWidth + 150;
|
||||
}
|
||||
|
||||
public DrawingArmoredVehicle(ArmoredVehicleEntity machine, IDrawingRoller rollers)
|
||||
{
|
||||
ArmoredVehicle = machine;
|
||||
roller = rollers;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -88,7 +116,6 @@ public class DrawingArmoredVehicle extends JPanel{
|
||||
_pictureHeight = height;
|
||||
|
||||
}
|
||||
repaint();
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения
|
||||
@ -118,7 +145,7 @@ public class DrawingArmoredVehicle extends JPanel{
|
||||
break;
|
||||
//вверх
|
||||
case Up:
|
||||
if (_startPosY - ArmoredVehicle.Step > 0)
|
||||
if (_startPosY - ArmoredVehicle.Step > 20)
|
||||
{
|
||||
_startPosY -= ArmoredVehicle.Step;
|
||||
}
|
||||
@ -131,45 +158,34 @@ public class DrawingArmoredVehicle extends JPanel{
|
||||
}
|
||||
break;
|
||||
}
|
||||
super.repaint();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Отрисовка
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
|
||||
@Override
|
||||
public void paint(Graphics gr) {
|
||||
|
||||
if (_startPosX < 0 || _startPosY < 0
|
||||
public void DrawTransport(Graphics2D gr)
|
||||
{
|
||||
if (_startPosX < 0 || _startPosY < 0
|
||||
|| _pictureHeight==0 || _pictureWidth==0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
gr.clearRect(0, 0, _pictureHeight+500, _pictureWidth+500);
|
||||
super.paintComponent(gr);
|
||||
Graphics2D g = (Graphics2D) gr;
|
||||
Color color = ArmoredVehicle.BodyColor != null ?
|
||||
ArmoredVehicle.BodyColor : Color.BLACK;
|
||||
g.setColor(color);
|
||||
|
||||
|
||||
|
||||
g.fillRect((int)_startPosX + 50, (int)_startPosY, 100, 40);
|
||||
g.fillRect((int)_startPosX + 15, (int)_startPosY+20, 200, 20);
|
||||
|
||||
|
||||
//контур
|
||||
g.drawRect((int)_startPosX + 50, (int)_startPosY, 100, 20);
|
||||
g.drawRect((int)_startPosX + 15, (int)_startPosY+20, 200, 20);
|
||||
g.drawOval((int)_startPosX + 15, (int)_startPosY + 25, 200, 35);
|
||||
|
||||
rolls.Init(Count, color, _startPosX, _startPosY, _ArmoredVehicleWidth);
|
||||
rolls.paint(gr);
|
||||
super.repaint();
|
||||
g.dispose();
|
||||
}
|
||||
|
||||
roller.DrawRoller(gr, (int)_startPosX, (int)_startPosY, 210, Count);
|
||||
}
|
||||
//
|
||||
/// <summary>
|
||||
/// Смена границ формы отрисовки
|
||||
/// </summary>
|
||||
@ -193,6 +209,15 @@ public class DrawingArmoredVehicle extends JPanel{
|
||||
{
|
||||
_startPosY = _pictureHeight - _ArmoredVehicleHeight;
|
||||
}
|
||||
super.repaint();
|
||||
}
|
||||
|
||||
public HashMap<String, Float> GetCurrentPosition()
|
||||
{
|
||||
HashMap<String, Float> hashMap = new HashMap<String, Float>();
|
||||
hashMap.put("Left", _startPosX);
|
||||
hashMap.put("Right", _startPosX + _ArmoredVehicleWidth);
|
||||
hashMap.put("Top", _startPosY);
|
||||
hashMap.put("Bottom", _startPosY + _ArmoredVehicleHeight);
|
||||
return hashMap;
|
||||
}
|
||||
}
|
||||
|
49
ArmoredVehicle/src/DrawingFirstRoller.java
Normal file
49
ArmoredVehicle/src/DrawingFirstRoller.java
Normal file
@ -0,0 +1,49 @@
|
||||
import java.awt.BasicStroke;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
public class DrawingFirstRoller implements IDrawingRoller{
|
||||
private Color color;
|
||||
private CountRollers Count;
|
||||
public DrawingFirstRoller(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCount(int n) {
|
||||
switch (n) {
|
||||
case 4 -> Count = CountRollers.Four;
|
||||
|
||||
case 5 -> Count = CountRollers.Five;
|
||||
|
||||
case 6 -> Count = CountRollers.Six;
|
||||
|
||||
default -> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DrawRoller(Graphics2D g, int startPosX, int startPosY, int Width, int count) {
|
||||
color = color != null ?
|
||||
color : Color.BLACK;
|
||||
g.setColor(color);
|
||||
setCount(count);
|
||||
switch (Count)
|
||||
{
|
||||
case Four -> count = 4;
|
||||
case Five -> count = 5;
|
||||
case Six -> count = 6;
|
||||
}
|
||||
int ras = (int)Width /count;
|
||||
|
||||
|
||||
for (int i = 0; i < count; i += 1)
|
||||
{
|
||||
g.drawOval((int)startPosX+ i*ras + 15, (int)startPosY + 35, 20, 20);
|
||||
g.fillOval((int)startPosX+ i*ras + 20, (int)startPosY + 40, 15, 15);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
56
ArmoredVehicle/src/DrawingObject.java
Normal file
56
ArmoredVehicle/src/DrawingObject.java
Normal file
@ -0,0 +1,56 @@
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DrawingObject implements IDrawingObject{
|
||||
private DrawingArmoredVehicle _machine = null;
|
||||
|
||||
public DrawingObject(DrawingArmoredVehicle machine) {
|
||||
this._machine = machine;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStep() {
|
||||
if (_machine != null)
|
||||
return _machine.ArmoredVehicle.Step;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void SetObject(int x, int y, int width, int height) {
|
||||
if (_machine != null)
|
||||
_machine.SetPosition(x, y, width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void MoveObject(Direction direction) {
|
||||
if (_machine != null)
|
||||
_machine.MoveTransport(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DrawingObject(Graphics2D g) {
|
||||
if (_machine != null)
|
||||
_machine.DrawTransport(g);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HashMap<String, Float> GetCurrentPosition() {
|
||||
return _machine.GetCurrentPosition();
|
||||
}
|
||||
public DrawingArmoredVehicle GetMachine()
|
||||
{
|
||||
return _machine;
|
||||
}
|
||||
public static IDrawingObject Create(String data){
|
||||
return new DrawingObject(ExtentionMachine.CreateDrawingMachine(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String GetInfo() {
|
||||
if (_machine != null){
|
||||
return ExtentionMachine.GetDataForSave(_machine);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
49
ArmoredVehicle/src/DrawingSecondRoller.java
Normal file
49
ArmoredVehicle/src/DrawingSecondRoller.java
Normal file
@ -0,0 +1,49 @@
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
public class DrawingSecondRoller implements IDrawingRoller{
|
||||
private Color color;
|
||||
private CountRollers Count;
|
||||
public DrawingSecondRoller(Color color) {
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCount(int n) {
|
||||
switch (n) {
|
||||
case 4 -> Count = CountRollers.Four;
|
||||
|
||||
case 5 -> Count = CountRollers.Five;
|
||||
|
||||
case 6 -> Count = CountRollers.Six;
|
||||
|
||||
default -> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DrawRoller(Graphics2D g, int startPosX, int startPosY, int Width, int count) {
|
||||
color = color != null ?
|
||||
color : Color.BLACK;
|
||||
g.setColor(color);
|
||||
setCount(count);
|
||||
switch (Count)
|
||||
{
|
||||
case Four -> count = 4;
|
||||
case Five -> count = 5;
|
||||
case Six -> count = 6;
|
||||
}
|
||||
int ras = (int)Width /count;
|
||||
|
||||
|
||||
for (int i = 0; i < count; i += 1)
|
||||
{
|
||||
g.drawOval((int)startPosX+ i*ras + 15, (int)startPosY + 35, 20, 20);
|
||||
g.drawRect((int)startPosX+ i*ras + 20, (int)startPosY + 40, 10, 10);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
47
ArmoredVehicle/src/DrawingTank.java
Normal file
47
ArmoredVehicle/src/DrawingTank.java
Normal file
@ -0,0 +1,47 @@
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
public class DrawingTank extends DrawingArmoredVehicle{
|
||||
public DrawingTank(int speed, float weight, Color bodyColor, Color dopColor, boolean machineGun, boolean tower)
|
||||
{
|
||||
super(speed, weight, bodyColor, 200, 60);
|
||||
ArmoredVehicle = new TankEntity(speed, weight, bodyColor, dopColor, machineGun, tower);
|
||||
}
|
||||
|
||||
|
||||
public DrawingTank(ArmoredVehicleEntity tank, IDrawingRoller roll)
|
||||
{
|
||||
super(tank, roll);
|
||||
ArmoredVehicle = (TankEntity)tank;
|
||||
roller = roll;
|
||||
}
|
||||
@Override
|
||||
public void DrawTransport(Graphics2D g)
|
||||
{
|
||||
if (!"TankEntity".equals(ArmoredVehicle.getClass().getName()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
TankEntity machine = (TankEntity) ArmoredVehicle;
|
||||
|
||||
|
||||
_startPosY += 40;
|
||||
super.DrawTransport(g);
|
||||
_startPosY -= 40;
|
||||
g.setColor(machine.DopColor);
|
||||
if (machine.Tower)
|
||||
{
|
||||
g.fillRect((int)_startPosX + 60, (int)_startPosY + 10, 80, 30);
|
||||
g.drawLine((int)_startPosX + 90, (int)_startPosY +20, (int)_startPosX + 250, (int)_startPosY + 20);
|
||||
if (machine.MachineGun)
|
||||
{
|
||||
g.drawLine((int) _startPosX + 90, (int)_startPosY, (int)_startPosX + 90, (int)_startPosY + 10);
|
||||
g.drawLine((int)_startPosX + 85, (int)_startPosY + 5, (int)_startPosX + 120,(int) _startPosY + 5);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
75
ArmoredVehicle/src/ExtentionMachine.java
Normal file
75
ArmoredVehicle/src/ExtentionMachine.java
Normal file
@ -0,0 +1,75 @@
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
/*
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alena
|
||||
*/
|
||||
public class ExtentionMachine {
|
||||
private static final char _separatorForObject = ':';
|
||||
public static DrawingArmoredVehicle CreateDrawingMachine(String info)
|
||||
{
|
||||
String[] strs = info.split(String.valueOf(_separatorForObject));
|
||||
Color color;
|
||||
if (strs.length == 5)
|
||||
{
|
||||
var temp = new DrawingArmoredVehicle(Integer.parseInt(strs[0]),
|
||||
Float.parseFloat(strs[1]), new Color(Integer.parseInt(strs[2])));
|
||||
color = new Color(Integer.parseInt(strs[2]));
|
||||
temp.Count = Integer.parseInt(strs[4]);
|
||||
|
||||
switch (strs[3])
|
||||
{
|
||||
case "DrawingRollers":
|
||||
temp.roller = new Roller(color);
|
||||
break;
|
||||
case "DrawingLinePatternRoller":
|
||||
temp.roller = new DrawingFirstRoller(color);
|
||||
break;
|
||||
case "DrawingPiePatternRoller":
|
||||
temp.roller = new DrawingSecondRoller(color);
|
||||
break;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
if (strs.length == 8)
|
||||
{
|
||||
color = new Color(Integer.parseInt(strs[2]));
|
||||
var temp = new DrawingTank(Integer.parseInt(strs[0]),
|
||||
Float.parseFloat(strs[1]), new Color(Integer.parseInt(strs[2])),
|
||||
new Color(Integer.parseInt(strs[5])), Boolean.parseBoolean(strs[6]),
|
||||
Boolean.parseBoolean(strs[7]));
|
||||
temp.Count = Integer.parseInt(strs[4]);
|
||||
switch (strs[3])
|
||||
{
|
||||
case "DrawingRollers":
|
||||
temp.roller = new Roller(color);
|
||||
break;
|
||||
case "DrawingLinePatternRoller":
|
||||
temp.roller = new DrawingFirstRoller(color);
|
||||
break;
|
||||
case "DrawingPiePatternRoller":
|
||||
temp.roller = new DrawingSecondRoller(color);
|
||||
break;
|
||||
}
|
||||
return temp;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public static String GetDataForSave(DrawingArmoredVehicle drawingMachine)
|
||||
{
|
||||
var machine = drawingMachine.ArmoredVehicle;
|
||||
var str = ""+machine.Speed + _separatorForObject + machine.Weight + _separatorForObject + machine.BodyColor.getRGB() + _separatorForObject + drawingMachine.roller + _separatorForObject + drawingMachine.Count;
|
||||
if (machine instanceof TankEntity tank)
|
||||
{
|
||||
return str + _separatorForObject + tank.DopColor.getRGB() + _separatorForObject + tank.MachineGun + _separatorForObject + tank.Tower;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}
|
599
ArmoredVehicle/src/FormArmoredVehicleConfig.form
Normal file
599
ArmoredVehicle/src/FormArmoredVehicleConfig.form
Normal file
@ -0,0 +1,599 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="java.awt.Choice" name="choice1">
|
||||
</Component>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="panelParams" min="-2" pref="420" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="panelObject" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
|
||||
<Component id="buttonAdd" min="-2" pref="69" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="42" max="-2" attributes="0"/>
|
||||
<Component id="buttonCancel" min="-2" pref="70" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="85" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="panelObject" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="buttonAdd" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonCancel" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="panelParams" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="java.awt.Panel" name="panelParams">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="checkboxGun" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="54" max="-2" attributes="0"/>
|
||||
<Component id="LabelSimple" min="-2" pref="67" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="27" max="-2" attributes="0"/>
|
||||
<Component id="LabelModify" min="-2" pref="87" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="labelParams" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="labelSpeed" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="labelWeight" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="SpinnerWeight" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="SpinnerSpeed" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="LabelCountRollers" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="ComboBoxCountRollers" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="panelColors" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="LabelFirstRoller" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="LabelSecondRoller" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="checkboxTower" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="LabelSimpleRollers" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
|
||||
<Component id="labelParams" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="labelSpeed" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="SpinnerSpeed" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="labelWeight" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="SpinnerWeight" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="LabelCountRollers" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="ComboBoxCountRollers" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="panelColors" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="LabelSecondRoller" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="LabelFirstRoller" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="LabelSimpleRollers" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="checkboxTower" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="checkboxGun" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="LabelModify" alignment="3" min="-2" pref="29" max="-2" attributes="0"/>
|
||||
<Component id="LabelSimple" alignment="3" min="-2" pref="29" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace pref="15" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="java.awt.Label" name="labelParams">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Параметры"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="java.awt.Label" name="labelSpeed">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Скорость"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="java.awt.Label" name="labelWeight">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Вес"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="java.awt.Checkbox" name="checkboxTower">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Признак наличия башни"/>
|
||||
<Property name="name" type="java.lang.String" value="Башня" noResource="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="java.awt.Checkbox" name="checkboxGun">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Признак наличия орудия"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="SpinnerSpeed">
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="SpinnerWeight">
|
||||
</Component>
|
||||
<Container class="java.awt.Panel" name="panelColors">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="PanelOrange" max="32767" attributes="0"/>
|
||||
<Component id="PanelBlack" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" max="-2" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="PanelGray" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="PanelRed" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="PanelYellow" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="PanelGreen" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="PanelPink" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="PanelBlue" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Component id="labelColors" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="28" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="labelColors" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="PanelRed" max="32767" attributes="0"/>
|
||||
<Component id="PanelBlack" max="32767" attributes="0"/>
|
||||
<Component id="PanelPink" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="PanelGray" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="PanelOrange" max="32767" attributes="0"/>
|
||||
<Component id="PanelGreen" max="32767" attributes="0"/>
|
||||
<Component id="PanelBlue" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="PanelYellow" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="33" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="java.awt.Label" name="labelColors">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Цвета"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JPanel" name="PanelRed">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="0" green="0" id="red" palette="1" red="ff" type="palette"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="45" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="37" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="PanelGray">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="80" green="80" id="gray" palette="1" red="80" type="palette"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="39" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="37" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="PanelBlack">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="0" green="0" id="black" palette="1" red="0" type="palette"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="PanelOrange">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="0" green="c8" id="orange" palette="1" red="ff" type="palette"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="39" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="39" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="PanelPink">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="af" green="af" id="pink" palette="1" red="ff" type="palette"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="39" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="PanelGreen">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="0" green="ff" id="green" palette="1" red="0" type="palette"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="39" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="PanelBlue">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="ff" green="0" id="blue" palette="1" red="0" type="palette"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="39" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="PanelYellow">
|
||||
<Properties>
|
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
|
||||
<Color blue="0" green="ff" id="yellow" palette="1" red="ff" type="palette"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="39" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
<Component class="java.awt.Label" name="label2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="label2"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="java.awt.Label" name="label1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="label1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="LabelCountRollers">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Количество катков"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="ComboBoxCountRollers">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="3">
|
||||
<StringItem index="0" value="4"/>
|
||||
<StringItem index="1" value="5"/>
|
||||
<StringItem index="2" value="6"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
</Properties>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="LabelModify">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Продвинутый"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="LabelSimple">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Простой"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="LabelFirstRoller">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Первый тип"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="LabelSecondRoller">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Второй тип"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="LabelSimpleRollers">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Простые"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="java.awt.Panel" name="panelObject">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="panelDraw" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="LabelColor" min="-2" pref="80" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="LabelDopColor" min="-2" pref="86" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="41" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="LabelColor" pref="29" max="32767" attributes="0"/>
|
||||
<Component id="LabelDopColor" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="27" max="32767" attributes="0"/>
|
||||
<Component id="panelDraw" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="LabelDopColor">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Доп. цвет"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="LabelColor">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Цвет"/>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.LineBorderInfo">
|
||||
<LineBorder/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="java.awt.Panel" name="panelDraw">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="160" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="java.awt.Button" name="buttonAdd">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Добавить"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="buttonAddMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="buttonCancel">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Отмена"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
598
ArmoredVehicle/src/FormArmoredVehicleConfig.java
Normal file
598
ArmoredVehicle/src/FormArmoredVehicleConfig.java
Normal file
@ -0,0 +1,598 @@
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.MouseAdapter;
|
||||
import java.awt.event.MouseEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.function.Consumer;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Alena
|
||||
*/
|
||||
public class FormArmoredVehicleConfig extends javax.swing.JFrame {
|
||||
DrawingArmoredVehicle _machine;
|
||||
Consumer<DrawingArmoredVehicle> EventAddMachine;
|
||||
public boolean DialogResult = false;
|
||||
Image img;
|
||||
/**
|
||||
* Creates new form FormArmoredVehicleConfig
|
||||
*/
|
||||
public void AddEvent(Consumer<DrawingArmoredVehicle> ev) { EventAddMachine = ev; }
|
||||
public FormArmoredVehicleConfig() {
|
||||
initComponents();
|
||||
MouseAdapter drag = new MouseAdapter() {
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
setCursor(new Cursor(Cursor.HAND_CURSOR));
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
Drop((JComponent) e.getSource());
|
||||
}
|
||||
};
|
||||
|
||||
MouseAdapter defCursor = new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseExited(MouseEvent e) {
|
||||
setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
};
|
||||
panelDraw.addMouseListener(defCursor);
|
||||
LabelColor.addMouseListener(defCursor);
|
||||
LabelDopColor.addMouseListener(defCursor);
|
||||
|
||||
PanelRed.addMouseListener(drag);
|
||||
PanelBlack.addMouseListener(drag);
|
||||
PanelGray.addMouseListener(drag);
|
||||
PanelOrange.addMouseListener(drag);
|
||||
PanelYellow.addMouseListener(drag);
|
||||
PanelPink.addMouseListener(drag);
|
||||
PanelGreen.addMouseListener(drag);
|
||||
PanelBlue.addMouseListener(drag);
|
||||
|
||||
LabelSimple.addMouseListener(drag);
|
||||
LabelModify.addMouseListener(drag);
|
||||
LabelFirstRoller.addMouseListener(drag);
|
||||
LabelSecondRoller.addMouseListener(drag);
|
||||
LabelSimpleRollers.addMouseListener(drag);
|
||||
|
||||
buttonAdd.addActionListener(e -> {
|
||||
EventAddMachine.accept(_machine);
|
||||
DialogResult = true;
|
||||
dispose();
|
||||
});
|
||||
|
||||
buttonCancel.addActionListener(e -> dispose());
|
||||
}
|
||||
|
||||
public DrawingArmoredVehicle getSelectedCar() {
|
||||
return _machine;
|
||||
}
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
choice1 = new java.awt.Choice();
|
||||
panelParams = new java.awt.Panel();
|
||||
labelParams = new java.awt.Label();
|
||||
labelSpeed = new java.awt.Label();
|
||||
labelWeight = new java.awt.Label();
|
||||
checkboxTower = new java.awt.Checkbox();
|
||||
checkboxGun = new java.awt.Checkbox();
|
||||
SpinnerSpeed = new javax.swing.JSpinner();
|
||||
SpinnerWeight = new javax.swing.JSpinner();
|
||||
panelColors = new java.awt.Panel();
|
||||
labelColors = new java.awt.Label();
|
||||
PanelRed = new javax.swing.JPanel();
|
||||
PanelGray = new javax.swing.JPanel();
|
||||
PanelBlack = new javax.swing.JPanel();
|
||||
PanelOrange = new javax.swing.JPanel();
|
||||
PanelPink = new javax.swing.JPanel();
|
||||
PanelGreen = new javax.swing.JPanel();
|
||||
PanelBlue = new javax.swing.JPanel();
|
||||
PanelYellow = new javax.swing.JPanel();
|
||||
label2 = new java.awt.Label();
|
||||
label1 = new java.awt.Label();
|
||||
LabelCountRollers = new javax.swing.JLabel();
|
||||
ComboBoxCountRollers = new javax.swing.JComboBox<>();
|
||||
LabelModify = new javax.swing.JLabel();
|
||||
LabelSimple = new javax.swing.JLabel();
|
||||
LabelFirstRoller = new javax.swing.JLabel();
|
||||
LabelSecondRoller = new javax.swing.JLabel();
|
||||
LabelSimpleRollers = new javax.swing.JLabel();
|
||||
panelObject = new java.awt.Panel();
|
||||
LabelDopColor = new javax.swing.JLabel();
|
||||
LabelColor = new javax.swing.JLabel();
|
||||
panelDraw = new java.awt.Panel();
|
||||
buttonAdd = new java.awt.Button();
|
||||
buttonCancel = new java.awt.Button();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
|
||||
labelParams.setText("Параметры");
|
||||
|
||||
labelSpeed.setText("Скорость");
|
||||
|
||||
labelWeight.setText("Вес");
|
||||
|
||||
checkboxTower.setLabel("Признак наличия башни");
|
||||
checkboxTower.setName("Башня"); // NOI18N
|
||||
|
||||
checkboxGun.setLabel("Признак наличия орудия");
|
||||
|
||||
labelColors.setText("Цвета");
|
||||
|
||||
PanelRed.setBackground(java.awt.Color.red);
|
||||
|
||||
javax.swing.GroupLayout PanelRedLayout = new javax.swing.GroupLayout(PanelRed);
|
||||
PanelRed.setLayout(PanelRedLayout);
|
||||
PanelRedLayout.setHorizontalGroup(
|
||||
PanelRedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 45, Short.MAX_VALUE)
|
||||
);
|
||||
PanelRedLayout.setVerticalGroup(
|
||||
PanelRedLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 37, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
PanelGray.setBackground(java.awt.Color.gray);
|
||||
|
||||
javax.swing.GroupLayout PanelGrayLayout = new javax.swing.GroupLayout(PanelGray);
|
||||
PanelGray.setLayout(PanelGrayLayout);
|
||||
PanelGrayLayout.setHorizontalGroup(
|
||||
PanelGrayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 39, Short.MAX_VALUE)
|
||||
);
|
||||
PanelGrayLayout.setVerticalGroup(
|
||||
PanelGrayLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 37, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
PanelBlack.setBackground(java.awt.Color.black);
|
||||
|
||||
javax.swing.GroupLayout PanelBlackLayout = new javax.swing.GroupLayout(PanelBlack);
|
||||
PanelBlack.setLayout(PanelBlackLayout);
|
||||
PanelBlackLayout.setHorizontalGroup(
|
||||
PanelBlackLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
);
|
||||
PanelBlackLayout.setVerticalGroup(
|
||||
PanelBlackLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
PanelOrange.setBackground(java.awt.Color.orange);
|
||||
|
||||
javax.swing.GroupLayout PanelOrangeLayout = new javax.swing.GroupLayout(PanelOrange);
|
||||
PanelOrange.setLayout(PanelOrangeLayout);
|
||||
PanelOrangeLayout.setHorizontalGroup(
|
||||
PanelOrangeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 39, Short.MAX_VALUE)
|
||||
);
|
||||
PanelOrangeLayout.setVerticalGroup(
|
||||
PanelOrangeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 39, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
PanelPink.setBackground(java.awt.Color.pink);
|
||||
|
||||
javax.swing.GroupLayout PanelPinkLayout = new javax.swing.GroupLayout(PanelPink);
|
||||
PanelPink.setLayout(PanelPinkLayout);
|
||||
PanelPinkLayout.setHorizontalGroup(
|
||||
PanelPinkLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 39, Short.MAX_VALUE)
|
||||
);
|
||||
PanelPinkLayout.setVerticalGroup(
|
||||
PanelPinkLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
PanelGreen.setBackground(java.awt.Color.green);
|
||||
|
||||
javax.swing.GroupLayout PanelGreenLayout = new javax.swing.GroupLayout(PanelGreen);
|
||||
PanelGreen.setLayout(PanelGreenLayout);
|
||||
PanelGreenLayout.setHorizontalGroup(
|
||||
PanelGreenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 39, Short.MAX_VALUE)
|
||||
);
|
||||
PanelGreenLayout.setVerticalGroup(
|
||||
PanelGreenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
PanelBlue.setBackground(java.awt.Color.blue);
|
||||
|
||||
javax.swing.GroupLayout PanelBlueLayout = new javax.swing.GroupLayout(PanelBlue);
|
||||
PanelBlue.setLayout(PanelBlueLayout);
|
||||
PanelBlueLayout.setHorizontalGroup(
|
||||
PanelBlueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 39, Short.MAX_VALUE)
|
||||
);
|
||||
PanelBlueLayout.setVerticalGroup(
|
||||
PanelBlueLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
PanelYellow.setBackground(java.awt.Color.yellow);
|
||||
|
||||
javax.swing.GroupLayout PanelYellowLayout = new javax.swing.GroupLayout(PanelYellow);
|
||||
PanelYellow.setLayout(PanelYellowLayout);
|
||||
PanelYellowLayout.setHorizontalGroup(
|
||||
PanelYellowLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 39, Short.MAX_VALUE)
|
||||
);
|
||||
PanelYellowLayout.setVerticalGroup(
|
||||
PanelYellowLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
label2.setText("label2");
|
||||
|
||||
javax.swing.GroupLayout panelColorsLayout = new javax.swing.GroupLayout(panelColors);
|
||||
panelColors.setLayout(panelColorsLayout);
|
||||
panelColorsLayout.setHorizontalGroup(
|
||||
panelColorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelColorsLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(panelColorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelColorsLayout.createSequentialGroup()
|
||||
.addGroup(panelColorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(PanelOrange, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(PanelBlack, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(panelColorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
||||
.addGroup(panelColorsLayout.createSequentialGroup()
|
||||
.addComponent(PanelGray, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(PanelRed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelColorsLayout.createSequentialGroup()
|
||||
.addComponent(PanelYellow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(PanelGreen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(panelColorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(PanelPink, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(PanelBlue, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addComponent(labelColors, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(28, Short.MAX_VALUE))
|
||||
);
|
||||
panelColorsLayout.setVerticalGroup(
|
||||
panelColorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelColorsLayout.createSequentialGroup()
|
||||
.addComponent(labelColors, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(20, 20, 20)
|
||||
.addGroup(panelColorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelColorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(PanelRed, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(PanelBlack, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(PanelPink, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addComponent(PanelGray, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelColorsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(PanelOrange, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(PanelGreen, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(PanelBlue, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(PanelYellow, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap(33, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
label1.setText("label1");
|
||||
|
||||
LabelCountRollers.setText("Количество катков");
|
||||
|
||||
ComboBoxCountRollers.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "4", "5", "6" }));
|
||||
|
||||
LabelModify.setText("Продвинутый");
|
||||
LabelModify.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
|
||||
LabelSimple.setText("Простой");
|
||||
LabelSimple.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
|
||||
LabelFirstRoller.setText("Первый тип");
|
||||
|
||||
LabelSecondRoller.setText("Второй тип");
|
||||
|
||||
LabelSimpleRollers.setText("Простые");
|
||||
|
||||
javax.swing.GroupLayout panelParamsLayout = new javax.swing.GroupLayout(panelParams);
|
||||
panelParams.setLayout(panelParamsLayout);
|
||||
panelParamsLayout.setHorizontalGroup(
|
||||
panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParamsLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParamsLayout.createSequentialGroup()
|
||||
.addComponent(checkboxGun, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(54, 54, 54)
|
||||
.addComponent(LabelSimple, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(27, 27, 27)
|
||||
.addComponent(LabelModify, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParamsLayout.createSequentialGroup()
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(labelParams, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(panelParamsLayout.createSequentialGroup()
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(labelSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(labelWeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(SpinnerWeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(SpinnerSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addGroup(panelParamsLayout.createSequentialGroup()
|
||||
.addComponent(LabelCountRollers)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(ComboBoxCountRollers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(panelColors, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParamsLayout.createSequentialGroup()
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
||||
.addGroup(panelParamsLayout.createSequentialGroup()
|
||||
.addComponent(LabelFirstRoller)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(LabelSecondRoller))
|
||||
.addComponent(checkboxTower, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(LabelSimpleRollers)))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
panelParamsLayout.setVerticalGroup(
|
||||
panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParamsLayout.createSequentialGroup()
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParamsLayout.createSequentialGroup()
|
||||
.addGap(34, 34, 34)
|
||||
.addComponent(labelParams, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(labelSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(SpinnerSpeed, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(labelWeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(SpinnerWeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(LabelCountRollers)
|
||||
.addComponent(ComboBoxCountRollers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addGroup(panelParamsLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(panelColors, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(LabelSecondRoller)
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(LabelFirstRoller)
|
||||
.addComponent(LabelSimpleRollers)))
|
||||
.addGap(12, 12, 12)
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParamsLayout.createSequentialGroup()
|
||||
.addComponent(checkboxTower, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(checkboxGun, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParamsLayout.createSequentialGroup()
|
||||
.addGap(20, 20, 20)
|
||||
.addGroup(panelParamsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(LabelModify, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(LabelSimple, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
.addContainerGap(15, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
LabelDopColor.setText("Доп. цвет");
|
||||
LabelDopColor.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
|
||||
LabelColor.setText("Цвет");
|
||||
LabelColor.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
|
||||
|
||||
javax.swing.GroupLayout panelDrawLayout = new javax.swing.GroupLayout(panelDraw);
|
||||
panelDraw.setLayout(panelDrawLayout);
|
||||
panelDrawLayout.setHorizontalGroup(
|
||||
panelDrawLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
);
|
||||
panelDrawLayout.setVerticalGroup(
|
||||
panelDrawLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 160, Short.MAX_VALUE)
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout panelObjectLayout = new javax.swing.GroupLayout(panelObject);
|
||||
panelObject.setLayout(panelObjectLayout);
|
||||
panelObjectLayout.setHorizontalGroup(
|
||||
panelObjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelObjectLayout.createSequentialGroup()
|
||||
.addGap(32, 32, 32)
|
||||
.addGroup(panelObjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelObjectLayout.createSequentialGroup()
|
||||
.addComponent(panelDraw, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelObjectLayout.createSequentialGroup()
|
||||
.addComponent(LabelColor, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(LabelDopColor, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(41, 41, 41))))
|
||||
);
|
||||
panelObjectLayout.setVerticalGroup(
|
||||
panelObjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelObjectLayout.createSequentialGroup()
|
||||
.addGap(15, 15, 15)
|
||||
.addGroup(panelObjectLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(LabelColor, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)
|
||||
.addComponent(LabelDopColor, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 27, Short.MAX_VALUE)
|
||||
.addComponent(panelDraw, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
buttonAdd.setLabel("Добавить");
|
||||
buttonAdd.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
buttonAddMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonCancel.setLabel("Отмена");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(panelParams, javax.swing.GroupLayout.PREFERRED_SIZE, 420, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(panelObject, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(10, 10, 10)
|
||||
.addComponent(buttonAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(42, 42, 42)
|
||||
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(85, Short.MAX_VALUE))))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(panelObject, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(buttonAdd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(buttonCancel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addComponent(panelParams, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void buttonAddMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_buttonAddMouseClicked
|
||||
DialogResult = true;
|
||||
dispose();
|
||||
}//GEN-LAST:event_buttonAddMouseClicked
|
||||
|
||||
|
||||
public void Drop(JComponent droppedItem) {
|
||||
if (droppedItem == null) {
|
||||
return;
|
||||
}
|
||||
Color color = Color.WHITE;
|
||||
Color dopColor = Color.BLACK;
|
||||
int rollers = Integer.parseInt((String) ComboBoxCountRollers.getSelectedItem());
|
||||
if (droppedItem instanceof JPanel panel) {
|
||||
if (_machine == null)
|
||||
return;
|
||||
boolean p = LabelColor.getMousePosition() != null;
|
||||
if (p) {
|
||||
color = panel.getBackground();
|
||||
if(_machine instanceof DrawingTank tank)
|
||||
{
|
||||
var obj = (TankEntity)_machine.ArmoredVehicle;
|
||||
_machine = new DrawingTank(obj.Speed, obj.Weight,
|
||||
color, obj.DopColor, obj.MachineGun, obj.Tower);
|
||||
}
|
||||
else _machine = new DrawingArmoredVehicle(_machine.ArmoredVehicle.Speed, _machine.ArmoredVehicle.Weight, color);
|
||||
}
|
||||
if (LabelDopColor.getMousePosition() != null && _machine instanceof DrawingTank tank) {
|
||||
dopColor = panel.getBackground();
|
||||
var obj = (TankEntity)_machine.ArmoredVehicle;
|
||||
_machine = new DrawingTank(obj.Speed, obj.Weight,
|
||||
obj.BodyColor, dopColor, obj.MachineGun, obj.Tower);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (droppedItem instanceof JLabel label && panelDraw.getMousePosition() != null) {
|
||||
int speed = (int)SpinnerSpeed.getValue();
|
||||
int weight = (int)SpinnerWeight.getValue();
|
||||
|
||||
boolean tower = checkboxTower.getState();
|
||||
boolean gun = checkboxGun.getState();
|
||||
Graphics g = panelDraw.getGraphics();
|
||||
if (label == LabelSimple) {
|
||||
_machine = new DrawingArmoredVehicle(speed, weight, color);
|
||||
} else if (label == LabelModify) {
|
||||
_machine = new DrawingTank(speed, weight, color, dopColor, gun, tower);
|
||||
}
|
||||
_machine.Count = rollers;
|
||||
|
||||
}
|
||||
if (droppedItem instanceof JLabel label && _machine!=null) {
|
||||
if (label == LabelSimpleRollers) {
|
||||
_machine = new DrawingArmoredVehicle(_machine.ArmoredVehicle, new Roller(_machine.ArmoredVehicle.BodyColor));
|
||||
} else if (label == LabelFirstRoller) {
|
||||
_machine = new DrawingArmoredVehicle(_machine.ArmoredVehicle, new DrawingFirstRoller(_machine.ArmoredVehicle.BodyColor));
|
||||
} else if (label == LabelSecondRoller) {
|
||||
_machine = new DrawingArmoredVehicle(_machine.ArmoredVehicle, new DrawingSecondRoller(_machine.ArmoredVehicle.BodyColor));
|
||||
}
|
||||
}
|
||||
|
||||
if (_machine!=null) {
|
||||
_machine.Count = rollers;
|
||||
_machine.SetPosition(panelDraw.getWidth() - 200, panelDraw.getHeight() - 150, panelDraw.getWidth(), panelDraw.getHeight());
|
||||
Graphics g = panelDraw.getGraphics();
|
||||
g.drawImage(Pic(), 0, 0, this);
|
||||
}
|
||||
|
||||
}
|
||||
Image Pic()
|
||||
{
|
||||
BufferedImage img = new BufferedImage(panelDraw.getWidth(), panelDraw.getHeight(), BufferedImage.TYPE_INT_BGR);
|
||||
Graphics2D gr = img.createGraphics();
|
||||
gr.setBackground(Color.yellow);
|
||||
_machine.DrawTransport(gr);
|
||||
return img;
|
||||
}
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JComboBox<String> ComboBoxCountRollers;
|
||||
private javax.swing.JLabel LabelColor;
|
||||
private javax.swing.JLabel LabelCountRollers;
|
||||
private javax.swing.JLabel LabelDopColor;
|
||||
private javax.swing.JLabel LabelFirstRoller;
|
||||
private javax.swing.JLabel LabelModify;
|
||||
private javax.swing.JLabel LabelSecondRoller;
|
||||
private javax.swing.JLabel LabelSimple;
|
||||
private javax.swing.JLabel LabelSimpleRollers;
|
||||
private javax.swing.JPanel PanelBlack;
|
||||
private javax.swing.JPanel PanelBlue;
|
||||
private javax.swing.JPanel PanelGray;
|
||||
private javax.swing.JPanel PanelGreen;
|
||||
private javax.swing.JPanel PanelOrange;
|
||||
private javax.swing.JPanel PanelPink;
|
||||
private javax.swing.JPanel PanelRed;
|
||||
private javax.swing.JPanel PanelYellow;
|
||||
private javax.swing.JSpinner SpinnerSpeed;
|
||||
private javax.swing.JSpinner SpinnerWeight;
|
||||
private java.awt.Button buttonAdd;
|
||||
private java.awt.Button buttonCancel;
|
||||
private java.awt.Checkbox checkboxGun;
|
||||
private java.awt.Checkbox checkboxTower;
|
||||
private java.awt.Choice choice1;
|
||||
private java.awt.Label label1;
|
||||
private java.awt.Label label2;
|
||||
private java.awt.Label labelColors;
|
||||
private java.awt.Label labelParams;
|
||||
private java.awt.Label labelSpeed;
|
||||
private java.awt.Label labelWeight;
|
||||
private java.awt.Panel panelColors;
|
||||
private java.awt.Panel panelDraw;
|
||||
private java.awt.Panel panelObject;
|
||||
private java.awt.Panel panelParams;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
386
ArmoredVehicle/src/FormMapWithSetMachine.form
Normal file
386
ArmoredVehicle/src/FormMapWithSetMachine.form
Normal file
@ -0,0 +1,386 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Menu class="javax.swing.JMenuBar" name="MenuBar">
|
||||
<SubComponents>
|
||||
<Menu class="javax.swing.JMenu" name="jMenuSave">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Сохранить карту"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jMenuSaveMouseClicked"/>
|
||||
</Events>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="jMenuLoad">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Загрузить карту"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jMenuLoadMouseClicked"/>
|
||||
</Events>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="jMenuSaveObj">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Сохранить объект"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jMenuSaveObjMouseClicked"/>
|
||||
</Events>
|
||||
</Menu>
|
||||
<Menu class="javax.swing.JMenu" name="jMenuLoadObj">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Загрузить объект"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jMenuLoadObjMouseClicked"/>
|
||||
</Events>
|
||||
</Menu>
|
||||
</SubComponents>
|
||||
</Menu>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="menuBar" type="java.lang.String" value="MenuBar"/>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="PicturePanel" pref="438" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="InstrumentPanel" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="InstrumentPanel" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="PicturePanel" min="-2" pref="597" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="PicturePanel">
|
||||
<LayoutCode>
|
||||
<CodeStatement>
|
||||
<CodeExpression id="1_PicturePanel">
|
||||
<CodeVariable name="PicturePanel" type="8194" declaredType="javax.swing.JPanel"/>
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="ComponentRef">
|
||||
<ComponentRef name="PicturePanel"/>
|
||||
</ExpressionProvider>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
<StatementProvider type="CodeMethod">
|
||||
<CodeMethod name="setLayout" class="java.awt.Container" parameterTypes="java.awt.LayoutManager"/>
|
||||
</StatementProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="2">
|
||||
<ExpressionOrigin>
|
||||
<ExpressionProvider type="CodeConstructor">
|
||||
<CodeConstructor class="javax.swing.OverlayLayout" parameterTypes="java.awt.Container"/>
|
||||
</ExpressionProvider>
|
||||
<Parameters>
|
||||
<CodeExpression id="1_PicturePanel"/>
|
||||
</Parameters>
|
||||
</ExpressionOrigin>
|
||||
</CodeExpression>
|
||||
</Parameters>
|
||||
</CodeStatement>
|
||||
</LayoutCode>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="InstrumentPanel">
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="AddMapButton" alignment="0" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="MapComboBox" max="32767" attributes="0"/>
|
||||
<Component id="MapNameTextField" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="jScrollPane2" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="DeleteMapButton" alignment="1" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="DeletedFormOpen" min="-2" pref="122" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="25" pref="25" max="-2" attributes="0"/>
|
||||
<Component id="UpButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="27" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="103" alignment="0" groupAlignment="0" attributes="0">
|
||||
<Component id="RightButton" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="LeftButton" min="-2" pref="22" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
|
||||
<Component id="DownButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="29" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="39" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="AddMachineButton" max="32767" attributes="0"/>
|
||||
<Component id="TextBoxPosition" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="DeleteButton" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="StoreButton" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="MapButton" alignment="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
|
||||
<Component id="MapNameTextField" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="MapComboBox" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="AddMapButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane2" min="-2" pref="117" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="22" max="-2" attributes="0"/>
|
||||
<Component id="DeleteMapButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="AddMachineButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="TextBoxPosition" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="DeleteButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="StoreButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="MapButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="UpButton" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="DeletedFormOpen" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="LeftButton" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="RightButton" alignment="1" min="-2" pref="30" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="21" pref="21" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="DownButton" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Инструменты"/>
|
||||
<Property name="name" type="java.lang.String" value="InstrumentLabel" noResource="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JComboBox" name="MapComboBox">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
|
||||
<StringArray count="3">
|
||||
<StringItem index="0" value="Простая карта"/>
|
||||
<StringItem index="1" value="Вертикальная карта"/>
|
||||
<StringItem index="2" value="Горизонтальная карта"/>
|
||||
</StringArray>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="MapComboBox" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="MapComboBoxActionPerformed"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="AddMachineButton">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Добавить машину"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="AddMachineButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.TextField" name="TextBoxPosition">
|
||||
<Properties>
|
||||
<Property name="name" type="java.lang.String" value="TextBoxPosition" noResource="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="DeleteButton">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Удалить машину"/>
|
||||
<Property name="name" type="java.lang.String" value="DeleteMachineButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="DeleteButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="StoreButton">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Посмотреть хранилище"/>
|
||||
<Property name="name" type="java.lang.String" value="StoreButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="StoreButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="MapButton">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Посмотреть карту"/>
|
||||
<Property name="name" type="java.lang.String" value="MapButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="MapButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="RightButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Right"/>
|
||||
<Property name="label" type="java.lang.String" value="→"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 30]"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="RightButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="RightButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="DownButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Left"/>
|
||||
<Property name="label" type="java.lang.String" value="↓"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 30]"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="LeftButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="DownButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="LeftButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Left"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 30]"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="LeftButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="LeftButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="UpButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Up"/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
<Property name="label" type="java.lang.String" value="↑"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="UpButtonMouseClicked"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new java.awt.Button()"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="java.awt.TextField" name="MapNameTextField">
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="AddMapButton">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Добавить карту"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="AddMapButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="DeleteMapButton">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Удалить карту"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="DeleteMapButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane2">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JList" name="MapList">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
|
||||
<StringArray count="0"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="MapListValueChanged"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="DeletedFormOpen">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Удаленные"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="DeletedFormOpenMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
725
ArmoredVehicle/src/FormMapWithSetMachine.java
Normal file
725
ArmoredVehicle/src/FormMapWithSetMachine.java
Normal file
@ -0,0 +1,725 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Image;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Queue;
|
||||
import javax.swing.event.ListSelectionEvent;
|
||||
import javax.swing.event.ListSelectionListener;
|
||||
import javax.swing.filechooser.FileNameExtensionFilter;
|
||||
import javax.swing.filechooser.FileFilter;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogManager;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class FormMapWithSetMachine extends javax.swing.JFrame {
|
||||
private Image img;
|
||||
private MapsCollection _mapCollection;
|
||||
private static Logger _logger;
|
||||
private final HashMap<String, AbstractMap> _mapsDict = new HashMap<>() {{
|
||||
put("Простая карта", new SimpleMap());
|
||||
put("Вертикальная карта", new VerticalMap());
|
||||
put("Горизонтальная карта", new HorizontalMap());
|
||||
}};
|
||||
public Queue<DrawingArmoredVehicle> deleted = new LinkedList<>();
|
||||
public FormMapWithSetMachine() {
|
||||
initComponents();
|
||||
LeftButton.setLabel("<");
|
||||
RightButton.setLabel(">");
|
||||
UpButton.setLabel("/\\");
|
||||
DownButton.setLabel("\\/");
|
||||
MapComboBox.removeAllItems();
|
||||
for (String elem : _mapsDict.keySet()) {
|
||||
MapComboBox.addItem(elem);
|
||||
}
|
||||
_mapCollection = new MapsCollection(PicturePanel.getWidth(), PicturePanel.getHeight());
|
||||
try(FileInputStream ins = new FileInputStream(this.getClass().getResource("log.config").toString().substring(6))){
|
||||
LogManager.getLogManager().readConfiguration(ins);
|
||||
_logger = Logger.getLogger(FormMapWithSetMachine.class.getName());
|
||||
}catch (Exception ignore){
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
PicturePanel = new javax.swing.JPanel();
|
||||
InstrumentPanel = new javax.swing.JPanel();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
MapComboBox = new javax.swing.JComboBox<>();
|
||||
AddMachineButton = new java.awt.Button();
|
||||
TextBoxPosition = new java.awt.TextField();
|
||||
DeleteButton = new java.awt.Button();
|
||||
StoreButton = new java.awt.Button();
|
||||
MapButton = new java.awt.Button();
|
||||
RightButton = new java.awt.Button();
|
||||
DownButton = new java.awt.Button();
|
||||
LeftButton = new java.awt.Button();
|
||||
UpButton = new java.awt.Button();
|
||||
MapNameTextField = new java.awt.TextField();
|
||||
AddMapButton = new java.awt.Button();
|
||||
DeleteMapButton = new java.awt.Button();
|
||||
jScrollPane2 = new javax.swing.JScrollPane();
|
||||
MapList = new javax.swing.JList<>();
|
||||
DeletedFormOpen = new javax.swing.JButton();
|
||||
MenuBar = new javax.swing.JMenuBar();
|
||||
jMenuSave = new javax.swing.JMenu();
|
||||
jMenuLoad = new javax.swing.JMenu();
|
||||
jMenuSaveObj = new javax.swing.JMenu();
|
||||
jMenuLoadObj = new javax.swing.JMenu();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
|
||||
PicturePanel.setLayout(new javax.swing.OverlayLayout(PicturePanel));
|
||||
|
||||
jLabel1.setText("Инструменты");
|
||||
jLabel1.setName("InstrumentLabel"); // NOI18N
|
||||
|
||||
MapComboBox.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Простая карта", "Вертикальная карта", "Горизонтальная карта" }));
|
||||
MapComboBox.setName("MapComboBox"); // NOI18N
|
||||
MapComboBox.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
MapComboBoxActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
AddMachineButton.setLabel("Добавить машину");
|
||||
AddMachineButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
AddMachineButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
TextBoxPosition.setName("TextBoxPosition"); // NOI18N
|
||||
|
||||
DeleteButton.setLabel("Удалить машину");
|
||||
DeleteButton.setName("DeleteMachineButton"); // NOI18N
|
||||
DeleteButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
DeleteButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
StoreButton.setLabel("Посмотреть хранилище");
|
||||
StoreButton.setName("StoreButton"); // NOI18N
|
||||
StoreButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
StoreButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
MapButton.setLabel("Посмотреть карту");
|
||||
MapButton.setName("MapButton"); // NOI18N
|
||||
MapButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
MapButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
RightButton.setActionCommand("Right");
|
||||
RightButton.setLabel("→");
|
||||
RightButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
RightButton.setName("RightButton"); // NOI18N
|
||||
RightButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
RightButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
DownButton.setActionCommand("Left");
|
||||
DownButton.setLabel("↓");
|
||||
DownButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
DownButton.setName("LeftButton"); // NOI18N
|
||||
DownButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
DownButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
LeftButton.setActionCommand("Left");
|
||||
LeftButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
LeftButton.setName("LeftButton"); // NOI18N
|
||||
LeftButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
LeftButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
UpButton.setActionCommand("Up");
|
||||
UpButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
|
||||
UpButton.setLabel("↑");
|
||||
UpButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
UpButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
UpButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
AddMapButton.setLabel("Добавить карту");
|
||||
AddMapButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
AddMapButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
DeleteMapButton.setLabel("Удалить карту");
|
||||
DeleteMapButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
DeleteMapButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
MapList.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
|
||||
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
|
||||
MapListValueChanged(evt);
|
||||
}
|
||||
});
|
||||
jScrollPane2.setViewportView(MapList);
|
||||
|
||||
DeletedFormOpen.setText("Удаленные");
|
||||
DeletedFormOpen.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
DeletedFormOpenMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout InstrumentPanelLayout = new javax.swing.GroupLayout(InstrumentPanel);
|
||||
InstrumentPanel.setLayout(InstrumentPanelLayout);
|
||||
InstrumentPanelLayout.setHorizontalGroup(
|
||||
InstrumentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(InstrumentPanelLayout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
.addGroup(InstrumentPanelLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(InstrumentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(AddMapButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(InstrumentPanelLayout.createSequentialGroup()
|
||||
.addGroup(InstrumentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(MapComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(MapNameTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(DeleteMapButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(InstrumentPanelLayout.createSequentialGroup()
|
||||
.addGap(12, 12, 12)
|
||||
.addGroup(InstrumentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(InstrumentPanelLayout.createSequentialGroup()
|
||||
.addComponent(DeletedFormOpen, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(InstrumentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(InstrumentPanelLayout.createSequentialGroup()
|
||||
.addGap(25, 25, 25)
|
||||
.addComponent(UpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(27, 27, 27))
|
||||
.addGroup(InstrumentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(RightButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, InstrumentPanelLayout.createSequentialGroup()
|
||||
.addComponent(LeftButton, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(1, 1, 1)
|
||||
.addComponent(DownButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(29, 29, 29))))
|
||||
.addGap(39, 39, 39))
|
||||
.addComponent(AddMachineButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(TextBoxPosition, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(DeleteButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(StoreButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(MapButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
|
||||
.addContainerGap())))
|
||||
);
|
||||
InstrumentPanelLayout.setVerticalGroup(
|
||||
InstrumentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(InstrumentPanelLayout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addGap(21, 21, 21)
|
||||
.addComponent(MapNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(MapComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(AddMapButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(22, 22, 22)
|
||||
.addComponent(DeleteMapButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(AddMachineButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(TextBoxPosition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(DeleteButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(StoreButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(MapButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(25, 25, 25)
|
||||
.addGroup(InstrumentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(UpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(DeletedFormOpen))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(InstrumentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, InstrumentPanelLayout.createSequentialGroup()
|
||||
.addGroup(InstrumentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(LeftButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(RightButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(21, 21, 21))
|
||||
.addComponent(DownButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
jMenuSave.setText("Сохранить карту");
|
||||
jMenuSave.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
jMenuSaveMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
MenuBar.add(jMenuSave);
|
||||
|
||||
jMenuLoad.setText("Загрузить карту");
|
||||
jMenuLoad.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
jMenuLoadMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
MenuBar.add(jMenuLoad);
|
||||
|
||||
jMenuSaveObj.setText("Сохранить объект");
|
||||
jMenuSaveObj.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
jMenuSaveObjMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
MenuBar.add(jMenuSaveObj);
|
||||
|
||||
jMenuLoadObj.setText("Загрузить объект");
|
||||
jMenuLoadObj.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
jMenuLoadObjMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
MenuBar.add(jMenuLoadObj);
|
||||
|
||||
setJMenuBar(MenuBar);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(PicturePanel, javax.swing.GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(InstrumentPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(InstrumentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(PicturePanel, javax.swing.GroupLayout.PREFERRED_SIZE, 597, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 0, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
private void RightButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_RightButtonMouseClicked
|
||||
Move("RightButton");
|
||||
}//GEN-LAST:event_RightButtonMouseClicked
|
||||
|
||||
private void DownButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DownButtonMouseClicked
|
||||
Move("DownButton");
|
||||
}//GEN-LAST:event_DownButtonMouseClicked
|
||||
|
||||
private void LeftButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LeftButtonMouseClicked
|
||||
Move("LeftButton");
|
||||
}//GEN-LAST:event_LeftButtonMouseClicked
|
||||
|
||||
private void UpButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_UpButtonMouseClicked
|
||||
Move("UpButton");
|
||||
}//GEN-LAST:event_UpButtonMouseClicked
|
||||
|
||||
private void AddMachineButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_AddMachineButtonMouseClicked
|
||||
if (_mapCollection == null)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "Не выбрана карта");
|
||||
return;
|
||||
}
|
||||
FormArmoredVehicleConfig form = new FormArmoredVehicleConfig();
|
||||
form.setVisible(true);
|
||||
form.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
try{
|
||||
if (form.getSelectedCar() == null)
|
||||
return;
|
||||
DrawingObject machine = new DrawingObject(form.getSelectedCar());
|
||||
if (_mapCollection.Get(MapList.getSelectedValue().toString()).add(machine) != -1)
|
||||
{
|
||||
if (form.DialogResult) {
|
||||
JOptionPane.showMessageDialog(null, "Объект добавлен");
|
||||
_logger.log(Level.INFO, "Добавлен объект: "+machine);
|
||||
img = _mapCollection.Get(MapList.getSelectedValue().toString()).ShowSet();
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.log(Level.INFO, "Не удалось добавить объект: "+machine);
|
||||
JOptionPane.showMessageDialog(null, MapList.getSelectedValue().toString()+" Не удалось добавить объект");
|
||||
}
|
||||
}
|
||||
catch(StorageOverflowException ex)
|
||||
{
|
||||
_logger.log(Level.WARNING, "Ошибка переполнения хранилища: "+ex.getMessage());
|
||||
JOptionPane.showMessageDialog(null, "Ошибка переполнения хранилища:"+ex.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}//GEN-LAST:event_AddMachineButtonMouseClicked
|
||||
|
||||
private void DeleteButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DeleteButtonMouseClicked
|
||||
if (TextBoxPosition.getText().equals(""))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
int res = JOptionPane.showConfirmDialog (null,"Удалить объект?",
|
||||
"Удаление", JOptionPane.YES_NO_OPTION);
|
||||
if (res == JOptionPane.YES_OPTION) {
|
||||
int pos = Integer.parseInt(TextBoxPosition.getText());
|
||||
var elem = _mapCollection.Get(MapList.getSelectedValue().toString()).GetMachineInList(pos).GetMachine();
|
||||
deleted.offer(elem);
|
||||
if (_mapCollection.Get(MapList.getSelectedValue().toString()).remove(pos) != null)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "Объект удален");
|
||||
_logger.log(Level.INFO, "Удален объект: "+elem);
|
||||
img = _mapCollection.Get(MapList.getSelectedValue().toString()).ShowSet();
|
||||
Draw();
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.log(Level.INFO, "Не удалось удалить объект по позиции: "+pos);
|
||||
JOptionPane.showMessageDialog(null, "Не удалось удалить объект");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MachineNotFoundException ex) {
|
||||
_logger.log(Level.WARNING, "Ошибка удаления: "+ex.getMessage());
|
||||
JOptionPane.showMessageDialog(null, "Ошибка удаления: "+ex.getMessage());
|
||||
} catch (Exception ex) {
|
||||
_logger.log(Level.WARNING, "Неизвестная ошибка удаления: "+ex.getMessage());
|
||||
JOptionPane.showMessageDialog(null, "Неизвестная ошибка: "+ex.getMessage());
|
||||
}
|
||||
|
||||
}//GEN-LAST:event_DeleteButtonMouseClicked
|
||||
|
||||
private void StoreButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_StoreButtonMouseClicked
|
||||
if (_mapCollection == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
img = _mapCollection.Get(MapList.getSelectedValue().toString()).ShowSet();
|
||||
Draw();
|
||||
}//GEN-LAST:event_StoreButtonMouseClicked
|
||||
|
||||
private void MapButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_MapButtonMouseClicked
|
||||
if (_mapCollection == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
img = _mapCollection.Get(MapList.getSelectedValue().toString()).ShowOnMap();
|
||||
Draw();
|
||||
}//GEN-LAST:event_MapButtonMouseClicked
|
||||
|
||||
private void AddMapButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_AddMapButtonMouseClicked
|
||||
if (MapComboBox.getSelectedIndex() == -1 || MapNameTextField.getText().isEmpty()) {
|
||||
_logger.log(Level.INFO,"Не все данные были заполнены при добавлении карты");
|
||||
JOptionPane.showMessageDialog(null, "Не все данные заполнены", "Ошибка", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
if (!_mapsDict.containsKey(MapComboBox.getSelectedItem())) {
|
||||
_logger.log(Level.INFO,"Нет карты с названием: "+MapComboBox.getSelectedItem());
|
||||
JOptionPane.showMessageDialog(null, "Нет такой карты", "Ошибка", JOptionPane.ERROR_MESSAGE);
|
||||
return;
|
||||
}
|
||||
_mapCollection.AddMap(MapNameTextField.getText(), _mapsDict.get(MapComboBox.getSelectedItem().toString()));
|
||||
_logger.log(Level.INFO, "Добавлена карта: "+MapNameTextField.getText());
|
||||
ReloadMaps();
|
||||
}//GEN-LAST:event_AddMapButtonMouseClicked
|
||||
private void ReloadMaps() {
|
||||
int index = MapList.getSelectedIndex();
|
||||
var list =_mapCollection.getKeys();
|
||||
MapList.setListData(list);
|
||||
var model = MapList.getModel();
|
||||
if (MapList.getModel().getSize() > 0 && (index == -1 || index >=
|
||||
MapList.getModel().getSize()))
|
||||
{
|
||||
MapList.setSelectedIndex(0);
|
||||
}
|
||||
else if (MapList.getModel().getSize() > 0 && index > -1 && index <
|
||||
MapList.getModel().getSize())
|
||||
{
|
||||
MapList.setSelectedIndex(index);
|
||||
}
|
||||
if(_mapCollection.Get((String)MapList.getSelectedValue()) == null)
|
||||
{
|
||||
|
||||
JOptionPane.showMessageDialog(null, "Такой карты нет");
|
||||
}
|
||||
else
|
||||
{
|
||||
img = _mapCollection.Get((String)MapList.getSelectedValue()).ShowSet();
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
private void DeleteMapButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DeleteMapButtonMouseClicked
|
||||
if (MapList.getSelectedIndex() == -1) {
|
||||
return;
|
||||
}
|
||||
if (JOptionPane.showConfirmDialog(null, "Удалить карту " + MapList.getSelectedValue().toString() + "?",
|
||||
"Удаление", JOptionPane.YES_NO_OPTION) == 0) {
|
||||
_mapCollection.DelMap(MapList.getSelectedValue().toString());
|
||||
ReloadMaps();
|
||||
_logger.log(Level.INFO, "Удалена карта: "+MapList.getSelectedValue().toString());
|
||||
}
|
||||
}//GEN-LAST:event_DeleteMapButtonMouseClicked
|
||||
|
||||
private void MapComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MapComboBoxActionPerformed
|
||||
AbstractMap map = null;
|
||||
String name = (String) MapComboBox.getSelectedItem();
|
||||
if(name!=null)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "Простая карта":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "Горизонтальная карта":
|
||||
map = new HorizontalMap();
|
||||
break;
|
||||
case "Вертикальная карта":
|
||||
map = new VerticalMap();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (map != null)
|
||||
{
|
||||
_mapCollection = new MapsCollection(PicturePanel.getWidth(), PicturePanel.getHeight());
|
||||
}
|
||||
else
|
||||
{
|
||||
_mapCollection = null;
|
||||
}
|
||||
}//GEN-LAST:event_MapComboBoxActionPerformed
|
||||
|
||||
private void MapListValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_MapListValueChanged
|
||||
var object = MapList.getSelectedValue();
|
||||
if(object == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
img = _mapCollection.Get((String)MapList.getSelectedValue()).ShowSet();
|
||||
Draw();
|
||||
_logger.log(Level.INFO, "Переход на карту: "+MapList.getSelectedValue().toString());
|
||||
}//GEN-LAST:event_MapListValueChanged
|
||||
|
||||
private void DeletedFormOpenMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DeletedFormOpenMouseClicked
|
||||
var elem = deleted.poll();
|
||||
if(elem != null)
|
||||
{
|
||||
MainForm form = new MainForm(elem);
|
||||
form.setVisible(true);
|
||||
form.addWindowListener(new WindowAdapter() {
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "Очередь пуста");
|
||||
}
|
||||
|
||||
}//GEN-LAST:event_DeletedFormOpenMouseClicked
|
||||
|
||||
private void jMenuSaveMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuSaveMouseClicked
|
||||
JFileChooser fs = new JFileChooser();
|
||||
fs.setAcceptAllFileFilterUsed(false);
|
||||
FileNameExtensionFilter filter = new FileNameExtensionFilter(".txt file", "txt");
|
||||
fs.addChoosableFileFilter(filter);
|
||||
fs.setDialogTitle("Сохранение карты");
|
||||
int result = fs.showSaveDialog(null);
|
||||
if (result == JFileChooser.APPROVE_OPTION) {
|
||||
try{
|
||||
File selectedFile = fs.getSelectedFile();
|
||||
_mapCollection.SaveMap(selectedFile.getPath(), MapList.getSelectedValue().toString());
|
||||
_logger.log(Level.INFO, "Успешное сохранение в файл: "+selectedFile.getPath());
|
||||
JOptionPane.showMessageDialog(null, "Сохранение карты прошло успешно", "Результат",JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.log(Level.INFO, "Данные не сохранились: "+ex.getMessage());
|
||||
JOptionPane.showMessageDialog(null, "Не сохранилась карта: "+ex.getMessage(), "Результат",JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_jMenuSaveMouseClicked
|
||||
|
||||
private void jMenuLoadMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuLoadMouseClicked
|
||||
JFileChooser fs = new JFileChooser();
|
||||
fs.setAcceptAllFileFilterUsed(false);
|
||||
FileNameExtensionFilter filter = new FileNameExtensionFilter(".txt file", "txt");
|
||||
fs.addChoosableFileFilter(filter);
|
||||
fs.setDialogTitle("Сохранение карты");
|
||||
int result = fs.showSaveDialog(null);
|
||||
if (result == JFileChooser.APPROVE_OPTION) {
|
||||
try
|
||||
{
|
||||
File selectedFile = fs.getSelectedFile();
|
||||
_mapCollection.LoadMap(selectedFile.getPath());
|
||||
|
||||
_logger.log(Level.INFO, "Успешная загрузка из файла: "+selectedFile.getPath());
|
||||
JOptionPane.showMessageDialog(null, "Загрузка карты прошла успешно", "Результат",JOptionPane.INFORMATION_MESSAGE);
|
||||
ReloadMaps();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.log(Level.WARNING, "Не загрузилось: "+ex.getMessage());
|
||||
JOptionPane.showMessageDialog(null, "Не сохранилась карта: "+ex.getMessage(), "Результат",JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
}//GEN-LAST:event_jMenuLoadMouseClicked
|
||||
|
||||
private void jMenuLoadObjMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuLoadObjMouseClicked
|
||||
JFileChooser fs = new JFileChooser();
|
||||
fs.setAcceptAllFileFilterUsed(false);
|
||||
FileNameExtensionFilter filter = new FileNameExtensionFilter(".txt file", "txt");
|
||||
fs.addChoosableFileFilter(filter);
|
||||
fs.setDialogTitle("Загрузка");
|
||||
int result = fs.showSaveDialog(null);
|
||||
if (result == JFileChooser.APPROVE_OPTION) {
|
||||
try{
|
||||
File selectedFile = fs.getSelectedFile();
|
||||
_mapCollection.LoadData(selectedFile.getPath());
|
||||
ReloadMaps();
|
||||
JOptionPane.showMessageDialog(null, "Загрузка прошла успешно", "Результат",JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "Не удалось загрузить: "+ex.getMessage(), "Результат",JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
}//GEN-LAST:event_jMenuLoadObjMouseClicked
|
||||
|
||||
private void jMenuSaveObjMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jMenuSaveObjMouseClicked
|
||||
JFileChooser fs = new JFileChooser();
|
||||
fs.setAcceptAllFileFilterUsed(false);
|
||||
FileNameExtensionFilter filter = new FileNameExtensionFilter(".txt file", "txt");
|
||||
fs.addChoosableFileFilter(filter);
|
||||
fs.setDialogTitle("Сохранение");
|
||||
int result = fs.showSaveDialog(null);
|
||||
if (result == JFileChooser.APPROVE_OPTION) {
|
||||
try{
|
||||
File selectedFile = fs.getSelectedFile();
|
||||
_mapCollection.SaveData(selectedFile.getPath()+".txt");
|
||||
JOptionPane.showMessageDialog(null, "Сохранение прошло успешно", "Результат",JOptionPane.INFORMATION_MESSAGE);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "Не сохранилось", "Результат",JOptionPane.ERROR_MESSAGE);
|
||||
}
|
||||
|
||||
}
|
||||
}//GEN-LAST:event_jMenuSaveObjMouseClicked
|
||||
public void Move(String name)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "UpButton" -> img = _mapCollection.Get(MapList.getSelectedValue().toString()).MoveObject(Direction.Up);
|
||||
case "DownButton" -> img = _mapCollection.Get(MapList.getSelectedValue().toString()).MoveObject(Direction.Down);
|
||||
case "LeftButton" -> img =_mapCollection.Get(MapList.getSelectedValue().toString()).MoveObject(Direction.Left);
|
||||
case "RightButton" -> img = _mapCollection.Get(MapList.getSelectedValue().toString()).MoveObject(Direction.Right);
|
||||
}
|
||||
|
||||
Draw();
|
||||
}
|
||||
|
||||
public static void main(String args[]) {
|
||||
/* Set the Nimbus look and feel */
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(FormMapWithSetMachine.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(FormMapWithSetMachine.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(FormMapWithSetMachine.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(FormMapWithSetMachine.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/* Create and display the form */
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new FormMapWithSetMachine().setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
void Draw()
|
||||
{
|
||||
Graphics g = PicturePanel.getGraphics();
|
||||
g.drawImage(img, 0, 0, this);
|
||||
}
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private java.awt.Button AddMachineButton;
|
||||
private java.awt.Button AddMapButton;
|
||||
private java.awt.Button DeleteButton;
|
||||
private java.awt.Button DeleteMapButton;
|
||||
private javax.swing.JButton DeletedFormOpen;
|
||||
private java.awt.Button DownButton;
|
||||
private javax.swing.JPanel InstrumentPanel;
|
||||
private java.awt.Button LeftButton;
|
||||
private java.awt.Button MapButton;
|
||||
private javax.swing.JComboBox<String> MapComboBox;
|
||||
private javax.swing.JList<String> MapList;
|
||||
private java.awt.TextField MapNameTextField;
|
||||
private javax.swing.JMenuBar MenuBar;
|
||||
private javax.swing.JPanel PicturePanel;
|
||||
private java.awt.Button RightButton;
|
||||
private java.awt.Button StoreButton;
|
||||
private java.awt.TextField TextBoxPosition;
|
||||
private java.awt.Button UpButton;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JMenu jMenuLoad;
|
||||
private javax.swing.JMenu jMenuLoadObj;
|
||||
private javax.swing.JMenu jMenuSave;
|
||||
private javax.swing.JMenu jMenuSaveObj;
|
||||
private javax.swing.JScrollPane jScrollPane2;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
54
ArmoredVehicle/src/HorizontalMap.java
Normal file
54
ArmoredVehicle/src/HorizontalMap.java
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
public class HorizontalMap extends AbstractMap{
|
||||
private final Color barrierColor = Color.RED;
|
||||
private final Color roadColor = Color.WHITE;
|
||||
@Override
|
||||
protected void GenerateMap() {
|
||||
map = new int[50][50];
|
||||
size_x = (float)width / map.length;
|
||||
size_y = (float)height / map[0].length;
|
||||
int counter = 0;
|
||||
for (int i = 0; i < map.length; ++i)
|
||||
{
|
||||
for (int j = 0; j < map[0].length; ++j)
|
||||
{
|
||||
map[i][j] = _freeRoad;
|
||||
}
|
||||
}
|
||||
while (counter < 7)
|
||||
{
|
||||
int x1 = random.nextInt(12);
|
||||
int x2 = random.nextInt(12, map[0].length);
|
||||
|
||||
int y1 = random.nextInt(12, map[1].length);
|
||||
|
||||
for (int i = x1; i < x2; i++)
|
||||
{
|
||||
if (map[i][y1] == _freeRoad)
|
||||
{
|
||||
map[i][y1] = _barrier;
|
||||
}
|
||||
}
|
||||
|
||||
counter++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void DrawRoadPart(Graphics2D gc, int i, int j) {
|
||||
gc.setColor(roadColor);
|
||||
gc.fillRect(i * (int)size_x, j * (int)size_y, i * ((int)size_x + 1), j * ((int)size_y + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void DrawBarrierPart(Graphics2D gc, int i, int j) {
|
||||
gc.setColor( barrierColor);
|
||||
gc.fillRect(i * (int)size_x, j * (int)size_y, i * ((int)size_x + 1), j * ((int)size_y + 1));
|
||||
}
|
||||
}
|
37
ArmoredVehicle/src/IDrawingObject.java
Normal file
37
ArmoredVehicle/src/IDrawingObject.java
Normal file
@ -0,0 +1,37 @@
|
||||
import java.awt.Graphics2D;
|
||||
import java.util.HashMap;
|
||||
|
||||
public interface IDrawingObject {
|
||||
/// <summary>
|
||||
/// Шаг перемещения объекта
|
||||
/// </summary>
|
||||
float getStep();
|
||||
/// <summary>
|
||||
/// Установка позиции объекта
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
/// <param name="width">Ширина полотна</param>
|
||||
/// <param name="height">Высота полотна</param>
|
||||
void SetObject(int x, int y, int width, int height);
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения объекта
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns></returns>
|
||||
void MoveObject(Direction direction);
|
||||
/// <summary>
|
||||
/// Отрисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
void DrawingObject(Graphics2D g);
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
HashMap<String, Float> GetCurrentPosition();
|
||||
//Получение информации по объекту
|
||||
String GetInfo();
|
||||
|
||||
public DrawingArmoredVehicle GetMachine();
|
||||
}
|
8
ArmoredVehicle/src/IDrawingRoller.java
Normal file
8
ArmoredVehicle/src/IDrawingRoller.java
Normal file
@ -0,0 +1,8 @@
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
public interface IDrawingRoller {
|
||||
void setCount(int n);
|
||||
|
||||
void DrawRoller(Graphics2D g2d, int startPosX, int startPosY, int Width, int count);
|
||||
}
|
5
ArmoredVehicle/src/MachineNotFoundException.java
Normal file
5
ArmoredVehicle/src/MachineNotFoundException.java
Normal file
@ -0,0 +1,5 @@
|
||||
public class MachineNotFoundException extends Exception {
|
||||
public MachineNotFoundException(int i){
|
||||
super("Не найден объект по позиции "+i);
|
||||
}
|
||||
}
|
@ -1,6 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<NonVisualComponents>
|
||||
<Component class="javax.swing.JButton" name="jButton1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="jButton1"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</NonVisualComponents>
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
@ -27,59 +34,86 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="444" max="32767" attributes="0"/>
|
||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="DrawPanel" pref="438" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="DrawPanel" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="309" max="32767" attributes="0"/>
|
||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="DrawPanel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="DrawPanel" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="22" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="DrawPanel">
|
||||
<Events>
|
||||
<EventHandler event="componentShown" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="DrawPanelComponentShown"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JPanel(){
 Graphics2D g2;}"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="367" pref="367" max="-2" attributes="0"/>
|
||||
<Component id="UpButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="337" pref="337" max="-2" attributes="0"/>
|
||||
<Component id="LeftButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="30" pref="30" max="-2" attributes="0"/>
|
||||
<Component id="RightButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="27" pref="27" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="exitButton" min="-2" pref="78" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="258" max="-2" attributes="0"/>
|
||||
<Component id="DownButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="PropertyText" min="-2" pref="330" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace pref="86" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="160" pref="160" max="-2" attributes="0"/>
|
||||
<Component id="UpButton" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="LeftButton" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="RightButton" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="exitButton" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="DownButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="13" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="10" pref="10" max="-2" attributes="0"/>
|
||||
<Component id="PropertyText" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="java.awt.TextField" name="PropertyText">
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="0" gridY="4" gridWidth="2" gridHeight="1" fill="0" ipadX="322" ipadY="0" insetsTop="10" insetsLeft="0" insetsBottom="10" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="CreateButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Create"/>
|
||||
<Property name="label" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code=""Создать"" type="code"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="CreateButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="CreateButtonMouseClicked"/>
|
||||
</Events>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="0" gridY="2" gridWidth="1" gridHeight="2" fill="0" ipadX="67" ipadY="0" insetsTop="13" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="UpButton">
|
||||
<Properties>
|
||||
@ -99,11 +133,6 @@
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new java.awt.Button()"/>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodePre" type="java.lang.String" value="ImageIcon arrowUp = new ImageIcon("C:\\Users\\Alena\\Desktop\\New Folder\\JavaApplication4\\src\\Resources\\arrowUp.jpg");"/>
|
||||
</AuxValues>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="4" gridY="0" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="160" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="LeftButton">
|
||||
<Properties>
|
||||
@ -116,11 +145,6 @@
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="LeftButtonMouseClicked"/>
|
||||
</Events>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="1" gridY="1" gridWidth="3" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="227" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="DownButton">
|
||||
<Properties>
|
||||
@ -134,11 +158,6 @@
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="DownButtonMouseClicked"/>
|
||||
</Events>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="4" gridY="2" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="18" weightX="0.0" weightY="0.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="RightButton">
|
||||
<Properties>
|
||||
@ -152,11 +171,15 @@
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="RightButtonMouseClicked"/>
|
||||
</Events>
|
||||
<Constraints>
|
||||
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
|
||||
<GridBagConstraints gridX="5" gridY="1" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="32" anchor="18" weightX="0.0" weightY="0.0"/>
|
||||
</Constraint>
|
||||
</Constraints>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="exitButton">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Выход"/>
|
||||
<Property name="name" type="java.lang.String" value="" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="exitButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
|
@ -2,172 +2,173 @@
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Random;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class MainForm extends javax.swing.JFrame {
|
||||
|
||||
|
||||
|
||||
private DrawingArmoredVehicle _ArmoredVehicle = new DrawingArmoredVehicle();;
|
||||
private Image img;
|
||||
private DrawingArmoredVehicle _ArmoredVehicle;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
java.awt.GridBagConstraints gridBagConstraints;
|
||||
|
||||
jButton1 = new javax.swing.JButton();
|
||||
DrawPanel = new javax.swing.JPanel(){
|
||||
Graphics2D g2;};
|
||||
PropertyText = new java.awt.TextField();
|
||||
CreateButton = new java.awt.Button();
|
||||
ImageIcon arrowUp = new ImageIcon("C:\\Users\\Alena\\Desktop\\New Folder\\JavaApplication4\\src\\Resources\\arrowUp.jpg");
|
||||
UpButton = new java.awt.Button();
|
||||
LeftButton = new java.awt.Button();
|
||||
DownButton = new java.awt.Button();
|
||||
RightButton = new java.awt.Button();
|
||||
exitButton = new java.awt.Button();
|
||||
|
||||
jButton1.setText("jButton1");
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setMinimumSize(new java.awt.Dimension(444, 303));
|
||||
setName("MainFrame"); // NOI18N
|
||||
|
||||
DrawPanel.setLayout(new java.awt.GridBagLayout());
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 0;
|
||||
gridBagConstraints.gridy = 4;
|
||||
gridBagConstraints.gridwidth = 2;
|
||||
gridBagConstraints.ipadx = 322;
|
||||
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
||||
gridBagConstraints.insets = new java.awt.Insets(10, 0, 10, 0);
|
||||
DrawPanel.add(PropertyText, gridBagConstraints);
|
||||
|
||||
CreateButton.setActionCommand("Create");
|
||||
CreateButton.setLabel("Создать");
|
||||
CreateButton.setName("CreateButton"); // NOI18N
|
||||
CreateButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
CreateButtonMouseClicked(evt);
|
||||
DrawPanel.addComponentListener(new java.awt.event.ComponentAdapter() {
|
||||
public void componentShown(java.awt.event.ComponentEvent evt) {
|
||||
DrawPanelComponentShown(evt);
|
||||
}
|
||||
});
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 0;
|
||||
gridBagConstraints.gridy = 2;
|
||||
gridBagConstraints.gridheight = 2;
|
||||
gridBagConstraints.ipadx = 67;
|
||||
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
||||
gridBagConstraints.insets = new java.awt.Insets(13, 0, 0, 0);
|
||||
DrawPanel.add(CreateButton, gridBagConstraints);
|
||||
|
||||
UpButton.setActionCommand("Up");
|
||||
UpButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
|
||||
UpButton.setLabel("↑");
|
||||
UpButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
UpButton.setPreferredSize(new java.awt.Dimension(30, 30));
|
||||
UpButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
UpButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 4;
|
||||
gridBagConstraints.gridy = 0;
|
||||
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
||||
gridBagConstraints.insets = new java.awt.Insets(160, 0, 0, 0);
|
||||
DrawPanel.add(UpButton, gridBagConstraints);
|
||||
|
||||
LeftButton.setActionCommand("Left");
|
||||
LeftButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
LeftButton.setName("LeftButton"); // NOI18N
|
||||
LeftButton.setPreferredSize(new java.awt.Dimension(30, 30));
|
||||
LeftButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
LeftButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 1;
|
||||
gridBagConstraints.gridy = 1;
|
||||
gridBagConstraints.gridwidth = 3;
|
||||
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
||||
gridBagConstraints.insets = new java.awt.Insets(0, 227, 0, 0);
|
||||
DrawPanel.add(LeftButton, gridBagConstraints);
|
||||
|
||||
DownButton.setActionCommand("Left");
|
||||
DownButton.setLabel("↓");
|
||||
DownButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
DownButton.setName("LeftButton"); // NOI18N
|
||||
DownButton.setPreferredSize(new java.awt.Dimension(30, 30));
|
||||
DownButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
DownButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 4;
|
||||
gridBagConstraints.gridy = 2;
|
||||
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
||||
DrawPanel.add(DownButton, gridBagConstraints);
|
||||
|
||||
RightButton.setActionCommand("Right");
|
||||
RightButton.setLabel("→");
|
||||
RightButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
RightButton.setName("RightButton"); // NOI18N
|
||||
RightButton.setPreferredSize(new java.awt.Dimension(30, 30));
|
||||
RightButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
RightButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
gridBagConstraints = new java.awt.GridBagConstraints();
|
||||
gridBagConstraints.gridx = 5;
|
||||
gridBagConstraints.gridy = 1;
|
||||
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
|
||||
gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 32);
|
||||
DrawPanel.add(RightButton, gridBagConstraints);
|
||||
|
||||
exitButton.setLabel("Выход");
|
||||
exitButton.setName(""); // NOI18N
|
||||
exitButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
exitButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout DrawPanelLayout = new javax.swing.GroupLayout(DrawPanel);
|
||||
DrawPanel.setLayout(DrawPanelLayout);
|
||||
DrawPanelLayout.setHorizontalGroup(
|
||||
DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addGroup(DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addGap(367, 367, 367)
|
||||
.addComponent(UpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addGap(337, 337, 337)
|
||||
.addComponent(LeftButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(30, 30, 30)
|
||||
.addComponent(RightButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addGap(27, 27, 27)
|
||||
.addGroup(DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(258, 258, 258)
|
||||
.addComponent(DownButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(PropertyText, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
.addContainerGap(86, Short.MAX_VALUE))
|
||||
);
|
||||
DrawPanelLayout.setVerticalGroup(
|
||||
DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addGap(160, 160, 160)
|
||||
.addComponent(UpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(LeftButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(RightButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(exitButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addComponent(DownButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(13, 13, 13)))
|
||||
.addGap(10, 10, 10)
|
||||
.addComponent(PropertyText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 444, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(DrawPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 438, Short.MAX_VALUE)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(DrawPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 309, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(DrawPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap()))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(DrawPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 22, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
public MainForm() {
|
||||
public MainForm(DrawingArmoredVehicle machine) {
|
||||
initComponents();
|
||||
LeftButton.setLabel("<");
|
||||
RightButton.setLabel(">");
|
||||
UpButton.setLabel("/\\");
|
||||
DownButton.setLabel("\\/");
|
||||
}
|
||||
private void CreateButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CreateButtonMouseClicked
|
||||
DownButton.setLabel("\\/");
|
||||
|
||||
_ArmoredVehicle = machine;
|
||||
Draw();
|
||||
SetData();
|
||||
}
|
||||
public void SetData()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
_ArmoredVehicle.Init(rnd.nextInt(100, 300), rnd.nextInt(1000, 2000),
|
||||
new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256)));
|
||||
_ArmoredVehicle.SetPosition(rnd.nextInt(0, 100), rnd.nextInt(25, 200),
|
||||
DrawPanel.getWidth(), DrawPanel.getHeight());
|
||||
PropertyText.setText("Скорость: " + _ArmoredVehicle.ArmoredVehicle.Speed +
|
||||
" Вес: "+_ArmoredVehicle.ArmoredVehicle.Weight +
|
||||
" Цвет: "+_ArmoredVehicle.ArmoredVehicle.BodyColor.getRGB()+
|
||||
" Катков: "+_ArmoredVehicle.Count);
|
||||
Draw();
|
||||
|
||||
}//GEN-LAST:event_CreateButtonMouseClicked
|
||||
|
||||
}
|
||||
public void Move(String name)
|
||||
{
|
||||
switch (name)
|
||||
@ -196,52 +197,48 @@ public class MainForm extends javax.swing.JFrame {
|
||||
Move("DownButton");
|
||||
}//GEN-LAST:event_DownButtonMouseClicked
|
||||
|
||||
public static void main(String args[]) {
|
||||
private void exitButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_exitButtonMouseClicked
|
||||
dispose();
|
||||
}//GEN-LAST:event_exitButtonMouseClicked
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
*/
|
||||
try {
|
||||
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
if ("Nimbus".equals(info.getName())) {
|
||||
javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ClassNotFoundException ex) {
|
||||
java.util.logging.Logger.getLogger(MainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (InstantiationException ex) {
|
||||
java.util.logging.Logger.getLogger(MainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (IllegalAccessException ex) {
|
||||
java.util.logging.Logger.getLogger(MainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
java.util.logging.Logger.getLogger(MainForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
}
|
||||
//</editor-fold>
|
||||
private void DrawPanelComponentShown(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_DrawPanelComponentShown
|
||||
Draw();
|
||||
}//GEN-LAST:event_DrawPanelComponentShown
|
||||
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
new MainForm().setVisible(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void Draw()
|
||||
private void Draw()
|
||||
{
|
||||
Graphics gr = getGraphics();
|
||||
_ArmoredVehicle.paint(gr);
|
||||
gr.dispose();
|
||||
Graphics g = DrawPanel.getGraphics();
|
||||
g.drawImage(Pic(), 0, 0, this);
|
||||
}
|
||||
private void createUIComponents() {
|
||||
DrawPanel = new JPanel() {
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
Draw();
|
||||
}
|
||||
};
|
||||
}
|
||||
Image Pic()
|
||||
{
|
||||
BufferedImage img = new BufferedImage(DrawPanel.getWidth(), DrawPanel.getHeight(), BufferedImage.TYPE_INT_BGR);
|
||||
Graphics2D gr = img.createGraphics();
|
||||
gr.setBackground(Color.yellow);
|
||||
_ArmoredVehicle.DrawTransport(gr);
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private java.awt.Button CreateButton;
|
||||
private java.awt.Button DownButton;
|
||||
private javax.swing.JPanel DrawPanel;
|
||||
private java.awt.Button LeftButton;
|
||||
private java.awt.TextField PropertyText;
|
||||
private java.awt.Button RightButton;
|
||||
private java.awt.Button UpButton;
|
||||
private java.awt.Button exitButton;
|
||||
private javax.swing.JButton jButton1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
||||
|
217
ArmoredVehicle/src/MapForm.form
Normal file
217
ArmoredVehicle/src/MapForm.form
Normal file
@ -0,0 +1,217 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
<Property name="title" type="java.lang.String" value="Карта"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[444, 303]"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="MainFrame" noResource="true"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="482" max="32767" attributes="0"/>
|
||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||
<Component id="DrawPanel" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="312" max="32767" attributes="0"/>
|
||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||
<Component id="DrawPanel" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="DrawPanel">
|
||||
<Events>
|
||||
<EventHandler event="componentResized" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="DrawPanelComponentResized"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JPanel(){
 Graphics2D g2;}"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="19" pref="19" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="UpButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="76" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="PropertyText" min="-2" pref="330" max="-2" attributes="0"/>
|
||||
<EmptySpace min="74" pref="133" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="CreateButton" min="-2" pref="83" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="CreateTankButton" min="-2" pref="132" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="SetButton" min="-2" pref="85" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="RightButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="49" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="LeftButton" min="-2" pref="22" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
|
||||
<Component id="DownButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="78" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace pref="217" max="32767" attributes="0"/>
|
||||
<Component id="UpButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="CreateButton" alignment="1" pref="30" max="32767" attributes="0"/>
|
||||
<Component id="LeftButton" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="RightButton" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="CreateTankButton" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="SetButton" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="PropertyText" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="DownButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="java.awt.TextField" name="PropertyText">
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="CreateButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Create"/>
|
||||
<Property name="label" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code=""Создать"" type="code"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="CreateButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="CreateButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="UpButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Up"/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
<Property name="label" type="java.lang.String" value="↑"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="UpButtonMouseClicked"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new java.awt.Button()"/>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodePre" type="java.lang.String" value="ImageIcon arrowUp = new ImageIcon("C:\\Users\\Alena\\Desktop\\New Folder\\JavaApplication4\\src\\Resources\\arrowUp.jpg");"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="LeftButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Left"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 30]"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="LeftButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="LeftButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="DownButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Left"/>
|
||||
<Property name="label" type="java.lang.String" value="↓"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 30]"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="LeftButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="DownButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="RightButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Right"/>
|
||||
<Property name="label" type="java.lang.String" value="→"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 30]"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="RightButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="RightButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="CreateTankButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Create"/>
|
||||
<Property name="label" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code=""Модификация"" type="code"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="CreateTankButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="CreateTankButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="SetButton">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Выбрать"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="SetButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
301
ArmoredVehicle/src/MapForm.java
Normal file
301
ArmoredVehicle/src/MapForm.java
Normal file
@ -0,0 +1,301 @@
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Random;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class MapForm extends JFrame{
|
||||
|
||||
|
||||
|
||||
private DrawingArmoredVehicle _ArmoredVehicle;
|
||||
private DrawingArmoredVehicle SelectedMachine;
|
||||
public boolean DialogResult = false;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
DrawPanel = new javax.swing.JPanel(){
|
||||
Graphics2D g2;};
|
||||
PropertyText = new java.awt.TextField();
|
||||
CreateButton = new java.awt.Button();
|
||||
ImageIcon arrowUp = new ImageIcon("C:\\Users\\Alena\\Desktop\\New Folder\\JavaApplication4\\src\\Resources\\arrowUp.jpg");
|
||||
UpButton = new java.awt.Button();
|
||||
LeftButton = new java.awt.Button();
|
||||
DownButton = new java.awt.Button();
|
||||
RightButton = new java.awt.Button();
|
||||
CreateTankButton = new java.awt.Button();
|
||||
SetButton = new java.awt.Button();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setTitle("Карта");
|
||||
setMinimumSize(new java.awt.Dimension(444, 303));
|
||||
setName("MainFrame"); // NOI18N
|
||||
|
||||
DrawPanel.addComponentListener(new java.awt.event.ComponentAdapter() {
|
||||
public void componentResized(java.awt.event.ComponentEvent evt) {
|
||||
DrawPanelComponentResized(evt);
|
||||
}
|
||||
});
|
||||
|
||||
CreateButton.setActionCommand("Create");
|
||||
CreateButton.setLabel("Создать");
|
||||
CreateButton.setName("CreateButton"); // NOI18N
|
||||
CreateButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
CreateButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
UpButton.setActionCommand("Up");
|
||||
UpButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
|
||||
UpButton.setLabel("↑");
|
||||
UpButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
UpButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
UpButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
LeftButton.setActionCommand("Left");
|
||||
LeftButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
LeftButton.setName("LeftButton"); // NOI18N
|
||||
LeftButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
LeftButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
DownButton.setActionCommand("Left");
|
||||
DownButton.setLabel("↓");
|
||||
DownButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
DownButton.setName("LeftButton"); // NOI18N
|
||||
DownButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
DownButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
RightButton.setActionCommand("Right");
|
||||
RightButton.setLabel("→");
|
||||
RightButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
RightButton.setName("RightButton"); // NOI18N
|
||||
RightButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
RightButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
CreateTankButton.setActionCommand("Create");
|
||||
CreateTankButton.setLabel("Модификация");
|
||||
CreateTankButton.setName("CreateTankButton"); // NOI18N
|
||||
CreateTankButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
CreateTankButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
SetButton.setLabel("Выбрать");
|
||||
SetButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
SetButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout DrawPanelLayout = new javax.swing.GroupLayout(DrawPanel);
|
||||
DrawPanel.setLayout(DrawPanelLayout);
|
||||
DrawPanelLayout.setHorizontalGroup(
|
||||
DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addGap(19, 19, 19)
|
||||
.addGroup(DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(UpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(76, 76, 76))
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addComponent(PropertyText, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(74, 133, Short.MAX_VALUE))
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addComponent(CreateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(CreateTankButton, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(SetButton, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DrawPanelLayout.createSequentialGroup()
|
||||
.addComponent(RightButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(49, 49, 49))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DrawPanelLayout.createSequentialGroup()
|
||||
.addComponent(LeftButton, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(1, 1, 1)
|
||||
.addComponent(DownButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(78, 78, 78))))))
|
||||
);
|
||||
DrawPanelLayout.setVerticalGroup(
|
||||
DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addContainerGap(217, Short.MAX_VALUE)
|
||||
.addComponent(UpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(1, 1, 1)
|
||||
.addGroup(DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DrawPanelLayout.createSequentialGroup()
|
||||
.addGroup(DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(CreateButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)
|
||||
.addComponent(LeftButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(RightButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(CreateTankButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(SetButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(PropertyText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DrawPanelLayout.createSequentialGroup()
|
||||
.addComponent(DownButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(19, 19, 19))))
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 482, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(DrawPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 312, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(DrawPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
public MapForm() {
|
||||
initComponents();
|
||||
LeftButton.setLabel("<");
|
||||
RightButton.setLabel(">");
|
||||
UpButton.setLabel("/\\");
|
||||
DownButton.setLabel("\\/");
|
||||
}
|
||||
private void CreateButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CreateButtonMouseClicked
|
||||
Random rnd = new Random();
|
||||
Color newColor = JColorChooser.showDialog(null, "Choose a color", Color.RED);
|
||||
_ArmoredVehicle = new DrawingArmoredVehicle(rnd.nextInt(100, 300), rnd.nextInt(1000, 2000),
|
||||
newColor);
|
||||
SetData();
|
||||
Draw();
|
||||
|
||||
}//GEN-LAST:event_CreateButtonMouseClicked
|
||||
public void SetData()
|
||||
{
|
||||
Random rnd = new Random();
|
||||
_ArmoredVehicle.SetPosition(rnd.nextInt(0, 100), rnd.nextInt(25, 200),
|
||||
DrawPanel.getWidth(), DrawPanel.getHeight());
|
||||
PropertyText.setText("Скорость: " + _ArmoredVehicle.ArmoredVehicle.Speed +
|
||||
" Вес: "+_ArmoredVehicle.ArmoredVehicle.Weight +
|
||||
" Цвет: "+_ArmoredVehicle.ArmoredVehicle.BodyColor.getRGB()+
|
||||
" Катков: "+_ArmoredVehicle.Count);
|
||||
}
|
||||
public DrawingArmoredVehicle getSelectedCar() {
|
||||
return SelectedMachine;
|
||||
}
|
||||
public void Move(String name)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "UpButton" -> _ArmoredVehicle.MoveTransport(Direction.Up);
|
||||
case "DownButton" -> _ArmoredVehicle.MoveTransport(Direction.Down);
|
||||
case "LeftButton" -> _ArmoredVehicle.MoveTransport(Direction.Left);
|
||||
case "RightButton" -> _ArmoredVehicle.MoveTransport(Direction.Right);
|
||||
}
|
||||
|
||||
Draw();
|
||||
}
|
||||
private void UpButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_UpButtonMouseClicked
|
||||
Move("UpButton");
|
||||
}//GEN-LAST:event_UpButtonMouseClicked
|
||||
|
||||
private void LeftButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LeftButtonMouseClicked
|
||||
Move("LeftButton");
|
||||
}//GEN-LAST:event_LeftButtonMouseClicked
|
||||
|
||||
private void RightButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_RightButtonMouseClicked
|
||||
Move("RightButton");
|
||||
}//GEN-LAST:event_RightButtonMouseClicked
|
||||
|
||||
private void DownButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DownButtonMouseClicked
|
||||
Move("DownButton");
|
||||
}//GEN-LAST:event_DownButtonMouseClicked
|
||||
|
||||
private void DrawPanelComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_DrawPanelComponentResized
|
||||
if (_ArmoredVehicle != null) {
|
||||
_ArmoredVehicle.ChangeBorders(DrawPanel.getWidth(), DrawPanel.getHeight());
|
||||
Draw();
|
||||
}
|
||||
}//GEN-LAST:event_DrawPanelComponentResized
|
||||
|
||||
private void CreateTankButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CreateTankButtonMouseClicked
|
||||
Random rnd = new Random();
|
||||
Color newColor = JColorChooser.showDialog(null, "Choose a color", Color.RED);
|
||||
Color newColorDop = JColorChooser.showDialog(null, "Choose a color", Color.RED);
|
||||
_ArmoredVehicle = new DrawingTank(rnd.nextInt(100, 300),
|
||||
rnd.nextInt(1000, 2000),
|
||||
newColor,
|
||||
newColorDop,
|
||||
1==rnd.nextInt(0, 2), 1==rnd.nextInt(0, 2));
|
||||
SetData();
|
||||
Draw();
|
||||
}//GEN-LAST:event_CreateTankButtonMouseClicked
|
||||
|
||||
private void SetButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SetButtonMouseClicked
|
||||
if (_ArmoredVehicle != null) {
|
||||
SelectedMachine = _ArmoredVehicle;
|
||||
DialogResult = true;
|
||||
dispose();
|
||||
}
|
||||
}//GEN-LAST:event_SetButtonMouseClicked
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
Graphics g = DrawPanel.getGraphics();
|
||||
g.drawImage(Pic(), 0, 0, this);
|
||||
}
|
||||
private void createUIComponents() {
|
||||
DrawPanel = new JPanel() {
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
Draw();
|
||||
}
|
||||
};
|
||||
}
|
||||
Image Pic()
|
||||
{
|
||||
BufferedImage img = new BufferedImage(DrawPanel.getWidth(), DrawPanel.getHeight(), BufferedImage.TYPE_INT_BGR);
|
||||
Graphics2D gr = img.createGraphics();
|
||||
gr.setBackground(Color.yellow);
|
||||
_ArmoredVehicle.DrawTransport(gr);
|
||||
return img;
|
||||
}
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private java.awt.Button CreateButton;
|
||||
private java.awt.Button CreateTankButton;
|
||||
private java.awt.Button DownButton;
|
||||
private javax.swing.JPanel DrawPanel;
|
||||
private java.awt.Button LeftButton;
|
||||
private java.awt.TextField PropertyText;
|
||||
private java.awt.Button RightButton;
|
||||
private java.awt.Button SetButton;
|
||||
private java.awt.Button UpButton;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
160
ArmoredVehicle/src/MapWithSetMachineGeneric.java
Normal file
160
ArmoredVehicle/src/MapWithSetMachineGeneric.java
Normal file
@ -0,0 +1,160 @@
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
public class MapWithSetMachineGeneric<T extends IDrawingObject, U extends AbstractMap> {
|
||||
|
||||
private int _pictureWidth;
|
||||
|
||||
private int _pictureHeight;
|
||||
|
||||
private int _placeSizeWidth = 210;
|
||||
|
||||
private int _placeSizeHeight = 110;
|
||||
|
||||
private SetArmoredCarsGeneric<T> _setCars;
|
||||
|
||||
private U _map;
|
||||
|
||||
public MapWithSetMachineGeneric(int picWidth, int picHeight, U map)
|
||||
{
|
||||
int width = picWidth / _placeSizeWidth;
|
||||
int height = picHeight / _placeSizeHeight;
|
||||
_setCars = new SetArmoredCarsGeneric<T>(width * height);
|
||||
_pictureWidth = picWidth;
|
||||
_pictureHeight = picHeight;
|
||||
_map = map;
|
||||
}
|
||||
public void Clear() {
|
||||
_setCars.Clear();
|
||||
}
|
||||
public int add(T car) throws StorageOverflowException
|
||||
{
|
||||
return _setCars.Insert(car);
|
||||
}
|
||||
|
||||
public T remove(int position) throws MachineNotFoundException
|
||||
{
|
||||
return _setCars.Remove(position);
|
||||
}
|
||||
|
||||
public T GetMachineInList(int ind){
|
||||
return _setCars.Get(ind);
|
||||
}
|
||||
public Image ShowSet()
|
||||
{
|
||||
Image bmp = new BufferedImage(_pictureWidth, _pictureHeight, BufferedImage.TYPE_INT_BGR);
|
||||
Graphics gr = bmp.getGraphics();
|
||||
DrawBackground(gr);
|
||||
DrawArmoredCars(gr);
|
||||
return bmp;
|
||||
}
|
||||
|
||||
public Image ShowOnMap()
|
||||
{
|
||||
Shaking();
|
||||
for (var machine : _setCars) {
|
||||
return _map.CreateMap(_pictureWidth, _pictureHeight, machine);
|
||||
}
|
||||
return new BufferedImage(_pictureWidth, _pictureHeight, BufferedImage.TYPE_INT_BGR);
|
||||
}
|
||||
|
||||
public Image MoveObject(Direction direction)
|
||||
{
|
||||
if (_map != null)
|
||||
{
|
||||
return _map.MoveObject(direction);
|
||||
}
|
||||
return new BufferedImage(_pictureWidth, _pictureHeight, BufferedImage.TYPE_INT_BGR);
|
||||
}
|
||||
|
||||
private void Shaking()
|
||||
{
|
||||
int j = _setCars.getCount() - 1;
|
||||
for (int i = 0; i < _setCars.getCount(); i++)
|
||||
{
|
||||
if (_setCars.Get(i) == null)
|
||||
{
|
||||
for (; j > i; j--)
|
||||
{
|
||||
var car = _setCars.Get(j);
|
||||
if (car != null)
|
||||
{
|
||||
try {
|
||||
_setCars.Insert(car, i);
|
||||
} catch (StorageOverflowException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
_setCars.Remove(j);
|
||||
} catch (MachineNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j <= i)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
g.setColor(Color.GREEN);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
||||
{//линия рамзетки места
|
||||
int dop = 0;
|
||||
if(i>0 && j>0)
|
||||
{
|
||||
dop = 30;
|
||||
}
|
||||
g.drawRect(i * _placeSizeWidth + dop, j * _placeSizeHeight + dop,_placeSizeWidth,_placeSizeHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawArmoredCars(Graphics g)
|
||||
{
|
||||
int width = _pictureWidth / _placeSizeWidth;
|
||||
for(int i = 0; i<_setCars.getCount(); i++)
|
||||
{
|
||||
if (_setCars.Get(i) != null) {
|
||||
_setCars.Get(i).SetObject(i % width * _placeSizeWidth + 5, i / width * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
|
||||
_setCars.Get(i).DrawingObject((Graphics2D) g);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Получение данных в виде строки
|
||||
public String GetData(char separatorType, char separatorData)
|
||||
{
|
||||
String data = _map.getClass().getName()+separatorType;
|
||||
data = data.substring(4);
|
||||
for (var machine : _setCars)
|
||||
{
|
||||
data += machine.GetInfo()+separatorData;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
public String GetDataMap(char separatorType, char separatorData)
|
||||
{
|
||||
String data = _map.getClass().getName()+separatorType;
|
||||
data = data.substring(4) + '\n';
|
||||
for (var machine : _setCars)
|
||||
{
|
||||
data += machine.GetInfo()+separatorData+'\n';
|
||||
}
|
||||
return data;
|
||||
}
|
||||
// Загрузка списка из массива строк
|
||||
public void LoadData(String[] records) throws StorageOverflowException
|
||||
{
|
||||
for (var rec : records)
|
||||
{
|
||||
_setCars.Insert((T)DrawingObject.Create(rec));
|
||||
}
|
||||
}
|
||||
}
|
241
ArmoredVehicle/src/MapsCollection.java
Normal file
241
ArmoredVehicle/src/MapsCollection.java
Normal file
@ -0,0 +1,241 @@
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JOptionPane;
|
||||
|
||||
public class MapsCollection {
|
||||
/// <summary>
|
||||
/// Словарь (хранилище) с картами
|
||||
/// </summary>
|
||||
Map <String, MapWithSetMachineGeneric<IDrawingObject, AbstractMap>> _mapStorages;
|
||||
/// <summary>
|
||||
/// Возвращение списка названий карт
|
||||
/// </summary>
|
||||
public ArrayList<String> Keys;
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
private int _pictureWidth;
|
||||
/// <summary>
|
||||
/// Высота окна отрисовки
|
||||
/// </summary>
|
||||
private int _pictureHeight;
|
||||
/// Разделитель для записи информации по элементу словаря в файл
|
||||
private final char separatorDict = '|';
|
||||
/// Разделитель для записей коллекции данных в файл
|
||||
private final char separatorData = ';';
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="pictureWidth"></param>
|
||||
/// <param name="pictureHeight"></param>
|
||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_mapStorages = new HashMap<String, MapWithSetMachineGeneric<IDrawingObject, AbstractMap>>();
|
||||
Keys = new ArrayList<String>(_mapStorages.keySet());
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
public String[] getKeys() {
|
||||
String[] res = new String[_mapStorages.size()];
|
||||
int i = 0;
|
||||
for(String elem: _mapStorages.keySet())
|
||||
{
|
||||
res[i] = elem;
|
||||
i++;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Добавление карты
|
||||
/// </summary>
|
||||
/// <param name="name">Название карты</param>
|
||||
/// <param name="map">Карта</param>
|
||||
public void AddMap(String name, AbstractMap map)
|
||||
{
|
||||
if (_mapStorages.keySet().contains(name))
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "Такая карта уже есть");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
var NewElem = new MapWithSetMachineGeneric<IDrawingObject, AbstractMap>(
|
||||
_pictureWidth, _pictureHeight, map);
|
||||
_mapStorages.put(name, NewElem);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Удаление карты
|
||||
/// </summary>
|
||||
/// <param name="name">Название карты</param>
|
||||
public void DelMap(String name)
|
||||
{
|
||||
if (_mapStorages.keySet().contains(name))
|
||||
{
|
||||
_mapStorages.remove(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
JOptionPane.showMessageDialog(null, "Такой карты нет");
|
||||
return;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Доступ к парковке
|
||||
/// </summary>
|
||||
/// <param name="ind"></param>
|
||||
/// <returns></returns>
|
||||
public MapWithSetMachineGeneric<IDrawingObject, AbstractMap> Get(String ind)
|
||||
{
|
||||
if(_mapStorages.keySet().contains(ind))
|
||||
{
|
||||
return _mapStorages.get(ind);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
public IDrawingObject Get(String name, int ind) {
|
||||
if (_mapStorages.containsKey(name))
|
||||
{
|
||||
return _mapStorages.get(name).GetMachineInList(ind);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
/// Сохранение информации по тракторам в хранилище в файл
|
||||
public void SaveData(String filename) {
|
||||
File file = new File(filename);
|
||||
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
try (BufferedWriter br = new BufferedWriter(new FileWriter(filename)))
|
||||
{
|
||||
br.write("MapsCollection\n");
|
||||
for (var storage : _mapStorages.entrySet()) {
|
||||
br.write(storage.getKey() + separatorDict + storage.getValue().GetData(separatorDict, separatorData) + "\n");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
/// Загрузка информации по машинам в депо из файла
|
||||
public void LoadData(String filename) throws FileNotFoundException
|
||||
{
|
||||
if (!(new File(filename).exists()))
|
||||
{
|
||||
throw new FileNotFoundException("Файл не найден");
|
||||
}
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(filename)))
|
||||
{
|
||||
String str = "";
|
||||
if ((str = br.readLine()) == null || !str.contains("MapsCollection"))
|
||||
{
|
||||
//если нет такой записи, то это не те данные
|
||||
throw new IllegalArgumentException("Формат данных в файле неправильный");
|
||||
}
|
||||
//очищаем записи
|
||||
_mapStorages.clear();
|
||||
while ((str = br.readLine()) != null)
|
||||
{
|
||||
var elem = str.split(String.format("\\%c",separatorDict));
|
||||
AbstractMap map = null;
|
||||
switch (elem[1])
|
||||
{
|
||||
case "SimpleMap":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "VerticalMap":
|
||||
map = new VerticalMap();
|
||||
break;
|
||||
case "HorizontalMap":
|
||||
map = new HorizontalMap();
|
||||
break;
|
||||
}
|
||||
_mapStorages.put(elem[0], new MapWithSetMachineGeneric<IDrawingObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
_mapStorages.get(elem[0]).LoadData(elem[2].split(separatorData + "\n?"));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
catch (StorageOverflowException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
public boolean SaveMap(String filename, String index) {
|
||||
File file = new File(filename);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
var elem = _mapStorages.get(index);
|
||||
if (elem==null)
|
||||
return false;
|
||||
try (BufferedWriter br = new BufferedWriter(new FileWriter(filename)))
|
||||
{
|
||||
br.write("MapsCollection\n");
|
||||
br.write(index + separatorDict);
|
||||
br.write(elem.GetDataMap(separatorDict, separatorData));
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
public boolean LoadMap(String filename) throws StorageOverflowException {
|
||||
if (!(new File(filename).exists()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
try (BufferedReader br = new BufferedReader(new FileReader(filename)))
|
||||
{
|
||||
String str = "";
|
||||
if ((str = br.readLine()) == null || !str.contains("MapsCollection"))
|
||||
{
|
||||
//если нет такой записи, то это не те данные
|
||||
return false;
|
||||
}
|
||||
if ((str = br.readLine()) != null)
|
||||
{
|
||||
var elem = str.split(String.format("\\%c",separatorDict));
|
||||
AbstractMap map = null;
|
||||
switch (elem[1])
|
||||
{
|
||||
case "SimpleMap":
|
||||
map = new SimpleMap();
|
||||
break;
|
||||
case "VerticalMap":
|
||||
map = new VerticalMap();
|
||||
break;
|
||||
case "HorizontalMap":
|
||||
map = new HorizontalMap();
|
||||
break;
|
||||
}
|
||||
if(_mapStorages.containsKey(elem[0])){
|
||||
_mapStorages.get(elem[0]).Clear();
|
||||
}
|
||||
else _mapStorages.put(elem[0], new MapWithSetMachineGeneric<IDrawingObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
|
||||
while((str = br.readLine()) != null) {
|
||||
_mapStorages.get(elem[0]).LoadData(str.split(separatorData + "\n?"));
|
||||
}
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
48
ArmoredVehicle/src/PolimorphClass.java
Normal file
48
ArmoredVehicle/src/PolimorphClass.java
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
|
||||
public class PolimorphClass <M extends ArmoredVehicleEntity, R extends IDrawingRoller> {
|
||||
ArrayList<M> machines;
|
||||
ArrayList<R> rollers;
|
||||
|
||||
int _machineCount = 0;
|
||||
int _rollersCount = 0;
|
||||
|
||||
public PolimorphClass(int machineCount, int rollersCount) {
|
||||
_machineCount = machineCount;
|
||||
_rollersCount = rollersCount;
|
||||
machines = new ArrayList<M>(_machineCount);
|
||||
rollers = new ArrayList<R>(_rollersCount);
|
||||
}
|
||||
|
||||
public int AddEntity(M machine)
|
||||
{
|
||||
if(_machineCount < machines.size()){
|
||||
machines.add(machine);
|
||||
return _machineCount++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int AddRollers(R rolls)
|
||||
{
|
||||
if(_rollersCount < rollers.size()){
|
||||
rollers.add(rolls);
|
||||
return _rollersCount++;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public DrawingArmoredVehicle CreateMachine() {
|
||||
int iMachine = new Random().nextInt(0, _machineCount);
|
||||
int iRoller = new Random().nextInt(0, _rollersCount);
|
||||
M selectedMachine = machines.get(iMachine);
|
||||
R selectedRoller = rollers.get(iRoller);
|
||||
if (selectedMachine instanceof TankEntity) {
|
||||
return new DrawingTank(selectedMachine, selectedRoller);
|
||||
}
|
||||
return new DrawingArmoredVehicle(selectedMachine, selectedRoller);
|
||||
}
|
||||
}
|
217
ArmoredVehicle/src/PolimorphForm.form
Normal file
217
ArmoredVehicle/src/PolimorphForm.form
Normal file
@ -0,0 +1,217 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.9" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
|
||||
<Properties>
|
||||
<Property name="defaultCloseOperation" type="int" value="3"/>
|
||||
<Property name="title" type="java.lang.String" value="Карта"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[444, 303]"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="MainFrame" noResource="true"/>
|
||||
</Properties>
|
||||
<SyntheticProperties>
|
||||
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
|
||||
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
|
||||
</SyntheticProperties>
|
||||
<AuxValues>
|
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
|
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
|
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
|
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
|
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="482" max="32767" attributes="0"/>
|
||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||
<Component id="DrawPanel" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="312" max="32767" attributes="0"/>
|
||||
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
|
||||
<Component id="DrawPanel" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Container class="javax.swing.JPanel" name="DrawPanel">
|
||||
<Events>
|
||||
<EventHandler event="componentResized" listener="java.awt.event.ComponentListener" parameters="java.awt.event.ComponentEvent" handler="DrawPanelComponentResized"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JPanel(){
 Graphics2D g2;}"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="19" pref="19" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
<Component id="UpButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="76" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="PropertyText" min="-2" pref="330" max="-2" attributes="0"/>
|
||||
<EmptySpace min="74" pref="133" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="CreateButton" min="-2" pref="83" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="CreateTankButton" min="-2" pref="132" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="SetButton" min="-2" pref="85" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="RightButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="49" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="LeftButton" min="-2" pref="22" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
|
||||
<Component id="DownButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="78" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace pref="217" max="32767" attributes="0"/>
|
||||
<Component id="UpButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Group type="103" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="CreateButton" alignment="1" pref="30" max="32767" attributes="0"/>
|
||||
<Component id="LeftButton" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="RightButton" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="CreateTankButton" alignment="0" max="32767" attributes="0"/>
|
||||
<Component id="SetButton" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="PropertyText" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<Component id="DownButton" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="java.awt.TextField" name="PropertyText">
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="CreateButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Create"/>
|
||||
<Property name="label" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code=""Создать"" type="code"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="CreateButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="CreateButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="UpButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Up"/>
|
||||
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
|
||||
<Color id="Default Cursor"/>
|
||||
</Property>
|
||||
<Property name="label" type="java.lang.String" value="↑"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 30]"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="UpButtonMouseClicked"/>
|
||||
</Events>
|
||||
<AuxValues>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new java.awt.Button()"/>
|
||||
<AuxValue name="JavaCodeGenerator_CreateCodePre" type="java.lang.String" value="ImageIcon arrowUp = new ImageIcon("C:\\Users\\Alena\\Desktop\\New Folder\\JavaApplication4\\src\\Resources\\arrowUp.jpg");"/>
|
||||
</AuxValues>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="LeftButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Left"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 30]"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="LeftButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="LeftButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="DownButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Left"/>
|
||||
<Property name="label" type="java.lang.String" value="↓"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 30]"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="LeftButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="DownButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="RightButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Right"/>
|
||||
<Property name="label" type="java.lang.String" value="→"/>
|
||||
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
|
||||
<Dimension value="[30, 30]"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="RightButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="RightButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="CreateTankButton">
|
||||
<Properties>
|
||||
<Property name="actionCommand" type="java.lang.String" value="Create"/>
|
||||
<Property name="label" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
|
||||
<Connection code=""Модификация"" type="code"/>
|
||||
</Property>
|
||||
<Property name="name" type="java.lang.String" value="CreateTankButton" noResource="true"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="CreateTankButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="java.awt.Button" name="SetButton">
|
||||
<Properties>
|
||||
<Property name="label" type="java.lang.String" value="Выбрать"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="SetButtonMouseClicked"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
350
ArmoredVehicle/src/PolimorphForm.java
Normal file
350
ArmoredVehicle/src/PolimorphForm.java
Normal file
@ -0,0 +1,350 @@
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.Image;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.Random;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JColorChooser;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class PolimorphForm extends JFrame{
|
||||
|
||||
|
||||
|
||||
private DrawingArmoredVehicle _ArmoredVehicle;
|
||||
private DrawingArmoredVehicle SelectedMachine;
|
||||
|
||||
protected PolimorphClass<ArmoredVehicleEntity, IDrawingRoller> polymorphMachine;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
DrawPanel = new javax.swing.JPanel(){
|
||||
Graphics2D g2;};
|
||||
PropertyText = new java.awt.TextField();
|
||||
CreateButton = new java.awt.Button();
|
||||
ImageIcon arrowUp = new ImageIcon("C:\\Users\\Alena\\Desktop\\New Folder\\JavaApplication4\\src\\Resources\\arrowUp.jpg");
|
||||
UpButton = new java.awt.Button();
|
||||
LeftButton = new java.awt.Button();
|
||||
DownButton = new java.awt.Button();
|
||||
RightButton = new java.awt.Button();
|
||||
CreateTankButton = new java.awt.Button();
|
||||
SetButton = new java.awt.Button();
|
||||
|
||||
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
|
||||
setTitle("Карта");
|
||||
setMinimumSize(new java.awt.Dimension(444, 303));
|
||||
setName("MainFrame"); // NOI18N
|
||||
|
||||
DrawPanel.addComponentListener(new java.awt.event.ComponentAdapter() {
|
||||
public void componentResized(java.awt.event.ComponentEvent evt) {
|
||||
DrawPanelComponentResized(evt);
|
||||
}
|
||||
});
|
||||
|
||||
CreateButton.setActionCommand("Create");
|
||||
CreateButton.setLabel("Создать");
|
||||
CreateButton.setName("CreateButton"); // NOI18N
|
||||
CreateButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
CreateButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
UpButton.setActionCommand("Up");
|
||||
UpButton.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
|
||||
UpButton.setLabel("↑");
|
||||
UpButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
UpButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
UpButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
LeftButton.setActionCommand("Left");
|
||||
LeftButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
LeftButton.setName("LeftButton"); // NOI18N
|
||||
LeftButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
LeftButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
DownButton.setActionCommand("Left");
|
||||
DownButton.setLabel("↓");
|
||||
DownButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
DownButton.setName("LeftButton"); // NOI18N
|
||||
DownButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
DownButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
RightButton.setActionCommand("Right");
|
||||
RightButton.setLabel("→");
|
||||
RightButton.setMinimumSize(new java.awt.Dimension(30, 30));
|
||||
RightButton.setName("RightButton"); // NOI18N
|
||||
RightButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
RightButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
CreateTankButton.setActionCommand("Create");
|
||||
CreateTankButton.setLabel("Модификация");
|
||||
CreateTankButton.setName("CreateTankButton"); // NOI18N
|
||||
CreateTankButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
CreateTankButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
SetButton.setLabel("Выбрать");
|
||||
SetButton.addMouseListener(new java.awt.event.MouseAdapter() {
|
||||
public void mouseClicked(java.awt.event.MouseEvent evt) {
|
||||
SetButtonMouseClicked(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout DrawPanelLayout = new javax.swing.GroupLayout(DrawPanel);
|
||||
DrawPanel.setLayout(DrawPanelLayout);
|
||||
DrawPanelLayout.setHorizontalGroup(
|
||||
DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addGap(19, 19, 19)
|
||||
.addGroup(DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addGap(0, 0, Short.MAX_VALUE)
|
||||
.addComponent(UpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(76, 76, 76))
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addComponent(PropertyText, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(74, 133, Short.MAX_VALUE))
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addComponent(CreateButton, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(CreateTankButton, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(SetButton, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DrawPanelLayout.createSequentialGroup()
|
||||
.addComponent(RightButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(49, 49, 49))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DrawPanelLayout.createSequentialGroup()
|
||||
.addComponent(LeftButton, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(1, 1, 1)
|
||||
.addComponent(DownButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(78, 78, 78))))))
|
||||
);
|
||||
DrawPanelLayout.setVerticalGroup(
|
||||
DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(DrawPanelLayout.createSequentialGroup()
|
||||
.addContainerGap(217, Short.MAX_VALUE)
|
||||
.addComponent(UpButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(1, 1, 1)
|
||||
.addGroup(DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DrawPanelLayout.createSequentialGroup()
|
||||
.addGroup(DrawPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(CreateButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)
|
||||
.addComponent(LeftButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(RightButton, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(CreateTankButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(SetButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(PropertyText, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap())
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DrawPanelLayout.createSequentialGroup()
|
||||
.addComponent(DownButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(19, 19, 19))))
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
|
||||
getContentPane().setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 482, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(DrawPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 312, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(DrawPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
pack();
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
public PolimorphForm() {
|
||||
initComponents();
|
||||
LeftButton.setLabel("<");
|
||||
RightButton.setLabel(">");
|
||||
UpButton.setLabel("/\\");
|
||||
DownButton.setLabel("\\/");
|
||||
polymorphMachine = new PolimorphClass<ArmoredVehicleEntity, IDrawingRoller>(50, 50);
|
||||
}
|
||||
private void CreateButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CreateButtonMouseClicked
|
||||
Random rnd = new Random();
|
||||
|
||||
Color newColor = JColorChooser.showDialog(null, "Choose a color", Color.RED);
|
||||
IDrawingRoller roll = null;
|
||||
switch (rnd.nextInt(3)) {
|
||||
case (0) -> roll = new Roller(newColor);
|
||||
case (1) -> roll = new DrawingFirstRoller(newColor);
|
||||
case (2) -> roll = new DrawingSecondRoller(newColor);
|
||||
}
|
||||
int c= rnd.nextInt(4, 6);
|
||||
roll.setCount(c);
|
||||
|
||||
ArmoredVehicleEntity machine = new ArmoredVehicleEntity(rnd.nextInt(300), rnd.nextInt(2000),
|
||||
newColor);
|
||||
|
||||
polymorphMachine.AddRollers(roll);
|
||||
polymorphMachine.AddEntity(machine);
|
||||
|
||||
_ArmoredVehicle = polymorphMachine.CreateMachine();
|
||||
_ArmoredVehicle.Count = c;
|
||||
SetData();
|
||||
Draw();
|
||||
|
||||
}//GEN-LAST:event_CreateButtonMouseClicked
|
||||
public void SetData()
|
||||
{
|
||||
|
||||
Random rnd = new Random();
|
||||
_ArmoredVehicle.SetPosition(rnd.nextInt(0, 100), rnd.nextInt(25, 200),
|
||||
DrawPanel.getWidth(), DrawPanel.getHeight());
|
||||
PropertyText.setText("Скорость: " + _ArmoredVehicle.ArmoredVehicle.Speed +
|
||||
" Вес: "+_ArmoredVehicle.ArmoredVehicle.Weight +
|
||||
" Цвет: "+_ArmoredVehicle.ArmoredVehicle.BodyColor.getRGB()+
|
||||
" Катков: "+_ArmoredVehicle.Count);
|
||||
}
|
||||
public DrawingArmoredVehicle getSelectedCar() {
|
||||
return SelectedMachine;
|
||||
}
|
||||
public void Move(String name)
|
||||
{
|
||||
switch (name)
|
||||
{
|
||||
case "UpButton" -> _ArmoredVehicle.MoveTransport(Direction.Up);
|
||||
case "DownButton" -> _ArmoredVehicle.MoveTransport(Direction.Down);
|
||||
case "LeftButton" -> _ArmoredVehicle.MoveTransport(Direction.Left);
|
||||
case "RightButton" -> _ArmoredVehicle.MoveTransport(Direction.Right);
|
||||
}
|
||||
|
||||
Draw();
|
||||
}
|
||||
private void UpButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_UpButtonMouseClicked
|
||||
Move("UpButton");
|
||||
}//GEN-LAST:event_UpButtonMouseClicked
|
||||
|
||||
private void LeftButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_LeftButtonMouseClicked
|
||||
Move("LeftButton");
|
||||
}//GEN-LAST:event_LeftButtonMouseClicked
|
||||
|
||||
private void RightButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_RightButtonMouseClicked
|
||||
Move("RightButton");
|
||||
}//GEN-LAST:event_RightButtonMouseClicked
|
||||
|
||||
private void DownButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_DownButtonMouseClicked
|
||||
Move("DownButton");
|
||||
}//GEN-LAST:event_DownButtonMouseClicked
|
||||
|
||||
private void DrawPanelComponentResized(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_DrawPanelComponentResized
|
||||
if (_ArmoredVehicle != null) {
|
||||
_ArmoredVehicle.ChangeBorders(DrawPanel.getWidth(), DrawPanel.getHeight());
|
||||
Draw();
|
||||
}
|
||||
}//GEN-LAST:event_DrawPanelComponentResized
|
||||
|
||||
private void CreateTankButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_CreateTankButtonMouseClicked
|
||||
Random rnd = new Random();
|
||||
Color newColor = JColorChooser.showDialog(null, "Choose a color", Color.RED);
|
||||
Color newColorDop = JColorChooser.showDialog(null, "Choose a color", Color.RED);
|
||||
_ArmoredVehicle = new DrawingTank(rnd.nextInt(100, 300),
|
||||
rnd.nextInt(1000, 2000),
|
||||
newColor,
|
||||
newColorDop,
|
||||
1==rnd.nextInt(0, 2), 1==rnd.nextInt(0, 2));
|
||||
SetData();
|
||||
Draw();
|
||||
}//GEN-LAST:event_CreateTankButtonMouseClicked
|
||||
|
||||
private void SetButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SetButtonMouseClicked
|
||||
if (_ArmoredVehicle != null) {
|
||||
SelectedMachine = _ArmoredVehicle;
|
||||
dispose();
|
||||
}
|
||||
}//GEN-LAST:event_SetButtonMouseClicked
|
||||
|
||||
private void Draw()
|
||||
{
|
||||
Graphics g = DrawPanel.getGraphics();
|
||||
g.drawImage(Pic(), 0, 0, this);
|
||||
}
|
||||
private void createUIComponents() {
|
||||
DrawPanel = new JPanel() {
|
||||
@Override
|
||||
public void paintComponent(Graphics g) {
|
||||
Draw();
|
||||
}
|
||||
};
|
||||
}
|
||||
Image Pic()
|
||||
{
|
||||
BufferedImage img = new BufferedImage(DrawPanel.getWidth(), DrawPanel.getHeight(), BufferedImage.TYPE_INT_BGR);
|
||||
Graphics2D gr = img.createGraphics();
|
||||
gr.setBackground(Color.yellow);
|
||||
_ArmoredVehicle.DrawTransport(gr);
|
||||
return img;
|
||||
}
|
||||
// public static void main(String args[]) {
|
||||
// /* Set the Nimbus look and feel */
|
||||
// //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
|
||||
// /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
|
||||
// * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
|
||||
// */
|
||||
// try {
|
||||
// for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
|
||||
// if ("Nimbus".equals(info.getName())) {
|
||||
// javax.swing.UIManager.setLookAndFeel(info.getClassName());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// } catch (ClassNotFoundException ex) {
|
||||
// java.util.logging.Logger.getLogger(MapForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
// } catch (InstantiationException ex) {
|
||||
// java.util.logging.Logger.getLogger(MapForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
// } catch (IllegalAccessException ex) {
|
||||
// java.util.logging.Logger.getLogger(MapForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
// } catch (javax.swing.UnsupportedLookAndFeelException ex) {
|
||||
// java.util.logging.Logger.getLogger(MapForm.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
|
||||
// }
|
||||
// //</editor-fold>
|
||||
//
|
||||
// /* Create and display the form */
|
||||
// java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
// public void run() {
|
||||
// new MapForm().setVisible(true);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private java.awt.Button CreateButton;
|
||||
private java.awt.Button CreateTankButton;
|
||||
private java.awt.Button DownButton;
|
||||
private javax.swing.JPanel DrawPanel;
|
||||
private java.awt.Button LeftButton;
|
||||
private java.awt.TextField PropertyText;
|
||||
private java.awt.Button RightButton;
|
||||
private java.awt.Button SetButton;
|
||||
private java.awt.Button UpButton;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
}
|
@ -2,73 +2,47 @@
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
public class Roller extends JPanel{
|
||||
/// <summary>
|
||||
/// Количество катоков
|
||||
/// </summary>
|
||||
public int _count;
|
||||
/// <summary>
|
||||
/// Цвет
|
||||
/// </summary>
|
||||
private Color _color;
|
||||
/// <summary>
|
||||
/// Левая координата отрисовки
|
||||
/// </summary>
|
||||
private float _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната отрисовки
|
||||
/// </summary>
|
||||
private float _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина поля под катки
|
||||
/// </summary>
|
||||
private float _Width;
|
||||
/// <summary>
|
||||
/// Перечисление
|
||||
/// </summary>
|
||||
private CountRollers rolls;
|
||||
|
||||
public void Init(int Count, Color color, float startPosX, float startPosY, float Width)
|
||||
public class Roller implements IDrawingRoller {
|
||||
private Color color;
|
||||
private CountRollers rolls;
|
||||
public Roller(Color bodyColor)
|
||||
{
|
||||
color = bodyColor;
|
||||
}
|
||||
@Override
|
||||
public void setCount(int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
_count = Count;
|
||||
_color = color;
|
||||
_startPosX = startPosX;
|
||||
_startPosY = startPosY;
|
||||
_Width = Width;
|
||||
Count(_count);
|
||||
}
|
||||
|
||||
private void Count(int c)
|
||||
{
|
||||
switch (c)
|
||||
{
|
||||
case 4 -> rolls = CountRollers.Four;
|
||||
case 5 -> rolls = CountRollers.Five;
|
||||
case 6 -> rolls = CountRollers.Six;
|
||||
}
|
||||
}
|
||||
public void paint(Graphics gr)
|
||||
case 4 -> rolls = CountRollers.Four;
|
||||
case 5 -> rolls = CountRollers.Five;
|
||||
case 6 -> rolls = CountRollers.Six;
|
||||
default -> {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void DrawRoller(Graphics2D gr, int startPosX, int startPosY, int Width, int count)
|
||||
{
|
||||
setCount(count);
|
||||
Graphics2D g = (Graphics2D) gr;
|
||||
Color color = _color != null ?
|
||||
_color : Color.BLACK;
|
||||
color = color != null ? color : Color.BLACK;
|
||||
g.setColor(color);
|
||||
//g.setColor(Color.BLUE);
|
||||
int count = 0;
|
||||
switch (rolls)
|
||||
{
|
||||
case Four -> count = 4;
|
||||
case Five -> count = 5;
|
||||
case Six -> count = 6;
|
||||
}
|
||||
int ras = (int)_Width /count;
|
||||
int ras = (int)Width /count;
|
||||
|
||||
for (int i = 0; i < count; i += 1)
|
||||
{
|
||||
g.drawOval((int)_startPosX+ i*ras + 15, (int)_startPosY + 35, 20, 20);
|
||||
g.drawOval((int)startPosX+ i*ras + 15, (int)startPosY + 35, 20, 20);
|
||||
}
|
||||
g.dispose();
|
||||
}
|
||||
|
||||
}
|
||||
|
68
ArmoredVehicle/src/SetArmoredCarsGeneric.java
Normal file
68
ArmoredVehicle/src/SetArmoredCarsGeneric.java
Normal file
@ -0,0 +1,68 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
|
||||
public class SetArmoredCarsGeneric<T> implements Iterable<T>{
|
||||
private ArrayList<T> _places;
|
||||
private int _MaxCount;
|
||||
public SetArmoredCarsGeneric(int count)
|
||||
{
|
||||
_MaxCount = count;
|
||||
_places = new ArrayList<T>(_MaxCount);
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return _places.isEmpty() ? 0 : _places.size();
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
_places.clear();
|
||||
}
|
||||
|
||||
public int Insert(T armoredCar) throws StorageOverflowException
|
||||
{
|
||||
if(_places.size()+1 <= _MaxCount) return Insert(armoredCar, 0);
|
||||
else return -1;
|
||||
}
|
||||
|
||||
public int Insert(T armoredCar, int position) throws StorageOverflowException
|
||||
{
|
||||
if ((position < 0 || position > getCount()))
|
||||
return -1;
|
||||
_places.add(position, armoredCar);
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
public T Remove(int position) throws MachineNotFoundException
|
||||
{
|
||||
if (position < 0 || position >= getCount())
|
||||
throw new MachineNotFoundException(position);
|
||||
if (_places.get(position) == null)
|
||||
throw new MachineNotFoundException(position);
|
||||
T armoredCar = _places.get(position);
|
||||
_places.set(position, null);
|
||||
|
||||
return armoredCar;
|
||||
}
|
||||
|
||||
public T Get(int position)
|
||||
{
|
||||
if (position < 0 || position >= getCount())
|
||||
return null;
|
||||
return _places.get(position);
|
||||
}
|
||||
public void Set(int position, T value){
|
||||
if (position < 0 || position + 1 >= getCount())
|
||||
return;
|
||||
try {
|
||||
Insert(value, position);
|
||||
} catch (StorageOverflowException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<T> iterator() {
|
||||
return _places.iterator();
|
||||
}
|
||||
}
|
43
ArmoredVehicle/src/SimpleMap.java
Normal file
43
ArmoredVehicle/src/SimpleMap.java
Normal file
@ -0,0 +1,43 @@
|
||||
import java.awt.*;
|
||||
|
||||
public class SimpleMap extends AbstractMap{
|
||||
private final Color barrierColor = Color.RED;
|
||||
private final Color roadColor = Color.WHITE;
|
||||
@Override
|
||||
protected void GenerateMap() {
|
||||
map = new int[100][100];
|
||||
size_x = (float)width / map.length;
|
||||
size_y = (float)height / map[0].length;
|
||||
int counter = 0;
|
||||
for (int i = 0; i < map.length; ++i)
|
||||
{
|
||||
for (int j = 0; j < map[0].length; ++j)
|
||||
{
|
||||
map[i][j] = _freeRoad;
|
||||
}
|
||||
}
|
||||
while (counter < 50)
|
||||
{
|
||||
int x = random.nextInt(100);
|
||||
int y = random.nextInt(100);
|
||||
if (map[x][y] == _freeRoad)
|
||||
{
|
||||
map[x][y] = _barrier;
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void DrawRoadPart(Graphics2D gc, int i, int j) {
|
||||
gc.setColor(Color.GRAY);
|
||||
gc.fillRect(i * (int)size_x, j * (int)size_y, i * ((int)size_x + 1), j * ((int)size_y + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void DrawBarrierPart(Graphics2D gc, int i, int j) {
|
||||
gc.setColor(Color.BLACK);
|
||||
gc.fillRect(i * (int)size_x, j * (int)size_y, i * ((int)size_x + 1), j * ((int)size_y + 1));
|
||||
}
|
||||
}
|
5
ArmoredVehicle/src/StorageOverflowException.java
Normal file
5
ArmoredVehicle/src/StorageOverflowException.java
Normal file
@ -0,0 +1,5 @@
|
||||
public class StorageOverflowException extends Exception {
|
||||
public StorageOverflowException(int count){
|
||||
super("В наборе превышено допустимое количество: "+count);
|
||||
}
|
||||
}
|
37
ArmoredVehicle/src/TankEntity.java
Normal file
37
ArmoredVehicle/src/TankEntity.java
Normal file
@ -0,0 +1,37 @@
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
public class TankEntity extends ArmoredVehicleEntity {
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="dopColor">Дополнительный цвет</param>
|
||||
/// <param name="MachineGun">Признак наличия пулемета</param>
|
||||
/// <param name="Tower">Признак наличия башни</param>
|
||||
/// <param name="Gun">Признак наличия орудия</param>
|
||||
|
||||
public TankEntity(int speed, float weight, Color bodyColor, Color dopColor,
|
||||
boolean machineGun, boolean tower)
|
||||
{
|
||||
super(speed, weight, bodyColor);
|
||||
DopColor = dopColor;
|
||||
MachineGun = machineGun;
|
||||
Tower = tower;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Дополнительный цвет
|
||||
/// </summary>
|
||||
public Color DopColor;
|
||||
/// <summary>
|
||||
/// Признак наличия пулемета
|
||||
/// </summary>
|
||||
public boolean MachineGun;
|
||||
/// <summary>
|
||||
/// Признак наличия башни
|
||||
/// </summary>
|
||||
public boolean Tower;
|
||||
}
|
55
ArmoredVehicle/src/VerticalMap.java
Normal file
55
ArmoredVehicle/src/VerticalMap.java
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics2D;
|
||||
|
||||
|
||||
public class VerticalMap extends AbstractMap{
|
||||
private final Color barrierColor = Color.BLUE;
|
||||
private final Color roadColor = Color.WHITE;
|
||||
@Override
|
||||
protected void GenerateMap() {
|
||||
map = new int[50][50];
|
||||
size_x = (float)width / map.length;
|
||||
size_y = (float)height / map[0].length;
|
||||
int counter = 0;
|
||||
for (int i = 0; i < map.length; ++i)
|
||||
{
|
||||
for (int j = 0; j < map[0].length; ++j)
|
||||
{
|
||||
map[i][j] = _freeRoad;
|
||||
}
|
||||
}
|
||||
while (counter < 7)
|
||||
{
|
||||
int x1 = random.nextInt(12);
|
||||
int x2 = random.nextInt(12, map[0].length);
|
||||
|
||||
int y1 = random.nextInt(12, map[1].length);
|
||||
|
||||
for (int i = x1; i < x2; i++)
|
||||
{
|
||||
if (map[y1][i] == _freeRoad)
|
||||
{
|
||||
map[y1][i] = _barrier;
|
||||
}
|
||||
}
|
||||
|
||||
counter++;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void DrawRoadPart(Graphics2D gc, int i, int j) {
|
||||
gc.setColor(roadColor);
|
||||
gc.fillRect(i * (int)size_x, j * (int)size_y, i * ((int)size_x + 1), j * ((int)size_y + 1));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void DrawBarrierPart(Graphics2D gc, int i, int j) {
|
||||
gc.setColor(barrierColor);
|
||||
gc.fillRect(i * (int)size_x, j * (int)size_y, i * ((int)size_x + 1), j * ((int)size_y + 1));
|
||||
}
|
||||
}
|
9
ArmoredVehicle/src/log.config
Normal file
9
ArmoredVehicle/src/log.config
Normal file
@ -0,0 +1,9 @@
|
||||
handlers = java.util.logging.FileHandler
|
||||
|
||||
java.util.logging.FileHandler.level = INFO
|
||||
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
|
||||
java.util.logging.FileHandler.append = true
|
||||
java.util.logging.FileHandler.pattern = log.txt
|
||||
|
||||
java.util.logging.ConsoleHandler.level = INFO
|
||||
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
|
Loading…
x
Reference in New Issue
Block a user