66 lines
2.1 KiB
Java
66 lines
2.1 KiB
Java
|
package CollectionGenericObjects;
|
||
|
import Drawnings.DrawningTruck;
|
||
|
|
||
|
import java.awt.*;
|
||
|
|
||
|
public class TruckShearingService extends AbstractCompany {
|
||
|
public TruckShearingService(int picWidth, int picHeight, ICollectionGenericObjects<DrawningTruck> collection)
|
||
|
{
|
||
|
super(picWidth, picHeight, collection);
|
||
|
}
|
||
|
|
||
|
private int start_width = 10, start_height = 20;
|
||
|
private int width_between = 60;
|
||
|
|
||
|
@Override
|
||
|
public void DrawBackgound(Graphics g)
|
||
|
{
|
||
|
g.setColor(Color.BLACK);
|
||
|
int height = 5, width = 5;
|
||
|
|
||
|
int maxWidth = _pictureWidth / (_placeSizeWidth + width_between);
|
||
|
int maxHeight = _pictureHeight / _placeSizeHeight;
|
||
|
|
||
|
for (int i = 0; i < maxWidth; i++)
|
||
|
{
|
||
|
height = 10;
|
||
|
for (int j = 0; j < maxHeight; j++)
|
||
|
{
|
||
|
g.drawLine(width, height, width + _placeSizeWidth, height);
|
||
|
g.drawLine(width, height, width, height + _placeSizeHeight);
|
||
|
height += _placeSizeHeight;
|
||
|
}
|
||
|
g.drawLine(width, height, width + _placeSizeWidth, height);
|
||
|
width = width + _placeSizeWidth + width_between;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
protected void SetObjectsPosition()
|
||
|
{
|
||
|
int maxWidth = _pictureWidth / (_placeSizeWidth + width_between);
|
||
|
int maxHeight = _pictureHeight / _placeSizeHeight;
|
||
|
int i_collection = 0;
|
||
|
int x_pos = start_width, y_pos = start_height;
|
||
|
|
||
|
|
||
|
if (_collection != null) {
|
||
|
for (int j = 0; j < maxHeight; j++)
|
||
|
{
|
||
|
x_pos = start_width;
|
||
|
for (int i = 0; i < maxWidth; i++)
|
||
|
{
|
||
|
if (_collection.Get(i_collection) != null)
|
||
|
{
|
||
|
_collection.Get(i_collection).SetPictureSize(_pictureWidth, _pictureHeight);
|
||
|
_collection.Get(i_collection).SetPosition(x_pos, y_pos);
|
||
|
x_pos += _placeSizeWidth + width_between;
|
||
|
i_collection++;
|
||
|
}
|
||
|
}
|
||
|
y_pos = y_pos + _placeSizeHeight;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|