Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
graphic-2024
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MESSAOUDI Melissa
graphic-2024
Commits
dfb1d9cb
Commit
dfb1d9cb
authored
9 months ago
by
BOUCHAL Stella
Browse files
Options
Downloads
Patches
Plain Diff
narwi lhala
parent
a0ff5b3b
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/main/java/shape/Decorator.java
+12
-0
12 additions, 0 deletions
src/main/java/shape/Decorator.java
src/main/java/shape/Polygone.java
+41
-1
41 additions, 1 deletion
src/main/java/shape/Polygone.java
src/main/java/shape/Rectangle.java
+17
-3
17 additions, 3 deletions
src/main/java/shape/Rectangle.java
with
70 additions
and
4 deletions
src/main/java/shape/Decorator.java
0 → 100644
+
12
−
0
View file @
dfb1d9cb
package
shape
;
public
class
Decorator
{
protected
Shape
decoratedShape
;
public
Decorator
(
Shape
decoratedShape
)
{
this
.
decoratedShape
=
decoratedShape
;
}
public
int
pointCounts
(){
return
};
}
This diff is collapsed.
Click to expand it.
src/main/java/shape/Polygone.java
+
41
−
1
View file @
dfb1d9cb
package
shape
;
package
shape
;
public
class
Polygone
{
import
javafx.geometry.Point2D
;
import
javafx.scene.paint.Color
;
import
javafx.scene.canvas.GraphicsContext
;
import
java.util.List
;
public
class
Polygone
extends
AbstractShape
{
private
Color
color
;
private
List
<
Point2D
>
points
;
public
Polygone
(
Color
color
,
List
<
Point2D
>
points
)
{
this
.
color
=
color
;
this
.
points
=
points
;
}
@Override
public
void
draw
(
GraphicsContext
gc
)
{
if
(
points
.
size
()
>
2
)
{
gc
.
setStroke
(
color
);
gc
.
beginPath
();
Point2D
start
=
points
.
get
(
0
);
gc
.
moveTo
(
start
.
getX
(),
start
.
getY
());
for
(
int
i
=
1
;
i
<
points
.
size
();
i
++)
{
Point2D
p
=
points
.
get
(
i
);
gc
.
lineTo
(
p
.
getX
(),
p
.
getY
());
}
gc
.
closePath
();
gc
.
stroke
();
}
}
public
Point2D
point
(
int
index
){
if
(
index
<
0
||
index
>=
points
.
size
()){
throw
new
IndexOutOfBoundsException
(
"Index out of bounds"
);
}
else
{
return
points
.
get
(
index
);
}
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/shape/Rectangle.java
+
17
−
3
View file @
dfb1d9cb
...
@@ -5,23 +5,37 @@ import javafx.scene.canvas.GraphicsContext;
...
@@ -5,23 +5,37 @@ import javafx.scene.canvas.GraphicsContext;
import
javafx.scene.paint.Color
;
import
javafx.scene.paint.Color
;
public
class
Rectangle
implements
Shape
{
public
class
Rectangle
implements
Shape
{
Color
color
;
private
Color
color
;
private
Point2D
point0
,
point1
;
Rectangle
(
Color
color
,
Point2D
point0
,
Point2D
point1
){
Rectangle
(
Color
color
,
Point2D
point0
,
Point2D
point1
){
this
.
color
=
color
;
this
.
color
=
color
;
this
.
point0
=
point0
;
this
.
point1
=
point1
;
}
}
@Override
@Override
public
int
pointsCount
()
{
public
int
pointsCount
()
{
return
0
;
return
2
;
}
}
@Override
@Override
public
Point2D
point
(
int
index
)
{
public
Point2D
point
(
int
index
)
{
return
null
;
if
(
index
==
0
)
return
point0
;
if
(
index
==
1
)
{
return
point1
;}
else
{
throw
new
IndexOutOfBoundsException
(
"Index out of bounds"
);
}
}
}
@Override
@Override
public
void
draw
(
GraphicsContext
context
)
{
public
void
draw
(
GraphicsContext
context
)
{
context
.
setStroke
(
color
);
double
x
=
Math
.
min
(
point0
.
getX
(),
point1
.
getX
());
double
y
=
Math
.
min
(
point0
.
getY
(),
point1
.
getY
());
double
width
=
Math
.
abs
(
point0
.
getX
()
-
point1
.
getX
());
double
height
=
Math
.
abs
(
point0
.
getY
()
-
point1
.
getY
());
context
.
strokeRect
(
x
,
y
,
width
,
height
);
}
}
}
}
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