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