90 lines
2.8 KiB
Java
90 lines
2.8 KiB
Java
package ProjectTankHard.DrawningObjects;
|
|
|
|
import ProjectTankHard.WheelQuantityType;
|
|
|
|
import java.awt.*;
|
|
import java.awt.geom.Ellipse2D;
|
|
|
|
public class DrawningWheelsOrn2 implements IDraw {
|
|
private WheelQuantityType WheelsQuantity;
|
|
private Color Color;
|
|
private int Width, Height;
|
|
public int currentX, currentY;
|
|
public DrawningWheelsOrn2(int width, int height, int x, int y, Color color){
|
|
Width = width;
|
|
Height = height;
|
|
currentX = x;
|
|
currentY = y;
|
|
Color = color;
|
|
}
|
|
public void ChangeX(int x){
|
|
currentX = x;
|
|
}
|
|
public void ChangeY(int y){
|
|
currentY = y;
|
|
}
|
|
public void ChangeWheelsQuantity(int x){
|
|
if(x <= 4)
|
|
WheelsQuantity = WheelsQuantity.Four;
|
|
if(x == 5)
|
|
WheelsQuantity = WheelsQuantity.Five;
|
|
if(x >= 6)
|
|
WheelsQuantity = WheelsQuantity.Six;
|
|
}
|
|
public void DrawWheels(Graphics2D g2d){
|
|
g2d.setColor(Color);
|
|
|
|
g2d.fill(new Ellipse2D.Double(currentX + 1, currentY + Height - 5 - 25, 25, 25));
|
|
DrawOrnament(g2d, currentX + 1, currentY + Height - 5 - 25, 25);
|
|
|
|
int x, y;
|
|
int diameter = 20;
|
|
|
|
if (WheelsQuantity == WheelQuantityType.Four) {
|
|
for (int i = 1; i <= 2; i++) {
|
|
x = currentX + 40 + (5 * i) + (35 * (i - 1));
|
|
y = currentY + Height - 5 - 17;
|
|
|
|
g2d.fill(new Ellipse2D.Double(x, y, diameter, diameter));
|
|
DrawOrnament(g2d, x, y, diameter);
|
|
}
|
|
}
|
|
|
|
if (WheelsQuantity == WheelQuantityType.Five) {
|
|
for (int i = 1; i <= 3; i++) {
|
|
x = currentX + 30 + (5 * i) + (25 * (i - 1));
|
|
y = currentY + Height - 5 - 20;
|
|
|
|
g2d.fill(new Ellipse2D.Double(x, y, diameter, diameter));
|
|
DrawOrnament(g2d, x, y, diameter);
|
|
}
|
|
}
|
|
|
|
if (WheelsQuantity == WheelQuantityType.Six) {
|
|
diameter = 15;
|
|
|
|
for (int i = 1; i <= 4; i++) {
|
|
x = currentX + 30 + (5 * i) + (15 * (i - 1));
|
|
y = currentY + Height - 5 - 15;
|
|
|
|
g2d.fill(new Ellipse2D.Double(x, y, diameter, diameter));
|
|
DrawOrnament(g2d, x, y, diameter);
|
|
}
|
|
}
|
|
|
|
g2d.fill(new Ellipse2D.Double(currentX + Width - 25 - 1, currentY + Height - 5 - 25, 25, 25));
|
|
DrawOrnament(g2d, currentX + Width - 25 - 1, currentY + Height - 5 - 25, 25);
|
|
}
|
|
private void DrawOrnament(Graphics2D g2d, int x, int y, int diameter) {
|
|
int centerX = x + diameter / 2;
|
|
int centerY = y + diameter / 2;
|
|
|
|
g2d.setColor(Color.RED);
|
|
g2d.fill(new Ellipse2D.Double(centerX - 8 / 2, centerY - 8 / 2, 8, 8));
|
|
|
|
/*g2d.setColor(Color.BLACK);
|
|
g2d.fillRect(centerX - 1, centerY - 1, 3, 3);*/
|
|
|
|
g2d.setColor(Color);
|
|
}
|
|
} |