Added two new types of rollers to draw
This commit is contained in:
parent
fbd46924d1
commit
1ef0f5465b
83
DrawingCrossRollers.java
Normal file
83
DrawingCrossRollers.java
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
import java.awt.geom.Line2D;
|
||||||
|
|
||||||
|
public class DrawingCrossRollers implements IDrawingRollers {
|
||||||
|
private RollersCount rollersCount;
|
||||||
|
private Color color;
|
||||||
|
|
||||||
|
public DrawingCrossRollers(int rollersCount, Color bodyColor) {
|
||||||
|
setRollersCount(rollersCount);
|
||||||
|
color = bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRollersCount(int num) {
|
||||||
|
if (num <= 4) {
|
||||||
|
rollersCount = RollersCount.Four;
|
||||||
|
} else if (num >= 6) {
|
||||||
|
rollersCount = RollersCount.Six;
|
||||||
|
} else {
|
||||||
|
rollersCount = RollersCount.Five;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(Graphics2D g, int x, int y, int artilleryWidth, int artilleryHeight) {
|
||||||
|
g.setColor(color != null ? color : Color.BLACK);
|
||||||
|
g.fillOval(x + artilleryWidth / 20, y + artilleryHeight * 7 / 15, artilleryWidth * 4 / 20, artilleryHeight * 10 / 32);
|
||||||
|
g.fillOval(x + artilleryWidth * 15 / 20, y + artilleryHeight * 7 / 15, artilleryWidth * 4 / 20, artilleryHeight * 10 / 32);
|
||||||
|
switch (rollersCount) {
|
||||||
|
case Six: {
|
||||||
|
g.fillOval(x + artilleryWidth * 8 / 20, y + artilleryHeight * 10 / 16, artilleryWidth * 2 / 20, artilleryHeight * 6 / 32);
|
||||||
|
}
|
||||||
|
case Five: {
|
||||||
|
g.fillOval(x + artilleryWidth * 10 / 20, y + artilleryHeight * 10 / 16, artilleryWidth * 2 / 20, artilleryHeight * 6 / 32);
|
||||||
|
}
|
||||||
|
case Four: {
|
||||||
|
g.fillOval(x + artilleryWidth * 5 / 20, y + artilleryHeight * 9 / 16, artilleryWidth * 3 / 20, artilleryHeight * 8 / 32);
|
||||||
|
g.fillOval(x + artilleryWidth * 12 / 20, y + artilleryHeight * 9 / 16, artilleryWidth * 3 / 20, artilleryHeight * 8 / 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawOrnament(g, x, y, artilleryWidth, artilleryHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawOrnament(Graphics2D g, int x, int y, int artilleryWidth, int artilleryHeight) {
|
||||||
|
g.setStroke(new BasicStroke(1));
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
|
||||||
|
|
||||||
|
g.drawLine(x + artilleryWidth / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 5 / 32, x + artilleryWidth * 5 / 20 - 1, y + artilleryHeight * 7 / 15 + artilleryHeight * 5 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 3 / 20, y + artilleryHeight * 7 / 15, x + artilleryWidth * 3 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 10 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 2 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 5 / 64, x + artilleryWidth * 4 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 15 / 64);
|
||||||
|
g.drawLine(x + artilleryWidth * 4 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 5 / 64, x + artilleryWidth * 2 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 15 / 64);
|
||||||
|
|
||||||
|
g.drawLine(x + artilleryWidth * 15 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 5 / 32, x + artilleryWidth * 19 / 20 - 1, y + artilleryHeight * 7 / 15 + artilleryHeight * 5 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 17 / 20, y + artilleryHeight * 7 / 15, x + artilleryWidth * 17 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 10 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 16 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 5 / 64, x + artilleryWidth * 18 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 15 / 64);
|
||||||
|
g.drawLine(x + artilleryWidth * 18 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 5 / 64, x + artilleryWidth * 16 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 15 / 64);
|
||||||
|
|
||||||
|
switch(rollersCount) {
|
||||||
|
case Six: {
|
||||||
|
g.drawLine(x + artilleryWidth * 8 / 20, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32, x + artilleryWidth * 10 / 20, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 9 / 20, y + artilleryHeight * 10 / 16, x + artilleryWidth * 9 / 20, y + artilleryHeight * 10 / 16 + artilleryHeight * 6 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 8 / 20 + artilleryWidth * 2 / 80, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32 - artilleryHeight * 3 / 64, x + artilleryWidth * 10 / 20 - artilleryWidth * 2 / 80, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32 + artilleryHeight * 3 / 64);
|
||||||
|
g.drawLine(x + artilleryWidth * 9 / 20 + artilleryWidth * 2 / 80, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32 - artilleryHeight * 3 / 64, x + artilleryWidth * 8 / 20 + artilleryWidth * 2 / 80, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32 + artilleryHeight * 3 / 64);
|
||||||
|
}
|
||||||
|
case Five: {
|
||||||
|
g.drawLine(x + artilleryWidth * 10 / 20, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32, x + artilleryWidth * 12 / 20, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 11 / 20, y + artilleryHeight * 10 / 16, x + artilleryWidth * 11 / 20, y + artilleryHeight * 10 / 16 + artilleryHeight * 6 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 12 / 20 + artilleryWidth * 2 / 80, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32 - artilleryHeight * 3 / 64, x + artilleryWidth * 12 / 20 - artilleryWidth * 2 / 80, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32 + artilleryHeight * 3 / 64);
|
||||||
|
g.drawLine(x + artilleryWidth * 11 / 20 + artilleryWidth * 2 / 80, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32 - artilleryHeight * 3 / 64, x + artilleryWidth * 10 / 20 + artilleryWidth * 2 / 80, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32 + artilleryHeight * 3 / 64);
|
||||||
|
}
|
||||||
|
case Four: {
|
||||||
|
g.drawLine(x + artilleryWidth * 5 / 20, y + artilleryHeight * 9 / 16 + artilleryHeight * 4 / 32, x + artilleryWidth * 5 / 20 + artilleryWidth * 3 / 20, y + artilleryHeight * 9 / 16 + artilleryHeight * 4 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 5 / 20 + artilleryWidth * 3 / 40, y + artilleryHeight * 9 / 16, x + artilleryWidth * 5 / 20 + artilleryWidth * 3 / 40, y + artilleryHeight * 9 / 16 + artilleryHeight * 8 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 5 / 20 + artilleryWidth * 3 / 80, y + artilleryHeight * 9 / 16 + artilleryHeight * 2 / 32, x + artilleryWidth * 5 / 20 + artilleryWidth * 9 / 80, y + artilleryHeight * 9 / 16 + artilleryHeight * 6 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 5 / 20 + artilleryWidth * 9 / 80, y + artilleryHeight * 9 / 16 + artilleryHeight * 2 / 32, x + artilleryWidth * 5 / 20 + artilleryWidth * 3 / 80, y + artilleryHeight * 9 / 16 + artilleryHeight * 6 / 32);
|
||||||
|
|
||||||
|
g.drawLine(x + artilleryWidth * 12 / 20, y + artilleryHeight * 9 / 16 + artilleryHeight * 4 / 32, x + artilleryWidth * 12 / 20 + artilleryWidth * 3 / 20, y + artilleryHeight * 9 / 16 + artilleryHeight * 4 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 12 / 20 + artilleryWidth * 3 / 40, y + artilleryHeight * 9 / 16, x + artilleryWidth * 12 / 20 + artilleryWidth * 3 / 40, y + artilleryHeight * 9 / 16 + artilleryHeight * 8 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 12 / 20 + artilleryWidth * 3 / 80, y + artilleryHeight * 9 / 16 + artilleryHeight * 2 / 32, x + artilleryWidth * 12 / 20 + artilleryWidth * 9 / 80, y + artilleryHeight * 9 / 16 + artilleryHeight * 6 / 32);
|
||||||
|
g.drawLine(x + artilleryWidth * 12 / 20 + artilleryWidth * 9 / 80, y + artilleryHeight * 9 / 16 + artilleryHeight * 2 / 32, x + artilleryWidth * 12 / 20 + artilleryWidth * 3 / 80, y + artilleryHeight * 9 / 16 + artilleryHeight * 6 / 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
107
DrawingSquaredRollers.java
Normal file
107
DrawingSquaredRollers.java
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
import java.awt.*;
|
||||||
|
|
||||||
|
public class DrawingSquaredRollers implements IDrawingRollers {
|
||||||
|
private RollersCount rollersCount;
|
||||||
|
private Color color;
|
||||||
|
|
||||||
|
public DrawingSquaredRollers(int rollersCount, Color bodyColor) {
|
||||||
|
setRollersCount(rollersCount);
|
||||||
|
color = bodyColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRollersCount(int num) {
|
||||||
|
if (num <= 4) {
|
||||||
|
rollersCount = RollersCount.Four;
|
||||||
|
} else if (num >= 6) {
|
||||||
|
rollersCount = RollersCount.Six;
|
||||||
|
} else {
|
||||||
|
rollersCount = RollersCount.Five;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw(Graphics2D g, int x, int y, int artilleryWidth, int artilleryHeight) {
|
||||||
|
g.setColor(color != null ? color : Color.BLACK);
|
||||||
|
g.fillOval(x + artilleryWidth / 20, y + artilleryHeight * 7 / 15, artilleryWidth * 4 / 20, artilleryHeight * 10 / 32);
|
||||||
|
g.fillOval(x + artilleryWidth * 15 / 20, y + artilleryHeight * 7 / 15, artilleryWidth * 4 / 20, artilleryHeight * 10 / 32);
|
||||||
|
switch (rollersCount) {
|
||||||
|
case Six: {
|
||||||
|
g.fillOval(x + artilleryWidth * 8 / 20, y + artilleryHeight * 10 / 16, artilleryWidth * 2 / 20, artilleryHeight * 6 / 32);
|
||||||
|
}
|
||||||
|
case Five: {
|
||||||
|
g.fillOval(x + artilleryWidth * 10 / 20, y + artilleryHeight * 10 / 16, artilleryWidth * 2 / 20, artilleryHeight * 6 / 32);
|
||||||
|
}
|
||||||
|
case Four: {
|
||||||
|
g.fillOval(x + artilleryWidth * 5 / 20, y + artilleryHeight * 9 / 16, artilleryWidth * 3 / 20, artilleryHeight * 8 / 32);
|
||||||
|
g.fillOval(x + artilleryWidth * 12 / 20, y + artilleryHeight * 9 / 16, artilleryWidth * 3 / 20, artilleryHeight * 8 / 32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
drawOrnament(g, x, y, artilleryWidth, artilleryHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void drawOrnament(Graphics2D g, int x, int y, int artilleryWidth, int artilleryHeight) {
|
||||||
|
g.setStroke(new BasicStroke(1));
|
||||||
|
g.setColor(Color.BLACK);
|
||||||
|
|
||||||
|
Polygon bigRollerFirstPattern = new Polygon();
|
||||||
|
bigRollerFirstPattern.addPoint(x + artilleryWidth / 20 + 1, y + artilleryHeight * 7 / 15 + artilleryHeight * 5 / 32);
|
||||||
|
bigRollerFirstPattern.addPoint(x + artilleryWidth * 3 / 20, y + artilleryHeight * 7 / 15 + 1);
|
||||||
|
bigRollerFirstPattern.addPoint(x + artilleryWidth * 5 / 20 - 1, y + artilleryHeight * 7 / 15 + artilleryHeight * 5 / 32);
|
||||||
|
bigRollerFirstPattern.addPoint(x + artilleryWidth * 3 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 10 / 32 - 1);
|
||||||
|
g.drawPolygon(bigRollerFirstPattern);
|
||||||
|
bigRollerFirstPattern.translate(artilleryWidth * 14 / 20, 0);
|
||||||
|
g.drawPolygon(bigRollerFirstPattern);
|
||||||
|
|
||||||
|
Polygon bigRollerSecondPattern = new Polygon();
|
||||||
|
bigRollerSecondPattern.addPoint(x + artilleryWidth * 2 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 5 / 64);
|
||||||
|
bigRollerSecondPattern.addPoint(x + artilleryWidth * 4 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 5 / 64);
|
||||||
|
bigRollerSecondPattern.addPoint(x + artilleryWidth * 4 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 15 / 64);
|
||||||
|
bigRollerSecondPattern.addPoint(x + artilleryWidth * 2 / 20, y + artilleryHeight * 7 / 15 + artilleryHeight * 15 / 64);
|
||||||
|
g.drawPolygon(bigRollerSecondPattern);
|
||||||
|
bigRollerSecondPattern.translate(artilleryWidth * 14 / 20, 0);
|
||||||
|
g.drawPolygon(bigRollerSecondPattern);
|
||||||
|
|
||||||
|
Polygon smallRollerFirstPattern = new Polygon();
|
||||||
|
smallRollerFirstPattern.addPoint(x + artilleryWidth * 8 / 20, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32);
|
||||||
|
smallRollerFirstPattern.addPoint(x + artilleryWidth * 9 / 20, y + artilleryHeight * 10 / 16);
|
||||||
|
smallRollerFirstPattern.addPoint(x + artilleryWidth * 10 / 20, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32);
|
||||||
|
smallRollerFirstPattern.addPoint(x + artilleryWidth * 9 / 20, y + artilleryHeight * 10 / 16 + artilleryHeight * 6 / 32);
|
||||||
|
|
||||||
|
Polygon smallRollerSecondPattern = new Polygon();
|
||||||
|
smallRollerSecondPattern.addPoint(x + artilleryWidth * 8 / 20 + artilleryWidth * 2 / 80, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32 - artilleryHeight * 3 / 64);
|
||||||
|
smallRollerSecondPattern.addPoint(x + artilleryWidth * 9 / 20 + artilleryWidth * 2 / 80, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32 - artilleryHeight * 3 / 64);
|
||||||
|
smallRollerSecondPattern.addPoint(x + artilleryWidth * 10 / 20 - artilleryWidth * 2 / 80, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32 + artilleryHeight * 3 / 64);
|
||||||
|
smallRollerSecondPattern.addPoint(x + artilleryWidth * 8 / 20 + artilleryWidth * 2 / 80, y + artilleryHeight * 10 / 16 + artilleryHeight * 3 / 32 + artilleryHeight * 3 / 64);
|
||||||
|
|
||||||
|
switch(rollersCount) {
|
||||||
|
case Six: {
|
||||||
|
g.drawPolygon(smallRollerFirstPattern);
|
||||||
|
g.drawPolygon(smallRollerSecondPattern);
|
||||||
|
}
|
||||||
|
case Five: {
|
||||||
|
smallRollerFirstPattern.translate(artilleryWidth * 2 / 20, 0);
|
||||||
|
smallRollerSecondPattern.translate(artilleryWidth * 2 / 20, 0);
|
||||||
|
g.drawPolygon(smallRollerFirstPattern);
|
||||||
|
g.drawPolygon(smallRollerSecondPattern);
|
||||||
|
}
|
||||||
|
case Four: {
|
||||||
|
Polygon mediumRollerFirstPattern = new Polygon();
|
||||||
|
mediumRollerFirstPattern.addPoint(x + artilleryWidth * 5 / 20, y + artilleryHeight * 9 / 16 + artilleryHeight * 4 / 32);
|
||||||
|
mediumRollerFirstPattern.addPoint(x + artilleryWidth * 5 / 20 + artilleryWidth * 3 / 40, y + artilleryHeight * 9 / 16);
|
||||||
|
mediumRollerFirstPattern.addPoint(x + artilleryWidth * 5 / 20 + artilleryWidth * 3 / 20, y + artilleryHeight * 9 / 16 + artilleryHeight * 4 / 32);
|
||||||
|
mediumRollerFirstPattern.addPoint(x + artilleryWidth * 5 / 20 + artilleryWidth * 3 / 40, y + artilleryHeight * 9 / 16 + artilleryHeight * 8 / 32);
|
||||||
|
g.drawPolygon(mediumRollerFirstPattern);
|
||||||
|
mediumRollerFirstPattern.translate(artilleryWidth * 7 / 20, 0);
|
||||||
|
g.drawPolygon(mediumRollerFirstPattern);
|
||||||
|
|
||||||
|
Polygon mediumRollerSecondPattern = new Polygon();
|
||||||
|
mediumRollerSecondPattern.addPoint(x + artilleryWidth * 5 / 20 + artilleryWidth * 3 / 80, y + artilleryHeight * 9 / 16 + artilleryHeight * 2 / 32);
|
||||||
|
mediumRollerSecondPattern.addPoint(x + artilleryWidth * 5 / 20 + artilleryWidth * 9 / 80, y + artilleryHeight * 9 / 16 + artilleryHeight * 2 / 32);
|
||||||
|
mediumRollerSecondPattern.addPoint(x + artilleryWidth * 5 / 20 + artilleryWidth * 9 / 80, y + artilleryHeight * 9 / 16 + artilleryHeight * 6 / 32);
|
||||||
|
mediumRollerSecondPattern.addPoint(x + artilleryWidth * 5 / 20 + artilleryWidth * 3 / 80, y + artilleryHeight * 9 / 16 + artilleryHeight * 6 / 32);
|
||||||
|
g.drawPolygon(mediumRollerSecondPattern);
|
||||||
|
mediumRollerSecondPattern.translate(artilleryWidth * 7 / 20, 0);
|
||||||
|
g.drawPolygon(mediumRollerSecondPattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user