Лабораторная работа №1 Изменения
This commit is contained in:
parent
4980d40df3
commit
48e5277680
@ -16,6 +16,7 @@ public class DrawningAirbus {
|
|||||||
private Integer pictureHeight;
|
private Integer pictureHeight;
|
||||||
private Integer startPosX;
|
private Integer startPosX;
|
||||||
private Integer startPosY;
|
private Integer startPosY;
|
||||||
|
private DrawningWindows drawningWindows;
|
||||||
|
|
||||||
private final int drawningAirbusWidth = 155;
|
private final int drawningAirbusWidth = 155;
|
||||||
private final int drawningAirbusHeight = 70;
|
private final int drawningAirbusHeight = 70;
|
||||||
@ -24,9 +25,14 @@ public class DrawningAirbus {
|
|||||||
return entityAirbus;
|
return entityAirbus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, boolean passengerSection, boolean engines) {
|
public DrawningWindows getDrawningWindows() {
|
||||||
|
return drawningWindows;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, boolean passengerSection, boolean engines, boolean windows) {
|
||||||
entityAirbus = new EntityAirbus();
|
entityAirbus = new EntityAirbus();
|
||||||
entityAirbus.Init(speed, weight, bodyColor, additionalColor, passengerSection, engines);
|
entityAirbus.Init(speed, weight, bodyColor, additionalColor, passengerSection, engines, windows);
|
||||||
|
drawningWindows = new DrawningWindows();
|
||||||
pictureWidth = null;
|
pictureWidth = null;
|
||||||
pictureHeight = null;
|
pictureHeight = null;
|
||||||
startPosX = null;
|
startPosX = null;
|
||||||
@ -158,5 +164,9 @@ public class DrawningAirbus {
|
|||||||
g.fillOval(startPosX, startPosY + 30, 35, 15);
|
g.fillOval(startPosX, startPosY + 30, 35, 15);
|
||||||
g.strokeOval(startPosX, startPosY + 30, 35, 15);
|
g.strokeOval(startPosX, startPosY + 30, 35, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(entityAirbus.getWindows()) {
|
||||||
|
drawningWindows.drawWindows(g, startPosX + 40, startPosY + 35, entityAirbus.getAdditionalColor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -54,6 +54,11 @@ public class EntityAirbus {
|
|||||||
return engines;
|
return engines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean windows;
|
||||||
|
public boolean getWindows() {
|
||||||
|
return windows;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Шаг перемещения аэробуса
|
* Шаг перемещения аэробуса
|
||||||
*/
|
*/
|
||||||
@ -70,12 +75,13 @@ public class EntityAirbus {
|
|||||||
* @param passengerSection Признак(опция) наличия доп. пассажирского отсека
|
* @param passengerSection Признак(опция) наличия доп. пассажирского отсека
|
||||||
* @param engines Признак(опция) наличия доп. двигателей
|
* @param engines Признак(опция) наличия доп. двигателей
|
||||||
*/
|
*/
|
||||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, boolean passengerSection, boolean engines) {
|
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, boolean passengerSection, boolean engines, boolean windows) {
|
||||||
this.speed = speed;
|
this.speed = speed;
|
||||||
this.weight = weight;
|
this.weight = weight;
|
||||||
this.bodyColor = bodyColor;
|
this.bodyColor = bodyColor;
|
||||||
this.additionalColor = additionalColor;
|
this.additionalColor = additionalColor;
|
||||||
this.passengerSection = passengerSection;
|
this.passengerSection = passengerSection;
|
||||||
this.engines = engines;
|
this.engines = engines;
|
||||||
|
this.windows = windows;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,8 @@ import javafx.fxml.FXML;
|
|||||||
import javafx.scene.canvas.Canvas;
|
import javafx.scene.canvas.Canvas;
|
||||||
import javafx.scene.canvas.GraphicsContext;
|
import javafx.scene.canvas.GraphicsContext;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
|
import javafx.scene.control.Spinner;
|
||||||
|
import javafx.scene.control.SpinnerValueFactory;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -17,12 +19,17 @@ public class FormAirbus {
|
|||||||
@FXML
|
@FXML
|
||||||
private Canvas mainCanvas;
|
private Canvas mainCanvas;
|
||||||
|
|
||||||
|
@FXML
|
||||||
|
private Spinner<Integer> spinnerSelector;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
private void initialize() {
|
private void initialize() {
|
||||||
drawningAirbus = new DrawningAirbus();
|
drawningAirbus = new DrawningAirbus();
|
||||||
graphicsContext = mainCanvas.getGraphicsContext2D();
|
graphicsContext = mainCanvas.getGraphicsContext2D();
|
||||||
graphicsContext.setImageSmoothing(false);
|
graphicsContext.setImageSmoothing(false);
|
||||||
|
|
||||||
|
spinnerSelector.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(10, 30, 10, 10));
|
||||||
|
|
||||||
random = new Random();
|
random = new Random();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,8 +43,9 @@ public class FormAirbus {
|
|||||||
random.nextInt(100, 300), random.nextInt(1000, 3000),
|
random.nextInt(100, 300), random.nextInt(1000, 3000),
|
||||||
Color.rgb(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
Color.rgb(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
||||||
Color.rgb(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
Color.rgb(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
||||||
random.nextBoolean(), random.nextBoolean()
|
random.nextBoolean(), random.nextBoolean(), random.nextBoolean()
|
||||||
);
|
);
|
||||||
|
drawningAirbus.getDrawningWindows().setSpinnerBlockCount(spinnerSelector.getValue());
|
||||||
drawningAirbus.setPictureSize((int) mainCanvas.getWidth(), (int) mainCanvas.getHeight());
|
drawningAirbus.setPictureSize((int) mainCanvas.getWidth(), (int) mainCanvas.getHeight());
|
||||||
drawningAirbus.setPosition(random.nextInt(10, 100), random.nextInt(10, 100));
|
drawningAirbus.setPosition(random.nextInt(10, 100), random.nextInt(10, 100));
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
<?import javafx.scene.canvas.Canvas?>
|
<?import javafx.scene.canvas.Canvas?>
|
||||||
<?import javafx.scene.control.Button?>
|
<?import javafx.scene.control.Button?>
|
||||||
|
<?import javafx.scene.control.Spinner?>
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
<?import javafx.scene.layout.AnchorPane?>
|
||||||
<?import javafx.scene.text.Font?>
|
<?import javafx.scene.text.Font?>
|
||||||
|
|
||||||
@ -16,5 +17,6 @@
|
|||||||
<Button id="buttonUp" layoutX="807.0" layoutY="452.0" mnemonicParsing="false" onAction="#buttonMove_Click" prefHeight="35.0" prefWidth="35.0" AnchorPane.bottomAnchor="55.199999999999974" AnchorPane.rightAnchor="57.600000000000065" />
|
<Button id="buttonUp" layoutX="807.0" layoutY="452.0" mnemonicParsing="false" onAction="#buttonMove_Click" prefHeight="35.0" prefWidth="35.0" AnchorPane.bottomAnchor="55.199999999999974" AnchorPane.rightAnchor="57.600000000000065" />
|
||||||
<Button id="buttonLeft" layoutX="764.0" layoutY="452.0" mnemonicParsing="false" onAction="#buttonMove_Click" prefHeight="35.0" prefWidth="35.0" AnchorPane.bottomAnchor="12.800000000000011" AnchorPane.rightAnchor="100.79999999999995" />
|
<Button id="buttonLeft" layoutX="764.0" layoutY="452.0" mnemonicParsing="false" onAction="#buttonMove_Click" prefHeight="35.0" prefWidth="35.0" AnchorPane.bottomAnchor="12.800000000000011" AnchorPane.rightAnchor="100.79999999999995" />
|
||||||
<Button id="buttonDown" layoutX="807.0" layoutY="452.0" mnemonicParsing="false" onAction="#buttonMove_Click" prefHeight="35.0" prefWidth="35.0" AnchorPane.bottomAnchor="12.800000000000011" AnchorPane.rightAnchor="57.799999999999955" />
|
<Button id="buttonDown" layoutX="807.0" layoutY="452.0" mnemonicParsing="false" onAction="#buttonMove_Click" prefHeight="35.0" prefWidth="35.0" AnchorPane.bottomAnchor="12.800000000000011" AnchorPane.rightAnchor="57.799999999999955" />
|
||||||
|
<Spinner fx:id="spinnerSelector" layoutX="15.0" layoutY="415.0" prefHeight="26.0" prefWidth="74.0" />
|
||||||
</children>
|
</children>
|
||||||
</AnchorPane>
|
</AnchorPane>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user