Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
tp-4
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
Model registry
Operate
Environments
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
pirkl-poo-2018
tp-4
Commits
9edce9fc
Commit
9edce9fc
authored
6 years ago
by
Alexis Durgnat
Browse files
Options
Downloads
Patches
Plain Diff
Clickable connections
parent
b8a41bbe
No related branches found
No related tags found
1 merge request
!21
*poof* final version
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/ch/hepia/ui/MainWindowController.java
+46
-5
46 additions, 5 deletions
src/main/java/ch/hepia/ui/MainWindowController.java
src/main/resources/fxml/MainWindow.fxml
+1
-1
1 addition, 1 deletion
src/main/resources/fxml/MainWindow.fxml
with
47 additions
and
6 deletions
src/main/java/ch/hepia/ui/MainWindowController.java
+
46
−
5
View file @
9edce9fc
...
@@ -9,6 +9,7 @@ import ch.hepia.api.transport.Section;
...
@@ -9,6 +9,7 @@ import ch.hepia.api.transport.Section;
import
ch.hepia.config.AppConfig
;
import
ch.hepia.config.AppConfig
;
import
ch.hepia.config.AppContext
;
import
ch.hepia.config.AppContext
;
import
ch.hepia.events.ChatMessage
;
import
ch.hepia.events.ChatMessage
;
import
ch.hepia.events.JoinedJourney
;
import
ch.hepia.models.User
;
import
ch.hepia.models.User
;
import
javafx.animation.TranslateTransition
;
import
javafx.animation.TranslateTransition
;
import
javafx.application.Platform
;
import
javafx.application.Platform
;
...
@@ -69,6 +70,11 @@ public class MainWindowController implements Initializable {
...
@@ -69,6 +70,11 @@ public class MainWindowController implements Initializable {
@FXML
@FXML
private
Pane
chatContainer
;
private
Pane
chatContainer
;
@FXML
private
Pane
connectionContainer
;
private
List
<
Connection
>
currentConnections
;
/**
/**
* Shows a sad message when the API crashes.
* Shows a sad message when the API crashes.
*/
*/
...
@@ -192,6 +198,28 @@ public class MainWindowController implements Initializable {
...
@@ -192,6 +198,28 @@ public class MainWindowController implements Initializable {
p
.
setMaxWidth
(
320
);
p
.
setMaxWidth
(
320
);
}
}
/**
* Style a connection panel
* @param p Panel to style
* @param color Background color of the gradient
*/
private
void
setConnectionPanelStyle
(
Pane
p
)
{
p
.
setBackground
(
new
Background
(
new
BackgroundFill
(
new
LinearGradient
(
0
,
0
,
0
,
1
,
true
,
CycleMethod
.
NO_CYCLE
,
new
Stop
(
1
,
AppConfig
.
COLOR_BLUE_10_OPACITY
),
new
Stop
(
0
,
Color
.
TRANSPARENT
)
),
new
CornerRadii
(
5
),
Insets
.
EMPTY
)));
p
.
setBorder
(
new
Border
(
new
BorderStroke
(
Color
.
color
(
0.6
,
0.6
,
0.6
),
BorderStrokeStyle
.
SOLID
,
new
CornerRadii
(
5
),
BorderWidths
.
DEFAULT
)));
p
.
setPrefWidth
(
AppConfig
.
APP_MAIN_VIEW_WIDTH
+
10
);
p
.
setPrefHeight
(
90
);
}
/**
/**
* Wrapper for local chat message
* Wrapper for local chat message
* @param message Message to print
* @param message Message to print
...
@@ -284,13 +312,26 @@ public class MainWindowController implements Initializable {
...
@@ -284,13 +312,26 @@ public class MainWindowController implements Initializable {
try
{
try
{
connectionCanvas
.
getGraphicsContext2D
()
connectionCanvas
.
getGraphicsContext2D
()
.
clearRect
(
0
,
0
,
connectionCanvas
.
getWidth
(),
connectionCanvas
.
getHeight
());
.
clearRect
(
0
,
0
,
connectionCanvas
.
getWidth
(),
connectionCanvas
.
getHeight
());
connectionContainer
.
getChildren
().
removeIf
(
c
->
c
instanceof
Pane
);
List
<
Connection
>
c
onnections
=
transportApi
.
getConnections
(
currentC
onnections
=
transportApi
.
getConnections
(
originComboBox
.
getValue
(),
destinationComboBox
.
getValue
());
originComboBox
.
getValue
(),
destinationComboBox
.
getValue
());
startStopLabel
.
setText
(
originComboBox
.
getValue
()
+
" - "
+
destinationComboBox
.
getValue
());
startStopLabel
.
setText
(
originComboBox
.
getValue
()
+
" - "
+
destinationComboBox
.
getValue
());
for
(
int
i
=
0
;
i
<
connections
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
c
urrentC
onnections
.
size
();
i
++){
// Now iterating over connections
// Now iterating over connections
drawConnection
(
connections
.
get
(
i
),
30
,
100
+
100
*
i
);
drawConnection
(
currentConnections
.
get
(
i
),
30
,
100
+
100
*
i
);
Pane
pane
=
new
Pane
();
setConnectionPanelStyle
(
pane
);
pane
.
setTranslateX
(
20
);
pane
.
setTranslateY
(
85
+
100
*
i
);
pane
.
setId
(
Integer
.
toString
(
i
));
Platform
.
runLater
(()
->
{
connectionContainer
.
getChildren
().
add
(
pane
);
pane
.
setOnMouseClicked
(
e
->
{
Pane
pnl
=
(
Pane
)
e
.
getSource
();
Integer
pos
=
Integer
.
parseInt
(
pnl
.
getId
());
app
.
getMessageManager
().
sendJoinedJourney
(
new
JoinedJourney
(
app
.
getUser
().
get
(),
currentConnections
.
get
(
pos
)));
});
});
}
}
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
showSadMessage
(
AppConfig
.
ERROR_API_UNREACHABLE
);
showSadMessage
(
AppConfig
.
ERROR_API_UNREACHABLE
);
...
...
This diff is collapsed.
Click to expand it.
src/main/resources/fxml/MainWindow.fxml
+
1
−
1
View file @
9edce9fc
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
</children></Pane>
</children></Pane>
</right>
</right>
<center>
<center>
<Pane
prefHeight=
"200.0"
prefWidth=
"200.0"
BorderPane.alignment=
"CENTER"
>
<Pane
id=
"connectionContainer"
fx:id=
"connectionContainer"
prefHeight=
"200.0"
prefWidth=
"200.0"
BorderPane.alignment=
"CENTER"
>
<children>
<children>
<Label
id=
"startStopLabel"
fx:id=
"startStopLabel"
layoutX=
"14.0"
layoutY=
"14.0"
text=
"Arrêt : CHANGEZ-MOI"
textFill=
"#4c7ba8"
>
<Label
id=
"startStopLabel"
fx:id=
"startStopLabel"
layoutX=
"14.0"
layoutY=
"14.0"
text=
"Arrêt : CHANGEZ-MOI"
textFill=
"#4c7ba8"
>
<font>
<font>
...
...
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