Skip to content
Snippets Groups Projects
Commit 3175d350 authored by Chadi's avatar Chadi
Browse files

need to check in uni

parent bc3215f2
Branches main
No related tags found
No related merge requests found
......@@ -13,16 +13,16 @@ public class Circle implements Shape {
this.x = x;
this.y = y;
this.radius = radius;
this.fillColor = Color.GREEN;
this.isFinished = false;
this.isFinished = true;
}
@Override
public void paint(GraphicsContext graphicsContext) {
graphicsContext.setStroke(Color.BLACK);
graphicsContext.setLineWidth(2);
if (isFinished) {
graphicsContext.setFill(fillColor);
graphicsContext.setFill(Color.GREEN);
graphicsContext.fillOval(x - radius, y - radius, 2 * radius, 2 * radius);
}
graphicsContext.strokeOval(x - radius, y - radius, 2 * radius, 2 * radius);
......@@ -46,12 +46,28 @@ public class Circle implements Shape {
return isFinished;
}
@Override
public void setFillColor(Color fillColor) {
this.fillColor = fillColor;
public void setX(double x) {
this.x = x;
}
public void setY(double y) {
this.y = y;
}
public void setFinished(boolean finished) {
isFinished = finished;
}
public void updateRadius(double newX, double newY) {
this.radius = Math.sqrt(Math.pow(newX - this.x, 2) + Math.pow(newY - this.y, 2));
}
public double getX() {
return x;
}
public double getY() {
return y;
}
}
......@@ -75,13 +75,11 @@ public class Drawer {
if(event.getButton() == MouseButton.PRIMARY && tempShape != null){
shapes.add(tempShape);
if (tempShape instanceof Rectangle){
tempShape.setFillColor(((Rectangle) tempShape).fillColor);
tempShape.isFinished();
((Rectangle) tempShape).setFinished(true);
}else if (tempShape instanceof Circle){
tempShape.setFillColor(((Circle) tempShape).fillColor);
tempShape.isFinished();
((Circle) tempShape).setFinished(true);
}
isFinished = true;
repaint();
tempShape = null;
}
......
......@@ -6,26 +6,24 @@ import javafx.scene.paint.Color;
public class Rectangle implements Shape{
private double x;
private double y;
private double width;
private double height;
private double x,y,width, height;
private boolean isFinished;
public Color fillColor = Color.RED;
public Color fillColor;
public Rectangle(double x, double y, double width, double height) {
this.x = x;
this.y = y;
this.width = width;
this.height = height;
this.isFinished = false;
this.isFinished = true;
}
@Override
public void paint(GraphicsContext graphicsContext) {
graphicsContext.setStroke(Color.BLACK);
graphicsContext.setLineWidth(2);
if(isFinished){
graphicsContext.setFill(fillColor);
graphicsContext.setFill(Color.RED);
graphicsContext.fillRect(x, y, width, height);
}
graphicsContext.strokeRect(x, y, width, height);
......@@ -49,10 +47,6 @@ public class Rectangle implements Shape{
return isFinished;
}
@Override
public void setFillColor(Color fillColor) {
this.fillColor = fillColor;
}
public void updateSize(double newX, double newY) {
this.width = Math.abs(newX - this.x);
......@@ -62,4 +56,16 @@ public class Rectangle implements Shape{
this.y = newY;
}
}
public Color getFillColor() {
return fillColor;
}
public void setFinished(boolean finished) {
isFinished = finished;
}
public void setFillColor(Color fillColor) {
this.fillColor = fillColor;
}
}
......@@ -9,5 +9,4 @@ public interface Shape {
boolean contains(double x, double y);
void translate(double dx, double dy);
boolean isFinished();
void setFillColor(Color fillColor);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment