Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
a0c597a084 | |||
52c006a00a | |||
7aa6219c78 | |||
2d2c0e9714 |
@ -2,7 +2,10 @@
|
|||||||
<module type="JAVA_MODULE" version="4">
|
<module type="JAVA_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
<exclude-output />
|
<exclude-output />
|
||||||
<content url="file://$MODULE_DIR$" />
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/ProjectContainerShip/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/ProjectContainerShip/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
|
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>
|
124
ProjectContainerShip/.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
ProjectContainerShip/resources/down.jpg
Normal file
After Width: | Height: | Size: 141 KiB |
BIN
ProjectContainerShip/resources/left.jpg
Normal file
After Width: | Height: | Size: 139 KiB |
BIN
ProjectContainerShip/resources/right.jpg
Normal file
After Width: | Height: | Size: 4.8 KiB |
BIN
ProjectContainerShip/resources/up.jpg
Normal file
After Width: | Height: | Size: 141 KiB |
29
ProjectContainerShip/src/DiffDecks/DeckType1.java
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package DiffDecks;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class DeckType1 implements IDifferentDecks {
|
||||||
|
private DecksCount numberOfDecks;
|
||||||
|
@Override
|
||||||
|
public void setNumberOfDecks(int numberofdeck) {
|
||||||
|
for (DecksCount numofenum : DecksCount.values()) {
|
||||||
|
if (numofenum.getDeckcount() == numberofdeck) {
|
||||||
|
numberOfDecks = numofenum;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public DecksCount getNumberOfDecks() {
|
||||||
|
return numberOfDecks;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void DrawDecks(Graphics2D g, int x, int y, int width, int height, Color bodyColor) {
|
||||||
|
g.setColor(bodyColor);
|
||||||
|
g.fillRect(x, y, width, height);
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
g.drawRect(x, y, width, height);
|
||||||
|
g.setColor(bodyColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
37
ProjectContainerShip/src/DiffDecks/DeckType2.java
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package DiffDecks;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class DeckType2 implements IDifferentDecks {
|
||||||
|
private DecksCount numberOfDecks;
|
||||||
|
@Override
|
||||||
|
public void setNumberOfDecks(int numberofdeck) {
|
||||||
|
for (DecksCount numofenum : DecksCount.values()) {
|
||||||
|
if (numofenum.getDeckcount() == numberofdeck) {
|
||||||
|
numberOfDecks = numofenum;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public DecksCount getNumberOfDecks() {
|
||||||
|
return numberOfDecks;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void DrawDecks(Graphics2D g, int x, int y, int width, int height, Color bodyColor) {
|
||||||
|
g.setStroke(new BasicStroke(3.0F));
|
||||||
|
g.setColor(bodyColor);
|
||||||
|
|
||||||
|
int curveRadius = 15;
|
||||||
|
g.drawRoundRect(x, y, width, height, curveRadius, curveRadius);
|
||||||
|
|
||||||
|
int numSupports = 6;
|
||||||
|
int spaceBetweenSupports = width / (numSupports + 1);
|
||||||
|
int supportWidth = 5;
|
||||||
|
for (int i = 1; i <= numSupports; i++) {
|
||||||
|
int supportX = x + i * spaceBetweenSupports;
|
||||||
|
g.fillRect(supportX - supportWidth / 2, y, supportWidth, height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
28
ProjectContainerShip/src/DiffDecks/DeckType3.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package DiffDecks;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class DeckType3 implements IDifferentDecks{
|
||||||
|
private DecksCount numberOfDecks;
|
||||||
|
@Override
|
||||||
|
public void setNumberOfDecks(int numberofdeck) {
|
||||||
|
for (DecksCount numofenum : DecksCount.values()) {
|
||||||
|
if (numofenum.getDeckcount() == numberofdeck) {
|
||||||
|
numberOfDecks = numofenum;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public DecksCount getNumberOfDecks() {
|
||||||
|
return numberOfDecks;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void DrawDecks(Graphics2D g, int x, int y, int width, int height, Color bodyColor) {
|
||||||
|
g.setColor(bodyColor);
|
||||||
|
g.fillRect(x, y, width, height);
|
||||||
|
g.setColor(Color.CYAN);
|
||||||
|
g.fillRect(x+ 10, y+5, width - 20, height-5);
|
||||||
|
g.setColor(bodyColor);
|
||||||
|
}
|
||||||
|
}
|
12
ProjectContainerShip/src/DiffDecks/DecksCount.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package DiffDecks;
|
||||||
|
|
||||||
|
public enum DecksCount {
|
||||||
|
OneDeck(1),
|
||||||
|
TwoDecks(2),
|
||||||
|
ThreeDecks(3);
|
||||||
|
private int deckcount;
|
||||||
|
DecksCount(int deckcount) {
|
||||||
|
this.deckcount = deckcount;
|
||||||
|
}
|
||||||
|
public int getDeckcount() {return deckcount;}
|
||||||
|
}
|
9
ProjectContainerShip/src/DiffDecks/IDifferentDecks.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package DiffDecks;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public interface IDifferentDecks {
|
||||||
|
void setNumberOfDecks(int numberofdeck);
|
||||||
|
DecksCount getNumberOfDecks();
|
||||||
|
void DrawDecks(Graphics2D g, int x, int y, int width, int height, Color bodyColor);
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package DrawingShip;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class CanvasContainerShip extends JComponent {
|
||||||
|
public DrawingShip _drawingShip;
|
||||||
|
public CanvasContainerShip(){}
|
||||||
|
public void paintComponent(Graphics g) {
|
||||||
|
if (_drawingShip == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
super.paintComponents(g);
|
||||||
|
Graphics2D g2d = (Graphics2D) g;
|
||||||
|
_drawingShip.DrawTransport(g2d);
|
||||||
|
super.repaint();
|
||||||
|
}
|
||||||
|
}
|
9
ProjectContainerShip/src/DrawingShip/DirectionType.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package DrawingShip;
|
||||||
|
|
||||||
|
public enum DirectionType {
|
||||||
|
Unknow,
|
||||||
|
Up,
|
||||||
|
Down,
|
||||||
|
Left,
|
||||||
|
Right
|
||||||
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
package DrawingShip;
|
||||||
|
import DiffDecks.DecksCount;
|
||||||
|
import Entities.EntityContainerShip;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class DrawingContainerShip extends DrawingShip {
|
||||||
|
public DrawingContainerShip(int speed, double weight, Color bodycolor, Color additionalcolor, boolean crane, boolean container) {
|
||||||
|
EntityShip = new EntityContainerShip(speed, weight, bodycolor, additionalcolor, crane, container);
|
||||||
|
SetAmountandTypeDecks();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void DrawTransport(Graphics2D g) {
|
||||||
|
if (EntityShip == null || !(EntityShip instanceof EntityContainerShip containerShip) || _StartPosX == null || _StartPosY == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
int originalStartPosY = _StartPosY;
|
||||||
|
int containerOffsetY = 0;
|
||||||
|
|
||||||
|
if (containerShip.Crane) {
|
||||||
|
int craneX = _StartPosX + drawingShipWidth - 40;
|
||||||
|
int craneY = _StartPosY + drawingShipHeight - 90;
|
||||||
|
|
||||||
|
//Кран
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
g.drawLine(craneX + 10, craneY + 40, craneX + 10, craneY);
|
||||||
|
g.drawLine(craneX + 10, craneY, craneX + 50, craneY);
|
||||||
|
g.drawLine(craneX + 10, craneY, craneX + 50, craneY + 5);
|
||||||
|
g.drawLine(craneX + 50, craneY, craneX + 50, craneY + 30);
|
||||||
|
|
||||||
|
//Хваталка крана
|
||||||
|
g.drawLine(craneX + 40, craneY + 30, craneX + 60, craneY + 30);
|
||||||
|
g.drawLine(craneX + 40, craneY + 30, craneX + 40, craneY + 35);
|
||||||
|
g.drawLine(craneX + 60, craneY + 30, craneX + 60, craneY + 35);
|
||||||
|
containerOffsetY += 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_StartPosY += containerOffsetY;
|
||||||
|
super.DrawTransport(g);
|
||||||
|
_StartPosY = originalStartPosY;
|
||||||
|
|
||||||
|
|
||||||
|
int count_decks = 0;
|
||||||
|
if (drawingDecks.getNumberOfDecks() != null) {
|
||||||
|
switch (drawingDecks.getNumberOfDecks()) {
|
||||||
|
case OneDeck:
|
||||||
|
count_decks = 1;
|
||||||
|
break;
|
||||||
|
case TwoDecks:
|
||||||
|
count_decks = 2;
|
||||||
|
break;
|
||||||
|
case ThreeDecks:
|
||||||
|
count_decks = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int containerY;
|
||||||
|
if (count_decks == 0) {
|
||||||
|
containerY = _StartPosY + 15;
|
||||||
|
} else {
|
||||||
|
containerY = _StartPosY + 15 + containerOffsetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (containerShip.Container) {
|
||||||
|
//Контейнер
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
g.drawRect(_StartPosX + 40, containerY, 40, 15);
|
||||||
|
g.setColor(containerShip.getAdditionalColor());
|
||||||
|
g.fillRect(_StartPosX + 40, containerY, 40, 15);
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
g.drawRect(_StartPosX + 60, containerY + 5, 40, 15);
|
||||||
|
g.setColor(containerShip.getAdditionalColor());
|
||||||
|
g.fillRect(_StartPosX + 60, containerY + 5, 40, 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (containerShip.Crane) {
|
||||||
|
drawingShipHeight += 30;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
147
ProjectContainerShip/src/DrawingShip/DrawingShip.java
Normal file
@ -0,0 +1,147 @@
|
|||||||
|
package DrawingShip;
|
||||||
|
import DiffDecks.DeckType2;
|
||||||
|
import DiffDecks.DeckType3;
|
||||||
|
import DiffDecks.IDifferentDecks;
|
||||||
|
import Entities.EntityShip;
|
||||||
|
|
||||||
|
import DiffDecks.DeckType1;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class DrawingShip extends JPanel {
|
||||||
|
public Entities.EntityShip EntityShip;
|
||||||
|
public IDifferentDecks drawingDecks;
|
||||||
|
private Integer picture_width;
|
||||||
|
private Integer picture_height;
|
||||||
|
public Integer _StartPosX;
|
||||||
|
public Integer _StartPosY;
|
||||||
|
protected int drawingShipWidth = 150;
|
||||||
|
protected int drawingShipHeight = 50;
|
||||||
|
public Integer GetPosX() {return _StartPosX;}
|
||||||
|
public Integer GetPosY() {return _StartPosY;}
|
||||||
|
public Integer GetWidth() {return drawingShipWidth;}
|
||||||
|
public Integer GetHeight() {return drawingShipHeight;}
|
||||||
|
protected DrawingShip() {
|
||||||
|
picture_width = null;
|
||||||
|
picture_height = null;
|
||||||
|
_StartPosX = null;
|
||||||
|
_StartPosY = null;
|
||||||
|
}
|
||||||
|
protected void SetAmountandTypeDecks() {
|
||||||
|
int numberOfDecks = (int)(Math.random() * 4 + 0);
|
||||||
|
switch ((int)(Math.random() * 3 + 1)) {
|
||||||
|
case 1:
|
||||||
|
drawingDecks = new DeckType1();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
drawingDecks = new DeckType2();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
drawingDecks = new DeckType3();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
numberOfDecks = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
drawingDecks.setNumberOfDecks(numberOfDecks);
|
||||||
|
}
|
||||||
|
public DrawingShip(int speed, double weight, Color bodycolor) {
|
||||||
|
super();
|
||||||
|
EntityShip = new EntityShip(speed, weight, bodycolor);
|
||||||
|
SetAmountandTypeDecks();
|
||||||
|
}
|
||||||
|
public boolean SetPictureSize(int width, int height) {
|
||||||
|
if (width < drawingShipWidth || height < drawingShipHeight) return false;
|
||||||
|
picture_width = width;
|
||||||
|
picture_height = height;
|
||||||
|
if (_StartPosX != null || _StartPosY != null) {
|
||||||
|
if (_StartPosX + drawingShipWidth > picture_width)
|
||||||
|
{
|
||||||
|
_StartPosX = _StartPosX - (_StartPosX + drawingShipWidth - picture_width);
|
||||||
|
}
|
||||||
|
else if (_StartPosX < 0) _StartPosX = 0;
|
||||||
|
if (_StartPosY + drawingShipHeight > picture_height)
|
||||||
|
{
|
||||||
|
_StartPosY = _StartPosY - (_StartPosY + drawingShipHeight - picture_height);
|
||||||
|
}
|
||||||
|
else if (_StartPosY < 0) _StartPosY = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public void SetPosition(int x, int y) {
|
||||||
|
if (!(picture_width != null && picture_height != null)) return;
|
||||||
|
if (x + drawingShipWidth > picture_width)
|
||||||
|
{
|
||||||
|
_StartPosX = x - (x + drawingShipWidth - picture_width);
|
||||||
|
}
|
||||||
|
else if (x < 0) _StartPosX = 0;
|
||||||
|
else _StartPosX = x;
|
||||||
|
if (y + drawingShipHeight > picture_height)
|
||||||
|
{
|
||||||
|
_StartPosY = y - (y + drawingShipHeight - picture_height);
|
||||||
|
}
|
||||||
|
else if (y < 0) _StartPosY = 0;
|
||||||
|
else _StartPosY = y;
|
||||||
|
}
|
||||||
|
public boolean MoveTransport(DirectionType direction) {
|
||||||
|
if (EntityShip == null || _StartPosX == null || _StartPosY == null) return false;
|
||||||
|
switch (direction) {
|
||||||
|
case DirectionType.Left:
|
||||||
|
if (_StartPosX - EntityShip.Step > 0) {
|
||||||
|
_StartPosX -= (int)EntityShip.Step;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case DirectionType.Up:
|
||||||
|
if (_StartPosY - EntityShip.Step > 0)
|
||||||
|
{
|
||||||
|
_StartPosY -= (int)EntityShip.Step;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case DirectionType.Right:
|
||||||
|
if (_StartPosX + drawingShipWidth + (int)EntityShip.Step < picture_width - EntityShip.Step)
|
||||||
|
{
|
||||||
|
_StartPosX += (int)EntityShip.Step;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
case DirectionType.Down:
|
||||||
|
if (_StartPosY + drawingShipHeight + (int)EntityShip.Step < picture_height - EntityShip.Step)
|
||||||
|
{
|
||||||
|
_StartPosY += (int)EntityShip.Step;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DrawTransport(Graphics2D g) {
|
||||||
|
if (EntityShip == null || _StartPosX == null || _StartPosY == null) return;
|
||||||
|
int y = _StartPosY;
|
||||||
|
g.setColor(EntityShip.getBodyColor());
|
||||||
|
if (drawingDecks.getNumberOfDecks() != null) {
|
||||||
|
y += 30;
|
||||||
|
switch (drawingDecks.getNumberOfDecks()) {
|
||||||
|
case OneDeck:
|
||||||
|
drawingDecks.DrawDecks(g, _StartPosX + 30, y, 80, 15, EntityShip.getBodyColor());
|
||||||
|
y += 15;
|
||||||
|
break;
|
||||||
|
case TwoDecks:
|
||||||
|
drawingDecks.DrawDecks(g, _StartPosX + 30, y, 80, 15, EntityShip.getBodyColor());
|
||||||
|
drawingDecks.DrawDecks(g, _StartPosX + 30, y + 15, 80, 15, EntityShip.getBodyColor());
|
||||||
|
y += 30;
|
||||||
|
break;
|
||||||
|
case ThreeDecks:
|
||||||
|
drawingDecks.DrawDecks(g, _StartPosX + 30, y, 80, 15, EntityShip.getBodyColor());
|
||||||
|
drawingDecks.DrawDecks(g, _StartPosX + 30, y + 15, 80, 15, EntityShip.getBodyColor());
|
||||||
|
drawingDecks.DrawDecks(g, _StartPosX + 30, y + 30, 80, 15, EntityShip.getBodyColor());
|
||||||
|
y += 45;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int[] arrayX = {_StartPosX, _StartPosX+150, _StartPosX+150, _StartPosX+120, _StartPosX+120, _StartPosX+30, _StartPosX+30, _StartPosX};
|
||||||
|
int[] arrayY = {y, y, y, y + 50, y + 50, y + 50, y + 50, y};
|
||||||
|
Polygon poly = new Polygon(arrayX, arrayY, 8);
|
||||||
|
g.fillPolygon(poly);
|
||||||
|
drawingShipHeight = y + 50 - _StartPosY;
|
||||||
|
}
|
||||||
|
}
|
18
ProjectContainerShip/src/Entities/EntityContainerShip.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package Entities;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class EntityContainerShip extends EntityShip{
|
||||||
|
private Color AdditionalColor;
|
||||||
|
public Color getAdditionalColor() {return AdditionalColor;}
|
||||||
|
public boolean Crane;
|
||||||
|
public boolean Container;
|
||||||
|
|
||||||
|
public EntityContainerShip(int speed, double weight, Color bodycolor, Color additionalcolor, boolean crane, boolean container)
|
||||||
|
{
|
||||||
|
super(speed,weight,bodycolor);
|
||||||
|
AdditionalColor = additionalcolor;
|
||||||
|
Crane = crane;
|
||||||
|
Container = container;
|
||||||
|
}
|
||||||
|
}
|
18
ProjectContainerShip/src/Entities/EntityShip.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package Entities;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class EntityShip {
|
||||||
|
private int Speed;
|
||||||
|
private double Weight;
|
||||||
|
private Color BodyColor;
|
||||||
|
public Color getBodyColor() {return BodyColor;}
|
||||||
|
public double Step;
|
||||||
|
public EntityShip(int speed, double weight, Color bodycolor)
|
||||||
|
{
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodycolor;
|
||||||
|
Step = Speed * 100 / Weight;
|
||||||
|
}
|
||||||
|
}
|
207
ProjectContainerShip/src/FormContainerShip.java
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
import DrawingShip.CanvasContainerShip;
|
||||||
|
import DrawingShip.DirectionType;
|
||||||
|
import DrawingShip.DrawingShip;
|
||||||
|
import DrawingShip.DrawingContainerShip;
|
||||||
|
import MovementStrategy.*;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.event.ActionEvent;
|
||||||
|
import java.awt.event.ActionListener;
|
||||||
|
import java.awt.event.ComponentAdapter;
|
||||||
|
import java.awt.event.ComponentEvent;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class FormContainerShip extends JFrame {
|
||||||
|
private String title;
|
||||||
|
private Dimension dimension;
|
||||||
|
private int Width, Height;
|
||||||
|
public CanvasContainerShip canvasContainerShip = new CanvasContainerShip();
|
||||||
|
private JButton CreateButton = new JButton("Создать контейнеровоз");;
|
||||||
|
private JButton CreateShipButton = new JButton("Создать корабль");
|
||||||
|
private JButton UpButton = new JButton();
|
||||||
|
private JButton DownButton = new JButton();;
|
||||||
|
private JButton LeftButton = new JButton();;
|
||||||
|
private JButton RightButton = new JButton();
|
||||||
|
private AbstractStrategy _strategy;
|
||||||
|
private JComboBox ComboBoxStrategy = new JComboBox(new String[]{"К центру", "К краю"});
|
||||||
|
private JButton ButtonStrategy = new JButton("Шаг");
|
||||||
|
public FormContainerShip(String title, Dimension dimension) {
|
||||||
|
this.title = title;
|
||||||
|
this.dimension = dimension;
|
||||||
|
}
|
||||||
|
private void CreateObject(String typeOfClass) {
|
||||||
|
int StartPositionX = (int)(Math.random() * 90 + 10);
|
||||||
|
int StartPositionY = (int)(Math.random() * 90 + 10);
|
||||||
|
int speed = (int)(Math.random() * 300 + 100);
|
||||||
|
double weight = (double)(Math.random() * 3000 + 1000);
|
||||||
|
Color bodyColor = new Color((int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0));
|
||||||
|
switch (typeOfClass) {
|
||||||
|
case "DrawingShip":
|
||||||
|
canvasContainerShip._drawingShip = new DrawingShip(speed, weight, bodyColor);
|
||||||
|
canvasContainerShip._drawingShip.SetPictureSize(Width, Height);
|
||||||
|
canvasContainerShip._drawingShip.SetPosition(StartPositionX, StartPositionY);
|
||||||
|
canvasContainerShip.repaint();
|
||||||
|
break;
|
||||||
|
case "DrawingContainerShip":
|
||||||
|
Color additionalColor = new Color((int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0),(int)(Math.random() * 255 + 0));;
|
||||||
|
boolean crane = new Random().nextBoolean();
|
||||||
|
boolean container = new Random().nextBoolean();;
|
||||||
|
canvasContainerShip._drawingShip = new DrawingContainerShip(speed, weight, bodyColor, additionalColor, crane, container);
|
||||||
|
canvasContainerShip._drawingShip.SetPictureSize(Width, Height);
|
||||||
|
canvasContainerShip._drawingShip.SetPosition(StartPositionX, StartPositionY);
|
||||||
|
canvasContainerShip.repaint();
|
||||||
|
break;
|
||||||
|
default: return;
|
||||||
|
}
|
||||||
|
_strategy = null;
|
||||||
|
ComboBoxStrategy.setEnabled(true);
|
||||||
|
}
|
||||||
|
public void Init() {
|
||||||
|
setTitle(title);
|
||||||
|
setMinimumSize(dimension);
|
||||||
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
|
||||||
|
Width = getWidth() - 10;
|
||||||
|
Height = getHeight() - 34;
|
||||||
|
_strategy = null;
|
||||||
|
|
||||||
|
CreateButton.setName("CREATE");
|
||||||
|
CreateShipButton.setName("CREATESHIPBUTTON");
|
||||||
|
Icon iconUp = new ImageIcon("src\\images\\up.jpg");
|
||||||
|
UpButton.setIcon(iconUp);
|
||||||
|
UpButton.setName("UP");
|
||||||
|
DownButton.setName("DOWN");
|
||||||
|
Icon iconDown = new ImageIcon("src\\images\\down.jpg");
|
||||||
|
DownButton.setIcon(iconDown);
|
||||||
|
LeftButton.setName("LEFT");
|
||||||
|
Icon iconLeft = new ImageIcon("src\\images\\left.jpg");
|
||||||
|
LeftButton.setIcon(iconLeft);
|
||||||
|
RightButton.setName("RIGHT");
|
||||||
|
Icon iconRight = new ImageIcon("src\\images\\right.jpg");
|
||||||
|
RightButton.setIcon(iconRight);
|
||||||
|
|
||||||
|
CreateButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
CreateObject("DrawingContainerShip");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
CreateShipButton.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
CreateObject("DrawingShip");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ButtonStrategy.addActionListener(new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent e) {
|
||||||
|
if (canvasContainerShip._drawingShip == null) return;
|
||||||
|
if (ComboBoxStrategy.isEnabled())
|
||||||
|
{
|
||||||
|
int index = ComboBoxStrategy.getSelectedIndex();
|
||||||
|
switch(index)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
_strategy = new MoveToCenter();
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
_strategy = new MoveToBorder();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
_strategy = null;
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
if (_strategy == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_strategy.SetData(new MoveableShip(canvasContainerShip._drawingShip), Width, Height);
|
||||||
|
}
|
||||||
|
if (_strategy == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ComboBoxStrategy.setEnabled(false);
|
||||||
|
_strategy.MakeStep();
|
||||||
|
if (_strategy.GetStatus() == StrategyStatus.Finish)
|
||||||
|
{
|
||||||
|
ComboBoxStrategy.setEnabled(true);
|
||||||
|
_strategy = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ActionListener actionListener = new ActionListener() {
|
||||||
|
@Override
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
if (canvasContainerShip._drawingShip == null) return;
|
||||||
|
boolean result = false;
|
||||||
|
switch ((((JButton)(event.getSource())).getName())) {
|
||||||
|
case "UP":
|
||||||
|
System.out.println("Кнопка UP нажата");
|
||||||
|
result = canvasContainerShip._drawingShip.MoveTransport(DirectionType.Up);
|
||||||
|
break;
|
||||||
|
case "DOWN":
|
||||||
|
result = canvasContainerShip._drawingShip.MoveTransport(DirectionType.Down);
|
||||||
|
break;
|
||||||
|
case "LEFT":
|
||||||
|
result = canvasContainerShip._drawingShip.MoveTransport(DirectionType.Left);
|
||||||
|
break;
|
||||||
|
case "RIGHT":
|
||||||
|
result = canvasContainerShip._drawingShip.MoveTransport(DirectionType.Right);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (result) {
|
||||||
|
canvasContainerShip.repaint();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
UpButton.addActionListener(actionListener);
|
||||||
|
DownButton.addActionListener(actionListener);
|
||||||
|
LeftButton.addActionListener(actionListener);
|
||||||
|
RightButton.addActionListener(actionListener);
|
||||||
|
|
||||||
|
setSize(dimension.width,dimension.height);
|
||||||
|
setLayout(null);
|
||||||
|
canvasContainerShip.setBounds(0,0, getWidth(), getHeight());
|
||||||
|
CreateButton.setBounds(10, getHeight() - 90, 140, 40);
|
||||||
|
CreateShipButton.setBounds(160, getHeight() - 90, 140, 40);
|
||||||
|
UpButton.setBounds(getWidth() - 140, getHeight() - 160, 50, 50);
|
||||||
|
DownButton.setBounds(getWidth() - 140, getHeight() - 100, 50, 50);
|
||||||
|
RightButton.setBounds(getWidth() - 80, getHeight() - 100, 50, 50);
|
||||||
|
LeftButton.setBounds(getWidth() - 200, getHeight() - 100, 50, 50);
|
||||||
|
ComboBoxStrategy.setBounds(getWidth() - 170, 10, 140, 35);
|
||||||
|
ButtonStrategy.setBounds(getWidth() - 130, 55, 100, 25);
|
||||||
|
add(CreateButton);
|
||||||
|
add(CreateShipButton);
|
||||||
|
add(UpButton);
|
||||||
|
add(DownButton);
|
||||||
|
add(RightButton);
|
||||||
|
add(LeftButton);
|
||||||
|
add(ComboBoxStrategy);
|
||||||
|
add(ButtonStrategy);
|
||||||
|
add(canvasContainerShip);
|
||||||
|
setVisible(true);
|
||||||
|
//обработка события изменения размеров окна
|
||||||
|
addComponentListener(new ComponentAdapter() {
|
||||||
|
public void componentResized(ComponentEvent e) {
|
||||||
|
Width = getWidth() - 10;
|
||||||
|
Height = getHeight() - 34;
|
||||||
|
if (canvasContainerShip._drawingShip != null)
|
||||||
|
canvasContainerShip._drawingShip.SetPictureSize(Width, Height);
|
||||||
|
canvasContainerShip.setBounds(0,0, getWidth(), getHeight());
|
||||||
|
CreateButton.setBounds(10, getHeight() - 90, 140, 40);
|
||||||
|
CreateShipButton.setBounds(160, getHeight() - 90, 140, 40);
|
||||||
|
UpButton.setBounds(getWidth() - 140, getHeight() - 160, 50, 50);
|
||||||
|
DownButton.setBounds(getWidth() - 140, getHeight() - 100, 50, 50);
|
||||||
|
RightButton.setBounds(getWidth() - 80, getHeight() - 100, 50, 50);
|
||||||
|
LeftButton.setBounds(getWidth() - 200, getHeight() - 100, 50, 50);
|
||||||
|
ComboBoxStrategy.setBounds(getWidth() - 170, 10, 140, 35);
|
||||||
|
ButtonStrategy.setBounds(getWidth() - 130, 55, 100, 25);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,8 @@
|
|||||||
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
|
import java.awt.*;
|
||||||
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
|
FormContainerShip form = new FormContainerShip("Контейнеровоз", new Dimension(500, 500));
|
||||||
// to see how IntelliJ IDEA suggests fixing it.
|
form.Init();
|
||||||
System.out.printf("Hello and welcome!");
|
|
||||||
|
|
||||||
for (int i = 1; i <= 5; i++) {
|
|
||||||
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
|
|
||||||
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
|
|
||||||
System.out.println("i = " + i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
package MovementStrategy;
|
||||||
|
|
||||||
|
public abstract class AbstractStrategy {
|
||||||
|
private IMoveableObjects _moveableObject;
|
||||||
|
private StrategyStatus _state = StrategyStatus.NotInit;
|
||||||
|
public int FieldWidth;
|
||||||
|
public int FieldHeight;
|
||||||
|
public StrategyStatus GetStatus() {return _state;}
|
||||||
|
public void SetData(IMoveableObjects moveableObjects, int width, int height)
|
||||||
|
{
|
||||||
|
if (moveableObjects == null)
|
||||||
|
{
|
||||||
|
_state = StrategyStatus.NotInit;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_state = StrategyStatus.InProgress;
|
||||||
|
_moveableObject = moveableObjects;
|
||||||
|
FieldWidth = width;
|
||||||
|
FieldHeight = height;
|
||||||
|
}
|
||||||
|
public void MakeStep()
|
||||||
|
{
|
||||||
|
if (_state != StrategyStatus.InProgress) return;
|
||||||
|
if (IsTargetDestinaion())
|
||||||
|
{
|
||||||
|
_state = StrategyStatus.Finish;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
MoveToTarget();
|
||||||
|
}
|
||||||
|
protected boolean MoveLeft() {return MoveTo(MovementDirection.Left);};
|
||||||
|
protected boolean MoveRight() {return MoveTo(MovementDirection.Right);};
|
||||||
|
protected boolean MoveUp() {return MoveTo(MovementDirection.Up);};
|
||||||
|
protected boolean MoveDown() {return MoveTo(MovementDirection.Down);};
|
||||||
|
protected ObjectParameters GetObjectParameters() {return _moveableObject.GetObjectPosition();};
|
||||||
|
protected Integer GetStep()
|
||||||
|
{
|
||||||
|
if (_state != StrategyStatus.InProgress)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return _moveableObject.GetStep();
|
||||||
|
}
|
||||||
|
protected abstract void MoveToTarget();
|
||||||
|
protected abstract boolean IsTargetDestinaion();
|
||||||
|
private boolean MoveTo(MovementDirection movementDirection)
|
||||||
|
{
|
||||||
|
if (_state != StrategyStatus.InProgress)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
boolean stateTryMoveObject = _moveableObject.TryMoveObject(movementDirection);
|
||||||
|
if (stateTryMoveObject) return stateTryMoveObject;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package MovementStrategy;
|
||||||
|
|
||||||
|
public interface IMoveableObjects {
|
||||||
|
ObjectParameters GetObjectPosition();
|
||||||
|
int GetStep();
|
||||||
|
boolean TryMoveObject(MovementDirection direction);
|
||||||
|
}
|
27
ProjectContainerShip/src/MovementStrategy/MoveToBorder.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package MovementStrategy;
|
||||||
|
|
||||||
|
public class MoveToBorder extends AbstractStrategy{
|
||||||
|
@Override
|
||||||
|
protected boolean IsTargetDestinaion() {
|
||||||
|
ObjectParameters objParams = GetObjectParameters();
|
||||||
|
if (objParams == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return objParams.RightBorder + GetStep() >= FieldWidth-GetStep() &&
|
||||||
|
objParams.DownBorder + GetStep() >= FieldHeight-GetStep();
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void MoveToTarget() {
|
||||||
|
ObjectParameters objParams = GetObjectParameters();
|
||||||
|
if (objParams == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//реализация в правый нижний угол
|
||||||
|
int x = objParams.RightBorder;
|
||||||
|
if (x + GetStep() < FieldWidth) MoveRight();
|
||||||
|
int y = objParams.DownBorder;
|
||||||
|
if (y + GetStep() < FieldHeight) MoveDown();
|
||||||
|
}
|
||||||
|
}
|
48
ProjectContainerShip/src/MovementStrategy/MoveToCenter.java
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package MovementStrategy;
|
||||||
|
|
||||||
|
public class MoveToCenter extends AbstractStrategy{
|
||||||
|
@Override
|
||||||
|
protected boolean IsTargetDestinaion() {
|
||||||
|
ObjectParameters objParams = GetObjectParameters();
|
||||||
|
if (objParams == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth / 2 &&
|
||||||
|
objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 &&
|
||||||
|
objParams.ObjectMiddleVertical - GetStep() <= FieldHeight / 2 &&
|
||||||
|
objParams.ObjectMiddleVertical + GetStep() >= FieldHeight /2;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
protected void MoveToTarget() {
|
||||||
|
ObjectParameters objParams = GetObjectParameters();
|
||||||
|
if (objParams == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2;
|
||||||
|
if (Math.abs(diffX) > GetStep())
|
||||||
|
{
|
||||||
|
if (diffX > 0)
|
||||||
|
{
|
||||||
|
MoveLeft();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MoveRight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int diffY = objParams.ObjectMiddleVertical - FieldHeight / 2;
|
||||||
|
if (Math.abs(diffY) > GetStep())
|
||||||
|
{
|
||||||
|
if (diffY > 0)
|
||||||
|
{
|
||||||
|
MoveUp();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MoveDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
45
ProjectContainerShip/src/MovementStrategy/MoveableShip.java
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package MovementStrategy;
|
||||||
|
|
||||||
|
import DrawingShip.CanvasContainerShip;
|
||||||
|
import DrawingShip.DirectionType;
|
||||||
|
import DrawingShip.DrawingShip;
|
||||||
|
|
||||||
|
public class MoveableShip implements IMoveableObjects{
|
||||||
|
private CanvasContainerShip canvas = new CanvasContainerShip();
|
||||||
|
public MoveableShip(DrawingShip drawningship)
|
||||||
|
{
|
||||||
|
canvas._drawingShip = drawningship;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public ObjectParameters GetObjectPosition() {
|
||||||
|
if (canvas._drawingShip == null || canvas._drawingShip.EntityShip == null ||
|
||||||
|
canvas._drawingShip.GetPosX() == null || canvas._drawingShip.GetPosY() == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new ObjectParameters(canvas._drawingShip.GetPosX(), canvas._drawingShip.GetPosY(),
|
||||||
|
canvas._drawingShip.GetWidth(), canvas._drawingShip.GetHeight());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int GetStep() {
|
||||||
|
return (int)(canvas._drawingShip.EntityShip.Step);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean TryMoveObject(MovementDirection direction) {
|
||||||
|
if (canvas._drawingShip == null || canvas._drawingShip.EntityShip == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return canvas._drawingShip.MoveTransport(GetDirectionType(direction));
|
||||||
|
}
|
||||||
|
private static DirectionType GetDirectionType(MovementDirection direction)
|
||||||
|
{
|
||||||
|
switch (direction) {
|
||||||
|
case MovementDirection.Left: return DirectionType.Left;
|
||||||
|
case MovementDirection.Right: return DirectionType.Right;
|
||||||
|
case MovementDirection.Up: return DirectionType.Up;
|
||||||
|
case MovementDirection.Down: return DirectionType.Down;
|
||||||
|
default: return DirectionType.Unknow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
package MovementStrategy;
|
||||||
|
|
||||||
|
public enum MovementDirection {
|
||||||
|
Up,
|
||||||
|
Down,
|
||||||
|
Left,
|
||||||
|
Right
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package MovementStrategy;
|
||||||
|
|
||||||
|
public class ObjectParameters {
|
||||||
|
private int _x;
|
||||||
|
private int _y;
|
||||||
|
private int _width;
|
||||||
|
private int _height;
|
||||||
|
public int LeftBorder = _x;
|
||||||
|
public int TopBorder = _y;
|
||||||
|
public int RightBorder = _x + _width;
|
||||||
|
public int DownBorder = _y + _height;
|
||||||
|
public int ObjectMiddleHorizontal = _x + _width / 2;
|
||||||
|
public int ObjectMiddleVertical = _y + _height / 2;
|
||||||
|
public ObjectParameters(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
_x = x;
|
||||||
|
_y = y;
|
||||||
|
_width = width;
|
||||||
|
_height = height;
|
||||||
|
LeftBorder = _x;
|
||||||
|
TopBorder = _y;
|
||||||
|
RightBorder = _x + _width;
|
||||||
|
DownBorder = _y + _height;
|
||||||
|
ObjectMiddleHorizontal = _x + _width / 2;
|
||||||
|
ObjectMiddleVertical = _y + _height / 2;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package MovementStrategy;
|
||||||
|
|
||||||
|
public enum StrategyStatus {
|
||||||
|
NotInit,
|
||||||
|
InProgress,
|
||||||
|
Finish
|
||||||
|
}
|
After Width: | Height: | Size: 141 KiB |
After Width: | Height: | Size: 139 KiB |
After Width: | Height: | Size: 4.8 KiB |
BIN
out/production/PIbd-11_Kudrinsky_O.S._ContainerShip_Hard/up.jpg
Normal file
After Width: | Height: | Size: 141 KiB |