PIbd-21_Bakalskaya_E.D._Ele.../ProjectElectricLocomotive/DrawingWheel.java

43 lines
1.3 KiB
Java
Raw Normal View History

package ProjectElectricLocomotive;
import java.awt.*;
public class DrawingWheel {
private WheelsCount _wheelsCount;
public void SetWheelsCount(int enginesCount) {
for (WheelsCount val : WheelsCount.values()) {
if (val.count == enginesCount) {
this._wheelsCount = val;
return;
}
}
}
private void DrawWheel(Graphics2D g2d, Color color, int x, int y, int w, int h) {
g2d.setColor(Color.BLACK);
g2d.fillOval(x, y, w, h);
}
public void DrawWheels(Graphics g, Color color, int startPosX, int startPosY, int drawingWidth, int drawingHeight) {
if (_wheelsCount == null) {
return;
}
Graphics2D g2d = (Graphics2D) g;
int wheelWidth = 5;
int wheelHeight = 5;
if (_wheelsCount.count >= _wheelsCount.Three.count) {
DrawWheel(g2d, color, startPosX + 105, startPosY + 45, wheelWidth, wheelHeight
);
}
if (_wheelsCount.count >= _wheelsCount.Four.count) {
DrawWheel(g2d, color, startPosX + 105, startPosY + 45, wheelWidth, wheelHeight
);
DrawWheel(g2d, color, startPosX + 130, startPosY + 45, wheelWidth, wheelHeight
);
}
}
}