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
c904134a
Verified
Commit
c904134a
authored
6 years ago
by
Théo Pirkl
Browse files
Options
Downloads
Patches
Plain Diff
Adds comment
parent
2d6e95b6
No related branches found
No related tags found
1 merge request
!21
*poof* final version
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/ch/hepia/ui/MainWindowController.java
+15
-4
15 additions, 4 deletions
src/main/java/ch/hepia/ui/MainWindowController.java
with
15 additions
and
4 deletions
src/main/java/ch/hepia/ui/MainWindowController.java
+
15
−
4
View file @
c904134a
...
...
@@ -6,6 +6,7 @@ import ch.hepia.api.transport.LinkAPI;
import
ch.hepia.api.transport.Section
;
import
ch.hepia.config.AppContext
;
import
ch.hepia.events.ChatMessage
;
import
ch.hepia.models.User
;
import
javafx.animation.TranslateTransition
;
import
javafx.application.Platform
;
import
javafx.beans.value.ChangeListener
;
...
...
@@ -19,6 +20,7 @@ import javafx.scene.image.Image;
import
javafx.scene.input.KeyCode
;
import
javafx.scene.layout.Background
;
import
javafx.scene.paint.Color
;
import
javafx.scene.text.TextAlignment
;
import
javafx.util.Duration
;
import
org.json.JSONArray
;
...
...
@@ -109,7 +111,6 @@ public class MainWindowController implements Initializable {
List
<
Section
>
sections
=
connection
.
getSections
();
connectionCanvas
.
getGraphicsContext2D
().
setFill
(
Color
.
RED
);
System
.
out
.
println
(
sections
.
size
());
for
(
int
i
=
0
;
i
<
sections
.
size
();
i
++){
connectionCanvas
.
getGraphicsContext2D
().
strokeLine
(
x
+
(
622
/
sections
.
size
())
*
(
i
),
y
,
622
/
sections
.
size
(),
y
);
...
...
@@ -122,7 +123,11 @@ public class MainWindowController implements Initializable {
}
}
private
void
drawMessage
(
String
message
){
/**
* Draws a newly received message
* @param message The message to draw
*/
private
void
drawMessage
(
User
user
,
String
message
){
Pane
p
=
new
Pane
();
p
.
setMaxWidth
(
326
);
...
...
@@ -130,6 +135,9 @@ public class MainWindowController implements Initializable {
msg
.
setWrapText
(
true
);
msg
.
setStyle
(
"-fx-padding: 8px"
);
msg
.
setText
(
message
);
if
(
Main
.
getContext
().
getUser
().
isPresent
()
&&
!
user
.
equals
(
Main
.
getContext
().
getUser
().
get
())){
msg
.
setTextAlignment
(
TextAlignment
.
RIGHT
);
}
msg
.
setMaxWidth
(
310
);
p
.
getChildren
().
add
(
msg
);
...
...
@@ -137,6 +145,9 @@ public class MainWindowController implements Initializable {
chatContainer
.
getChildren
().
add
(
p
);
}
/**
* Moves the older messages downwards
*/
private
void
insertMessageIntoQueue
(){
for
(
int
i
=
0
;
i
<
chatContainer
.
getChildren
().
size
();
i
++){
Pane
sp
=
(
Pane
)
chatContainer
.
getChildren
().
get
(
i
);
...
...
@@ -208,7 +219,7 @@ public class MainWindowController implements Initializable {
chatMessage
->
{
Platform
.
runLater
(()
->
{
String
message
=
chatMessage
.
getUser
().
toString
()
+
": "
+
chatMessage
.
getMessage
();
drawMessage
(
message
);
drawMessage
(
chatMessage
.
getUser
(),
message
);
});
},
chatMessage
->
!(
app
.
getUser
().
get
().
getIgnoredUserList
().
contains
(
chatMessage
.
getUser
()))
...
...
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