lab 1 DONE!
This commit is contained in:
parent
6bd0eb1d8c
commit
c815fc49e8
@ -4,7 +4,10 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="91fba623-49d8-4a60-90d5-98344ab7724a" name="Changes" comment="" />
|
||||
<list default="true" id="91fba623-49d8-4a60-90d5-98344ab7724a" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Hydroplane/src/main/java/org/example/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/Hydroplane/src/main/java/org/example/Main.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
@ -29,7 +32,8 @@
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true"
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"last_opened_file_path": "C:/RPP HARD/PIbd-22_Fedorenko_G.Y._Hydroplane_HARD/Hydroplane"
|
||||
}
|
||||
}]]></component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
|
3
Hydroplane/.idea/.gitignore
vendored
Normal file
3
Hydroplane/.idea/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
13
Hydroplane/.idea/compiler.xml
Normal file
13
Hydroplane/.idea/compiler.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="Hydroplane" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
7
Hydroplane/.idea/encodings.xml
Normal file
7
Hydroplane/.idea/encodings.xml
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>
|
20
Hydroplane/.idea/jarRepositories.xml
Normal file
20
Hydroplane/.idea/jarRepositories.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
14
Hydroplane/.idea/misc.xml
Normal file
14
Hydroplane/.idea/misc.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" default="true" project-jdk-name="19" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
124
Hydroplane/.idea/uiDesigner.xml
Normal file
124
Hydroplane/.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>
|
6
Hydroplane/.idea/vcs.xml
Normal file
6
Hydroplane/.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
9
Hydroplane/src/main/java/org/example/Direction.java
Normal file
9
Hydroplane/src/main/java/org/example/Direction.java
Normal file
@ -0,0 +1,9 @@
|
||||
package org.example;
|
||||
|
||||
public enum Direction {
|
||||
Up,
|
||||
Down,
|
||||
Left,
|
||||
Right;
|
||||
}
|
||||
|
147
Hydroplane/src/main/java/org/example/DrawingHydroplane.java
Normal file
147
Hydroplane/src/main/java/org/example/DrawingHydroplane.java
Normal file
@ -0,0 +1,147 @@
|
||||
package org.example;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.Timer;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class DrawingHydroplane{
|
||||
|
||||
private WindowDrawing windowDrawing;
|
||||
|
||||
public EntityHydroplane _EntityHydroplane;
|
||||
|
||||
private int _pictureWidth;
|
||||
|
||||
private int _pictureHeight;
|
||||
|
||||
private int _startPosX;
|
||||
|
||||
private int _startPosY;
|
||||
|
||||
private int _planeWidth = 190;
|
||||
|
||||
private int _planeHeight = 80;
|
||||
|
||||
public boolean Init(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, boolean boat, boolean bobber, int numWindow, int width, int height)
|
||||
{
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
if (_pictureHeight < _planeHeight || _pictureWidth < _planeWidth)
|
||||
return false;
|
||||
_EntityHydroplane = new EntityHydroplane();
|
||||
_EntityHydroplane.Init(speed, weight, bodyColor, additionalColor,boat, bobber, numWindow);
|
||||
|
||||
windowDrawing = new WindowDrawing();
|
||||
windowDrawing.setNumWindow(numWindow);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
_startPosX = Math.min(x, _pictureWidth-_planeWidth);
|
||||
_startPosY = Math.min(y, _pictureHeight-_planeHeight);
|
||||
}
|
||||
|
||||
public void MoveTransport(Direction direction)
|
||||
{
|
||||
if (_EntityHydroplane == null){
|
||||
return;
|
||||
}
|
||||
switch (direction)
|
||||
{
|
||||
case Left:
|
||||
if (_startPosX - _EntityHydroplane.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)_EntityHydroplane.Step;
|
||||
}
|
||||
break;
|
||||
case Up:
|
||||
if (_startPosY - _EntityHydroplane.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)_EntityHydroplane.Step;
|
||||
}
|
||||
break;
|
||||
case Right:
|
||||
if (_startPosX + _planeWidth + _EntityHydroplane.Step < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)_EntityHydroplane.Step;
|
||||
}
|
||||
break;
|
||||
case Down:
|
||||
if (_startPosY + _planeHeight + _EntityHydroplane.Step < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)_EntityHydroplane.Step;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawTransport(Graphics2D g)
|
||||
{
|
||||
|
||||
if (_EntityHydroplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
g.setColor(_EntityHydroplane.BodyColor);
|
||||
g.fillPolygon(
|
||||
new int[]{ _startPosX + 5, _startPosX + 5, _startPosX + 130, _startPosX + 160, _startPosX + 130, _startPosX + 130, _startPosX + 55 },
|
||||
new int[]{ _startPosY, _startPosY + 55, _startPosY + 55, _startPosY + 40, _startPosY + 40, _startPosY + 25, _startPosY + 25 },
|
||||
7);
|
||||
|
||||
g.fillRect(_startPosX + 65, _startPosY + 55, 5, 15);
|
||||
g.fillRect(_startPosX + 125, _startPosY + 55, 5, 15);
|
||||
|
||||
g.setColor(_EntityHydroplane.AdditionalColor);
|
||||
|
||||
g.fillPolygon(
|
||||
new int[]{ _startPosX + 160, _startPosX + 130, _startPosX + 130 },
|
||||
new int[]{ _startPosY + 40, _startPosY + 40, _startPosY + 25 },
|
||||
3
|
||||
);
|
||||
|
||||
g.drawRect(_startPosX + 5, _startPosY + 25, 125, 30);
|
||||
|
||||
g.drawLine(_startPosX + 130, _startPosY + 25, _startPosX + 160, _startPosY + 40);
|
||||
g.drawLine(_startPosX + 130, _startPosY + 55, _startPosX + 160, _startPosY + 40);
|
||||
g.drawLine(_startPosX + 130, _startPosY + 40, _startPosX + 160, _startPosY + 40);
|
||||
|
||||
g.drawOval(_startPosX + 35, _startPosY + 43, 80, 7);
|
||||
|
||||
g.drawLine(_startPosX + 65, _startPosY + 55, _startPosX + 65, _startPosY + 70);
|
||||
g.drawLine(_startPosX + 70, _startPosY + 55, _startPosX + 70, _startPosY + 70);
|
||||
g.drawLine(_startPosX + 125, _startPosY + 55, _startPosX + 125, _startPosY + 70);
|
||||
g.drawLine(_startPosX + 130, _startPosY + 55, _startPosX + 130, _startPosY + 70);
|
||||
|
||||
windowDrawing.Draw(_startPosX, _startPosY, _EntityHydroplane.AdditionalColor, g);
|
||||
|
||||
if (_EntityHydroplane.Bobber) {
|
||||
g.fillPolygon(
|
||||
new int[]{ _startPosX + 55, _startPosX + 55, _startPosX + 155, _startPosX + 175 },
|
||||
new int[]{ _startPosY + 70, _startPosY + 80, _startPosY + 80, _startPosY + 70 },
|
||||
4
|
||||
);
|
||||
g.drawPolygon(
|
||||
new int[]{ _startPosX + 55, _startPosX + 55, _startPosX + 155, _startPosX + 175 },
|
||||
new int[]{ _startPosY + 70, _startPosY + 80, _startPosY + 80, _startPosY + 70 },
|
||||
4
|
||||
);
|
||||
}
|
||||
else {
|
||||
g.fillOval(_startPosX + 60, _startPosY + 70, 15, 15);
|
||||
g.fillOval(_startPosX + 120, _startPosY + 70, 15, 15);
|
||||
|
||||
g.drawOval(_startPosX + 60, _startPosY + 70, 15, 15);
|
||||
g.drawOval(_startPosX + 120, _startPosY + 70, 15, 15);
|
||||
}
|
||||
|
||||
if (_EntityHydroplane.Boat){
|
||||
g.fillOval(_startPosX, _startPosY + 21, 32, 8);
|
||||
g.drawOval(_startPosX, _startPosY + 21, 32, 8);
|
||||
}
|
||||
}
|
||||
}
|
39
Hydroplane/src/main/java/org/example/EntityHydroplane.java
Normal file
39
Hydroplane/src/main/java/org/example/EntityHydroplane.java
Normal file
@ -0,0 +1,39 @@
|
||||
package org.example;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.Timer;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class EntityHydroplane{
|
||||
|
||||
public int Speed;
|
||||
|
||||
public double Weight;
|
||||
|
||||
public Color BodyColor;
|
||||
|
||||
public Color AdditionalColor;
|
||||
|
||||
public boolean Boat;
|
||||
|
||||
public boolean Bobber;
|
||||
|
||||
public double Step;
|
||||
|
||||
public int numWindow;
|
||||
|
||||
public void Init(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, boolean boat, boolean bobber, int _numWindow)
|
||||
{
|
||||
numWindow = _numWindow;
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
Boat = boat;
|
||||
Bobber = bobber;
|
||||
Step = (double)Speed * 100 / Weight;
|
||||
}
|
||||
}
|
124
Hydroplane/src/main/java/org/example/FormHydroplane.java
Normal file
124
Hydroplane/src/main/java/org/example/FormHydroplane.java
Normal file
@ -0,0 +1,124 @@
|
||||
package org.example;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.Timer;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class FormHydroplane{
|
||||
private DrawingHydroplane _drawingHydroplane;
|
||||
Canvas canv;
|
||||
|
||||
public void Draw(){
|
||||
canv.repaint();
|
||||
}
|
||||
|
||||
public FormHydroplane(){
|
||||
JFrame w=new JFrame ("Hydroplane");
|
||||
JButton buttonCreate = new JButton("create");
|
||||
JButton up = new JButton();
|
||||
up.setBorderPainted(false);
|
||||
up.setFocusPainted(false);
|
||||
up.setContentAreaFilled(false);
|
||||
up.setName("up");
|
||||
up.setIcon(new ImageIcon("C:\\RPP HARD\\PIbd-22_Fedorenko_G.Y._Hydroplane_HARD\\Hydroplane\\src\\main\\java\\org\\example\\images\\up.png"));
|
||||
JButton down = new JButton();
|
||||
down.setBorderPainted(false);
|
||||
down.setFocusPainted(false);
|
||||
down.setContentAreaFilled(false);
|
||||
down.setName("down");
|
||||
down.setIcon(new ImageIcon("C:\\RPP HARD\\PIbd-22_Fedorenko_G.Y._Hydroplane_HARD\\Hydroplane\\src\\main\\java\\org\\example\\images\\down.png"));
|
||||
JButton left = new JButton();
|
||||
left.setBorderPainted(false);
|
||||
left.setFocusPainted(false);
|
||||
left.setContentAreaFilled(false);
|
||||
left.setName("left");
|
||||
left.setIcon(new ImageIcon("C:\\RPP HARD\\PIbd-22_Fedorenko_G.Y._Hydroplane_HARD\\Hydroplane\\src\\main\\java\\org\\example\\images\\left.png"));
|
||||
JButton right = new JButton();
|
||||
right.setBorderPainted(false);
|
||||
right.setFocusPainted(false);
|
||||
right.setContentAreaFilled(false);
|
||||
right.setName("right");
|
||||
right.setIcon(new ImageIcon("C:\\RPP HARD\\PIbd-22_Fedorenko_G.Y._Hydroplane_HARD\\Hydroplane\\src\\main\\java\\org\\example\\images\\right.png"));
|
||||
|
||||
buttonCreate.addActionListener(
|
||||
new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e){
|
||||
//System.out.println(e.getActionCommand());
|
||||
Random random = new Random();
|
||||
_drawingHydroplane = new DrawingHydroplane();
|
||||
_drawingHydroplane.Init(random.nextInt(100, 300), random.nextInt(1000, 3000),
|
||||
new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
||||
new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
|
||||
random.nextInt(0, 2) == 1, random.nextInt(0, 2) == 1,
|
||||
random.nextInt(1, 4)*10, 1000, 560);
|
||||
_drawingHydroplane.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100));
|
||||
canv._drawingHydroplane = _drawingHydroplane;
|
||||
Draw();
|
||||
}
|
||||
}
|
||||
);
|
||||
ActionListener actioListener = new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e){
|
||||
//System.out.println(((JButton)(e.getSource())).getName());
|
||||
if (_drawingHydroplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch(((JButton)(e.getSource())).getName()){
|
||||
case "up":
|
||||
_drawingHydroplane.MoveTransport(Direction.Up);
|
||||
break;
|
||||
case "down":
|
||||
_drawingHydroplane.MoveTransport(Direction.Down);
|
||||
break;
|
||||
case "left":
|
||||
_drawingHydroplane.MoveTransport(Direction.Left);
|
||||
break;
|
||||
case "right":
|
||||
_drawingHydroplane.MoveTransport(Direction.Right);
|
||||
break;
|
||||
}
|
||||
Draw();
|
||||
}
|
||||
};
|
||||
up.addActionListener(actioListener);
|
||||
down.addActionListener(actioListener);
|
||||
left.addActionListener(actioListener);
|
||||
right.addActionListener(actioListener);
|
||||
|
||||
w.setSize (1000, 600);
|
||||
w.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
|
||||
w.setLayout(null);
|
||||
canv = new Canvas();
|
||||
canv.setBounds(0, 0, 1000, 600);
|
||||
buttonCreate.setBounds(2, 540, 100, 20);
|
||||
up.setBounds(900, 480, 40, 40);
|
||||
down.setBounds(900, 520, 40, 40);
|
||||
left.setBounds(860, 520, 40, 40);
|
||||
right.setBounds(940, 520, 40, 40);
|
||||
w.add(canv);
|
||||
w.add(buttonCreate);
|
||||
w.add(up);
|
||||
w.add(down);
|
||||
w.add(left);
|
||||
w.add(right);
|
||||
w.setVisible (true);
|
||||
}
|
||||
}
|
||||
|
||||
class Canvas extends JComponent{
|
||||
public DrawingHydroplane _drawingHydroplane;
|
||||
public Canvas(){
|
||||
}
|
||||
public void paintComponent (Graphics g){
|
||||
if (_drawingHydroplane == null){
|
||||
return;
|
||||
}
|
||||
super.paintComponents (g) ;
|
||||
Graphics2D g2d = (Graphics2D)g;
|
||||
_drawingHydroplane.DrawTransport(g2d);
|
||||
super.repaint();
|
||||
}
|
||||
}
|
@ -2,6 +2,6 @@ package org.example;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello world!");
|
||||
new FormHydroplane();
|
||||
}
|
||||
}
|
8
Hydroplane/src/main/java/org/example/NumWindow.java
Normal file
8
Hydroplane/src/main/java/org/example/NumWindow.java
Normal file
@ -0,0 +1,8 @@
|
||||
package org.example;
|
||||
|
||||
public enum NumWindow
|
||||
{
|
||||
tenWindows,
|
||||
twentyWindows,
|
||||
thirtyWindows
|
||||
}
|
60
Hydroplane/src/main/java/org/example/WindowDrawing.java
Normal file
60
Hydroplane/src/main/java/org/example/WindowDrawing.java
Normal file
@ -0,0 +1,60 @@
|
||||
package org.example;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
public class WindowDrawing{
|
||||
private NumWindow numWindow;
|
||||
|
||||
public NumWindow getSomeProperty() {
|
||||
return numWindow;
|
||||
}
|
||||
|
||||
public void setNumWindow(int kWindow){
|
||||
switch(kWindow){
|
||||
case 10:
|
||||
numWindow = NumWindow.tenWindows;
|
||||
break;
|
||||
case 20:
|
||||
numWindow = NumWindow.twentyWindows;
|
||||
break;
|
||||
case 30:
|
||||
numWindow = NumWindow.thirtyWindows;
|
||||
break;
|
||||
default:
|
||||
numWindow = NumWindow.tenWindows;
|
||||
System.out.println("Произошел косяк с количеством, но давайте их будет 10, вообще было " + kWindow);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Draw(int _startPosX, int _startPosY, Color color, Graphics2D g){
|
||||
g.setColor(color);
|
||||
switch (numWindow) {
|
||||
case tenWindows -> {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
g.fillOval(_startPosX + 35 + i * 8, _startPosY + 30, 4, 4);
|
||||
}
|
||||
}
|
||||
case twentyWindows -> {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
g.fillOval(_startPosX + 35 + i * 8, _startPosY + 30, 4, 4);
|
||||
}
|
||||
for (int i = 0; i < 10; i++) {
|
||||
g.fillOval(_startPosX + 35 + i * 8, _startPosY + 30 + 4, 4, 4);
|
||||
}
|
||||
}
|
||||
case thirtyWindows -> {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
g.fillOval(_startPosX + 35 + i * 8, _startPosY + 30, 4, 4);
|
||||
}
|
||||
for (int i = 0; i < 10; i++) {
|
||||
g.fillOval(_startPosX + 35 + i * 8, _startPosY + 30 + 4, 4, 4);
|
||||
}
|
||||
for (int i = 0; i < 10; i++) {
|
||||
g.fillOval(_startPosX + 35 + i * 8, _startPosY + 30 + 8, 4, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
Hydroplane/src/main/java/org/example/images/down.png
Normal file
BIN
Hydroplane/src/main/java/org/example/images/down.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 256 B |
BIN
Hydroplane/src/main/java/org/example/images/left.png
Normal file
BIN
Hydroplane/src/main/java/org/example/images/left.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 269 B |
BIN
Hydroplane/src/main/java/org/example/images/right.png
Normal file
BIN
Hydroplane/src/main/java/org/example/images/right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 257 B |
BIN
Hydroplane/src/main/java/org/example/images/up.png
Normal file
BIN
Hydroplane/src/main/java/org/example/images/up.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 250 B |
Loading…
Reference in New Issue
Block a user