Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
graphic-tp4
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
SAYEH Nahlane ghina
graphic-tp4
Commits
898345ca
Commit
898345ca
authored
6 months ago
by
SAYEH Nahlane ghina
Browse files
Options
Downloads
Patches
Plain Diff
modification de ShapeContainer
creation de AbstractShape creation de Polygon,BorderDecorator et CenterDecorator
parent
b8dc2b1f
Branches
master
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/shape/App.java
+25
-15
25 additions, 15 deletions
src/main/java/shape/App.java
with
25 additions
and
15 deletions
src/main/java/shape/App.java
+
25
−
15
View file @
898345ca
...
...
@@ -7,34 +7,44 @@ import javafx.scene.Scene;
import
javafx.scene.canvas.Canvas
;
import
javafx.scene.canvas.GraphicsContext
;
import
javafx.scene.paint.Color
;
import
javafx.scene.paint.Paint
;
import
javafx.stage.Stage
;
public
class
App
extends
Application
{
public
static
void
main
(
String
[]
args
)
{
launch
(
args
);
launch
(
args
);
// Lance l'application JavaFX
}
@Override
public
void
start
(
Stage
primaryStage
)
{
// Créer un groupe racine pour contenir le Canvas
Group
root
=
new
Group
();
Canvas
canvas
=
new
Canvas
(
130
,
110
);
// Créer un canvas sur lequel on va dessiner
Canvas
canvas
=
new
Canvas
(
300
,
300
);
GraphicsContext
graphicsContext
=
canvas
.
getGraphicsContext2D
();
// Créer un ShapeContainer pour stocker les formes
ShapeContainer
shapeContainer
=
new
ShapeContainer
();
graphicsContext
.
setFill
(
Color
.
AQUAMARINE
);
graphicsContext
.
fillOval
(
10
,
10
,
10
,
10
);
shapeContainer
.
add
(
new
Rectangle
(
Color
.
BLUE
,
new
Point2D
(
10
,
10
),
new
Point2D
(
40
,
40
)));
shapeContainer
.
draw
(
graphicsContext
);
root
.
getChildren
().
add
(
canvas
);
primaryStage
.
setScene
(
new
Scene
(
root
));
primaryStage
.
show
();
}
// Ajouter des formes et appliquer des décorateurs
Shape
polygon
=
new
Polygon
(
Color
.
BLUE
,
new
Point2D
(
50
,
50
),
new
Point2D
(
100
,
50
),
new
Point2D
(
75
,
100
));
Shape
decoratedPolygon
=
new
BorderDecorator
(
polygon
,
10
);
// Ajouter une bordure au polygone
Shape
centerDecoratedPolygon
=
new
CenterDecorator
(
decoratedPolygon
,
5
);
// Ajouter un cercle au centre
// Ajouter la forme décorée au conteneur
shapeContainer
.
add
(
centerDecoratedPolygon
);
// Dessiner toutes les formes dans le GraphicsContext
shapeContainer
.
draw
(
graphicsContext
);
// Ajouter le canvas au groupe racine
root
.
getChildren
().
add
(
canvas
);
}
\ No newline at end of file
// Créer une scène et l'ajouter à la fenêtre principale
Scene
scene
=
new
Scene
(
root
,
300
,
300
);
primaryStage
.
setScene
(
scene
);
primaryStage
.
setTitle
(
"Dessin de Formes avec Décorateurs"
);
primaryStage
.
show
();
// Afficher la fenêtre
}
}
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