PIbd-23_Mochalov_D.V._Locom.../ExtraStarWheelDraw.java

67 lines
2.1 KiB
Java

import java.awt.*;
public class ExtraStarWheelDraw implements IDrawningExtra{
private WheelsCount wheelsCount = WheelsCount.Two;
private ExtraWheelsDraw extraWheelsDraw;
private Color color;
public void setExtraNum(int num) {
switch (num) {
case 0: {
wheelsCount = WheelsCount.Three;
break;
}
case 1: {
wheelsCount = WheelsCount.Four;
break;
}
default:
break;
}
}
public String TypeString() {
return "Star";
}
public int getWheelsCount() {
if (wheelsCount == WheelsCount.Two) return 2;
if (wheelsCount == WheelsCount.Three) return 3;
else return 4;
}
public ExtraStarWheelDraw (int num, Color bodyColor) {
setExtraNum(num);
extraWheelsDraw = new ExtraWheelsDraw(num, bodyColor);
}
public void SetColor(Color color) {
this.color = color;
}
public void DrawExtra(int startPosX, int startPosY, Graphics2D g) {
extraWheelsDraw.DrawExtra(startPosX, startPosY, g);
DrawStarOnWheel(startPosX, startPosY + 30, g);
DrawStarOnWheel(startPosX + 90, startPosY + 30, g);
switch (wheelsCount) {
case Four: {
DrawStarOnWheel(startPosX + 70, startPosY + 30, g);
}
case Three: {
DrawStarOnWheel(startPosX + 20, startPosY + 30, g);
break;
}
default:
break;
}
}
private void DrawStarOnWheel(int startPosX, int startPosY, Graphics2D g) {
g.setColor(color);
g.drawLine(startPosX + 10, startPosY, startPosX + 15, startPosY + 17);
g.drawLine(startPosX + 10, startPosY, startPosX + 5, startPosY + 17);
g.drawLine(startPosX + 15, startPosY + 17, startPosX + 2, startPosY + 8);
g.drawLine(startPosX + 5, startPosY + 17, startPosX + 18, startPosY + 8);
g.drawLine(startPosX + 2, startPosY + 8, startPosX + 18, startPosY + 8);
}
}