some fixes
1
.idea/.name
generated
Normal file
@ -0,0 +1 @@
|
|||||||
|
DrawningCatamaran.java
|
BIN
ProjectCatamaran/Resources/30px_arrow_down.png
Normal file
After Width: | Height: | Size: 244 B |
BIN
ProjectCatamaran/Resources/30px_arrow_left.png
Normal file
After Width: | Height: | Size: 249 B |
BIN
ProjectCatamaran/Resources/30px_arrow_right.png
Normal file
After Width: | Height: | Size: 254 B |
BIN
ProjectCatamaran/Resources/30px_arrow_up.png
Normal file
After Width: | Height: | Size: 257 B |
BIN
ProjectCatamaran/Resources/arrowDown.jpg
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
ProjectCatamaran/Resources/arrowLeft.jpg
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
ProjectCatamaran/Resources/arrowRight.jpg
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
ProjectCatamaran/Resources/arrowUp.jpg
Normal file
After Width: | Height: | Size: 61 KiB |
@ -5,8 +5,8 @@ public class DrawningCatamaran {
|
|||||||
public EntityCatamaran entityCatamaran;
|
public EntityCatamaran entityCatamaran;
|
||||||
private Integer _pictureWidth = null;
|
private Integer _pictureWidth = null;
|
||||||
private Integer _pictureHeight = null;
|
private Integer _pictureHeight = null;
|
||||||
private int _startPosX;
|
private Integer _startPosX;
|
||||||
private int _startPosY;
|
private Integer _startPosY;
|
||||||
private final int _drawingCatamaranWidth = 120;
|
private final int _drawingCatamaranWidth = 120;
|
||||||
private final int _drawingCatamaranHeight = 70;
|
private final int _drawingCatamaranHeight = 70;
|
||||||
private DrawningCatamaranPaddle _drawingCatamaranPaddle;
|
private DrawningCatamaranPaddle _drawingCatamaranPaddle;
|
||||||
@ -28,12 +28,42 @@ public class DrawningCatamaran {
|
|||||||
|
|
||||||
|
|
||||||
public void setPosition(int x, int y, int width, int height) {
|
public void setPosition(int x, int y, int width, int height) {
|
||||||
if (x > 0 && x + _drawingCatamaranWidth < width && y> 0 && y + _drawingCatamaranHeight < height) {
|
if (_pictureHeight == null || _pictureWidth == null)
|
||||||
_startPosX = x;
|
return;
|
||||||
_startPosY = y;
|
if (x + _drawingCatamaranWidth > _pictureWidth) _startPosX = _pictureWidth - _drawingCatamaranWidth;
|
||||||
_pictureWidth = width;
|
else if (x < 0) _startPosX = 0;
|
||||||
_pictureHeight = height;
|
else _startPosX = x;
|
||||||
|
|
||||||
|
if (y + _drawingCatamaranHeight > _pictureHeight) _startPosY = _pictureHeight - _drawingCatamaranHeight;
|
||||||
|
else if (y < 0) _startPosY = 0;
|
||||||
|
else _startPosY = y;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
public boolean setPictureSize(int width, int height) {
|
||||||
|
_pictureHeight = height;
|
||||||
|
_pictureWidth = width;
|
||||||
|
if (_drawingCatamaranHeight > height || _drawingCatamaranWidth > width)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (_startPosX != null || _startPosY != null)
|
||||||
|
{
|
||||||
|
if (_startPosX + _drawingCatamaranWidth > _pictureWidth)
|
||||||
|
_startPosX = _pictureWidth - _drawingCatamaranWidth;
|
||||||
|
else if (_startPosX < 0)
|
||||||
|
_startPosX = 0;
|
||||||
|
if (_startPosY + _drawingCatamaranHeight > _pictureHeight)
|
||||||
|
_startPosY = _pictureHeight - _drawingCatamaranHeight;
|
||||||
|
else if (_startPosY < 0)
|
||||||
|
_startPosY = 0;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean moveTransport(DirectionType direction) {
|
public boolean moveTransport(DirectionType direction) {
|
||||||
@ -152,25 +182,10 @@ public class DrawningCatamaran {
|
|||||||
g2d.setColor(entityCatamaran.getAdditionalColor());
|
g2d.setColor(entityCatamaran.getAdditionalColor());
|
||||||
g2d.fillPolygon(sailPolygon);
|
g2d.fillPolygon(sailPolygon);
|
||||||
|
|
||||||
// вёсла катамарана
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
public void changeBorders(int width, int height) {
|
|
||||||
_pictureWidth = width;
|
|
||||||
_pictureHeight = height;
|
|
||||||
if (_pictureWidth <= _drawingCatamaranWidth || _pictureHeight <= _drawingCatamaranHeight) {
|
|
||||||
_pictureWidth = null;
|
|
||||||
_pictureHeight = null;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (_startPosX + _drawingCatamaranWidth > _pictureWidth)
|
|
||||||
_startPosX = _pictureWidth - _drawingCatamaranWidth;
|
|
||||||
if (_startPosY + _drawingCatamaranHeight > _pictureHeight)
|
|
||||||
_startPosY = _pictureHeight - _drawingCatamaranHeight;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,9 @@ public class DrawningCatamaranPaddle {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setEnumNumber(int paddlesCount) {
|
public void setEnumNumber(int paddlesCount) {
|
||||||
for (PaddlesCount val : PaddlesCount.values()) {
|
for (PaddlesCount value : PaddlesCount.values()) {
|
||||||
if (val.enumNumber == paddlesCount) {
|
if (value.enumNumber == paddlesCount) {
|
||||||
_paddlesCount = val;
|
_paddlesCount = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,6 @@ import javax.swing.*;
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.event.ComponentAdapter;
|
|
||||||
import java.awt.event.ComponentEvent;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -38,6 +36,7 @@ public class FormCatamaran extends JFrame {
|
|||||||
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
|
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
|
||||||
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
|
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
|
||||||
random.nextBoolean(), random.nextBoolean() );
|
random.nextBoolean(), random.nextBoolean() );
|
||||||
|
_drawningCatamaran.setPictureSize(PictureBox.getWidth(), PictureBox.getHeight());
|
||||||
_drawningCatamaran.setPosition(random.nextInt(35, 100),
|
_drawningCatamaran.setPosition(random.nextInt(35, 100),
|
||||||
random.nextInt(35, 100), PictureBox.getWidth(), PictureBox.getHeight());
|
random.nextInt(35, 100), PictureBox.getWidth(), PictureBox.getHeight());
|
||||||
|
|
||||||
@ -45,15 +44,6 @@ public class FormCatamaran extends JFrame {
|
|||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
PanelWrapper.addComponentListener(new ComponentAdapter() {
|
|
||||||
@Override
|
|
||||||
public void componentResized(ComponentEvent e) {
|
|
||||||
super.componentResized(e);
|
|
||||||
|
|
||||||
_drawningCatamaran.changeBorders(PictureBox.getWidth(), PictureBox.getHeight());
|
|
||||||
Draw();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
ActionListener buttonMoveClickedListener = new ActionListener() {
|
ActionListener buttonMoveClickedListener = new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
@ -101,12 +91,13 @@ public class FormCatamaran extends JFrame {
|
|||||||
RepaintControls();
|
RepaintControls();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RepaintControls() {
|
private void RepaintControls() {
|
||||||
for (JComponent control : controls) {
|
for (JComponent control : controls) {
|
||||||
control.repaint();
|
control.repaint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void InitializeControlsRepaintList() {
|
private void InitializeControlsRepaintList() {
|
||||||
controls = new LinkedList<>();
|
controls = new LinkedList<>();
|
||||||
controls.add(buttonCreate);
|
controls.add(buttonCreate);
|
||||||
|
BIN
out/production/ProjectCatamaran/30px_arrow_down.png
Normal file
After Width: | Height: | Size: 244 B |
BIN
out/production/ProjectCatamaran/30px_arrow_left.png
Normal file
After Width: | Height: | Size: 249 B |
BIN
out/production/ProjectCatamaran/30px_arrow_right.png
Normal file
After Width: | Height: | Size: 254 B |
BIN
out/production/ProjectCatamaran/30px_arrow_up.png
Normal file
After Width: | Height: | Size: 257 B |
BIN
out/production/ProjectCatamaran/DirectionType.class
Normal file
BIN
out/production/ProjectCatamaran/DrawningCatamaran$1.class
Normal file
BIN
out/production/ProjectCatamaran/DrawningCatamaran.class
Normal file
BIN
out/production/ProjectCatamaran/DrawningCatamaranPaddle.class
Normal file
BIN
out/production/ProjectCatamaran/EntityCatamaran.class
Normal file
BIN
out/production/ProjectCatamaran/FormCatamaran$1.class
Normal file
BIN
out/production/ProjectCatamaran/FormCatamaran$2.class
Normal file
BIN
out/production/ProjectCatamaran/FormCatamaran.class
Normal file
BIN
out/production/ProjectCatamaran/Main.class
Normal file
BIN
out/production/ProjectCatamaran/PaddlesCount.class
Normal file
BIN
out/production/ProjectCatamaran/arrowDown.jpg
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
out/production/ProjectCatamaran/arrowLeft.jpg
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
out/production/ProjectCatamaran/arrowRight.jpg
Normal file
After Width: | Height: | Size: 60 KiB |
BIN
out/production/ProjectCatamaran/arrowUp.jpg
Normal file
After Width: | Height: | Size: 61 KiB |