First stage: Refactoring MapWithSetArtilleriesGeneric
This commit is contained in:
parent
9c4f1d4327
commit
0ae6527361
@ -1,5 +1,6 @@
|
|||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
public class MapWithSetArtilleriesGeneric<T extends IDrawingObject, U extends AbstractMap> {
|
public class MapWithSetArtilleriesGeneric<T extends IDrawingObject, U extends AbstractMap> {
|
||||||
public final int _pictureWidth;
|
public final int _pictureWidth;
|
||||||
@ -12,7 +13,7 @@ public class MapWithSetArtilleriesGeneric<T extends IDrawingObject, U extends Ab
|
|||||||
public MapWithSetArtilleriesGeneric(int picWidth, int picHeight, U map) {
|
public MapWithSetArtilleriesGeneric(int picWidth, int picHeight, U map) {
|
||||||
int width = picWidth / _placeSizeWidth;
|
int width = picWidth / _placeSizeWidth;
|
||||||
int height = picHeight / _placeSizeHeight;
|
int height = picHeight / _placeSizeHeight;
|
||||||
_setArtilleries = new SetArtilleriesGeneric<T>(width * height);
|
_setArtilleries = new SetArtilleriesGeneric<>(width * height);
|
||||||
_pictureWidth = picWidth;
|
_pictureWidth = picWidth;
|
||||||
_pictureHeight = picHeight;
|
_pictureHeight = picHeight;
|
||||||
_map = map;
|
_map = map;
|
||||||
@ -36,13 +37,8 @@ public class MapWithSetArtilleriesGeneric<T extends IDrawingObject, U extends Ab
|
|||||||
|
|
||||||
public Image showOnMap() {
|
public Image showOnMap() {
|
||||||
shaking();
|
shaking();
|
||||||
for (int i = 0; i < _setArtilleries.getCount(); i++)
|
for (T artillery : _setArtilleries.getArtilleries()) {
|
||||||
{
|
return _map.createMap(_pictureWidth, _pictureHeight, artillery);
|
||||||
var car = _setArtilleries.get(i);
|
|
||||||
if (car != null)
|
|
||||||
{
|
|
||||||
return _map.createMap(_pictureWidth, _pictureHeight, car);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return new BufferedImage(_pictureWidth, _pictureHeight, BufferedImage.TYPE_INT_ARGB);
|
return new BufferedImage(_pictureWidth, _pictureHeight, BufferedImage.TYPE_INT_ARGB);
|
||||||
}
|
}
|
||||||
@ -120,14 +116,12 @@ public class MapWithSetArtilleriesGeneric<T extends IDrawingObject, U extends Ab
|
|||||||
int width = _pictureWidth / _placeSizeWidth;
|
int width = _pictureWidth / _placeSizeWidth;
|
||||||
int height = _pictureHeight / _placeSizeHeight;
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
|
|
||||||
for (int i = 0; i < _setArtilleries.getCount(); i++)
|
int index = 0;
|
||||||
|
for (T artillery : _setArtilleries.getArtilleries())
|
||||||
{
|
{
|
||||||
var artillery = _setArtilleries.get(i);
|
artillery.setObject(index % width * _placeSizeWidth + 10, (height - 1 - index / width) * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
|
||||||
if (artillery != null)
|
artillery.drawingObject(g);
|
||||||
{
|
index++;
|
||||||
artillery.setObject(i % width * _placeSizeWidth + 10, (height - 1 - i / width) * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
|
|
||||||
artillery.drawingObject(g);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user