PIbd-12_Karamushko_M.K._Air.../DrawingWavyEngines.java

64 lines
1.7 KiB
Java
Raw Normal View History

2022-11-10 16:44:45 +04:00
import java.awt.*;
public class DrawingWavyEngines implements IDrawingEngines {
private EnginesCount enginesCount;
private Color color;
public DrawingWavyEngines(int count, Color bodyColor) {
setCount(count);
color = bodyColor;
}
@Override
public void setCount(int count) {
if(count <= 2) enginesCount = EnginesCount.Two;
else if(count >= 6) enginesCount = EnginesCount.Six;
else enginesCount = EnginesCount.Four;
}
2022-11-29 17:50:40 +04:00
@Override
public void setColor(Color color) {
this.color = color;
}
2022-12-02 11:17:40 +04:00
@Override
public int getCount() {
if(enginesCount == EnginesCount.Two) return 2;
if(enginesCount == EnginesCount.Four) return 4;
return 6;
}
@Override
public Color getColor() {
return color;
}
2022-11-10 16:44:45 +04:00
private void drawEngine(Graphics2D g, int x, int y) {
g.setColor(color);
g.fillRect(x, y, 21, 10);
g.fillArc(x, y - 4, 7, 8, 0, 180);
g.fillArc(x + 7, y - 4, 7, 8, 0, 180);
g.fillArc(x + 14, y - 4, 7, 8, 0, 180);
g.fillArc(x, y + 6, 7, 8, 180, 180);
g.fillArc(x + 7, y + 6, 7, 8, 180, 180);
g.fillArc(x + 14, y + 6, 7, 8, 180, 180);
}
public void draw(Graphics2D g, int startPosX, int startPosY) {
drawEngine(g, startPosX + 84, startPosY + 10);
drawEngine(g, startPosX + 84, startPosY + 146);
if(enginesCount == EnginesCount.Two) return;
drawEngine(g, startPosX + 84, startPosY + 30);
drawEngine(g, startPosX + 84, startPosY + 125);
if(enginesCount == EnginesCount.Four) return;
drawEngine(g, startPosX + 84, startPosY + 50);
drawEngine(g, startPosX + 84, startPosY + 106);
}
}