PIbd-14_Antonova_A.A.__Hard/Drawnings/CanvasFormDumpTruckCollection.java
2024-06-10 21:17:02 +04:00

34 lines
1.1 KiB
Java

package Drawnings;
import CollectionGenericObjects.AbstractCompany;
import CollectionGenericObjects.ICollectionGenericObjects;
import CollectionGenericObjects.MassiveGenericObjects;
import javax.swing.*;
import java.awt.*;
public class CanvasFormDumpTruckCollection <T> extends JComponent {
public ICollectionGenericObjects<T> collection = new MassiveGenericObjects<T>();
public AbstractCompany company = null;
public void SetCollectionToCanvas(AbstractCompany company) {
this.company = company;
}
public CanvasFormDumpTruckCollection(){};
public void paintComponent(Graphics g) {
super.paintComponents(g);
if (company == null || company._collection == null) {
return;
}
company.DrawBackgound(g);
for (int i = 0; i < company._collection.getCount(); i++) {
Graphics2D g2d = (Graphics2D) g;
T obj = (T)company._collection.Get(i);
if (obj instanceof DrawningTruck) {
((DrawningTruck) obj).DrawTransport(g2d);
}
}
super.repaint();
}
}