Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
3620ff93c4 | |||
9b085d63dd | |||
90f708dc78 | |||
4f332375a5 | |||
0c64c0df9b | |||
b28d6d2993 | |||
9aac507fce | |||
56f57afc19 | |||
ad362f0fab | |||
9d85732740 | |||
5cae31af03 | |||
6a421a6fc7 | |||
4ccf6834d6 | |||
ea9980c65a | |||
64d698b9ed | |||
fc4e673492 | |||
f217bdcff2 | |||
c6a896b04c | |||
0402abec1d |
7
.idea/encodings.xml
generated
Normal file
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
8
.idea/inspectionProfiles/Project_Default.xml
generated
Normal file
@ -0,0 +1,8 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="EnhancedSwitchMigration" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="myMaxNumberStatementsForBranch" value="1" />
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
124
.idea/uiDesigner.xml
generated
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
3
pom.xml
@ -75,7 +75,8 @@
|
||||
<!-- Default configuration for running with: mvn clean javafx:run -->
|
||||
<id>default-cli</id>
|
||||
<configuration>
|
||||
<mainClass>kvr.missilecruiser_hard/kvr.missilecruiser_hard.ApplicationMissileCruiser</mainClass>
|
||||
<mainClass>kvr.missilecruiser_hard/kvr.missilecruiser_hard.Main</mainClass>
|
||||
<commandlineArgs>-disable_hidpi</commandlineArgs>
|
||||
<launcher>app</launcher>
|
||||
<jlinkZipName>app</jlinkZipName>
|
||||
<jlinkImageName>app</jlinkImageName>
|
||||
|
@ -6,18 +6,27 @@ import javafx.scene.Scene;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ApplicationMissileCruiser extends Application {
|
||||
public class ApplicationMissileCruiser extends Application
|
||||
{
|
||||
@Override
|
||||
public void start(Stage stage) throws IOException {
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(ApplicationMissileCruiser.class.getResource("ViewMissileCruiser.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load(), 320, 240);
|
||||
stage.setTitle("Hello!");
|
||||
public void start(Stage stage) throws IOException
|
||||
{
|
||||
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("ViewMissileCruiser.fxml"));
|
||||
Scene scene = new Scene(fxmlLoader.load(), 900, 500);
|
||||
|
||||
String stylesheet = Objects.requireNonNull(getClass().getResource("StylesMissileCruiser.css")).toExternalForm();
|
||||
scene.getStylesheets().add(stylesheet);
|
||||
|
||||
stage.setResizable(false);
|
||||
stage.setTitle("Ракетный крейсер");
|
||||
|
||||
stage.setScene(scene);
|
||||
stage.show();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
launch();
|
||||
public static void run(String[] args) {
|
||||
launch(args);
|
||||
}
|
||||
}
|
@ -1,14 +1,74 @@
|
||||
package kvr.missilecruiser_hard;
|
||||
|
||||
import javafx.event.ActionEvent;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Spinner;
|
||||
import javafx.scene.control.SpinnerValueFactory.IntegerSpinnerValueFactory;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.canvas.Canvas;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
|
||||
public class ControllerMissileCruiser {
|
||||
@FXML
|
||||
private Label welcomeText;
|
||||
import java.util.Random;
|
||||
|
||||
public class ControllerMissileCruiser
|
||||
{
|
||||
private DrawingMissileCruiser drawingMissileCruiser;
|
||||
private GraphicsContext graphicsContext;
|
||||
private Random random;
|
||||
|
||||
@FXML
|
||||
protected void onHelloButtonClick() {
|
||||
welcomeText.setText("Welcome to JavaFX Application!");
|
||||
private Canvas mainCanvas;
|
||||
|
||||
@FXML
|
||||
private Spinner<Integer> spinnerVlsSelector;
|
||||
|
||||
@FXML
|
||||
private void initialize() {
|
||||
drawingMissileCruiser = new DrawingMissileCruiser();
|
||||
graphicsContext = mainCanvas.getGraphicsContext2D();
|
||||
graphicsContext.setImageSmoothing(false);
|
||||
|
||||
spinnerVlsSelector.setValueFactory(new IntegerSpinnerValueFactory(2, 6, 2, 2));
|
||||
|
||||
random = new Random();
|
||||
}
|
||||
|
||||
private void DrawOnCanvas(){
|
||||
drawingMissileCruiser.DrawTransport(graphicsContext);
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void buttonCreate_Click() {
|
||||
drawingMissileCruiser.Init(
|
||||
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)),
|
||||
random.nextBoolean(), random.nextBoolean()
|
||||
);
|
||||
drawingMissileCruiser.getDrawingVLS().setVlsBlockCount(spinnerVlsSelector.getValue());
|
||||
|
||||
drawingMissileCruiser.SetPictureSize((int) mainCanvas.getWidth(), (int) mainCanvas.getHeight());
|
||||
drawingMissileCruiser.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100));
|
||||
|
||||
DrawOnCanvas();
|
||||
}
|
||||
|
||||
@FXML
|
||||
protected void buttonsMove_Click(ActionEvent event) {
|
||||
String name = ((Button) event.getSource()).getId();
|
||||
|
||||
boolean result = switch (name) {
|
||||
case "buttonUp" -> drawingMissileCruiser.MoveTransport(DirectionType.Up);
|
||||
case "buttonDown" -> drawingMissileCruiser.MoveTransport(DirectionType.Down);
|
||||
case "buttonLeft" -> drawingMissileCruiser.MoveTransport(DirectionType.Left);
|
||||
case "buttonRight" -> drawingMissileCruiser.MoveTransport(DirectionType.Right);
|
||||
default -> false;
|
||||
};
|
||||
|
||||
if (result)
|
||||
{
|
||||
DrawOnCanvas();
|
||||
}
|
||||
}
|
||||
}
|
8
src/main/java/kvr/missilecruiser_hard/DirectionType.java
Normal file
@ -0,0 +1,8 @@
|
||||
package kvr.missilecruiser_hard;
|
||||
|
||||
public enum DirectionType {
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right
|
||||
}
|
183
src/main/java/kvr/missilecruiser_hard/DrawingMissileCruiser.java
Normal file
@ -0,0 +1,183 @@
|
||||
package kvr.missilecruiser_hard;
|
||||
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class DrawingMissileCruiser {
|
||||
private EntityMissileCruiser entityMissileCruiser;
|
||||
private DrawingVLS drawingVLS;
|
||||
|
||||
public EntityMissileCruiser getEntityMissileCruiser(){
|
||||
return entityMissileCruiser;
|
||||
}
|
||||
|
||||
public DrawingVLS getDrawingVLS() {
|
||||
return drawingVLS;
|
||||
}
|
||||
|
||||
private int pictureWidth;
|
||||
private int pictureHeight;
|
||||
private int posX;
|
||||
private int posY;
|
||||
|
||||
private final int entityWidth = 150;
|
||||
private final int entityHeight = 35;
|
||||
|
||||
/**
|
||||
* Инициализирует класс отрисовки и сущности
|
||||
* @param speed Скорость
|
||||
* @param weight Вес крейсера
|
||||
* @param primaryColor Основной цвет
|
||||
* @param secondaryColor Дополнительный цвет
|
||||
* @param vls Признак наличия установок вертикального пуска
|
||||
* @param helipad Признак наличия вертолётной площадки
|
||||
*/
|
||||
public void Init(int speed, int weight, Color primaryColor, Color secondaryColor, boolean vls, boolean helipad)
|
||||
{
|
||||
entityMissileCruiser = new EntityMissileCruiser();
|
||||
drawingVLS = new DrawingVLS();
|
||||
entityMissileCruiser.Init(speed, weight, primaryColor, secondaryColor, vls, helipad);
|
||||
pictureWidth = 0;
|
||||
pictureHeight = 0;
|
||||
posX = 0;
|
||||
posY = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установка границ поля где будет находится объект.
|
||||
* Если объект находится за пределами поля, то он будет отодвинут внутрь нового поля.
|
||||
* @param width Ширина поля
|
||||
* @param height Высота поля
|
||||
* @return true - границы заданы, false - проверка не пройдена, нельзя разместить объект в этих размерах
|
||||
*/
|
||||
public boolean SetPictureSize(int width, int height)
|
||||
{
|
||||
if (entityMissileCruiser == null || width <= 0 || height <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entityWidth < width && entityHeight < height)
|
||||
{
|
||||
pictureWidth = width;
|
||||
pictureHeight = height;
|
||||
|
||||
posX = Math.clamp(posX, 0, pictureWidth - entityWidth);
|
||||
posY = Math.clamp(posY, 0, pictureHeight - entityHeight);
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Установка позиции объекта
|
||||
* @param x Координата X
|
||||
* @param y Координата Y
|
||||
*/
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
if (pictureWidth == 0 || pictureHeight == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
posX = Math.clamp(x, 0, pictureWidth - entityWidth);
|
||||
posY = Math.clamp(y, 0, pictureHeight - entityHeight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Перемещение объекта в заданную сторону
|
||||
* @param direction Направление
|
||||
* @return true - перемещене выполнено, false - перемещение невозможно
|
||||
*/
|
||||
public boolean MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (entityMissileCruiser == null || pictureWidth <= 0 || pictureHeight <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int step = entityMissileCruiser.getStep();
|
||||
switch (direction)
|
||||
{
|
||||
case DirectionType.Left:
|
||||
if (posX - step >= 0)
|
||||
{
|
||||
posX -= step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Up:
|
||||
if (posY - step >= 0)
|
||||
{
|
||||
posY -= step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Right:
|
||||
if (posX + step < pictureWidth - entityWidth)
|
||||
{
|
||||
posX += step;
|
||||
}
|
||||
return true;
|
||||
case DirectionType.Down:
|
||||
if (posY + step < pictureHeight - entityHeight)
|
||||
{
|
||||
posY += step;
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static final Image cruiserContourImg = new Image(
|
||||
Objects.requireNonNull(DrawingMissileCruiser.class.getResource("images/cruiser_contour.png")).toExternalForm()
|
||||
);
|
||||
private static final Image helipadImg = new Image(
|
||||
Objects.requireNonNull(DrawingMissileCruiser.class.getResource("images/cruiser_helipad.png")).toExternalForm()
|
||||
);
|
||||
|
||||
/**
|
||||
* Прорисовка объекта
|
||||
* @param gc Объект GDI+
|
||||
*/
|
||||
public void DrawTransport(GraphicsContext gc)
|
||||
{
|
||||
if (entityMissileCruiser == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// FUCK JavaFX, I had to use SUBPIXEL offsets to not see artifacts of antialiasing, which you can't disable!
|
||||
double[] contourPolygonX = new double[] {
|
||||
posX + 10.75, posX + 116.25, posX + 150, posX + 116.25, posX + 10.75, posX + 0.5, posX + 0.5
|
||||
};
|
||||
double[] contourPolygonY = new double[] {
|
||||
posY + 0.5, posY + 0.5, posY + 17.5, posY + 34.5, posY + 34.5, posY + 29.5, posY + 5.5
|
||||
};
|
||||
|
||||
gc.clearRect(0, 0, pictureWidth, pictureHeight);
|
||||
|
||||
gc.setFill(entityMissileCruiser.getPrimaryColor());
|
||||
gc.fillPolygon(contourPolygonX, contourPolygonY, contourPolygonX.length);
|
||||
|
||||
if (entityMissileCruiser.getVLS())
|
||||
{
|
||||
drawingVLS.drawVLS(gc, posX, posY, entityMissileCruiser.getSecondaryColor());
|
||||
}
|
||||
if (entityMissileCruiser.getHelipad())
|
||||
{
|
||||
gc.setFill(entityMissileCruiser.getSecondaryColor());
|
||||
gc.fillOval(posX + 2.5, posY + 9.5, 16, 16);
|
||||
gc.drawImage(helipadImg, posX, posY, entityWidth, entityHeight);
|
||||
}
|
||||
|
||||
gc.drawImage(cruiserContourImg, posX, posY, entityWidth, entityHeight);
|
||||
}
|
||||
}
|
55
src/main/java/kvr/missilecruiser_hard/DrawingVLS.java
Normal file
@ -0,0 +1,55 @@
|
||||
package kvr.missilecruiser_hard;
|
||||
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class DrawingVLS {
|
||||
private VlsBlockCount vlsBlockCount;
|
||||
|
||||
public VlsBlockCount getVlsBlockCount() {
|
||||
return vlsBlockCount;
|
||||
}
|
||||
|
||||
public void setVlsBlockCount(int vlsBlockCount) {
|
||||
if (vlsBlockCount > 4) {
|
||||
this.vlsBlockCount = VlsBlockCount.six;
|
||||
} else if (vlsBlockCount > 2) {
|
||||
this.vlsBlockCount = VlsBlockCount.four;
|
||||
} else {
|
||||
this.vlsBlockCount = VlsBlockCount.two;
|
||||
}
|
||||
}
|
||||
|
||||
private final Image doubleVlsImage = new Image(
|
||||
Objects.requireNonNull(getClass().getResource("images/doubleVLS.png")).toExternalForm()
|
||||
);
|
||||
public void drawVLS(GraphicsContext gc, double x, double y, Color secondaryColor) {
|
||||
gc.setFill(secondaryColor);
|
||||
|
||||
switch (vlsBlockCount) {
|
||||
case VlsBlockCount.six:
|
||||
gc.fillRect(x + 43, y + 14, 12, 6);
|
||||
gc.fillRect(x + 57, y + 14, 12, 6);
|
||||
gc.drawImage(doubleVlsImage, x, y + 9);
|
||||
// lack of "break;" is intentional
|
||||
case VlsBlockCount.four:
|
||||
gc.fillRect(x + 43, y + 5, 12, 6);
|
||||
gc.fillRect(x + 57, y + 5, 12, 6);
|
||||
|
||||
gc.fillRect(x + 43, y + 23, 12, 6);
|
||||
gc.fillRect(x + 57, y + 23, 12, 6);
|
||||
|
||||
gc.drawImage(doubleVlsImage, x, y);
|
||||
gc.drawImage(doubleVlsImage, x, y + 18);
|
||||
break;
|
||||
case VlsBlockCount.two:
|
||||
gc.fillRect(x + 43, y + 14, 12, 6);
|
||||
gc.fillRect(x + 57, y + 14, 12, 6);
|
||||
gc.drawImage(doubleVlsImage, x, y + 9);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package kvr.missilecruiser_hard;
|
||||
|
||||
import javafx.scene.paint.Color;
|
||||
|
||||
public class EntityMissileCruiser {
|
||||
|
||||
/// Скорость
|
||||
private int speed;
|
||||
|
||||
public int getSpeed(){
|
||||
return speed;
|
||||
}
|
||||
|
||||
/// Вес
|
||||
private double weight;
|
||||
|
||||
public double getWeight(){
|
||||
return weight;
|
||||
}
|
||||
|
||||
/// Основной цвет
|
||||
private Color primaryColor;
|
||||
|
||||
public Color getPrimaryColor(){
|
||||
return primaryColor;
|
||||
}
|
||||
|
||||
/// Дополнительный цвет (для опциональных элементов)
|
||||
private Color secondaryColor;
|
||||
|
||||
public Color getSecondaryColor(){
|
||||
return secondaryColor;
|
||||
}
|
||||
|
||||
/// Установки вертикального пуска
|
||||
private boolean vls;
|
||||
|
||||
public boolean getVLS(){
|
||||
return vls;
|
||||
}
|
||||
|
||||
/// Вертолётная площадка
|
||||
private boolean helipad;
|
||||
|
||||
public boolean getHelipad(){
|
||||
return helipad;
|
||||
}
|
||||
|
||||
/// Шаг перемещения
|
||||
public int getStep() {
|
||||
return (int)(speed * 100 / weight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Инициализация полей объекта-класса ракетного крейсера
|
||||
* @param speed Скорость
|
||||
* @param weight Вес крейсера
|
||||
* @param primaryColor Основной цвет
|
||||
* @param secondaryColor Дополнительный цвет
|
||||
* @param vls Признак наличия установок вертикального пуска
|
||||
* @param helipad Признак наличия вертолётной площадки
|
||||
*/
|
||||
public void Init(int speed, int weight, Color primaryColor, Color secondaryColor, boolean vls, boolean helipad)
|
||||
{
|
||||
this.speed = speed;
|
||||
this.weight = weight;
|
||||
this.primaryColor = primaryColor;
|
||||
this.secondaryColor = secondaryColor;
|
||||
this.vls = vls;
|
||||
this.helipad = helipad;
|
||||
}
|
||||
}
|
13
src/main/java/kvr/missilecruiser_hard/Main.java
Normal file
@ -0,0 +1,13 @@
|
||||
package kvr.missilecruiser_hard;
|
||||
|
||||
public class Main
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
if (args.length > 0 && args[0].equals("-disable_hidpi")) {
|
||||
System.setProperty("prism.allowhidpi", "false");
|
||||
}
|
||||
|
||||
ApplicationMissileCruiser.run(args);
|
||||
}
|
||||
}
|
7
src/main/java/kvr/missilecruiser_hard/VlsBlockCount.java
Normal file
@ -0,0 +1,7 @@
|
||||
package kvr.missilecruiser_hard;
|
||||
|
||||
public enum VlsBlockCount {
|
||||
two,
|
||||
four,
|
||||
six
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
#buttonLeft
|
||||
{
|
||||
-fx-background-image: url("images/arrowLeft.png");
|
||||
-fx-background-size: 85%;
|
||||
-fx-background-position: center;
|
||||
-fx-background-repeat: space;
|
||||
}
|
||||
|
||||
#buttonUp
|
||||
{
|
||||
-fx-background-image: url("images/arrowUp.png");
|
||||
-fx-background-size: 85%;
|
||||
-fx-background-position: center;
|
||||
-fx-background-repeat: space;
|
||||
}
|
||||
|
||||
#buttonDown
|
||||
{
|
||||
-fx-background-image: url("images/arrowDown.png");
|
||||
-fx-background-size: 85%;
|
||||
-fx-background-position: center;
|
||||
-fx-background-repeat: space;
|
||||
}
|
||||
|
||||
#buttonRight
|
||||
{
|
||||
-fx-background-image: url("images/arrowRight.png");
|
||||
-fx-background-size: 85%;
|
||||
-fx-background-position: center;
|
||||
-fx-background-repeat: space;
|
||||
}
|
||||
|
||||
#spinnerVlsSelector .text-field {
|
||||
-fx-font-size: 15px;
|
||||
-fx-alignment: center;
|
||||
}
|
@ -1,16 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<?import javafx.geometry.Insets?>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
|
||||
<?import javafx.scene.canvas.Canvas?>
|
||||
<?import javafx.scene.control.Button?>
|
||||
<VBox alignment="CENTER" spacing="20.0" xmlns:fx="http://javafx.com/fxml"
|
||||
fx:controller="kvr.missilecruiser_hard.ControllerMissileCruiser">
|
||||
<padding>
|
||||
<Insets bottom="20.0" left="20.0" right="20.0" top="20.0"/>
|
||||
</padding>
|
||||
<?import javafx.scene.control.Label?>
|
||||
<?import javafx.scene.control.Spinner?>
|
||||
<?import javafx.scene.layout.AnchorPane?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
|
||||
<Label fx:id="welcomeText"/>
|
||||
<Button text="Hello!" onAction="#onHelloButtonClick"/>
|
||||
</VBox>
|
||||
<AnchorPane maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="500.0" minWidth="900.0" xmlns="http://javafx.com/javafx/null" xmlns:fx="http://javafx.com/fxml/1" fx:controller="kvr.missilecruiser_hard.ControllerMissileCruiser">
|
||||
<Canvas fx:id="mainCanvas" height="500.0" width="900.0" />
|
||||
<Button id="buttonCreate" layoutX="14.0" layoutY="455.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="32.0" minWidth="90.0" mnemonicParsing="false" onAction="#buttonCreate_Click" text="Создать" textAlignment="CENTER" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="14.0">
|
||||
<font>
|
||||
<Font size="15.0" />
|
||||
</font>
|
||||
</Button>
|
||||
<Button id="buttonRight" layoutX="846.0" layoutY="446.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="40.0" minWidth="40.0" mnemonicParsing="false" onAction="#buttonsMove_Click" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="14.0" />
|
||||
<Button id="buttonDown" layoutX="800.0" layoutY="446.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="40.0" minWidth="40.0" mnemonicParsing="false" onAction="#buttonsMove_Click" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="60.0" />
|
||||
<Button id="buttonLeft" layoutX="754.0" layoutY="446.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="40.0" minWidth="40.0" mnemonicParsing="false" onAction="#buttonsMove_Click" AnchorPane.bottomAnchor="14.0" AnchorPane.rightAnchor="106.0" />
|
||||
<Button id="buttonUp" layoutX="800.0" layoutY="399.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" minHeight="40.0" minWidth="40.0" mnemonicParsing="false" onAction="#buttonsMove_Click" AnchorPane.bottomAnchor="60.0" AnchorPane.rightAnchor="60.0" />
|
||||
<Spinner fx:id="spinnerVlsSelector" layoutX="112.0" layoutY="454.0" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" prefHeight="32.0" prefWidth="56.0" AnchorPane.bottomAnchor="14.0" AnchorPane.leftAnchor="112.0" />
|
||||
<Label layoutX="175.0" layoutY="459.0" text="VLS Count" AnchorPane.bottomAnchor="19.2" AnchorPane.leftAnchor="175.0">
|
||||
<font>
|
||||
<Font size="15.0" />
|
||||
</font>
|
||||
</Label>
|
||||
</AnchorPane>
|
||||
|
BIN
src/main/resources/kvr/missilecruiser_hard/images/arrowDown.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
src/main/resources/kvr/missilecruiser_hard/images/arrowLeft.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
src/main/resources/kvr/missilecruiser_hard/images/arrowRight.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
BIN
src/main/resources/kvr/missilecruiser_hard/images/arrowUp.png
Normal file
After Width: | Height: | Size: 4.6 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 703 B |
BIN
src/main/resources/kvr/missilecruiser_hard/images/doubleVLS.png
Normal file
After Width: | Height: | Size: 647 B |