antihype commit
This commit is contained in:
parent
f5247f6ce8
commit
5f914ddb22
@ -1,7 +1,8 @@
|
|||||||
package src.DrawningObjects;
|
package src.DrawningObjects;
|
||||||
|
|
||||||
import src.DirectionType;
|
import src.DirectionType;
|
||||||
import src.Entities.EntityAirplane;
|
import src.Entities.EntityAirplane;
|
||||||
|
import src.MovementStrategy.DrawningObjectAirplane;
|
||||||
|
import src.MovementStrategy.IMoveableObject;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -68,12 +69,17 @@ public class DrawningAirplane {
|
|||||||
return;
|
return;
|
||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
|
DrawningIlluminators.ChangeX(_startPosX);
|
||||||
|
DrawningIlluminators.ChangeY(_startPosY);
|
||||||
if (x < 0 || y < 0 || x + _airplaneWidth >= _pictureWidth || y + _airplaneHeight >= _pictureHeight) {
|
if (x < 0 || y < 0 || x + _airplaneWidth >= _pictureWidth || y + _airplaneHeight >= _pictureHeight) {
|
||||||
x = y = 10;
|
x = y = 10;
|
||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public IMoveableObject GetMoveableObject(){
|
||||||
|
return new DrawningObjectAirplane(this);
|
||||||
|
}
|
||||||
public int GetPosX(){return _startPosX;}
|
public int GetPosX(){return _startPosX;}
|
||||||
public int GetPosY(){return _startPosY;}
|
public int GetPosY(){return _startPosY;}
|
||||||
public int GetWidth(){return _airplaneWidth;}
|
public int GetWidth(){return _airplaneWidth;}
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package src;
|
package src;
|
||||||
|
|
||||||
import src.DrawningObjects.DrawningAirplane;
|
import src.DrawningObjects.DrawningAirplane;
|
||||||
|
|
||||||
import src.MovementStrategy.*;
|
import src.MovementStrategy.*;
|
||||||
import src.DrawningObjects.DrawningAirplaneWithRadar;
|
import src.DrawningObjects.DrawningAirplaneWithRadar;
|
||||||
|
import org.w3c.dom.ranges.DocumentRange;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@ -17,16 +16,25 @@ public class FormAirplaneWithRadar {
|
|||||||
Canvas canv;
|
Canvas canv;
|
||||||
static int pictureBoxWidth = 882;
|
static int pictureBoxWidth = 882;
|
||||||
static int pictureBoxHeight = 453;
|
static int pictureBoxHeight = 453;
|
||||||
|
public JButton buttonSelect;
|
||||||
|
public JFrame AirplaneFrame;
|
||||||
public void Draw(){
|
public void Draw(){
|
||||||
canv.repaint();
|
canv.repaint();
|
||||||
}
|
}
|
||||||
|
public Color ChooseColor(JFrame MonorailFrame){
|
||||||
|
JColorChooser dialog = new JColorChooser();
|
||||||
|
Color res = JColorChooser.showDialog(MonorailFrame, "Выберите цвет", Color.WHITE);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
public DrawningAirplane SelectedAirplane(){
|
||||||
|
return DrawningAirplane;
|
||||||
|
}
|
||||||
public FormAirplaneWithRadar(){
|
public FormAirplaneWithRadar(){
|
||||||
JFrame MonorailFrame =new JFrame ();
|
AirplaneFrame =new JFrame ();
|
||||||
JButton buttonCreate = new JButton("Создать");
|
JButton buttonCreate = new JButton("Создать");
|
||||||
JButton buttonCreateLocomotive = new JButton("Создать самолет с радаром");
|
JButton buttonCreateLocomotive = new JButton("Создать самолет с радаром");
|
||||||
JButton buttonStep = new JButton("Шаг");
|
JButton buttonStep = new JButton("Шаг");
|
||||||
|
buttonSelect = new JButton ("Выбрать");
|
||||||
JComboBox comboBoxStrategy = new JComboBox(
|
JComboBox comboBoxStrategy = new JComboBox(
|
||||||
new String[]{
|
new String[]{
|
||||||
"Довести до центра",
|
"Довести до центра",
|
||||||
@ -89,8 +97,13 @@ public class FormAirplaneWithRadar {
|
|||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
Color color = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256));
|
||||||
|
Color choosen = ChooseColor(AirplaneFrame);
|
||||||
|
if(choosen != null){
|
||||||
|
color = choosen;
|
||||||
|
}
|
||||||
DrawningAirplane = new DrawningAirplane(random.nextInt(100, 300), random.nextDouble(1000, 3000),
|
DrawningAirplane = new DrawningAirplane(random.nextInt(100, 300), random.nextDouble(1000, 3000),
|
||||||
Color.getHSBColor(random.nextInt(0, 301), random.nextInt(0, 301), random.nextInt(0, 301)),
|
color,
|
||||||
pictureBoxWidth, pictureBoxHeight);
|
pictureBoxWidth, pictureBoxHeight);
|
||||||
canv.DrawningAirplane = DrawningAirplane;
|
canv.DrawningAirplane = DrawningAirplane;
|
||||||
comboBoxStrategy.enable(true);
|
comboBoxStrategy.enable(true);
|
||||||
@ -102,9 +115,19 @@ public class FormAirplaneWithRadar {
|
|||||||
new ActionListener() {
|
new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent e){
|
public void actionPerformed(ActionEvent e){
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
Color color = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256));
|
||||||
|
Color additionalColor = new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256));
|
||||||
|
Color choosen = ChooseColor(AirplaneFrame);
|
||||||
|
if(choosen != null){
|
||||||
|
color = choosen;
|
||||||
|
}
|
||||||
|
choosen = ChooseColor(AirplaneFrame);
|
||||||
|
if(choosen != null){
|
||||||
|
additionalColor = choosen;
|
||||||
|
}
|
||||||
DrawningAirplane = new DrawningAirplaneWithRadar(random.nextInt(100, 300), random.nextDouble(1000, 3000),
|
DrawningAirplane = new DrawningAirplaneWithRadar(random.nextInt(100, 300), random.nextDouble(1000, 3000),
|
||||||
Color.getHSBColor(random.nextInt(0, 301), random.nextInt(0, 301), random.nextInt(0, 301)),
|
color,
|
||||||
Color.getHSBColor(random.nextInt(0, 301), random.nextInt(0, 301), random.nextInt(0, 301)),
|
additionalColor,
|
||||||
random.nextBoolean(), random.nextBoolean(),
|
random.nextBoolean(), random.nextBoolean(),
|
||||||
pictureBoxWidth, pictureBoxHeight);
|
pictureBoxWidth, pictureBoxHeight);
|
||||||
canv.DrawningAirplane = DrawningAirplane;
|
canv.DrawningAirplane = DrawningAirplane;
|
||||||
@ -151,11 +174,12 @@ public class FormAirplaneWithRadar {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
MonorailFrame.setSize (900, 500);
|
AirplaneFrame.setSize (900, 500);
|
||||||
MonorailFrame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
|
AirplaneFrame.setDefaultCloseOperation (JFrame.DISPOSE_ON_CLOSE);
|
||||||
MonorailFrame.setLayout(null);
|
AirplaneFrame.setLayout(null);
|
||||||
canv = new Canvas();
|
canv = new Canvas();
|
||||||
canv.setSize(pictureBoxWidth, pictureBoxHeight);
|
canv.setSize(pictureBoxWidth, pictureBoxHeight);
|
||||||
|
buttonSelect.setBounds(383,401, 180, 40);
|
||||||
buttonCreate.setBounds(198, 401, 180, 40);
|
buttonCreate.setBounds(198, 401, 180, 40);
|
||||||
buttonCreateLocomotive.setBounds(12, 401, 180, 40);
|
buttonCreateLocomotive.setBounds(12, 401, 180, 40);
|
||||||
RightButton.setBounds(840,411,30,30);
|
RightButton.setBounds(840,411,30,30);
|
||||||
@ -164,16 +188,17 @@ public class FormAirplaneWithRadar {
|
|||||||
DownButton.setBounds(804,411,30,30);
|
DownButton.setBounds(804,411,30,30);
|
||||||
comboBoxStrategy.setBounds(719,12,151,28);
|
comboBoxStrategy.setBounds(719,12,151,28);
|
||||||
buttonStep.setBounds(768, 46, 94, 29);
|
buttonStep.setBounds(768, 46, 94, 29);
|
||||||
MonorailFrame.add(canv);
|
AirplaneFrame.add(canv);
|
||||||
MonorailFrame.add(buttonCreate);
|
AirplaneFrame.add(buttonCreate);
|
||||||
MonorailFrame.add(buttonCreateLocomotive);
|
AirplaneFrame.add(buttonCreateLocomotive);
|
||||||
MonorailFrame.add(UpButton);
|
AirplaneFrame.add(UpButton);
|
||||||
MonorailFrame.add(DownButton);
|
AirplaneFrame.add(DownButton);
|
||||||
MonorailFrame.add(LeftButton);
|
AirplaneFrame.add(LeftButton);
|
||||||
MonorailFrame.add(RightButton);
|
AirplaneFrame.add(RightButton);
|
||||||
MonorailFrame.add(comboBoxStrategy);
|
AirplaneFrame.add(comboBoxStrategy);
|
||||||
MonorailFrame.add(buttonStep);
|
AirplaneFrame.add(buttonStep);
|
||||||
MonorailFrame.setVisible(true);
|
AirplaneFrame.add(buttonSelect);
|
||||||
|
AirplaneFrame.setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Canvas extends JComponent{
|
class Canvas extends JComponent{
|
||||||
|
@ -14,6 +14,7 @@ import javax.swing.*;
|
|||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
FormAirplaneWithRadar form = new FormAirplaneWithRadar();
|
FormAirplaneCollection form =new FormAirplaneCollection();
|
||||||
|
//FormForHard form = new FormForHard();
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user