Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
graphic-2020-TP5
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MANSOUR Chadi
graphic-2020-TP5
Commits
d0a4191d
Commit
d0a4191d
authored
6 months ago
by
MANSOUR Chadi
Browse files
Options
Downloads
Patches
Plain Diff
to correct later
parent
b29bdbe1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/java/shape/Circle.java
+16
-1
16 additions, 1 deletion
src/main/java/shape/Circle.java
src/main/java/shape/Rectangle.java
+6
-0
6 additions, 0 deletions
src/main/java/shape/Rectangle.java
src/main/java/shape/Shape.java
+1
-0
1 addition, 0 deletions
src/main/java/shape/Shape.java
with
23 additions
and
1 deletion
src/main/java/shape/Circle.java
+
16
−
1
View file @
d0a4191d
...
@@ -7,17 +7,23 @@ import javafx.scene.paint.Color;
...
@@ -7,17 +7,23 @@ import javafx.scene.paint.Color;
public
class
Circle
implements
Shape
{
public
class
Circle
implements
Shape
{
private
double
radius
,
x
,
y
;
private
double
radius
,
x
,
y
;
private
Color
fillColor
;
public
Circle
(
double
x
,
double
y
,
double
radius
)
{
public
Circle
(
double
x
,
double
y
,
double
radius
)
{
this
.
x
=
x
;
this
.
x
=
x
;
this
.
y
=
y
;
this
.
y
=
y
;
this
.
radius
=
radius
;
this
.
radius
=
radius
;
this
.
fillColor
=
Color
.
GREEN
;
}
}
@Override
@Override
public
void
paint
(
GraphicsContext
graphicsContext
)
{
public
void
paint
(
GraphicsContext
graphicsContext
)
{
graphicsContext
.
setStroke
(
Color
.
RED
);
graphicsContext
.
setStroke
(
Color
.
BLACK
);
if
(
isFinished
)
{
graphicsContext
.
setFill
(
Color
.
GREEN
);
graphicsContext
.
fillOval
(
x
-
radius
,
y
-
radius
,
2
*
radius
,
2
*
radius
);
}
graphicsContext
.
strokeOval
(
x
-
radius
,
y
-
radius
,
2
*
radius
,
2
*
radius
);
graphicsContext
.
strokeOval
(
x
-
radius
,
y
-
radius
,
2
*
radius
,
2
*
radius
);
}
}
...
@@ -33,8 +39,17 @@ public class Circle implements Shape {
...
@@ -33,8 +39,17 @@ public class Circle implements Shape {
this
.
x
+=
dx
;
this
.
x
+=
dx
;
this
.
y
+=
dy
;
this
.
y
+=
dy
;
}
}
@Override
public
boolean
isFinished
()
{
return
true
;
}
public
void
updateRadius
(
double
newX
,
double
newY
)
{
public
void
updateRadius
(
double
newX
,
double
newY
)
{
this
.
radius
=
Math
.
sqrt
(
Math
.
pow
(
newX
-
this
.
x
,
2
)
+
Math
.
pow
(
newY
-
this
.
y
,
2
));
this
.
radius
=
Math
.
sqrt
(
Math
.
pow
(
newX
-
this
.
x
,
2
)
+
Math
.
pow
(
newY
-
this
.
y
,
2
));
}
}
public
void
setFillColor
(
Color
fillColor
)
{
this
.
fillColor
=
fillColor
;
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/shape/Rectangle.java
+
6
−
0
View file @
d0a4191d
...
@@ -36,6 +36,12 @@ public class Rectangle implements Shape{
...
@@ -36,6 +36,12 @@ public class Rectangle implements Shape{
x
+=
dx
;
x
+=
dx
;
y
+=
dy
;
y
+=
dy
;
}
}
@Override
public
boolean
isFinished
()
{
return
false
;
}
public
void
updateSize
(
double
newX
,
double
newY
)
{
public
void
updateSize
(
double
newX
,
double
newY
)
{
this
.
width
=
Math
.
abs
(
newX
-
this
.
x
);
this
.
width
=
Math
.
abs
(
newX
-
this
.
x
);
this
.
height
=
Math
.
abs
(
newY
-
this
.
y
);
this
.
height
=
Math
.
abs
(
newY
-
this
.
y
);
...
...
This diff is collapsed.
Click to expand it.
src/main/java/shape/Shape.java
+
1
−
0
View file @
d0a4191d
...
@@ -7,4 +7,5 @@ public interface Shape {
...
@@ -7,4 +7,5 @@ public interface Shape {
void
paint
(
GraphicsContext
graphicsContext
);
void
paint
(
GraphicsContext
graphicsContext
);
boolean
contains
(
double
x
,
double
y
);
boolean
contains
(
double
x
,
double
y
);
void
translate
(
double
dx
,
double
dy
);
void
translate
(
double
dx
,
double
dy
);
boolean
isFinished
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment