package ProjectStormtrooper; import java.awt.*; public interface IDrawingEngines { void SetEnumEnginesCount(int enginesCount); EnumEnginesCount GetEnumEnginesCount(); void DrawEngine(Graphics2D g2d, Color color, int x, int y, int w, int h); default void DrawEngines(Graphics g, Color color, int startPosX, int startPosY, int drawingWidth, int drawingHeight) { EnumEnginesCount enginesCount = GetEnumEnginesCount(); if (enginesCount == null) { return; } Graphics2D g2d = (Graphics2D) g; g2d.setStroke(new BasicStroke(2)); int engineWidth = 20; int engineHeight = 6; if (enginesCount.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 (enginesCount.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 (enginesCount.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 ); } } }