49 lines
1.9 KiB
Java
49 lines
1.9 KiB
Java
package Scripts.CollectionGenericObjects;
|
|
|
|
import Scripts.Drawing.DrawingMonorail;
|
|
|
|
import java.awt.*;
|
|
|
|
public class DepotSharingService extends AbstractCompany {
|
|
public DepotSharingService (int picWidth, int picHeight, ICollectionGenericObjects<DrawingMonorail> collection) {
|
|
super(picWidth, picHeight, collection);
|
|
}
|
|
|
|
private int _offsetX = 30;
|
|
|
|
@Override
|
|
public void DrawBackgound(Graphics graphics) {
|
|
int width = _pictureWidth / _placeSizeWidth;
|
|
int height = _pictureHeight / _placeSizeHeight;
|
|
graphics.setColor(Color.BLACK);
|
|
for (int i = 0; i < width; i++)
|
|
{
|
|
for (int j = 0; j < height; ++j)
|
|
{
|
|
graphics.drawLine(i * _offsetX + i * _placeSizeWidth, j * _placeSizeHeight, _placeSizeWidth + i * _offsetX + i * _placeSizeWidth, j * _placeSizeHeight);
|
|
graphics.drawLine(i * _offsetX + i * _placeSizeWidth, j * _placeSizeHeight, i * _offsetX + i * _placeSizeWidth, _placeSizeHeight + j * _placeSizeHeight);
|
|
graphics.drawLine(i * _offsetX + i * _placeSizeWidth, _placeSizeHeight + j * _placeSizeHeight, _placeSizeWidth + i * _offsetX + i * _placeSizeWidth, _placeSizeHeight + j * _placeSizeHeight);
|
|
}
|
|
}
|
|
}
|
|
@Override
|
|
protected void SetObjectsPosition() {
|
|
int width = _pictureWidth / _placeSizeWidth;
|
|
int height = _pictureHeight / _placeSizeHeight;
|
|
|
|
int boarderOffsetX = 20;
|
|
int boarderOffsetY = 20;
|
|
|
|
int currnetIndex = 0;
|
|
|
|
for (int j = height - 1; j >= 0; j--) {
|
|
for (int i = 0; i < width; i++, currnetIndex++) {
|
|
if (_collection.Get(currnetIndex) == null) continue;
|
|
|
|
_collection.Get(currnetIndex).SetPictureSize(_pictureWidth, _pictureHeight);
|
|
_collection.Get(currnetIndex).SetPosition(boarderOffsetX + i * _placeSizeWidth + i * _offsetX, boarderOffsetY + j * _placeSizeHeight);
|
|
}
|
|
}
|
|
}
|
|
}
|