PIbd-21_Potapov_N.S._Stormt.../ProjectStormtrooper/DrawingEngines.java

86 lines
2.9 KiB
Java
Raw Normal View History

package ProjectStormtrooper;
import java.awt.*;
public class DrawingEngines {
private EnumEnginesCount _enumEnginesCount;
public void SetEnumEnginesCount(int enginesCount) {
for (EnumEnginesCount val : EnumEnginesCount.values()) {
if (val.count == enginesCount) {
this._enumEnginesCount = val;
return;
}
}
this._enumEnginesCount = EnumEnginesCount.Two;
}
private void DrawEngine(Graphics2D g2d, Color color, int x, int y, int w, int h) {
g2d.setColor(Color.WHITE);
g2d.fillRect(x, y, w, h);
g2d.setColor(Color.BLACK);
g2d.drawRect(x, y, w, h);
g2d.setColor(color);
g2d.fillRect(x, y, 6, h);
}
public void DrawEngines(Graphics g, Color color, int startPosX, int startPosY, int drawingWidth, int drawingHeight) {
if (_enumEnginesCount == null) {
return;
}
Graphics2D g2d = (Graphics2D) g;
int engineWidth = 20;
int engineHeight = 6;
if (_enumEnginesCount.count >= EnumEnginesCount.Two.count) {
DrawEngine(
g2d, color,
startPosX + drawingWidth - drawingWidth / 5,
startPosY + drawingHeight / 2 - drawingHeight / 6,
engineWidth,
engineHeight
);
DrawEngine(
g2d, color,
startPosX + drawingWidth - drawingWidth / 5,
startPosY + drawingHeight / 2 + drawingHeight / 6 - engineHeight,
engineWidth,
engineHeight
);
}
if (_enumEnginesCount.count >= EnumEnginesCount.Four.count) {
DrawEngine(
g2d, color,
startPosX + drawingWidth - drawingWidth / 5 + 5,
startPosY + drawingHeight / 2 - drawingHeight / 6 - 10,
engineWidth - 5,
engineHeight
);
DrawEngine(
g2d, color,
startPosX + drawingWidth - drawingWidth / 5 + 5,
startPosY + drawingHeight / 2 + drawingHeight / 6 - engineHeight + 10,
engineWidth - 5,
engineHeight
);
}
if (_enumEnginesCount.count >= EnumEnginesCount.Six.count) {
DrawEngine(
g2d, color,
startPosX + drawingWidth / 2 - 10,
startPosY + drawingHeight / 2 - drawingHeight / 6 - 10,
engineWidth,
engineHeight
);
DrawEngine(
g2d, color,
startPosX + drawingWidth / 2 - 10,
startPosY + drawingHeight / 2 + drawingHeight / 6 + 3,
engineWidth,
engineHeight
);
}
}
}