full 1 laba fix
This commit is contained in:
parent
cdc497da5a
commit
baef175283
1
.idea/.name
Normal file
1
.idea/.name
Normal file
@ -0,0 +1 @@
|
|||||||
|
Main.java
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
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>
|
BIN
resources/down-arrow.png
Normal file
BIN
resources/down-arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 281 B |
BIN
resources/left-arrow.png
Normal file
BIN
resources/left-arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 265 B |
BIN
resources/right-arrow.png
Normal file
BIN
resources/right-arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 224 B |
BIN
resources/upper-arrow.png
Normal file
BIN
resources/upper-arrow.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 264 B |
120
src/DrawingShip.java
Normal file
120
src/DrawingShip.java
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class DrawingShip {
|
||||||
|
private EntityShip entityShip;
|
||||||
|
public EntityShip GetEntityShip(){
|
||||||
|
return entityShip;
|
||||||
|
}
|
||||||
|
private void SetEntityShip(EntityShip entityShip){
|
||||||
|
this.entityShip = entityShip;
|
||||||
|
}
|
||||||
|
private DrawingDecks drawingDecks;
|
||||||
|
public DrawingDecks GetDrawingDecks(){
|
||||||
|
return drawingDecks;
|
||||||
|
}
|
||||||
|
private void SetDrawingDecks( DrawingDecks drawingDecks){
|
||||||
|
this.drawingDecks = drawingDecks;
|
||||||
|
}
|
||||||
|
private int _pictureWidth;
|
||||||
|
private int _pictureHeight;
|
||||||
|
private int _startPosX;
|
||||||
|
private int _startPosY;
|
||||||
|
private final int _shipWidth = 185;
|
||||||
|
private final int _shipHeight = 180;
|
||||||
|
public boolean Init(int speed, double weight, Color bodyColor, Color addColor, boolean pipes, boolean section, int width, int height, int countDecks){
|
||||||
|
if (width < _shipWidth || height <_shipHeight){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
entityShip = new EntityShip();
|
||||||
|
entityShip.Init(speed, weight, bodyColor, addColor, pipes, section);
|
||||||
|
drawingDecks = new DrawingDecks();
|
||||||
|
drawingDecks.SetCountDecks(countDecks);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public void SetPosition(int x, int y){
|
||||||
|
if (x < 0 || x + _shipWidth > _pictureWidth){
|
||||||
|
x = 20;
|
||||||
|
}
|
||||||
|
if (y < 0 || y + _shipHeight > _pictureHeight){
|
||||||
|
y = 20;
|
||||||
|
}
|
||||||
|
_startPosX = x;
|
||||||
|
_startPosY = y;
|
||||||
|
}
|
||||||
|
public void MoveTransport(Direction direction){
|
||||||
|
if (entityShip == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (direction){
|
||||||
|
case Left:
|
||||||
|
System.out.println(_startPosX + " " + entityShip.GetStep() + " " + _shipWidth + " " + (_startPosX + entityShip.GetStep() + _shipWidth) + " " + _pictureWidth);
|
||||||
|
if (_startPosX - entityShip.GetStep() > 0){
|
||||||
|
_startPosX -= (int)entityShip.GetStep();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Up:
|
||||||
|
System.out.println(_startPosY + " " + entityShip.GetStep() + " " + (_startPosY + entityShip.GetStep()) + " " + _pictureHeight);
|
||||||
|
if (_startPosY - entityShip.GetStep() > 0){
|
||||||
|
_startPosY -= (int)entityShip.GetStep();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Right:
|
||||||
|
System.out.println(_startPosX + " " + entityShip.GetStep() + " " + _shipWidth + " " + (_startPosX + entityShip.GetStep() + _shipWidth) + " " + _pictureWidth);
|
||||||
|
if (_startPosX + entityShip.GetStep() + _shipWidth < _pictureWidth){
|
||||||
|
_startPosX += (int)entityShip.GetStep();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Down:
|
||||||
|
System.out.println(_startPosY + " " + entityShip.GetStep() + " " + (_startPosY + entityShip.GetStep()) + " " + _pictureHeight);
|
||||||
|
if (_startPosY + entityShip.GetStep() + _shipHeight < _pictureHeight){
|
||||||
|
_startPosY += (int)entityShip.GetStep();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DrawTransport(Graphics g) {
|
||||||
|
if (entityShip == null || drawingDecks == null) {
|
||||||
|
System.out.println("Error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//корпус
|
||||||
|
int[] XPoints = {_startPosX, _startPosX + 180, _startPosX + 140, _startPosX + 40, _startPosX};
|
||||||
|
int[] YPoints = {_startPosY + 110, _startPosY + 110, _startPosY + 185, _startPosY + 185, _startPosY + 110};
|
||||||
|
|
||||||
|
int nPoints = 5;
|
||||||
|
g.setColor(entityShip.GetBodyColor());
|
||||||
|
g.fillPolygon(XPoints, YPoints, nPoints);
|
||||||
|
g.setColor(Color.black);
|
||||||
|
g.drawPolygon(XPoints, YPoints, nPoints);
|
||||||
|
|
||||||
|
//якорь
|
||||||
|
g.drawLine(_startPosX + 50, _startPosY + 130, _startPosX + 50, _startPosY + 150);
|
||||||
|
g.drawLine(_startPosX + 40, _startPosY + 140, _startPosX + 60, _startPosY + 140);
|
||||||
|
g.drawLine(_startPosX + 45, _startPosY + 150, _startPosX + 55, _startPosY + 150);
|
||||||
|
|
||||||
|
//трубы
|
||||||
|
if (entityShip.GetPipes()) {
|
||||||
|
g.setColor(entityShip.GetAddColor());
|
||||||
|
g.fillRect(_startPosX + 55, _startPosY, 25, 80);
|
||||||
|
g.fillRect(_startPosX + 90, _startPosY + 20, 25, 60);
|
||||||
|
g.setColor(Color.black);
|
||||||
|
g.drawRect(_startPosX + 55, _startPosY, 25, 80);
|
||||||
|
g.drawRect(_startPosX + 90, _startPosY + 20, 25, 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
//топливный отсек
|
||||||
|
if (entityShip.GetSection()) {
|
||||||
|
g.setColor(Color.gray);
|
||||||
|
g.fillOval(_startPosX + 130, _startPosY + 130, 20, 20);
|
||||||
|
g.setColor(Color.black);
|
||||||
|
g.drawOval(_startPosX + 130, _startPosY + 130, 20, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
//палуба
|
||||||
|
drawingDecks.DrawingDecks(_startPosX, _startPosY, entityShip.GetBodyColor(), g);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user