Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
graphic-2020
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
LATIOUI Abdelilah
graphic-2020
Commits
52d229b4
Commit
52d229b4
authored
1 year ago
by
1380
Browse files
Options
Downloads
Patches
Plain Diff
BorderDecorator,shapeContainer
parent
c93bd542
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/App.java
+11
-7
11 additions, 7 deletions
src/main/java/shape/App.java
src/main/java/shape/BorderDecorator.java
+2
-1
2 additions, 1 deletion
src/main/java/shape/BorderDecorator.java
src/main/java/shape/ShapeContainer.java
+1
-0
1 addition, 0 deletions
src/main/java/shape/ShapeContainer.java
with
14 additions
and
8 deletions
src/main/java/shape/App.java
+
11
−
7
View file @
52d229b4
...
@@ -23,18 +23,22 @@ public class App extends Application {
...
@@ -23,18 +23,22 @@ public class App extends Application {
@Override
@Override
public
void
start
(
Stage
primaryStage
)
{
public
void
start
(
Stage
primaryStage
)
{
Group
root
=
new
Group
();
Group
root
=
new
Group
();
Canvas
canvas
=
new
Canvas
(
13
0
,
11
0
);
Canvas
canvas
=
new
Canvas
(
26
0
,
22
0
);
GraphicsContext
graphicsContext
=
canvas
.
getGraphicsContext2D
();
GraphicsContext
graphicsContext
=
canvas
.
getGraphicsContext2D
();
ShapeContainer
shapeContainer
=
new
ShapeContainer
();
ShapeContainer
shapeContainer
=
new
ShapeContainer
();
graphicsContext
.
setFill
(
Color
.
AQUAMARINE
);
graphicsContext
.
setFill
(
Color
.
AQUAMARINE
);
graphicsContext
.
fillOval
(
10
,
10
,
10
,
10
);
graphicsContext
.
fillOval
(
10
,
10
,
10
,
10
);
shapeContainer
.
addShape
(
new
Rectangle
(
Color
.
BLUE
,
new
Point2D
(
50
,
50
),
new
Point2D
(
100
,
100
)));
Rectangle
rectangle
=
new
Rectangle
(
Color
.
BLUE
,
new
Point2D
(
100
,
100
),
new
Point2D
(
200
,
200
));
shapeContainer
.
addShape
(
rectangle
);
List
<
Point2D
>
points
=
new
ArrayList
<>();
List
<
Point2D
>
points
=
new
ArrayList
<>();
points
.
add
(
new
Point2D
(
20
,
20
));
points
.
add
(
new
Point2D
(
10
,
10
));
points
.
add
(
new
Point2D
(
30
,
30
));
points
.
add
(
new
Point2D
(
100
,
40
));
//points.add(new Point2D(80,80));
points
.
add
(
new
Point2D
(
60
,
60
));
points
.
add
(
new
Point2D
(
40
,
100
));
shapeContainer
.
addShape
(
new
Polygon
(
Color
.
BLACK
,
points
));
Polygon
polygon
=
new
Polygon
(
Color
.
BLACK
,
points
);
shapeContainer
.
addShape
(
polygon
);
BorderDecorator
borderDecorator
=
new
BorderDecorator
(
rectangle
,
10
);
borderDecorator
.
drawDecoration
(
graphicsContext
);
shapeContainer
.
draw
(
graphicsContext
);
shapeContainer
.
draw
(
graphicsContext
);
root
.
getChildren
().
add
(
canvas
);
root
.
getChildren
().
add
(
canvas
);
primaryStage
.
setScene
(
new
Scene
(
root
));
primaryStage
.
setScene
(
new
Scene
(
root
));
...
...
This diff is collapsed.
Click to expand it.
src/main/java/shape/BorderDecorator.java
+
2
−
1
View file @
52d229b4
...
@@ -2,6 +2,7 @@ package shape;
...
@@ -2,6 +2,7 @@ package shape;
import
javafx.geometry.Point2D
;
import
javafx.geometry.Point2D
;
import
javafx.scene.canvas.GraphicsContext
;
import
javafx.scene.canvas.GraphicsContext
;
import
javafx.scene.paint.Color
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -23,7 +24,7 @@ public class BorderDecorator extends Decorator{
...
@@ -23,7 +24,7 @@ public class BorderDecorator extends Decorator{
list
.
add
(
point
(
index
));
list
.
add
(
point
(
index
));
}
}
for
(
Point2D
point
:
list
){
for
(
Point2D
point
:
list
){
graphicsContext
.
stroke
Oval
(
point
.
getX
(),
point
.
getY
(),
radius
,
radius
);
graphicsContext
.
fill
Oval
(
point
.
getX
()
-(
radius
/
2
)
,
point
.
getY
()
-(
radius
/
2
)
,
radius
,
radius
);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
src/main/java/shape/ShapeContainer.java
+
1
−
0
View file @
52d229b4
...
@@ -17,4 +17,5 @@ public class ShapeContainer{
...
@@ -17,4 +17,5 @@ public class ShapeContainer{
for
(
Shape
shape
:
shapes
)
for
(
Shape
shape
:
shapes
)
shape
.
draw
(
context
);
shape
.
draw
(
context
);
}
}
}
}
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