Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
ProjetSyntheseL2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
GOLINELLI Mathias
ProjetSyntheseL2
Commits
044dc7f4
Commit
044dc7f4
authored
2 years ago
by
vitawrap
Browse files
Options
Downloads
Patches
Plain Diff
Java: Diagramme de Gantt (donnés bidon)
parent
b7b5a002
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
java/app/src/main/java/application/ProjetController.java
+78
-0
78 additions, 0 deletions
java/app/src/main/java/application/ProjetController.java
java/app/src/main/resources/application/ProjetView.fxml
+1
-6
1 addition, 6 deletions
java/app/src/main/resources/application/ProjetView.fxml
with
79 additions
and
6 deletions
java/app/src/main/java/application/ProjetController.java
+
78
−
0
View file @
044dc7f4
...
@@ -2,11 +2,17 @@ package application;
...
@@ -2,11 +2,17 @@ package application;
import
javafx.event.ActionEvent
;
import
javafx.event.ActionEvent
;
import
javafx.fxml.FXML
;
import
javafx.fxml.FXML
;
import
javafx.geometry.VPos
;
import
javafx.scene.canvas.Canvas
;
import
javafx.scene.canvas.Canvas
;
import
javafx.scene.canvas.GraphicsContext
;
import
javafx.scene.control.CheckBox
;
import
javafx.scene.control.CheckBox
;
import
javafx.scene.control.Label
;
import
javafx.scene.control.Label
;
import
javafx.scene.control.Spinner
;
import
javafx.scene.control.Spinner
;
import
javafx.scene.control.TextField
;
import
javafx.scene.control.TextField
;
import
javafx.scene.layout.AnchorPane
;
import
javafx.scene.paint.Color
;
import
javafx.scene.paint.Paint
;
import
javafx.scene.text.Font
;
public
class
ProjetController
{
public
class
ProjetController
{
...
@@ -25,6 +31,78 @@ public class ProjetController {
...
@@ -25,6 +31,78 @@ public class ProjetController {
@FXML
@FXML
Canvas
_canvas
;
Canvas
_canvas
;
private
void
redrawGraph
()
{
// Constantes
final
double
w
=
_canvas
.
getWidth
();
final
double
h
=
_canvas
.
getHeight
();
final
double
xmargin
=
90
;
// Marge pour nom de machine
final
double
dtunit
=
20
;
// Unité en pixels pour un delta de 1 T.
final
double
hentry
=
32
;
// Préparation de la toile.
GraphicsContext
g
=
_canvas
.
getGraphicsContext2D
();
g
.
clearRect
(
0
,
0
,
w
,
h
);
g
.
setTextBaseline
(
VPos
.
CENTER
);
// Marge
g
.
setStroke
(
Color
.
DARKGRAY
);
g
.
strokeRect
(
0
,
0
,
xmargin
,
h
);
// Remplissage alterné des machines. (avec données de test)
var
machines
=
new
String
[]{
"M1"
,
"M2"
,
"M300"
};
int
mach
=
0
;
for
(
int
y
=
0
;
y
<
_canvas
.
getHeight
();
y
+=
hentry
)
{
if
((
y
&
32
)
==
0
)
{
g
.
setFill
(
Color
.
LIGHTGRAY
);
g
.
fillRect
(
xmargin
,
y
,
w
-
xmargin
,
hentry
);
}
if
(
mach
<
machines
.
length
)
{
g
.
setFill
(
Color
.
DARKGRAY
);
g
.
fillText
(
machines
[
mach
++],
4
,
y
+
(
hentry
/
2
),
xmargin
-
4
);
}
}
// Affichage des tâches par machine (Avec données de test)
var
task_machine
=
new
int
[]
{
0
,
1
,
2
};
var
task_begin
=
new
int
[]
{
1
,
4
,
12
};
var
task_enddt
=
new
int
[]
{
2
,
6
,
8
};
g
.
setFill
(
Color
.
DODGERBLUE
);
for
(
int
i
=
0
;
i
<
task_machine
.
length
;
++
i
)
{
g
.
fillRect
(
xmargin
+
(
task_begin
[
i
]
*
dtunit
),
task_machine
[
i
]
*
hentry
,
task_enddt
[
i
]
*
dtunit
,
hentry
);
}
// Et enfin, remplissage du temps par unités delta
g
.
setStroke
(
Color
.
BLACK
);
for
(
int
x
=
0
;
x
<
_canvas
.
getWidth
();
x
+=
dtunit
)
g
.
strokeLine
(
xmargin
+
x
,
0
,
xmargin
+
x
,
h
);
}
@FXML
public
void
initialize
()
{
redrawGraph
();
((
AnchorPane
)
_canvas
.
getParent
()).
widthProperty
().
addListener
(
(
observableValue
,
number
,
t1
)
->
{
_canvas
.
setWidth
(
number
.
doubleValue
());
redrawGraph
();
}
);
((
AnchorPane
)
_canvas
.
getParent
()).
heightProperty
().
addListener
(
(
observableValue
,
number
,
t1
)
->
{
_canvas
.
setHeight
(
number
.
doubleValue
());
redrawGraph
();
}
);
}
@FXML
@FXML
public
void
submitToDiagram
(
ActionEvent
event
)
public
void
submitToDiagram
(
ActionEvent
event
)
{
{
...
...
This diff is collapsed.
Click to expand it.
java/app/src/main/resources/application/ProjetView.fxml
+
1
−
6
View file @
044dc7f4
...
@@ -8,7 +8,6 @@
...
@@ -8,7 +8,6 @@
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.SplitPane?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.Pane?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.layout.VBox?>
<?import javafx.scene.text.Text?>
<?import javafx.scene.text.Text?>
...
@@ -37,11 +36,7 @@
...
@@ -37,11 +36,7 @@
</children></AnchorPane>
</children></AnchorPane>
<AnchorPane
minHeight=
"0.0"
minWidth=
"0.0"
prefHeight=
"160.0"
prefWidth=
"100.0"
>
<AnchorPane
minHeight=
"0.0"
minWidth=
"0.0"
prefHeight=
"160.0"
prefWidth=
"100.0"
>
<children>
<children>
<BorderPane
prefHeight=
"398.4"
prefWidth=
"417.6"
AnchorPane.bottomAnchor=
"0.0"
AnchorPane.leftAnchor=
"0.0"
AnchorPane.rightAnchor=
"0.0"
AnchorPane.topAnchor=
"0.0"
>
<Canvas
fx:id=
"_canvas"
height=
"380.0"
width=
"400.0"
AnchorPane.bottomAnchor=
"0.0"
AnchorPane.leftAnchor=
"0.0"
AnchorPane.rightAnchor=
"0.0"
AnchorPane.topAnchor=
"0.0"
/>
<center>
<Canvas
fx:id=
"_canvas"
height=
"380.0"
width=
"400.0"
BorderPane.alignment=
"CENTER"
/>
</center>
</BorderPane>
</children></AnchorPane>
</children></AnchorPane>
</items>
</items>
</SplitPane>
</SplitPane>
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