diff --git a/SelfPropelledArtilleryUnit/DrawningObjects/DrawningClamps.java b/SelfPropelledArtilleryUnit/DrawningObjects/DrawningClamps.java new file mode 100644 index 0000000..e589fb1 --- /dev/null +++ b/SelfPropelledArtilleryUnit/DrawningObjects/DrawningClamps.java @@ -0,0 +1,67 @@ +package SelfPropelledArtilleryUnit.DrawningObjects; +import SelfPropelledArtilleryUnit.NumbeRollers; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.geom.Ellipse2D; + +public class DrawningClamps implements IDrawable { + + Graphics2D g2d; + int startPosX; + int startPosY; + Color color; + private NumbeRollers _numbeRollers; + + @Override + public void setNum(int numRollers) { + if (numRollers < 4 || numRollers > 6 ){ + + _numbeRollers = NumbeRollers.fromNumberToEnum(numRollers); + return; + } + _numbeRollers = NumbeRollers.fromNumberToEnum(numRollers); + } + + public DrawningClamps(Graphics2D g2d, int startPosX, int startPosY, Color color, int numRollers){ + this.color = color; + this.g2d = g2d; + this.startPosX = startPosX; + this.startPosY = startPosY; + setNum(numRollers); + } + + @Override + public void Draw(){ + Ellipse2D ellipse1 = new Ellipse2D.Double(startPosX + 10, startPosY + 55, 10, 10); + Ellipse2D ellipse2 = new Ellipse2D.Double(startPosX + 35, startPosY + 55, 10, 10); + Ellipse2D ellipse3 = new Ellipse2D.Double(startPosX + 60, startPosY + 55, 10, 10); + Ellipse2D ellipse4 = new Ellipse2D.Double(startPosX + 85, startPosY + 55, 10, 10); + Ellipse2D ellipse5 = new Ellipse2D.Double(startPosX + 110, startPosY + 55, 10, 10); + Ellipse2D ellipse6 = new Ellipse2D.Double(startPosX + 127, startPosY + 60, 5, 5); + g2d.setPaint(color); + switch (_numbeRollers) { + case Min: + g2d.fill(ellipse1); + g2d.fill(ellipse2); + g2d.fill(ellipse3); + g2d.fill(ellipse4); + break; + case Mid: + g2d.fill(ellipse1); + g2d.fill(ellipse2); + g2d.fill(ellipse3); + g2d.fill(ellipse4); + g2d.fill(ellipse5); + break; + case Max: + g2d.fill(ellipse1); + g2d.fill(ellipse2); + g2d.fill(ellipse3); + g2d.fill(ellipse4); + g2d.fill(ellipse5); + g2d.fill(ellipse6); + break; + } + } +} diff --git a/SelfPropelledArtilleryUnit/DrawningObjects/DrawningNails.java b/SelfPropelledArtilleryUnit/DrawningObjects/DrawningNails.java new file mode 100644 index 0000000..f91009a --- /dev/null +++ b/SelfPropelledArtilleryUnit/DrawningObjects/DrawningNails.java @@ -0,0 +1,67 @@ +package SelfPropelledArtilleryUnit.DrawningObjects; +import SelfPropelledArtilleryUnit.NumbeRollers; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.geom.Ellipse2D; + +public class DrawningNails implements IDrawable { + + Graphics2D g2d; + int startPosX; + int startPosY; + Color color; + private NumbeRollers _numbeRollers; + + @Override + public void setNum(int numRollers) { + if (numRollers < 4 || numRollers > 6 ){ + + _numbeRollers = NumbeRollers.fromNumberToEnum(numRollers); + return; + } + _numbeRollers = NumbeRollers.fromNumberToEnum(numRollers); + } + + public DrawningNails(Graphics2D g2d, int startPosX, int startPosY, Color color, int numRollers){ + this.color = color; + this.g2d = g2d; + this.startPosX = startPosX; + this.startPosY = startPosY; + setNum(numRollers); + } + + @Override + public void Draw(){ + Ellipse2D ellipse1 = new Ellipse2D.Double(startPosX + 15, startPosY + 60, 2, 2); + Ellipse2D ellipse2 = new Ellipse2D.Double(startPosX + 40, startPosY + 60, 2, 2); + Ellipse2D ellipse3 = new Ellipse2D.Double(startPosX + 65, startPosY + 60, 2, 2); + Ellipse2D ellipse4 = new Ellipse2D.Double(startPosX + 90, startPosY + 60, 2, 2); + Ellipse2D ellipse5 = new Ellipse2D.Double(startPosX + 115, startPosY + 60, 2, 2); + Ellipse2D ellipse6 = new Ellipse2D.Double(startPosX + 130, startPosY + 65, 1, 1); + g2d.setPaint(Color.BLACK); + switch (_numbeRollers) { + case Min: + g2d.fill(ellipse1); + g2d.fill(ellipse2); + g2d.fill(ellipse3); + g2d.fill(ellipse4); + break; + case Mid: + g2d.fill(ellipse1); + g2d.fill(ellipse2); + g2d.fill(ellipse3); + g2d.fill(ellipse4); + g2d.fill(ellipse5); + break; + case Max: + g2d.fill(ellipse1); + g2d.fill(ellipse2); + g2d.fill(ellipse3); + g2d.fill(ellipse4); + g2d.fill(ellipse5); + g2d.fill(ellipse6); + break; + } + } +} \ No newline at end of file diff --git a/SelfPropelledArtilleryUnit/DrawningObjects/DrawningRollers.java b/SelfPropelledArtilleryUnit/DrawningObjects/DrawningRollers.java index eb559ad..eb270c8 100644 --- a/SelfPropelledArtilleryUnit/DrawningObjects/DrawningRollers.java +++ b/SelfPropelledArtilleryUnit/DrawningObjects/DrawningRollers.java @@ -5,14 +5,15 @@ import java.awt.Color; import java.awt.Graphics2D; import java.awt.geom.Ellipse2D; -public class DrawningRollers { +public class DrawningRollers implements IDrawable{ Graphics2D g2d; int startPosX; int startPosY; Color color; private NumbeRollers _numbeRollers; - public void setNumRollers(int numRollers) { + @Override + public void setNum(int numRollers) { if (numRollers < 4 || numRollers > 6 ){ _numbeRollers = NumbeRollers.fromNumberToEnum(numRollers); @@ -26,9 +27,10 @@ public class DrawningRollers { this.g2d = g2d; this.startPosX = startPosX; this.startPosY = startPosY; - setNumRollers(numRollers); + setNum(numRollers); } + @Override public void Draw(){ g2d.setPaint(Color.BLACK); Ellipse2D ellipse7 = new Ellipse2D.Double(startPosX + 10, startPosY + 55, 120, 20); @@ -39,7 +41,6 @@ public class DrawningRollers { Ellipse2D ellipse4 = new Ellipse2D.Double(startPosX + 80, startPosY + 50, 20, 20); Ellipse2D ellipse5 = new Ellipse2D.Double(startPosX + 105, startPosY + 50, 20, 20); Ellipse2D ellipse6 = new Ellipse2D.Double(startPosX + 125, startPosY + 60, 10, 10); - g2d.setPaint(color); g2d.draw(ellipse7); switch (_numbeRollers) { case Min: diff --git a/SelfPropelledArtilleryUnit/DrawningObjects/DrawningSPAU.java b/SelfPropelledArtilleryUnit/DrawningObjects/DrawningSPAU.java index 107ae61..72e51bd 100644 --- a/SelfPropelledArtilleryUnit/DrawningObjects/DrawningSPAU.java +++ b/SelfPropelledArtilleryUnit/DrawningObjects/DrawningSPAU.java @@ -113,6 +113,10 @@ public class DrawningSPAU { //гусеницы DrawningRollers Rollers = new DrawningRollers(g2d, startPosX, startPosY, bodyColor, _numbeRollers); Rollers.Draw(); + DrawningClamps Clamps = new DrawningClamps(g2d, startPosX, startPosY, bodyColor, _numbeRollers); + Clamps.Draw(); + DrawningNails Nails = new DrawningNails(g2d, startPosX, startPosY, bodyColor, _numbeRollers); + Nails.Draw(); // пушка path.moveTo(startPosX + 35, startPosY + 40); diff --git a/SelfPropelledArtilleryUnit/DrawningObjects/IDrawable.java b/SelfPropelledArtilleryUnit/DrawningObjects/IDrawable.java new file mode 100644 index 0000000..21cf889 --- /dev/null +++ b/SelfPropelledArtilleryUnit/DrawningObjects/IDrawable.java @@ -0,0 +1,6 @@ +package SelfPropelledArtilleryUnit.DrawningObjects; + +public interface IDrawable { + public void setNum(int num); + public void Draw(); +}